snengame/internal/game/cmd.go

35 lines
838 B
Go
Raw Permalink Normal View History

2021-07-22 15:37:25 -04:00
package game
import "fmt"
type CmdType string
const (
2021-07-23 17:42:12 -04:00
ActCmd = "a"
StateCmd = "s"
DebugCmd = "d"
InvalidCmd = "e"
)
type Command struct {
PlayerID int `json:"player_id"`
Type CmdType `json:"type"`
Cmd string `json:"cmd"`
}
2021-07-22 13:09:56 -04:00
func (c *Command) String() string {
return fmt.Sprintf("%v %v %v", c.PlayerID, c.Type, c.Cmd)
}
2021-07-22 13:09:56 -04:00
type CommandResult struct {
PlayerID int `json:"player_id"`
ResultType CmdType `json:"result_type"`
StateResult *GameView `json:"state_result,omitempty"`
ActionResult *Deck `json:"action_result,omitempty"`
DebugResult *Game `json:"debug_result,omitempty"`
}
func (c *CommandResult) String() string {
return fmt.Sprintf("%v %v\nState Result: %v\nAction Result: %v\nDebug: %v\n", c.PlayerID, c.ResultType, c.StateResult, c.ActionResult, c.DebugResult)
2021-07-22 13:09:56 -04:00
}