consolidate turn advance
This commit is contained in:
parent
93aa4b49d0
commit
4d2f5a43dc
18
game/game.go
18
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
|
||||
|
||||
@ -24,7 +24,6 @@ type Game struct {
|
||||
func NewGame() *Game {
|
||||
return &Game{
|
||||
RNG: NewRNG(),
|
||||
Damage: 1,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
@ -36,3 +36,8 @@ const (
|
||||
Cuffed
|
||||
CuffedSkip
|
||||
)
|
||||
|
||||
func (c CuffState) NextState() CuffState {
|
||||
var m = [...]CuffState{Uncuffed, Uncuffed, Cuffed}
|
||||
return m[c]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user