2021-07-22 15:37:25 -04:00
|
|
|
package game
|
2021-07-22 12:44:25 -04:00
|
|
|
|
2021-07-23 16:43:39 -04:00
|
|
|
import "fmt"
|
|
|
|
|
2021-07-22 12:44:25 -04:00
|
|
|
type CmdType string
|
|
|
|
|
|
|
|
const (
|
2021-07-23 17:42:12 -04:00
|
|
|
ActCmd = "a"
|
|
|
|
StateCmd = "s"
|
|
|
|
DebugCmd = "d"
|
|
|
|
InvalidCmd = "e"
|
2021-07-22 12:44:25 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Command struct {
|
|
|
|
PlayerID int `json:"player_id"`
|
|
|
|
Type CmdType `json:"type"`
|
|
|
|
Cmd string `json:"cmd"`
|
|
|
|
}
|
2021-07-22 13:09:56 -04:00
|
|
|
|
2021-07-23 16:43:39 -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"`
|
2021-07-23 16:43:39 -04:00
|
|
|
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
|
|
|
}
|