diff --git a/game/game.go b/game/game.go index 8a934ff..1100097 100644 --- a/game/game.go +++ b/game/game.go @@ -10,10 +10,10 @@ type Game struct { RNG RNG PP [2]Player Shells []bool - HP int8 Round uint Group uint Turn uint + HP int8 Damage int8 Reveal bool @@ -23,8 +23,7 @@ type Game struct { func NewGame() *Game { return &Game{ - RNG: NewRNG(), - Damage: 1, + RNG: NewRNG(), } } @@ -32,6 +31,8 @@ func (g *Game) StartRound() { g.PP[0].StartRound() g.PP[1].StartRound() g.Round++ + g.Group = 0 + g.StartGroup() } func (g *Game) StartGroup() { @@ -50,6 +51,15 @@ func (g *Game) StartGroup() { ShuffleSlice(&g.RNG, g.Shells) g.Group++ g.Turn = 0 + g.NextTurn() +} + +func (g *Game) NextTurn() { + g.Turn++ + g.Damage = 1 + g.Reveal = false + cur := g.CurrentPlayer() + cur.Cuffs = cur.Cuffs.NextState() } // CurrentPlayer gets the index of the current player, either 0 or 1. @@ -120,9 +130,9 @@ func (g *Game) Shoot(id player.ID, self bool) error { live := g.PopShell() if live { target.HP -= g.Damage - g.Turn++ + g.NextTurn() } else if !self { - g.Turn++ + g.NextTurn() } return nil } diff --git a/game/player.go b/game/player.go index 1d156df..a86233a 100644 --- a/game/player.go +++ b/game/player.go @@ -36,3 +36,8 @@ const ( Cuffed CuffedSkip ) + +func (c CuffState) NextState() CuffState { + var m = [...]CuffState{Uncuffed, Uncuffed, Cuffed} + return m[c] +}