Add life total change logging to game log#9845
Add life total change logging to game log#9845TytaniumDev wants to merge 5 commits intoCard-Forge:masterfrom
Conversation
8111b9d to
634d65f
Compare
GameEventPlayerLivesChanged is already fired on every life change but had no visitor in GameLogFormatter, so the event was silently discarded. - Add GameLogEntryType.LIFE enum value (answers the "Where's life loss?" comment that was in the enum) - Add visit(GameEventPlayerLivesChanged) to GameLogFormatter - Add lblLogPlayerLifeChange localization key to all language files - Log format: "Life: PlayerName oldLife -> newLife" - Add 6 tests in GameLogLifeChangeTest covering loss, gain, format, zero-loss no-op, setLife (both directions + no-op), multiple changes Closes Card-Forge#9844 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
634d65f to
02fd6cc
Compare
|
I think this is a good addition, but suspect it doesn't need built-in tests to validate the logging capability as long as we're confident it works? i.e. do other |
|
yea imo AI a bit too overeager: a more generic test for logging would be more valuable |
|
@tool4ever @MostCromulent would you like me to remove the test, or condense it somehow? Or should I try to have the AI write a more generic logging test in this PR (seems out of scope)? |
|
I'd suggest just removing the tests from this PR - we're doing some work on logging separately and can think about a more general test there if needed. Really the proof is in the pudding on this one - either the life events show up in the log or they don't. |
Tests for life total change logging are not needed at this time. Logging validation will be handled separately as part of broader logging infrastructure work. https://claude.ai/code/session_01PXr1guxfuZVQvSYZUwhxk7
…-njYqQ Remove GameLogLifeChangeTest per reviewer feedback
|
@MostCromulent done! |
I'm building a tool that uses headless Forge simulations to play commander games and then analyze the logs (more detail in #9844 ). Player life changes are currently not logged, which makes it hard to visualize game states at a high level.
This PR adds life logging. The code was primarily written by Claude but I've verified it and made sure tests were written to validate all the scenarios I could think of.
Summary
GameEventPlayerLivesChangedis already fired on every life total change but had no visitor inGameLogFormatter— the event was silently discardedGameLogEntryType.LIFEenum value, replacing the// Where's life loss?comment that was next toDAMAGEvisit(GameEventPlayerLivesChanged)toGameLogFormatterproducing log lines like:Life: Ai(1)-Doran Big Butts 40 -> 37lblLogPlayerLifeChangeto all language files (English fallback for non-English locales)GameLogLifeChangeTestNo behavior changes to existing log entries.
Closes #9844
Example game log output
Combat damage → life change
Two Nest Robbers (2/1 haste) attack an opponent at 4 life:
Lifegain from spell resolution
AI casts Lightning Helix (3 damage + 3 life) targeting opponent at 3 life:
Test results
Existing tests (63/63 passing, no regressions)
Full build with Checkstyle (all 13 modules passing)
Build command:
mvn -U -B clean install -P windows-linuxTest plan
mvn -U -B clean install -P windows-linuxpasses (includes Checkstyle)GameSimulationTest— all 63 tests pass (no regressions)[LIFE]entries after[DAMAGE]entries in combat scenarios[LIFE]entries for both damage-caused loss and spell-caused gain (Lightning Helix)Damage:,Combat:, etc.) are unchangedLife:lines show accurate before/after values matching the game state🤖 Generated with Claude Code