don't care about player index, we have ids
This commit is contained in:
parent
b7c7fd260f
commit
56f8387385
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user