49 lines
2.1 KiB
Go
49 lines
2.1 KiB
Go
package game
|
|
|
|
import "testing"
|
|
|
|
// Regression (improvements.txt): a Crocodile set aside must still throw its
|
|
// last-pet volley when the enemy plays their final pet, even though the
|
|
// Crocodile's own side is already out of pets. Previously the "battle over"
|
|
// check fired first and swallowed the parting shot.
|
|
func TestCrocodileLastPetVolleyFiresWhenOwnerOut(t *testing.T) {
|
|
g, _, _ := testGame(t)
|
|
g.RollDie = func() int { return 2 } // 3 rocks -> 6 damage
|
|
res := forceBattle(t, g,
|
|
[]Card{g.pet("Killer", 4), g.pet("Last", 3)}, // seat 0 plays its last pet
|
|
[]Card{g.realPet(t, "Crocodile")}, // seat 1's Croc faints, sets aside
|
|
)
|
|
// Killer trades with Crocodile (set aside). Seat 0 then plays its last pet,
|
|
// and the Crocodile's 3 rocks (roll 6) pelt it dead — turning a win into a
|
|
// mutual knockout.
|
|
rocks := eventsOfType(res, "rock")
|
|
if len(rocks) != 1 || rocks[0].Seat != 1 || rocks[0].Roll != 6 || !rocks[0].TargetDied {
|
|
t.Fatalf("Crocodile should volley the last pet for 6: %+v", rocks)
|
|
}
|
|
if res.WinnerSeat != -1 {
|
|
t.Fatalf("both sides should be out (draw), got winner %d", res.WinnerSeat)
|
|
}
|
|
}
|
|
|
|
// Regression: a pair that can't hurt each other (two 0-attack pets, here
|
|
// Spooked down to nothing) must both faint so the pets behind them settle the
|
|
// battle. Previously the stalemate ended the whole battle in a draw, even with
|
|
// most of both decks still to come.
|
|
func TestStalematedPairFaintsAndBattleContinues(t *testing.T) {
|
|
g, p1, _ := unicornGame(t)
|
|
p1.Mana = 2
|
|
res := forceBattle(t, g,
|
|
// Nightcrawler (1 power) Spooks Barghest twice; Barghest (1 power)
|
|
// Spooks it once. Neither can deal damage, but Pengobble is next up.
|
|
[]Card{g.unicornPet(t, "Nightcrawler"), g.unicornPet(t, "Pengobble")},
|
|
[]Card{g.unicornPet(t, "Barghest"), g.pet("Chaff", 1)},
|
|
)
|
|
clashes := eventsOfType(res, "clash")
|
|
if len(clashes) != 1 || !clashes[0].Died[0] || !clashes[0].Died[1] {
|
|
t.Fatalf("the stuck pair should both faint in one clash: %+v", clashes)
|
|
}
|
|
if res.WinnerSeat != 0 {
|
|
t.Fatalf("Pengobble should go on to win for seat 0, got winner %d", res.WinnerSeat)
|
|
}
|
|
}
|