debug commands
This commit is contained in:
parent
b09d0b37f1
commit
d05b670e23
1
cmd.go
1
cmd.go
@ -5,6 +5,7 @@ type CmdType string
|
||||
const (
|
||||
ActCmd = "a"
|
||||
StateCmd = "s"
|
||||
DebugCmd = "d"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
|
18
game.go
18
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user