PokéRogue
    Preparing search index...

    Module src/data/arena-tag

    ArenaTags are are meant for effects that are tied to the arena (as opposed to a specific pokemon). Examples include (but are not limited to)

    • Cross-turn effects that persist even if the user/target switches out, such as Happy Hour
    • Effects that are applied to a specific side of the field, such as Crafty Shield, Reflect, and Spikes
    • Field-Effects, like Gravity and Trick Room

    Any arena tag that persists across turns must extend from SerializableArenaTag in the class definition signature.

    Serializable ArenaTags have strict rules for their fields. These rules ensure that only the data necessary to reconstruct the tag is serialized, and that the session loader is able to deserialize saved tags correctly.

    If the data is static (i.e. it is always the same for all instances of the class, such as the type that is weakened by Mud Sport/Water Sport), then it must not be defined as a field, and must instead be defined as a getter. A static property is also acceptable, though static properties are less ergonomic with inheritance.

    If the data is mutable (i.e. it can change over the course of the tag's lifetime), then it must be defined as a field, and it must be set in the loadTag method. Such fields cannot be marked as private/protected; if they were, Typescript would omit them from types that are based off of the class, namely, ArenaTagTypeData. It is preferrable to trade the type-safety of private/protected fields for the type safety when deserializing arena tags from save data.

    For data that is mutable only within a turn (e.g. SuppressAbilitiesTag's beingRemoved field), where it does not make sense to be serialized, the field should use ES2020's private field syntax. If the field should be accessible outside of the class, then a public getter should be used.

    If any new serializable fields are added, then the class must override the loadTag method to set the new fields. Its signature must match the example below,

    class ExampleTag extends SerializableArenaTag {
    // Example, if we add 2 new fields that should be serialized:
    public a: string;
    public b: number;
    // Then we must also define a loadTag method with one of the following signatures
    public override loadTag(source: BaseArenaTag & Pick<ExampleTag, "tagType" | "a" | "b"): void;
    public override loadTag<const T extends this>(source: BaseArenaTag & Pick<T, "tagType" | "a" | "b">): void;
    }

    Notes

    • If the class has any subclasses, then the second form of loadTag must be used.
    ArenaTag
    AuroraVeilTag
    ConditionalProtectTag
    CraftyShieldTag
    DamagingTrapTag
    EntryHazardTag
    FairyLockTag
    FireGrassPledgeTag
    GrassWaterPledgeTag
    GravityTag
    HappyHourTag
    ImprisonTag
    IonDelugeTag
    LightScreenTag
    MatBlockTag
    MistTag
    MudSportTag
    NoCritTag
    NoneTag
    PendingHealTag
    QuickGuardTag
    ReflectTag
    RoomArenaTag
    SafeguardTag
    SerializableArenaTag
    SpikesTag
    StealthRockTag
    StickyWebTag
    SuppressAbilitiesTag
    TailwindTag
    ToxicSpikesTag
    TrickRoomTag
    WaterFirePledgeTag
    WaterSportTag
    WeakenMoveScreenTag
    WeakenMoveTypeTag
    WideGuardTag
    BaseArenaTag
    PendingHealEffect
    ArenaTagTypeMap
    ProtectConditionFunc
    getArenaTag
    loadArenaTag