mwg API
    Preparing search index...

    Class Party<C>

    A roster with a limited active lineup and unlimited off-party storage - a box, a PC, whatever a game calls it. Active slots can hold a gap (a fainted, withdrawn, or simply empty slot); storage is just an overflow list in the order creatures were added to it.

    import { Party, Creature, type Species } from '@datamoc/mw_games/battle';

    const species: Species = { id: 'fireling', types: ['fire'], baseStats: { attack: 10 } };
    const party = new Party<Creature>(3); // 3 active slots

    party.add(new Creature({ species })); // fills an active slot, then overflows to storage
    console.log(party.members.length, party.boxed.length);

    Type Parameters

    • C
    Index
    • the first empty active slot, or storage when the lineup is full

      Parameters

      • creature: C

      Returns void

    • moves an active member to storage, leaving its slot empty

      Parameters

      • index: number

      Returns void

    • brings a boxed creature into a specific active slot, swapping out whatever was there

      Parameters

      • storageIndex: number
      • activeSlot: number

      Returns void