diff --git a/cmd.go b/cmd.go index e73eb0c..8cbb955 100644 --- a/cmd.go +++ b/cmd.go @@ -5,6 +5,7 @@ type CmdType string const ( ActCmd = "a" StateCmd = "s" + DebugCmd = "d" ) type Command struct { diff --git a/game.go b/game.go index 0be03ea..ef42617 100644 --- a/game.go +++ b/game.go @@ -72,8 +72,11 @@ func (g *Game) Parse(cmd *Command) *CommandResult { action_res = g.PlayerAct(cmd.PlayerID, cmd.Cmd) res_type = ActCmd } else if cmd.Type == StateCmd { - state_res, debug_res = g.PlayerStateAct(cmd.PlayerID, cmd.Cmd) + state_res = g.PlayerStateAct(cmd.PlayerID, cmd.Cmd) res_type = StateCmd + } else { + debug_res = g + res_type = DebugCmd } return &CommandResult{ PlayerID: cmd.PlayerID, @@ -84,14 +87,11 @@ func (g *Game) Parse(cmd *Command) *CommandResult { } } -func (g *Game) PlayerStateAct(id int, cmd string) (*GameView, *Game) { +func (g *Game) PlayerStateAct(id int, cmd string) *GameView { switch cmd { - case "d": - //debug game state - return nil, g case "g": //game state - return NewView(id, g), nil + return NewView(id, g) case "b": //begin game g.Status = StatusReady @@ -112,7 +112,7 @@ func (g *Game) PlayerStateAct(id int, cmd string) (*GameView, *Game) { g.HasDrawn = false } if id != g.CurrentTurn { - return nil, nil + return nil } if id == SentinalID { for _, v := range g.GameBoard.Sentinal { @@ -126,7 +126,7 @@ func (g *Game) PlayerStateAct(id int, cmd string) (*GameView, *Game) { case "e": //end turn and clean up if id != g.CurrentTurn { - return nil, nil + return nil } g.CardBuffer = []Card{} if id == SentinalID { @@ -144,7 +144,7 @@ func (g *Game) PlayerStateAct(id int, cmd string) (*GameView, *Game) { g.CurrentTurn = SentinalID } } - return NewView(id, g), nil + return NewView(id, g) } func (g *Game) PlayerAct(id int, cmd string) []Card { diff --git a/main.go b/main.go index c4ce455..4af21fb 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ func main() { } cmd_raw, _ := reader.ReadString('\n') cmd = strings.TrimSpace(cmd_raw) - if t == "s" { + if t == "s" || t == "d" { c := &Command{ PlayerID: i, Type: CmdType(t),