mwg API
    Preparing search index...

    Type Alias BattleStatCategory

    BattleStatCategory:
        | "recruits"
        | "recalls"
        | "advances"
        | "kills"
        | "deaths"
        | "damageDealt"
        | "damageTaken"

    A per-run battle statistics breakdown by category and unit type - recruits, recalls, advances, kills, deaths, damage dealt, damage taken - the shape Wesnoth's own statistics dialog shows and a bare core.PlayerStats<T> cannot give a game for free, since T there is an opaque summary the game must already know how to combine. Here the categories and the per-unit-type breakdown are the primitive: a game records one event at a time as it happens and reads either a category's total or its breakdown by unit type, then folds toJSON() into a core.RunHistory entry or a core.PlayerStats total the way any other run summary would.

    import { BattleStats } from '@datamoc/mw_games/battle';

    const stats = new BattleStats();
    stats.record('kills', 'orc-grunt');
    stats.record('kills', 'orc-grunt');
    stats.record('damageDealt', 'elvish-archer', 12);

    console.log(stats.total('kills')); // 2
    console.log(stats.breakdown('kills')); // [{ unitType: 'orc-grunt', count: 2 }]