Various bug fixes and improvements.

This commit is contained in:
Greyson Parrelli
2026-07-24 10:47:59 -04:00
parent 0fe0757e18
commit 6558806ba0
10 changed files with 66 additions and 27 deletions
+5 -5
View File
@@ -2,7 +2,6 @@ package game
import (
"fmt"
"slices"
)
// BattleUnit is a pet in play with its attached foods applied. Power
@@ -1165,19 +1164,20 @@ func (g *Game) runBattle() *BattleResult {
Text: fmt.Sprintf("%s eats an apple (now +%d).", q.unit.Card.Name, q.unit.Bonus)})
}
case ActionShuffleApples:
// Komodo: only if it's the side's first pet, shuffle apples into
// random deck positions (deterministic via the battle draw tape).
// Komodo: only if it's the side's first pet, add apples to the
// remaining deck and shuffle the whole thing so the apples and the
// existing pets intermix (not just apples dropped in).
if q.effect.Condition == ConditionFirstPet && sides[q.seat].petsPlayed != 1 {
continue
}
s := sides[q.seat]
for range q.effect.count() {
pos := g.battleDraw(len(s.stack) + 1)
apple := g.newApple()
s.stack = slices.Insert(s.stack, pos, apple)
s.stack = append(s.stack, apple)
emit(BattleEvent{Type: "summon", Seat: q.seat, Card: &apple,
Text: fmt.Sprintf("%s shuffles an apple into %s's deck.", q.unit.Card.Name, pname(q.seat))})
}
g.battleShuffle(s.stack)
case ActionSpendRocks:
// Nurse Shark: spend as many Trumpets as available (up to Count) to
// throw two rocks each.
+2 -2
View File
@@ -196,8 +196,8 @@ const (
ActionRevealForApples EffectAction = "revealForApples"
// --- Golden pack, tier 6 ---
// ActionShuffleApples (play) shuffles Count apples into random positions of
// the owner's remaining deck (Komodo). Gated by ConditionFirstPet.
// ActionShuffleApples (play) adds Count apples to the owner's remaining
// deck and shuffles the whole deck (Komodo). Gated by ConditionFirstPet.
ActionShuffleApples EffectAction = "shuffleApples"
// ActionReactivateBuys (battle prep) re-fires the Buy ability of every pet
// in the owner's hand (Catfish).
+9
View File
@@ -159,6 +159,15 @@ func (g *Game) battleDraw(n int) int {
// rollRockDie rolls one rock die: 0, 1, or 2 with equal probability.
func (g *Game) rollRockDie() int { return g.battleDraw(3) }
// battleShuffle does an in-place Fisher-Yates over a battle deck, routing its
// randomness through battleDraw like every other in-battle draw (Komodo).
func (g *Game) battleShuffle(s []Card) {
for i := len(s) - 1; i > 0; i-- {
j := g.battleDraw(i + 1)
s[i], s[j] = s[j], s[i]
}
}
var (
ErrNotYourTurn = errors.New("not your turn")
ErrWrongPhase = errors.New("action not allowed in this phase")
+7 -3
View File
@@ -18,9 +18,12 @@ type PlayerView struct {
Avocados int `json:"avocados,omitempty"`
// FirstBuyFree / BuysThisRound (Golden pack) are self-only: they'd reveal
// hidden deck facts (a Manta Ray) to opponents.
FirstBuyFree bool `json:"firstBuyFree,omitempty"`
BuysThisRound int `json:"buysThisRound,omitempty"`
Deck []Card `json:"deck,omitempty"` // self only
FirstBuyFree bool `json:"firstBuyFree,omitempty"`
BuysThisRound int `json:"buysThisRound,omitempty"`
// Trumpets is the count banked for the next battle (Bird of Paradise).
// Self-only — shown under the player's own deck.
Trumpets int `json:"trumpets,omitempty"`
Deck []Card `json:"deck,omitempty"` // self only
}
// View is the full game state as seen by one player.
@@ -105,6 +108,7 @@ func (g *Game) ViewFor(playerID string) View {
pv.Deck = p.Deck
pv.FirstBuyFree = p.FirstBuyFree
pv.BuysThisRound = p.BuysThisRound
pv.Trumpets = p.PendingTrumpets
}
v.Players = append(v.Players, pv)
}