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.
|
// CurrentPlayer gets the index of the current player, either 0 or 1.
|
||||||
func (g *Game) CurrentPlayer() uint {
|
func (g *Game) CurrentPlayer() *Player {
|
||||||
return g.Turn % 2
|
return &g.PP[g.Turn%2]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opponent returns the player who is not the current player.
|
// Opponent returns the player who is not the current player.
|
||||||
func (g *Game) Opponent() *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.
|
// Apply uses an item by index for the current player.
|
||||||
func (g *Game) Apply(item int) {
|
func (g *Game) Apply(item int) {
|
||||||
cur := &g.PP[g.CurrentPlayer()]
|
cur := g.CurrentPlayer()
|
||||||
if item < 0 || item >= len(cur.Items) {
|
if item < 0 || item >= len(cur.Items) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func (i Item) Apply(g *Game) bool {
|
|||||||
g.Reveal = true
|
g.Reveal = true
|
||||||
return true
|
return true
|
||||||
case ItemCig:
|
case ItemCig:
|
||||||
cur := &g.PP[g.CurrentPlayer()]
|
cur := g.CurrentPlayer()
|
||||||
if cur.HP < g.HP {
|
if cur.HP < g.HP {
|
||||||
cur.HP++
|
cur.HP++
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user