mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-02-03 06:37:12 +00:00
13f38dce8d
* Use BattlerTag for move-disabling effects * Fix RUN command causing freeze * Improve documentation * Clean up and document PokemonMove.isUsable * Fix isMoveDisabled missing return * Tags define the message shown when disabling interrupts a move * Fix -1 duration on Disable effect * Add tests for Disable * En loc and fix message functions * Fix Disable test * Fix broken imports * Fix test * All disable tests passing * Localize remaining strings * Move cancellation logic out of lapse; use use TURN_END for lapse type * Prevent disabling STRUGGLE * Inline struggle check function * Restore RechargingTag docs * Move cancellation logic back to tag Wanted to increase similarity to the existing code base to avoid that stupid hyper beam error but it's still happening here * Fix hyper beam test * Remove erroneous shit * Fill movesets with SPLASH for disable test * More robust condition for disable checking * Remove DisabledTag lapse * Simplify DisablingBattlerTag lapse * Cancel disable-interrupted moves instead of failing them * Avoid disabling virtual moves * Consistent access modifiers across Disable tags * Add abstract function for message when player tries to select the disabled move * Fix syntax mistake * Always disable last-used non-virtual move * Overhaul tests + add tests * Implement loadTag for DisabledTag * Update translations * Update translations * Reimplement phase changes * fix battlertag strings * Fix disable test not running * Update name of base class * Rename "disabling" to "restriction" * Fix sneaky string fuckup * Fix test failure * fix merge problems * fix merge problems * Update tests * rerun RNG test * Properly mock stats in test * Document everything in battlertag * More docs + typo fix * Update tests --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
161 lines
6.3 KiB
TypeScript
161 lines
6.3 KiB
TypeScript
import { BattleType } from "../battle";
|
|
import BattleScene from "../battle-scene";
|
|
import { Gender } from "../data/gender";
|
|
import { Nature } from "../data/nature";
|
|
import { PokeballType } from "../data/pokeball";
|
|
import { getPokemonSpecies } from "../data/pokemon-species";
|
|
import { Status } from "../data/status-effect";
|
|
import Pokemon, { EnemyPokemon, PokemonMove, PokemonSummonData } from "../field/pokemon";
|
|
import { TrainerSlot } from "../data/trainer-config";
|
|
import { Variant } from "#app/data/variant";
|
|
import { loadBattlerTag } from "../data/battler-tags";
|
|
import { Biome } from "#enums/biome";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
|
|
export default class PokemonData {
|
|
public id: integer;
|
|
public player: boolean;
|
|
public species: Species;
|
|
public nickname: string;
|
|
public formIndex: integer;
|
|
public abilityIndex: integer;
|
|
public passive: boolean;
|
|
public shiny: boolean;
|
|
public variant: Variant;
|
|
public pokeball: PokeballType;
|
|
public level: integer;
|
|
public exp: integer;
|
|
public levelExp: integer;
|
|
public gender: Gender;
|
|
public hp: integer;
|
|
public stats: integer[];
|
|
public ivs: integer[];
|
|
public nature: Nature;
|
|
public natureOverride: Nature | -1;
|
|
public moveset: (PokemonMove | null)[];
|
|
public status: Status | null;
|
|
public friendship: integer;
|
|
public metLevel: integer;
|
|
public metBiome: Biome | -1;
|
|
public metSpecies: Species;
|
|
public luck: integer;
|
|
public pauseEvolutions: boolean;
|
|
public pokerus: boolean;
|
|
public usedTMs: Moves[];
|
|
|
|
public fusionSpecies: Species;
|
|
public fusionFormIndex: integer;
|
|
public fusionAbilityIndex: integer;
|
|
public fusionShiny: boolean;
|
|
public fusionVariant: Variant;
|
|
public fusionGender: Gender;
|
|
public fusionLuck: integer;
|
|
|
|
public boss: boolean;
|
|
public bossSegments?: integer;
|
|
|
|
public summonData: PokemonSummonData;
|
|
|
|
constructor(source: Pokemon | any, forHistory: boolean = false) {
|
|
const sourcePokemon = source instanceof Pokemon ? source : null;
|
|
this.id = source.id;
|
|
this.player = sourcePokemon ? sourcePokemon.isPlayer() : source.player;
|
|
this.species = sourcePokemon ? sourcePokemon.species.speciesId : source.species;
|
|
this.nickname = sourcePokemon ? sourcePokemon.nickname : source.nickname;
|
|
this.formIndex = Math.max(Math.min(source.formIndex, getPokemonSpecies(this.species).forms.length - 1), 0);
|
|
this.abilityIndex = source.abilityIndex;
|
|
this.passive = source.passive;
|
|
this.shiny = source.shiny;
|
|
this.variant = source.variant;
|
|
this.pokeball = source.pokeball;
|
|
this.level = source.level;
|
|
this.exp = source.exp;
|
|
if (!forHistory) {
|
|
this.levelExp = source.levelExp;
|
|
}
|
|
this.gender = source.gender;
|
|
if (!forHistory) {
|
|
this.hp = source.hp;
|
|
}
|
|
this.stats = source.stats;
|
|
this.ivs = source.ivs;
|
|
this.nature = source.nature !== undefined ? source.nature : 0 as Nature;
|
|
this.natureOverride = source.natureOverride !== undefined ? source.natureOverride : -1;
|
|
this.friendship = source.friendship !== undefined ? source.friendship : getPokemonSpecies(this.species).baseFriendship;
|
|
this.metLevel = source.metLevel || 5;
|
|
this.metBiome = source.metBiome !== undefined ? source.metBiome : -1;
|
|
this.metSpecies = source.metSpecies;
|
|
this.luck = source.luck !== undefined ? source.luck : (source.shiny ? (source.variant + 1) : 0);
|
|
if (!forHistory) {
|
|
this.pauseEvolutions = !!source.pauseEvolutions;
|
|
}
|
|
this.pokerus = !!source.pokerus;
|
|
|
|
this.fusionSpecies = sourcePokemon ? sourcePokemon.fusionSpecies?.speciesId : source.fusionSpecies;
|
|
this.fusionFormIndex = source.fusionFormIndex;
|
|
this.fusionAbilityIndex = source.fusionAbilityIndex;
|
|
this.fusionShiny = source.fusionShiny;
|
|
this.fusionVariant = source.fusionVariant;
|
|
this.fusionGender = source.fusionGender;
|
|
this.fusionLuck = source.fusionLuck !== undefined ? source.fusionLuck : (source.fusionShiny ? source.fusionVariant + 1 : 0);
|
|
this.usedTMs = source.usedTMs ?? [];
|
|
|
|
if (!forHistory) {
|
|
this.boss = (source instanceof EnemyPokemon && !!source.bossSegments) || (!this.player && !!source.boss);
|
|
this.bossSegments = source.bossSegments;
|
|
}
|
|
|
|
if (sourcePokemon) {
|
|
this.moveset = sourcePokemon.moveset;
|
|
if (!forHistory) {
|
|
this.status = sourcePokemon.status;
|
|
if (this.player) {
|
|
this.summonData = sourcePokemon.summonData;
|
|
}
|
|
}
|
|
} else {
|
|
this.moveset = (source.moveset || [ new PokemonMove(Moves.TACKLE), new PokemonMove(Moves.GROWL) ]).filter(m => m).map((m: any) => new PokemonMove(m.moveId, m.ppUsed, m.ppUp));
|
|
if (!forHistory) {
|
|
this.status = source.status
|
|
? new Status(source.status.effect, source.status.turnCount, source.status.cureTurn)
|
|
: null;
|
|
}
|
|
|
|
this.summonData = new PokemonSummonData();
|
|
if (!forHistory && source.summonData) {
|
|
this.summonData.stats = source.summonData.stats;
|
|
this.summonData.statStages = source.summonData.statStages;
|
|
this.summonData.moveQueue = source.summonData.moveQueue;
|
|
this.summonData.abilitySuppressed = source.summonData.abilitySuppressed;
|
|
this.summonData.abilitiesApplied = source.summonData.abilitiesApplied;
|
|
|
|
this.summonData.ability = source.summonData.ability;
|
|
this.summonData.moveset = source.summonData.moveset?.map(m => PokemonMove.loadMove(m));
|
|
this.summonData.types = source.summonData.types;
|
|
|
|
if (source.summonData.tags) {
|
|
this.summonData.tags = source.summonData.tags?.map(t => loadBattlerTag(t));
|
|
} else {
|
|
this.summonData.tags = [];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
toPokemon(scene: BattleScene, battleType?: BattleType, partyMemberIndex: integer = 0, double: boolean = false): Pokemon {
|
|
const species = getPokemonSpecies(this.species);
|
|
const ret: Pokemon = this.player
|
|
? scene.addPlayerPokemon(species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this, (playerPokemon) => {
|
|
if (this.nickname) {
|
|
playerPokemon.nickname = this.nickname;
|
|
}
|
|
})
|
|
: scene.addEnemyPokemon(species, this.level, battleType === BattleType.TRAINER ? !double || !(partyMemberIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER : TrainerSlot.NONE, this.boss, this);
|
|
if (this.summonData) {
|
|
ret.primeSummonData(this.summonData);
|
|
}
|
|
return ret;
|
|
}
|
|
}
|