36 lines
618 B
Go
36 lines
618 B
Go
package game
|
|
|
|
type Game struct {
|
|
RNG RNG
|
|
PP [2]Player
|
|
Shells []bool
|
|
Round int
|
|
Turn int
|
|
Damage int8
|
|
|
|
// Backing storage for shells.
|
|
ShellArray [8]bool
|
|
}
|
|
|
|
func NewGame() *Game {
|
|
return &Game{RNG: NewRNG()}
|
|
}
|
|
|
|
func (g *Game) StartRound() {
|
|
items := g.RNG.Intn(4) + 1
|
|
g.PP[0].StartRound(&g.RNG, items)
|
|
g.PP[1].StartRound(&g.RNG, items)
|
|
shells := g.RNG.Intn(6) + 2
|
|
for i := 0; i < shells/2; i++ {
|
|
g.ShellArray[i] = true
|
|
}
|
|
for i := shells / 2; i < shells; i++ {
|
|
g.ShellArray[i] = false
|
|
}
|
|
g.Shells = g.ShellArray[:shells]
|
|
ShuffleSlice(&g.RNG, g.Shells)
|
|
g.Round++
|
|
g.Turn = 0
|
|
g.Damage = 1
|
|
}
|