Journal

Finishing the GameBattler Refactor

Posted by:

This week, we finished another important code cleanup: removing the last pieces of the old GameBattler architecture.

GameBattler used to be responsible for far too much. It held definition data, runtime HP/MP/Rage values, battle flags, states, passive bonuses, counterattack behavior, slip damage, cooldowns, equipment bonuses, and a long list of battle helper functions.

That worked earlier in development, but as Last Dream II grew, it became harder to maintain. Actors, enemies, states, equipment, passive skills, and battle mechanics were all tangled together in one place.

The new architecture separates those responsibilities much more cleanly.

Actor progress now lives in persistent actor state. Runtime battle behavior goes through ActionBattler and its backends. State effects are compiled through StateEffects and StateEffectsCompiler. Slip damage, rage loss, counterattacks, passive capabilities, and vital changes each have their own focused systems.

One of the biggest improvements was fully migrating counterattacks. Counters are now handled through a cleaner pipeline: states provide counter behavior, the battle counter system selects the best counter damage option, the action intent carries that information forward, and the damage resolver evaluates the final result. That makes counterattacks much easier to reason about and much safer to extend.

We also confirmed that passive skills no longer need special handling inside GameBattler. Passive effects are now treated like persistent state effects, which is exactly what they are mechanically. That means abilities like tunneling, lockpicking, beast mastery, and other passive capabilities can be resolved through the same state-effect system used everywhere else.

This is another behind-the-scenes refactor, but it is a big one. Removing the old GameBattler responsibilities gives the codebase a cleaner foundation and reduces the risk of future systems accidentally depending on outdated battle logic.

The end result is simple: battlers are now much more clearly separated into definition data, persistent state, runtime battle state, and computed effects. That makes future battle mechanics, character builds, enemy behavior, and status effects much easier to build and maintain.