mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 05:52:17 +02:00
Fied a few
This commit is contained in:
parent
a7b5a4d2e1
commit
169789f25e
@ -14,7 +14,7 @@ export class CustomPokemonData {
|
|||||||
public types: PokemonType[];
|
public types: PokemonType[];
|
||||||
|
|
||||||
constructor(data?: CustomPokemonData | Partial<CustomPokemonData>) {
|
constructor(data?: CustomPokemonData | Partial<CustomPokemonData>) {
|
||||||
this.spriteScale = data?.spriteScale ?? 1;
|
this.spriteScale = data?.spriteScale ?? -1;
|
||||||
this.ability = data?.ability ?? -1;
|
this.ability = data?.ability ?? -1;
|
||||||
this.passive = data?.passive ?? -1;
|
this.passive = data?.passive ?? -1;
|
||||||
this.nature = data?.nature ?? -1;
|
this.nature = data?.nature ?? -1;
|
||||||
|
@ -2663,7 +2663,7 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
|
|||||||
* Attribute that causes targets of the move to eat a berry. Used for Teatime, Stuff Cheeks
|
* Attribute that causes targets of the move to eat a berry. Used for Teatime, Stuff Cheeks
|
||||||
*/
|
*/
|
||||||
export class EatBerryAttr extends MoveEffectAttr {
|
export class EatBerryAttr extends MoveEffectAttr {
|
||||||
protected chosenBerry: BerryModifier | undefined;
|
protected chosenBerry: BerryModifier;
|
||||||
constructor() {
|
constructor() {
|
||||||
super(true, { trigger: MoveEffectTrigger.HIT });
|
super(true, { trigger: MoveEffectTrigger.HIT });
|
||||||
}
|
}
|
||||||
@ -2713,13 +2713,13 @@ export class EatBerryAttr extends MoveEffectAttr {
|
|||||||
|
|
||||||
eatBerry(consumer: Pokemon, berryOwner: Pokemon = consumer) {
|
eatBerry(consumer: Pokemon, berryOwner: Pokemon = consumer) {
|
||||||
// consumer eats berry, owner triggers unburden and similar effects
|
// consumer eats berry, owner triggers unburden and similar effects
|
||||||
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer);
|
// These are the same under normal circumstances
|
||||||
|
getBerryEffectFunc(this.chosenBerry.berryType)(consumer);
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner, false);
|
||||||
|
|
||||||
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new BooleanHolder(false));
|
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new BooleanHolder(false));
|
||||||
|
|
||||||
// Harvest doesn't track berries eaten by other pokemon
|
// Harvest doesn't track berries eaten by other pokemon
|
||||||
consumer.recordEatenBerry(this.chosenBerry!.berryType, berryOwner !== consumer);
|
consumer.recordEatenBerry(this.chosenBerry.berryType, berryOwner !== consumer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,14 +331,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
*/
|
*/
|
||||||
private summonDataPrimer: PokemonSummonData | null;
|
private summonDataPrimer: PokemonSummonData | null;
|
||||||
|
|
||||||
/* Pokemon data types, in vague order of precedence */
|
/* Pokemon data types, in vaguely decreasing order of precedence */
|
||||||
|
|
||||||
/** Data that resets on switch (stat stages, battler tags, etc.) */
|
/**
|
||||||
|
* Data that resets only on *battle* end (hit count, harvest berries, etc.)
|
||||||
|
* Kept between waves.
|
||||||
|
*/
|
||||||
|
public battleData: PokemonBattleData = new PokemonBattleData;
|
||||||
|
/** Data that resets on switch or battle end (stat stages, battler tags, etc.) */
|
||||||
public summonData: PokemonSummonData = new PokemonSummonData;
|
public summonData: PokemonSummonData = new PokemonSummonData;
|
||||||
/** Wave data correponding to moves/ability information revealed */
|
/** Wave data correponding to moves/ability information revealed */
|
||||||
public waveData: PokemonWaveData = new PokemonWaveData;
|
public waveData: PokemonWaveData = new PokemonWaveData;
|
||||||
/** Data that resets only on battle end (hit count, harvest berries, etc.) */
|
|
||||||
public battleData: PokemonBattleData = new PokemonBattleData;
|
|
||||||
/** Per-turn data like hit count & flinch tracking */
|
/** Per-turn data like hit count & flinch tracking */
|
||||||
public turnData: PokemonTurnData = new PokemonTurnData;
|
public turnData: PokemonTurnData = new PokemonTurnData;
|
||||||
|
|
||||||
@ -5844,9 +5847,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reset a {@linkcode Pokemon}'s {@linkcode PokemonWaveData | waveData}.
|
* Reset a {@linkcode Pokemon}'s {@linkcode PokemonWaveData | waveData}.
|
||||||
Called once per new wave start as well as by {@linkcode resetBattleAndWaveData}.
|
* Called once per new wave start as well as by {@linkcode resetBattleAndWaveData}.
|
||||||
*/
|
*/
|
||||||
resetWaveData(): void {
|
resetWaveData(): void {
|
||||||
this.waveData = new PokemonWaveData();
|
this.waveData = new PokemonWaveData();
|
||||||
}
|
}
|
||||||
|
@ -334,8 +334,9 @@ export class EncounterPhase extends BattlePhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const pokemon of globalScene.getPlayerParty()) {
|
for (const pokemon of globalScene.getPlayerParty()) {
|
||||||
|
// Only reset wave data, not battle data
|
||||||
if (pokemon) {
|
if (pokemon) {
|
||||||
pokemon.resetBattleAndWaveData();
|
pokemon.resetWaveData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,17 +74,12 @@ export default class PokemonData {
|
|||||||
public customPokemonData: CustomPokemonData;
|
public customPokemonData: CustomPokemonData;
|
||||||
public fusionCustomPokemonData: CustomPokemonData;
|
public fusionCustomPokemonData: CustomPokemonData;
|
||||||
|
|
||||||
// Deprecated attributes, needed for now to allow SessionData migration (see PR#4619 comments).
|
|
||||||
// TODO: These can probably be safely deleted (what with the upgrade scripts and all)
|
|
||||||
public natureOverride: Nature | -1;
|
|
||||||
public mysteryEncounterPokemonData: CustomPokemonData | null;
|
|
||||||
public fusionMysteryEncounterPokemonData: CustomPokemonData | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new {@linkcode PokemonData} instance out of a {@linkcode Pokemon}
|
* Construct a new {@linkcode PokemonData} instance out of a {@linkcode Pokemon}
|
||||||
* or JSON representation thereof.
|
* or JSON representation thereof.
|
||||||
* @param source The {@linkcode Pokemon} to convert into data (or a JSON object representing one)
|
* @param source The {@linkcode Pokemon} to convert into data (or a JSON object representing one)
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove any from type signature
|
||||||
constructor(source: Pokemon | any) {
|
constructor(source: Pokemon | any) {
|
||||||
const sourcePokemon = source instanceof Pokemon ? source : undefined;
|
const sourcePokemon = source instanceof Pokemon ? source : undefined;
|
||||||
this.id = source.id;
|
this.id = source.id;
|
||||||
@ -141,7 +136,7 @@ export default class PokemonData {
|
|||||||
this.evoCounter = source.evoCounter ?? 0;
|
this.evoCounter = source.evoCounter ?? 0;
|
||||||
|
|
||||||
this.boss = (source instanceof EnemyPokemon && !!source.bossSegments) || (!this.player && !!source.boss);
|
this.boss = (source instanceof EnemyPokemon && !!source.bossSegments) || (!this.player && !!source.boss);
|
||||||
this.bossSegments = source.bossSegments;
|
this.bossSegments = source.bossSegments ?? 0;
|
||||||
this.status =
|
this.status =
|
||||||
sourcePokemon?.status ??
|
sourcePokemon?.status ??
|
||||||
(source.status
|
(source.status
|
||||||
@ -149,11 +144,11 @@ export default class PokemonData {
|
|||||||
: null);
|
: null);
|
||||||
|
|
||||||
this.summonData = source.summonData;
|
this.summonData = source.summonData;
|
||||||
|
this.battleData = source.battleData;
|
||||||
|
|
||||||
this.summonDataSpeciesFormIndex = sourcePokemon
|
this.summonDataSpeciesFormIndex = sourcePokemon
|
||||||
? this.getSummonDataSpeciesFormIndex()
|
? this.getSummonDataSpeciesFormIndex()
|
||||||
: source.summonDataSpeciesFormIndex;
|
: source.summonDataSpeciesFormIndex;
|
||||||
this.battleData = sourcePokemon?.battleData ?? source.battleData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toPokemon(battleType?: BattleType, partyMemberIndex = 0, double = false): Pokemon {
|
toPokemon(battleType?: BattleType, partyMemberIndex = 0, double = false): Pokemon {
|
||||||
|
@ -14,7 +14,7 @@ import { PokeballType } from "#enums/pokeball";
|
|||||||
const migratePartyData: SessionSaveMigrator = {
|
const migratePartyData: SessionSaveMigrator = {
|
||||||
version: "1.9.0",
|
version: "1.9.0",
|
||||||
migrate: (data: SessionSaveData): void => {
|
migrate: (data: SessionSaveData): void => {
|
||||||
data.party = data.party.map(pkmnData => {
|
const mapParty = (pkmnData: PokemonData) => {
|
||||||
// this stuff is copied straight from the constructor fwiw
|
// this stuff is copied straight from the constructor fwiw
|
||||||
pkmnData.moveset = pkmnData.moveset.filter(m => !!m) ?? [
|
pkmnData.moveset = pkmnData.moveset.filter(m => !!m) ?? [
|
||||||
new PokemonMove(Moves.TACKLE),
|
new PokemonMove(Moves.TACKLE),
|
||||||
@ -28,8 +28,11 @@ const migratePartyData: SessionSaveMigrator = {
|
|||||||
) {
|
) {
|
||||||
pkmnData.battleData.hitCount = pkmnData.customPokemonData?.["hitsRecCount"];
|
pkmnData.battleData.hitCount = pkmnData.customPokemonData?.["hitsRecCount"];
|
||||||
}
|
}
|
||||||
return new PokemonData(pkmnData);
|
pkmnData = new PokemonData(pkmnData);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
data.party.forEach(mapParty);
|
||||||
|
data.enemyParty.forEach(mapParty);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -213,7 +213,8 @@ describe("Spec - Pokemon", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be more or less equivalent when converting to and from PokemonData", async () => {
|
// TODO: Remove/rework after save data overhaul
|
||||||
|
it("should preserve common fields when converting to and from PokemonData", async () => {
|
||||||
await game.classicMode.startBattle([Species.ALAKAZAM]);
|
await game.classicMode.startBattle([Species.ALAKAZAM]);
|
||||||
const alakazam = game.scene.getPlayerPokemon()!;
|
const alakazam = game.scene.getPlayerPokemon()!;
|
||||||
expect(alakazam).toBeDefined();
|
expect(alakazam).toBeDefined();
|
||||||
@ -233,7 +234,7 @@ describe("Spec - Pokemon", () => {
|
|||||||
alakaData,
|
alakaData,
|
||||||
);
|
);
|
||||||
for (const key of Object.keys(alakazam).filter(k => k in alakaData)) {
|
for (const key of Object.keys(alakazam).filter(k => k in alakaData)) {
|
||||||
expect(alakazam[key]).toEqual(alaka2["key"]);
|
expect(alakazam[key]).toEqual(alaka2[key]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -72,21 +72,18 @@ describe("Moves - Rage Fist", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should not count subsitute hits or confusion damage", async () => {
|
it("should not count subsitute hits or confusion damage", async () => {
|
||||||
game.override.enemySpecies(Species.MAGIKARP).startingWave(4).enemyMoveset([Moves.CONFUSE_RAY, Moves.DOUBLE_KICK]);
|
game.override.enemySpecies(Species.SHUCKLE).enemyMoveset([Moves.CONFUSE_RAY, Moves.DOUBLE_KICK]);
|
||||||
|
|
||||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||||
|
|
||||||
game.move.select(Moves.SUBSTITUTE);
|
game.move.select(Moves.SUBSTITUTE);
|
||||||
await game.forceEnemyMove(Moves.DOUBLE_KICK);
|
await game.forceEnemyMove(Moves.DOUBLE_KICK);
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
await game.toNextTurn();
|
||||||
|
|
||||||
// no increase due to substitute
|
// no increase due to substitute
|
||||||
expect(move.calculateBattlePower).toHaveLastReturnedWith(50);
|
|
||||||
expect(game.scene.getPlayerPokemon()?.battleData.hitCount).toBe(0);
|
expect(game.scene.getPlayerPokemon()?.battleData.hitCount).toBe(0);
|
||||||
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
// remove substitute and get confused
|
// remove substitute and get confused
|
||||||
game.move.select(Moves.TIDY_UP);
|
game.move.select(Moves.TIDY_UP);
|
||||||
await game.forceEnemyMove(Moves.CONFUSE_RAY);
|
await game.forceEnemyMove(Moves.CONFUSE_RAY);
|
||||||
@ -94,8 +91,8 @@ describe("Moves - Rage Fist", () => {
|
|||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
game.move.select(Moves.RAGE_FIST);
|
game.move.select(Moves.RAGE_FIST);
|
||||||
await game.move.forceStatusActivation(true);
|
await game.move.forceConfusionActivation(true);
|
||||||
await game.forceEnemyMove(Moves.SPLASH);
|
await game.forceEnemyMove(Moves.DOUBLE_KICK);
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
// didn't go up
|
// didn't go up
|
||||||
@ -104,7 +101,8 @@ describe("Moves - Rage Fist", () => {
|
|||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
game.move.select(Moves.RAGE_FIST);
|
game.move.select(Moves.RAGE_FIST);
|
||||||
await game.move.forceStatusActivation(false);
|
await game.forceEnemyMove(Moves.DOUBLE_KICK);
|
||||||
|
await game.move.forceConfusionActivation(false);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(move.calculateBattlePower).toHaveLastReturnedWith(150);
|
expect(move.calculateBattlePower).toHaveLastReturnedWith(150);
|
||||||
|
Loading…
Reference in New Issue
Block a user