diff --git a/game/game.go b/game/game.go index 6c8b0f1..43cc0af 100644 --- a/game/game.go +++ b/game/game.go @@ -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 } diff --git a/game/item.go b/game/item.go index d0ed602..54f881b 100644 --- a/game/item.go +++ b/game/item.go @@ -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