2023-10-28 15:51:34 +01:00
|
|
|
import { BattleType } from "../battle";
|
2023-04-28 20:03:42 +01:00
|
|
|
import BattleScene from "../battle-scene";
|
|
|
|
import { Gender } from "../data/gender";
|
|
|
|
import { PokeballType } from "../data/pokeball";
|
|
|
|
import { getPokemonSpecies } from "../data/pokemon-species";
|
|
|
|
import { Species } from "../data/species";
|
|
|
|
import { Status } from "../data/status-effect";
|
|
|
|
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove, PokemonSummonData } from "../pokemon";
|
|
|
|
|
|
|
|
export default class PokemonData {
|
|
|
|
public id: integer;
|
|
|
|
public player: boolean;
|
|
|
|
public species: Species;
|
|
|
|
public formIndex: integer;
|
|
|
|
public abilityIndex: integer;
|
|
|
|
public shiny: boolean;
|
|
|
|
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 moveset: PokemonMove[];
|
|
|
|
public status: Status;
|
|
|
|
public winCount: integer;
|
2023-10-25 19:15:44 +01:00
|
|
|
public pokerus: boolean;
|
2023-04-28 20:03:42 +01:00
|
|
|
|
|
|
|
public summonData: PokemonSummonData;
|
|
|
|
|
|
|
|
constructor(source: Pokemon | any) {
|
|
|
|
const sourcePokemon = source instanceof Pokemon ? source as Pokemon : null;
|
|
|
|
this.id = source.id;
|
|
|
|
this.player = sourcePokemon ? sourcePokemon.isPlayer() : source.player;
|
|
|
|
this.species = sourcePokemon ? sourcePokemon.species.speciesId : source.species;
|
|
|
|
this.formIndex = source.formIndex;
|
|
|
|
this.abilityIndex = source.abilityIndex;
|
|
|
|
this.shiny = source.shiny;
|
|
|
|
this.pokeball = source.pokeball;
|
|
|
|
this.level = source.level;
|
|
|
|
this.exp = source.exp;
|
|
|
|
this.levelExp = source.levelExp;
|
|
|
|
this.gender = source.gender;
|
|
|
|
this.hp = source.hp;
|
|
|
|
this.stats = source.stats;
|
|
|
|
this.ivs = source.ivs;
|
|
|
|
this.winCount = source.winCount;
|
2023-10-25 19:15:44 +01:00
|
|
|
this.pokerus = !!source.pokerus;
|
2023-04-28 20:03:42 +01:00
|
|
|
|
|
|
|
if (sourcePokemon) {
|
|
|
|
this.moveset = sourcePokemon.moveset;
|
|
|
|
this.status = sourcePokemon.status;
|
|
|
|
if (this.player)
|
|
|
|
this.summonData = sourcePokemon.summonData;
|
|
|
|
} else {
|
2023-10-25 19:15:44 +01:00
|
|
|
this.moveset = source.moveset.map((m: any) => new PokemonMove(m.moveId, m.ppUsed, m.ppUp));
|
2023-04-28 20:03:42 +01:00
|
|
|
this.status = source.status
|
|
|
|
? new Status(source.status.effect, source.status.turnCount, source.status.cureTurn)
|
|
|
|
: undefined;
|
|
|
|
|
|
|
|
this.summonData = new PokemonSummonData();
|
|
|
|
if (source.summonData) {
|
|
|
|
this.summonData.battleStats = source.summonData.battleStats;
|
|
|
|
this.summonData.moveQueue = source.summonData.moveQueue;
|
|
|
|
this.summonData.tags = []; // TODO
|
2023-05-06 05:42:01 +01:00
|
|
|
this.summonData.moveset = source.summonData.moveset;
|
2023-04-28 20:03:42 +01:00
|
|
|
this.summonData.types = source.summonData.types;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-28 15:51:34 +01:00
|
|
|
toPokemon(scene: BattleScene, battleType?: BattleType): Pokemon {
|
2023-04-28 20:03:42 +01:00
|
|
|
const species = getPokemonSpecies(this.species);
|
|
|
|
if (this.player)
|
|
|
|
return new PlayerPokemon(scene, species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this);
|
2023-10-28 15:51:34 +01:00
|
|
|
return new EnemyPokemon(scene, species, this.level, battleType === BattleType.TRAINER, this);
|
2023-04-28 20:03:42 +01:00
|
|
|
}
|
|
|
|
}
|