Implement priority token.
This commit is contained in:
@@ -393,12 +393,17 @@ func TestFullGameFlow(t *testing.T) {
|
||||
g, p1, p2 := testGame(t)
|
||||
p1.Deck = append(p1.Deck, g.pet("Champ", 9))
|
||||
p2.Deck = append(p2.Deck, g.pet("Chump", 1))
|
||||
// testGame pins the priority token to seat 0, and seat 0 wins every
|
||||
// battle, so the token moves to seat 1 after round 1 and stays there (a
|
||||
// loser keeps it). Whoever holds it shops first.
|
||||
wantPriority := p1.Seat
|
||||
for round := 1; round <= MaxRounds; round++ {
|
||||
if g.Round != round || g.Phase != PhaseShop {
|
||||
t.Fatalf("expected shop of round %d, got round %d phase %s", round, g.Round, g.Phase)
|
||||
}
|
||||
if g.Turn != (round-1)%len(g.Players) {
|
||||
t.Fatalf("round %d should rotate the starting player, turn=%d", round, g.Turn)
|
||||
if g.PrioritySeat != wantPriority || g.Turn != wantPriority {
|
||||
t.Fatalf("round %d: priority holder should shop first (want seat %d, priority=%d turn=%d)",
|
||||
round, wantPriority, g.PrioritySeat, g.Turn)
|
||||
}
|
||||
for _, c := range g.ShopRow {
|
||||
if c.ID != "" && c.Tier != round {
|
||||
@@ -417,6 +422,10 @@ func TestFullGameFlow(t *testing.T) {
|
||||
if g.Battle.WinnerSeat != p1.Seat {
|
||||
t.Fatalf("round %d: seat 0 should win", round)
|
||||
}
|
||||
// The winner hands the token to the loser; a loser keeps it.
|
||||
if wantPriority == g.Battle.WinnerSeat {
|
||||
wantPriority = (wantPriority + 1) % len(g.Players)
|
||||
}
|
||||
for _, p := range g.Players {
|
||||
if err := g.AcknowledgeBattle(p.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user