[Bug] [Beta] Fix serializable battler tags (#6183)

Fix serializable battler tags
This commit is contained in:
Sirz Benjie 2025-07-31 17:44:03 -06:00 committed by GitHub
parent 12433b78e5
commit 6204a6fdcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -1659,7 +1659,10 @@ export function getArenaTag(
* @param source - An arena tag
* @returns The valid arena tag
*/
export function loadArenaTag(source: ArenaTag | ArenaTagTypeData): ArenaTag {
export function loadArenaTag(source: ArenaTag | ArenaTagTypeData | { tagType: ArenaTagType.NONE }): ArenaTag {
if (source.tagType === ArenaTagType.NONE) {
return new NoneTag();
}
const tag =
getArenaTag(source.tagType, source.turnCount, source.sourceMove, source.sourceId, source.side) ?? new NoneTag();
tag.loadTag(source);

View File

@ -201,7 +201,7 @@ export class BattlerTag implements BaseBattlerTag {
}
}
export abstract class SerializableBattlerTag extends BattlerTag {
export class SerializableBattlerTag extends BattlerTag {
/** Nonexistent, dummy field to allow typescript to distinguish this class from `BattlerTag` */
private declare __SerializableBattlerTag: never;
}
@ -3641,7 +3641,7 @@ export function getBattlerTag(
case BattlerTagType.FRENZY:
return new FrenzyTag(turnCount, sourceMove, sourceId);
case BattlerTagType.CHARGING:
return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, 1, sourceMove, sourceId);
return new SerializableBattlerTag(tagType, BattlerTagLapseType.CUSTOM, 1, sourceMove, sourceId);
case BattlerTagType.ENCORE:
return new EncoreTag(sourceId);
case BattlerTagType.HELPING_HAND:
@ -3726,10 +3726,10 @@ export function getBattlerTag(
return new DragonCheerTag();
case BattlerTagType.ALWAYS_CRIT:
case BattlerTagType.IGNORE_ACCURACY:
return new BattlerTag(tagType, BattlerTagLapseType.TURN_END, 2, sourceMove);
return new SerializableBattlerTag(tagType, BattlerTagLapseType.TURN_END, 2, sourceMove);
case BattlerTagType.ALWAYS_GET_HIT:
case BattlerTagType.RECEIVE_DOUBLE_DAMAGE:
return new BattlerTag(tagType, BattlerTagLapseType.PRE_MOVE, 1, sourceMove);
return new SerializableBattlerTag(tagType, BattlerTagLapseType.PRE_MOVE, 1, sourceMove);
case BattlerTagType.BYPASS_SLEEP:
return new BattlerTag(tagType, BattlerTagLapseType.TURN_END, turnCount, sourceMove);
case BattlerTagType.IGNORE_FLYING: