Reveal tripled-in pets but keep the pick secret unless it buys.
This commit is contained in:
@@ -2,6 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -225,6 +226,54 @@ func TestTradeTriggersTripleAndBuyEffects(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A triple makes the three discarded pets public, but keeps the chosen pet
|
||||
// secret — unless it has a Buy ability, which performs publicly.
|
||||
func TestTradeVisibilityHidesPickUnlessBuyEffect(t *testing.T) {
|
||||
logContains := func(g *Game, sub string) bool {
|
||||
for _, e := range g.Log {
|
||||
if strings.Contains(e.Text, sub) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
trade := func(g *Game, pick Card) *Game {
|
||||
p := current(g)
|
||||
var ids []string
|
||||
for range 3 {
|
||||
c := g.pet("Newt", 1)
|
||||
c.Suit = SuitBlue
|
||||
p.Deck = append(p.Deck, c)
|
||||
ids = append(ids, c.ID)
|
||||
}
|
||||
if err := g.TradeStart(p.ID, ids); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
g.Pending.Options[0] = pick
|
||||
if err := g.TradeChoose(p.ID, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return g
|
||||
}
|
||||
|
||||
// Discarded trio is named; an effect-less pick stays hidden.
|
||||
g, _, _ := testGame(t)
|
||||
trade(g, g.pet("SecretPet", 3))
|
||||
if !logContains(g, "Newt") {
|
||||
t.Fatal("the discarded pets should be public in the log")
|
||||
}
|
||||
if logContains(g, "SecretPet") {
|
||||
t.Fatal("a pick with no buy ability must stay hidden")
|
||||
}
|
||||
|
||||
// A pick with a Buy ability (Otter) is revealed.
|
||||
g2, _, _ := testGame(t)
|
||||
trade(g2, g2.realPet(t, "Otter"))
|
||||
if !logContains(g2, "Otter") {
|
||||
t.Fatal("a pick with a buy ability should be revealed in the log")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuyWormAddsTwoApples(t *testing.T) {
|
||||
g, _, _ := testGame(t)
|
||||
p := current(g)
|
||||
|
||||
Reference in New Issue
Block a user