Add DEBUG-gated panel to buy any card in the shop
When the server's DEBUG env var is on, expose a card catalog endpoint and a collapsible client panel that drops any pet or food straight into your deck (free, off-turn). Gated server-side so it is inert in normal play.
This commit is contained in:
@@ -519,6 +519,60 @@ func (g *Game) buildShopDecks() {
|
||||
}
|
||||
}
|
||||
|
||||
// Catalog returns one representative card for every pet and food in the game,
|
||||
// tier by tier, for the debug "buy any card" panel. IDs are name-based
|
||||
// placeholders (not real instances); pets use their first printed suit.
|
||||
func Catalog() []Card {
|
||||
var cards []Card
|
||||
for tierIdx := range petTiers {
|
||||
for _, t := range petTiers[tierIdx] {
|
||||
suit := SuitRed
|
||||
if len(t.Suits) > 0 {
|
||||
suit = t.Suits[0]
|
||||
}
|
||||
cards = append(cards, Card{
|
||||
ID: "pet-" + t.Name, Kind: KindPet, Name: t.Name, Tier: tierIdx + 1,
|
||||
Power: t.Power, Suit: suit, Effects: t.Effects, EffectText: t.EffectText,
|
||||
})
|
||||
}
|
||||
for _, f := range foodTiers[tierIdx] {
|
||||
cards = append(cards, Card{
|
||||
ID: "food-" + f.Name, Kind: KindFood, Name: f.Name, Tier: tierIdx + 1,
|
||||
Food: f.Food, Perk: f.Perk, Effects: f.Effects, EffectText: f.EffectText,
|
||||
})
|
||||
}
|
||||
}
|
||||
return cards
|
||||
}
|
||||
|
||||
// cardByName mints a fresh instance of the named pet or food from its
|
||||
// template (pets take their first printed suit). Returns false if unknown.
|
||||
func (g *Game) cardByName(name string) (Card, bool) {
|
||||
for tierIdx := range petTiers {
|
||||
for _, t := range petTiers[tierIdx] {
|
||||
if t.Name == name {
|
||||
suit := SuitRed
|
||||
if len(t.Suits) > 0 {
|
||||
suit = t.Suits[0]
|
||||
}
|
||||
return Card{
|
||||
ID: g.newCardID(), Kind: KindPet, Name: t.Name, Tier: tierIdx + 1,
|
||||
Power: t.Power, Suit: suit, Effects: t.Effects, EffectText: t.EffectText,
|
||||
}, true
|
||||
}
|
||||
}
|
||||
for _, f := range foodTiers[tierIdx] {
|
||||
if f.Name == name {
|
||||
return Card{
|
||||
ID: g.newCardID(), Kind: KindFood, Name: f.Name, Tier: tierIdx + 1,
|
||||
Food: f.Food, Perk: f.Perk, Effects: f.Effects, EffectText: f.EffectText,
|
||||
}, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return Card{}, false
|
||||
}
|
||||
|
||||
// newApple mints an apple food card. Apples are temporary: they vanish from
|
||||
// the deck after the next battle.
|
||||
func (g *Game) newApple() Card {
|
||||
|
||||
Reference in New Issue
Block a user