Implement priority token.

This commit is contained in:
Greyson Parrelli
2026-07-23 00:45:25 -04:00
parent 1c457c602a
commit b8775432b4
6 changed files with 280 additions and 39 deletions
+23 -3
View File
@@ -195,6 +195,18 @@ func (g *Game) resolveBattle() {
sides[p.Seat] = s
res.StackSizes[p.Seat] = len(p.Deck)
}
// seatOrder resolves the priority-token holder first, then everyone else.
// Reveals, queued play effects, and cross-side triggers all follow it, so
// when two pets would act simultaneously (e.g. both throwing rocks) the
// holder acts first — its rocks can faint the enemy pet before that pet's
// own queued rocks resolve.
seatOrder := make([]int, 0, n)
seatOrder = append(seatOrder, g.PrioritySeat)
for seat := range sides {
if seat != g.PrioritySeat {
seatOrder = append(seatOrder, seat)
}
}
// Battle-prep effects that start apples in play (Monkey): they attach
// to the owner's first pet.
for _, p := range g.Players {
@@ -399,7 +411,8 @@ func (g *Game) resolveBattle() {
// effects queue up and resolve after all reveals (simultaneous).
var plays []queuedPlay
newlyPlayed := make([]bool, n)
for seat, s := range sides {
for _, seat := range seatOrder {
s := sides[seat]
for s.unit == nil && len(s.stack) > 0 {
c := s.stack[0]
s.stack = s.stack[1:]
@@ -447,11 +460,12 @@ func (g *Game) resolveBattle() {
}
// Cross-side play triggers: Rhino rocks anyone who just played;
// Crocodile volleys when the enemy plays their last pet.
for seat := range sides {
for _, seat := range seatOrder {
if !newlyPlayed[seat] {
continue
}
for other, os := range sides {
for _, other := range seatOrder {
os := sides[other]
if other == seat {
continue
}
@@ -644,6 +658,12 @@ func (g *Game) resolveBattle() {
res.Trophies = 2
}
g.Players[winner].Trophies += res.Trophies
// Priority token: the winner hands it to the other player; a loser
// who held it keeps it; a draw leaves it put. (Two-player rule; the
// "other player" is unambiguous only at n == 2.)
if winner == g.PrioritySeat {
g.PrioritySeat = (winner + 1) % n
}
}
g.Battle = res