Pair per-card energy generated with energy wasted #331
No reviewers
Labels
No labels
4-29
bug
documentation
duplicate
enhancement
flow improvement
good first issue
help wanted
invalid
investigating
issue-agent
issue-agent-blocked
issue-agent-complete
issue-agent-pr-open
issue-agent-runner-nelsonlaptop
issue-agent-runner-nelsonpc
issue-agent-runner-nelsonpc-user
issue-agent-running
needs-verification
next to do
question
queue
recon
relics-stats-onboarding
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/spirelens!331
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/energy-wasted-ledger"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
TotalEnergyGeneratedhas had no counterpart since it landed. A card thathands you 2 energy on a turn you have nothing left to spend it on scores the
same 2 as one that fuels a kill — the number reads as pure profit and isn't.
This is the same unpaired-stat gap as took/shown, in the energy column.
Approach
Energy is a single fungible pool, so this reuses the provenance ledger the
block stats already run on, under the same stated convention:
EnergyChunkowned by one source — a cardinstance, a relic id, or nobody;
them before it lands on a card.
The two seams
Neither is the obvious hook, and both are recorded in the primer:
PlayerCombatState.LoseEnergyis the spend point, not the finished cardplay. The pool is already short by a card's cost while that card is still
resolving, so inferring the spend afterwards would make a mid-resolution gain
reconcile as LIFO waste rather than a FIFO spend — and blame the wrong
card.
PlayerCombatState.ResetEnergyis the waste point, patched as a prefixbecause the leftover is unreadable afterwards.
Hook.AfterEnergyResetfireson both branches of
CombatManager.SetupPlayerTurnand cannot tell a resetfrom a conserve.
ResetEnergyis only reached when the pool is genuinelythrown away, so energy conservation needs no handling at all: those chunks
survive into the next turn and stay spendable.
Energy still in the pool when combat ends is wasted too, alongside the existing
block flush.
Surfaces
Verification
EnergyLedgerConservationTestspin FIFO-spend / LIFO-waste, that theuntagged refill absorbs waste instead of blaming a card, and relic ownership.
energy-wasted-ledger-run.jsonfixture plusSchemaLoadingTestscases forboth new persisted fields, and a case proving older runs default to zero
wasted rather than failing to load.
Restart note:
LoseEnergyandResetEnergywere unpatched earlier in therunning process, so per the primer's "Newly Added Harmony Targets Need One Full
Restart" finding, behavioral verification needs one full game restart. Hot
reload installed both classes (437 patched, 0 failed).
🤖 Generated with Claude Code
Follow-up commit
d36eab7: the pair was going in as two extra rows mirroring the block stats, not as the singlex/yrow #330 established. Card tooltip now renders one⚡ gained/wasted 8/3 38%row in both full and compact views, dropping the standalone gained row and the derived used row.The relic side keeps a separate zero-suppressed row on purpose. Only relics whose gain runs through a
PlayerEnergyGainattribution window — Happy Flower, Nunchaku, Booming Conch, Gremlin Horn, and the turn-energy relics — put an owned chunk in the ledger. Art of War, Seal of Gold and the max-energy relics (Prismatic Gem, Pumpkin Candle, Spiked Gauntlets, Blood-Soaked Rose) reach the pool by routes that ledger untagged, so pairing them would print0 wastedand assert something never measured. Suppressing at zero says "not attributed"; pairing can follow once those routes are ledgered.18cc2af: the refill is no longer one ownerless block.MaxEnergyis the character's base folded throughHook.ModifyMaxEnergy, which runs each combat hook listener in turn and passes the running total on. Replaying that fold at both refill points recovers each source's exact contribution, so the allowance enters as ordered chunks — base first, then each max-energy relic in the game's own listener order. Max-energy relics (Prismatic Gem, Pumpkin Candle, Spiked Gauntlets, Blood-Soaked Rose) now own their point of the pool and inherit the existing FIFO-spend / LIFO-waste convention. No invented rule, no proportional fractions.AddMaxEnergyToCurrentgets the same split — it wastes nothing, but the incoming allowance still needs its sources named.Remaining unattributed: Art of War and Seal of Gold, which pass through
GainEnergybut arm no attribution window.c85afdf: all three remaining unowned routes are ledgered, and the relic row is now a real pair.Art of War, Seal of Gold and Venerable Tea Set each measure their own gain from a before/after pool delta rather than through an attribution window. Tea Set wasn't in the two I named earlier — it turned up only by enumerating every writer of
RelicAggregate.EnergyGenerated.They arm a new
PlayerEnergyLedgerOwnerwindow: names the chunk's owner, credits nothing. An ordinaryPlayerEnergyGainwindow would tag the chunk and doubleEnergyGenerated; removing their own counting instead would have left those stats asserted only by test seams nothing calls.With every route owned, a relic's
0 wastedis a measurement rather than an absence of one — so the relic tooltip folds into onegenerated/wastedrow, same convention as the card tooltip and #330. That changed the rendered value for 13 relic tooltips and 1 card tooltip; their assertions moved with it.Full suite: 2150 passed, 0 failed. One of those 14 failures predated this commit — the card-side pairing in
d36eab7went out without a full suite run.