PokéRogue
    Preparing search index...

    Module src/data/battler-tags

    BattlerTags are used to represent semi-persistent effects attached to individual Pokemon.

    During serialization, a new blank tag object is created, before its loadTag is called with the object that was serialized.
    This makes it fairly straightforward to avoid serializing fields — anything not set in the class constructor or the tag's loadTag method will not be serialized.

    Any battler tag that can persist across waves (meaning it lasts longer than 1 turn) must extend SerializableBattlerTag in its class definition signature.

    SerializableBattlerTags have strict requirements for their fields:

    • Properties that are not necessary to reconstruct the tag must not be serialized This can be accomplished by using private elements and/or getters.
      Note that getters do not need to be tied to a class field, for example:

      class Example {
      public get thing(): number {
      return 5;
      }
      }
    • If a property that is intended to be "private" should be serialized, it must be declared as public readonly instead. Then, in the loadTag method (or any internal method that needs to adjust the property), use a cast to Writable<this> (such as (this as Writable<this>).propertyName = value).
      This ensures that Typescript is aware of the shape of the serialized version of the class.

    • 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 SerializableBattlerTag {
      // 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:
      // This signature should be used if the class has no subclasses:
      public override loadTag(source: BaseBattlerTag & Pick<ExampleTag, "tagType" | "a" | "b"): void;
      // This signature should be used if the class has any subclasses:
      public override loadTag<const T extends this>(source: BaseBattlerTag & Pick<T, "tagType" | "a" | "b">): void {
      this.a = source.a;
      this.b = source.b;
      }
      }
    AbilityBattlerTag
    AquaRingTag
    AutotomizedTag
    BattlerTag
    BeakBlastChargingTag
    BindTag
    BypassSpeedTag
    CenterOfAttentionTag
    ClampTag
    CommandedTag
    ConfusedTag
    ContactDamageProtectedTag
    ContactProtectedTag
    ContactSetStatusProtectedTag
    ContactStatStageChangeProtectedTag
    CritBoostTag
    CursedTag
    DamagingTrapTag
    DestinyBondTag
    DisabledTag
    DoTTag
    DrowsyTag
    ElectrifiedTag
    EncoreTag
    EnduringTag
    ExposedTag
    FireSpinTag
    FlinchedTag
    FloatingTag
    FrenzyTag
    GenericTrappedTag
    GorillaTacticsTag
    GroundedTag
    GrudgeTag
    GulpMissileTag
    HealBlockTag
    HelpingHandTag
    HighestStatBoostTag
    ImprisonTag
    InfatuatedTag
    InfestationTag
    IngrainTag
    InterruptedTag
    MagicCoatTag
    MagmaStormTag
    MinimizeTag
    MoveLockTag
    MoveRestrictionBattlerTag
    MysteryEncounterPostSummonTag
    NightmareTag
    NoRetreatTag
    OctolockTag
    PerishSongTag
    PowderTag
    PowerTrickTag
    ProtectedTag
    PsychoShiftTag
    RageTag
    RechargingTag
    RemovedTypeTag
    RoostedTag
    SaltCuredTag
    SandTombTag
    SeedTag
    SemiInvulnerableTag
    SerializableBattlerTag
    ShellTrapTag
    SlowStartTag
    SnapTrapTag
    StockpilingTag
    SturdyTag
    SubstituteTag
    SupremeOverlordTag
    SyrupBombTag
    TarShotTag
    TauntTag
    TelekinesisTag
    TerrainHighestStatBoostTag
    ThroatChoppedTag
    ThunderCageTag
    TormentTag
    TrappedTag
    TruantTag
    TypeBoostTag
    UnburdenTag
    WeatherHighestStatBoostTag
    WhirlpoolTag
    WrapTag
    BaseBattlerTag
    DamageOverTimeTag
    GenericSerializableBattlerTag
    BattlerTagFromType
    BattlerTagTypeMap
    DamagingBattlerTag
    DamagingBattlerTag
    getBattlerTag
    loadBattlerTag