mwg API
    Preparing search index...

    Class SideTurns

    Which side is taking its turn, which round it is, and what time of day applies - the outer scenario loop. advance() moves to the next side; wrapping past the last side opens a new round and steps the schedule on one entry, cycling. timeOfDayAt(x, y) and lawfulBonusAt(...) read the schedule for a cell, so a time area can give one region a different bonus without a second turn counter.

    import { SideTurns } from '@datamoc/mw_games/world';

    const turns = new SideTurns({
    sides: ['rebels', 'undead'],
    schedule: [
    { id: 'day', lawfulBonus: 25 },
    { id: 'night', lawfulBonus: -25 },
    ],
    });

    console.log(turns.side, turns.round, turns.timeOfDay.id); // 'rebels' 1 'day'
    console.log(turns.lawfulBonusAt('lawful', 4, 4)); // 25 - a lawful unit in the day
    turns.advance(); // 'undead', still round 1
    turns.advance(); // 'rebels', round 2, timeOfDay is now 'night'
    Index
    schedule: readonly TimeOfDay[]
    sides: readonly string[]
    • The percentage bonus alignment gets at a cell, through that cell's own time of day.

      Parameters

      Returns number

    • The time of day at a cell: the first containing time area's entry, else the global one.

      Parameters

      • x: number
      • y: number

      Returns TimeOfDay