mwg API
    Preparing search index...

    Interface AchievementCriterion

    Achievements: named milestones unlocked by counters crossing a target - monsters slain, gold collected, floors descended, runs won.

    The shape every badge/achievement list shares: a definition names a counter and the value that earns it, the game increments counters as things happen, and unlocking is derived (a counter at or past its target), never stored separately - so a counter can only ever move one way and an unlocked achievement can never disagree with the count behind it. Descriptions are display text mwg never reads; persistence is the usual definitions-fresh, progress-saved split (QuestLog's own convention).

    An achievement can also name several criteria instead of one - Wesnoth's own "sub-achievements" shape, such as "recruit one of every unit type" being six counters that must each reach 1 - and it unlocks only once every one of them has. A single counter/target is shorthand for a one-criterion achievement; both forms share the same unlock, progress and save code, since a one-element criteria list behaves identically to the shorthand.

    import { Achievements } from '@datamoc/mwg/core';

    const achievements = new Achievements();
    achievements.define({ id: 'first-blood', counter: 'kills', target: 1 });
    achievements.define({ id: 'slayer', counter: 'kills', target: 100 });
    achievements.define({
    id: 'diverse-army',
    criteria: [
    { counter: 'recruited-archer', target: 1 },
    { counter: 'recruited-knight', target: 1 },
    ],
    });

    const unlocked = achievements.increment('kills', 1);
    console.log(unlocked); // ['first-blood']

    // later, a UI drains and announces whatever unlocked since it last checked
    const toast = achievements.drainNew();
    interface AchievementCriterion {
        counter: string;
        target: number;
    }
    Index
    counter: string

    the counter this criterion watches, incremented by the game as things happen

    target: number

    the counter value that satisfies this criterion