tome_lib/cmd.go

35 lines
852 B
Go
Raw Normal View History

2021-10-01 12:43:55 -04:00
package tome_lib
import "fmt"
type CmdType string
const (
ActCmd = "a"
StateCmd = "s"
DebugCmd = "d"
InvalidCmd = "e"
)
type Command struct {
PlayerID int `json:"player_id"`
Type CmdType `json:"type"`
Cmd string `json:"cmd"`
}
func (c *Command) String() string {
return fmt.Sprintf("%v %v %v", c.PlayerID, c.Type, c.Cmd)
}
type CommandResult struct {
2021-10-01 13:42:05 -04:00
PlayerID int `json:"player_id"`
ResultType CmdType `json:"result_type"`
StateResult *GameView `json:"state_result,omitempty"`
ActionResult *Deck `json:"action_result,omitempty"`
DebugResult interface{} `json:"debug_result,omitempty"`
2021-10-01 12:43:55 -04:00
}
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)
}