mwg API
    Preparing search index...

    Class RecruitmentPattern

    The order a side recruits in - Wesnoth's recruitment_pattern, e.g. scout, fighter, archer - cycled by turn. A side with nothing left to recruit falls back to its fallback, and a side with neither recruits nothing.

    import { RecruitmentPattern } from '@datamoc/mw_games/ai';

    const pattern = new RecruitmentPattern(['scout', 'fighter'], 'fighter');
    console.log(pattern.at(0), pattern.at(1), pattern.at(2)); // scout fighter scout
    Index
    • the unit type at a position in the cycle, or the fallback when the pattern is empty

      Parameters

      • index: number

      Returns string | null

    • the entry after after in the cycle, or the first when after is not in it

      Parameters

      • after: string | null

      Returns string | null