Skip to content

Add explicit life change logs #9844

@TytaniumDev

Description

@TytaniumDev

Is your feature request related to a problem? Please describe.
I'm building a tool that uses Forge in a headless state to simulate many games of commander to roughly determine decks' power levels (https://github.com/TytaniumDev/MagicBracketSimulator). My tool uses the logs output by the forge runs to figure out what happened in each game.

It's currently extremely difficult to track life totals for each player, since any changes to life are implied through things like resolving effects on the stack, which requires tracking of multiple pieces of information and is very error prone.

Describe the solution you'd like
Add a log line whenever a player's life total changes, with the format something like:

Life: Ai(1)-DeckName life changed to 38

Describe alternatives you've considered
It's a relatively simple change, but there could be many ways the log line could be formatted. Open to opinions here.

Additional context
It looks like the change would be something like this:

File: forge-game/src/main/java/forge/game/GameLogFormatter.java

Add this method alongside the existing visit(GameEventPlayerDamaged) and visit(GameEventPlayerPoisoned) methods:

 @Override
 public GameLogEntry visit(GameEventPlayerLivesChanged ev) {
     String message = localizer.getMessage("lblLogPlayerLifeChange",
         ev.player().toString(),
         String.valueOf(ev.oldLives()),
         String.valueOf(ev.newLives()));
     return new GameLogEntry(GameLogEntryType.DAMAGE, message);
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions