don't care about player index, we have ids

This commit is contained in:
Branden J Brown 2024-01-20 23:39:59 -06:00
parent b7c7fd260f
commit 56f8387385
2 changed files with 5 additions and 5 deletions

View File

@ -47,18 +47,18 @@ func (g *Game) StartGroup() {
}
// CurrentPlayer gets the index of the current player, either 0 or 1.
func (g *Game) CurrentPlayer() uint {
return g.Turn % 2
func (g *Game) CurrentPlayer() *Player {
return &g.PP[g.Turn%2]
}
// Opponent returns the player who is not the current player.
func (g *Game) Opponent() *Player {
return &g.PP[1^g.CurrentPlayer()]
return &g.PP[g.Turn%2^1]
}
// Apply uses an item by index for the current player.
func (g *Game) Apply(item int) {
cur := &g.PP[g.CurrentPlayer()]
cur := g.CurrentPlayer()
if item < 0 || item >= len(cur.Items) {
return
}

View File

@ -26,7 +26,7 @@ func (i Item) Apply(g *Game) bool {
g.Reveal = true
return true
case ItemCig:
cur := &g.PP[g.CurrentPlayer()]
cur := g.CurrentPlayer()
if cur.HP < g.HP {
cur.HP++
return true