mwg API
    Preparing search index...

    Class AttackDialog

    The attack dialog's whole state, with no renderer: the unit selector, the damage preview the game's numbers build, and the animation clock the preview is sampled on.

    The order of business is the one a player sees - choose an attacker, choose a target, and the dialog shows a blow that lands over time - so the clock is here rather than in a widget: update takes the frame's dt and returns the preview frame to draw, and finished says when the animation has run out and the caller may apply the result. damageFor is where the game's own rules live; this model never invents damage.

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

    const dialog = new AttackDialog({
    units: [{ id: 'hero', side: '1' }, { id: 'rat', side: '2' }],
    side: '1',
    damageFor: () => ({ damage: 4, strikes: 2 }),
    strikeDuration: 0.25,
    });
    dialog.select();
    dialog.select();
    console.log(dialog.update(0.3)?.defenderHp); // the defender after the second strike
    Index
    onChange: Signal<void> = ...
    selector: UnitSelector