mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 06:19:29 +02:00
Merge branch 'beta' of https://github.com/pagefaultgames/pokerogue into critcatch
This commit is contained in:
commit
fe41a1940a
@ -13,9 +13,10 @@ import { Arena, ArenaBase } from "#app/field/arena";
|
||||
import { GameData } from "#app/system/game-data";
|
||||
import { addTextObject, getTextColor, TextStyle } from "#app/ui/text";
|
||||
import { allMoves } from "#app/data/move";
|
||||
import { MusicPreference } from "#app/system/settings/settings";
|
||||
import { getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getModifierType, getPartyLuckValue, ModifierPoolType, modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||
import AbilityBar from "#app/ui/ability-bar";
|
||||
import { allAbilities, applyAbAttrs, applyPostBattleInitAbAttrs, BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, PostBattleInitAbAttr } from "#app/data/ability";
|
||||
import { allAbilities, applyAbAttrs, applyPostBattleInitAbAttrs, applyPostItemLostAbAttrs, BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, PostBattleInitAbAttr, PostItemLostAbAttr } from "#app/data/ability";
|
||||
import Battle, { BattleType, FixedBattleConfig } from "#app/battle";
|
||||
import { GameMode, GameModes, getGameMode } from "#app/game-mode";
|
||||
import FieldSpritePipeline from "#app/pipelines/field-sprite";
|
||||
@ -169,7 +170,7 @@ export default class BattleScene extends SceneBase {
|
||||
public uiTheme: UiTheme = UiTheme.DEFAULT;
|
||||
public windowType: integer = 0;
|
||||
public experimentalSprites: boolean = false;
|
||||
public musicPreference: integer = 0;
|
||||
public musicPreference: number = MusicPreference.MIXED;
|
||||
public moveAnimations: boolean = true;
|
||||
public expGainsSpeed: ExpGainsSpeed = ExpGainsSpeed.DEFAULT;
|
||||
public skipSeenDialogues: boolean = false;
|
||||
@ -764,57 +765,65 @@ export default class BattleScene extends SceneBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
getParty(): PlayerPokemon[] {
|
||||
public getPlayerParty(): PlayerPokemon[] {
|
||||
return this.party;
|
||||
}
|
||||
|
||||
getPlayerPokemon(): PlayerPokemon | undefined {
|
||||
return this.getPlayerField().find(p => p.isActive());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the first {@linkcode Pokemon.isActive() | active PlayerPokemon} that isn't also currently switching out
|
||||
* @returns Either the first {@linkcode PlayerPokemon} satisfying, or undefined if no player pokemon on the field satisfy
|
||||
* @returns An array of {@linkcode PlayerPokemon} filtered from the player's party
|
||||
* that are {@linkcode PlayerPokemon.isAllowedInBattle | allowed in battle}.
|
||||
*/
|
||||
getNonSwitchedPlayerPokemon(): PlayerPokemon | undefined {
|
||||
return this.getPlayerField().find(p => p.isActive() && p.switchOutStatus === false);
|
||||
public getPokemonAllowedInBattle(): PlayerPokemon[] {
|
||||
return this.getPlayerParty().filter(p => p.isAllowedInBattle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of PlayerPokemon of length 1 or 2 depending on if double battles or not
|
||||
* @returns The first {@linkcode PlayerPokemon} that is {@linkcode getPlayerField on the field}
|
||||
* and {@linkcode PlayerPokemon.isActive is active}
|
||||
* (aka {@linkcode PlayerPokemon.isAllowedInBattle is allowed in battle}),
|
||||
* or `undefined` if there are no valid pokemon
|
||||
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true`
|
||||
*/
|
||||
public getPlayerPokemon(includeSwitching: boolean = true): PlayerPokemon | undefined {
|
||||
return this.getPlayerField().find(p => p.isActive() && (includeSwitching || p.switchOutStatus === false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of PlayerPokemon of length 1 or 2 depending on if in a double battle or not.
|
||||
* Does not actually check if the pokemon are on the field or not.
|
||||
* @returns array of {@linkcode PlayerPokemon}
|
||||
*/
|
||||
getPlayerField(): PlayerPokemon[] {
|
||||
const party = this.getParty();
|
||||
public getPlayerField(): PlayerPokemon[] {
|
||||
const party = this.getPlayerParty();
|
||||
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));
|
||||
}
|
||||
|
||||
getEnemyParty(): EnemyPokemon[] {
|
||||
public getEnemyParty(): EnemyPokemon[] {
|
||||
return this.currentBattle?.enemyParty ?? [];
|
||||
}
|
||||
|
||||
getEnemyPokemon(): EnemyPokemon | undefined {
|
||||
return this.getEnemyField().find(p => p.isActive());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the first {@linkcode Pokemon.isActive() | active EnemyPokemon} pokemon from the enemy that isn't also currently switching out
|
||||
* @returns Either the first {@linkcode EnemyPokemon} satisfying, or undefined if no player pokemon on the field satisfy
|
||||
* @returns The first {@linkcode EnemyPokemon} that is {@linkcode getEnemyField on the field}
|
||||
* and {@linkcode EnemyPokemon.isActive is active}
|
||||
* (aka {@linkcode EnemyPokemon.isAllowedInBattle is allowed in battle}),
|
||||
* or `undefined` if there are no valid pokemon
|
||||
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true`
|
||||
*/
|
||||
getNonSwitchedEnemyPokemon(): EnemyPokemon | undefined {
|
||||
return this.getEnemyField().find(p => p.isActive() && p.switchOutStatus === false);
|
||||
public getEnemyPokemon(includeSwitching: boolean = true): EnemyPokemon | undefined {
|
||||
return this.getEnemyField().find(p => p.isActive() && (includeSwitching || p.switchOutStatus === false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of EnemyPokemon of length 1 or 2 depending on if double battles or not
|
||||
* Returns an array of EnemyPokemon of length 1 or 2 depending on if in a double battle or not.
|
||||
* Does not actually check if the pokemon are on the field or not.
|
||||
* @returns array of {@linkcode EnemyPokemon}
|
||||
*/
|
||||
getEnemyField(): EnemyPokemon[] {
|
||||
public getEnemyField(): EnemyPokemon[] {
|
||||
const party = this.getEnemyParty();
|
||||
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));
|
||||
}
|
||||
|
||||
getField(activeOnly: boolean = false): Pokemon[] {
|
||||
public getField(activeOnly: boolean = false): Pokemon[] {
|
||||
const ret = new Array(4).fill(null);
|
||||
const playerField = this.getPlayerField();
|
||||
const enemyField = this.getEnemyField();
|
||||
@ -867,7 +876,7 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
getPokemonById(pokemonId: integer): Pokemon | null {
|
||||
const findInParty = (party: Pokemon[]) => party.find(p => p.id === pokemonId);
|
||||
return (findInParty(this.getParty()) || findInParty(this.getEnemyParty())) ?? null;
|
||||
return (findInParty(this.getPlayerParty()) || findInParty(this.getEnemyParty())) ?? null;
|
||||
}
|
||||
|
||||
addPlayerPokemon(species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData, postProcess?: (playerPokemon: PlayerPokemon) => void): PlayerPokemon {
|
||||
@ -1062,7 +1071,7 @@ export default class BattleScene extends SceneBase {
|
||||
this.modifierBar.removeAll(true);
|
||||
this.enemyModifierBar.removeAll(true);
|
||||
|
||||
for (const p of this.getParty()) {
|
||||
for (const p of this.getPlayerParty()) {
|
||||
p.destroy();
|
||||
}
|
||||
this.party = [];
|
||||
@ -1275,7 +1284,7 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
});
|
||||
|
||||
for (const pokemon of this.getParty()) {
|
||||
for (const pokemon of this.getPlayerParty()) {
|
||||
pokemon.resetBattleData();
|
||||
applyPostBattleInitAbAttrs(PostBattleInitAbAttr, pokemon);
|
||||
}
|
||||
@ -1285,7 +1294,7 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
}
|
||||
|
||||
for (const pokemon of this.getParty()) {
|
||||
for (const pokemon of this.getPlayerParty()) {
|
||||
this.triggerPokemonFormChange(pokemon, SpeciesFormChangeTimeOfDayTrigger);
|
||||
}
|
||||
|
||||
@ -1480,7 +1489,7 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
|
||||
trySpreadPokerus(): void {
|
||||
const party = this.getParty();
|
||||
const party = this.getPlayerParty();
|
||||
const infectedIndexes: integer[] = [];
|
||||
const spread = (index: number, spreadTo: number) => {
|
||||
const partyMember = party[index + spreadTo];
|
||||
@ -1677,7 +1686,7 @@ export default class BattleScene extends SceneBase {
|
||||
updateAndShowText(duration: number): void {
|
||||
const labels = [ this.luckLabelText, this.luckText ];
|
||||
labels.forEach(t => t.setAlpha(0));
|
||||
const luckValue = getPartyLuckValue(this.getParty());
|
||||
const luckValue = getPartyLuckValue(this.getPlayerParty());
|
||||
this.luckText.setText(getLuckString(luckValue));
|
||||
if (luckValue < 14) {
|
||||
this.luckText.setTint(getLuckTextTint(luckValue));
|
||||
@ -2593,9 +2602,19 @@ export default class BattleScene extends SceneBase {
|
||||
const addModifier = () => {
|
||||
if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) {
|
||||
if (target.isPlayer()) {
|
||||
this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => resolve(true));
|
||||
this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => {
|
||||
if (source) {
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
||||
}
|
||||
resolve(true);
|
||||
});
|
||||
} else {
|
||||
this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => resolve(true));
|
||||
this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => {
|
||||
if (source) {
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
||||
}
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
resolve(false);
|
||||
@ -2615,7 +2634,7 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
removePartyMemberModifiers(partyMemberIndex: integer): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
const pokemonId = this.getParty()[partyMemberIndex].id;
|
||||
const pokemonId = this.getPlayerParty()[partyMemberIndex].id;
|
||||
const modifiersToRemove = this.modifiers.filter(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === pokemonId);
|
||||
for (const m of modifiersToRemove) {
|
||||
this.modifiers.splice(this.modifiers.indexOf(m), 1);
|
||||
@ -2742,7 +2761,7 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
}
|
||||
|
||||
this.updatePartyForModifiers(player ? this.getParty() : this.getEnemyParty(), instant).then(() => {
|
||||
this.updatePartyForModifiers(player ? this.getPlayerParty() : this.getEnemyParty(), instant).then(() => {
|
||||
(player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers);
|
||||
if (!player) {
|
||||
this.updateUIPositions();
|
||||
@ -2980,22 +2999,16 @@ export default class BattleScene extends SceneBase {
|
||||
*/
|
||||
getActiveKeys(): string[] {
|
||||
const keys: string[] = [];
|
||||
const playerParty = this.getParty();
|
||||
playerParty.forEach(p => {
|
||||
let activePokemon: (PlayerPokemon | EnemyPokemon)[] = this.getPlayerParty();
|
||||
activePokemon = activePokemon.concat(this.getEnemyParty());
|
||||
activePokemon.forEach((p) => {
|
||||
keys.push(p.getSpriteKey(true));
|
||||
keys.push(p.getBattleSpriteKey(true, true));
|
||||
keys.push("cry/" + p.species.getCryKey(p.formIndex));
|
||||
if (p.fusionSpecies) {
|
||||
keys.push("cry/" + p.fusionSpecies.getCryKey(p.fusionFormIndex));
|
||||
if (p instanceof PlayerPokemon) {
|
||||
keys.push(p.getBattleSpriteKey(true, true));
|
||||
}
|
||||
});
|
||||
// enemyParty has to be operated on separately from playerParty because playerPokemon =/= enemyPokemon
|
||||
const enemyParty = this.getEnemyParty();
|
||||
enemyParty.forEach(p => {
|
||||
keys.push(p.getSpriteKey(true));
|
||||
keys.push("cry/" + p.species.getCryKey(p.formIndex));
|
||||
keys.push(p.species.getCryKey(p.formIndex));
|
||||
if (p.fusionSpecies) {
|
||||
keys.push("cry/" + p.fusionSpecies.getCryKey(p.fusionFormIndex));
|
||||
keys.push(p.fusionSpecies.getCryKey(p.fusionFormIndex));
|
||||
}
|
||||
});
|
||||
return keys;
|
||||
@ -3016,7 +3029,7 @@ export default class BattleScene extends SceneBase {
|
||||
this.setFieldScale(0.75);
|
||||
this.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false);
|
||||
this.currentBattle.double = true;
|
||||
const availablePartyMembers = this.getParty().filter((p) => p.isAllowedInBattle());
|
||||
const availablePartyMembers = this.getPlayerParty().filter((p) => p.isAllowedInBattle());
|
||||
if (availablePartyMembers.length > 1) {
|
||||
this.pushPhase(new ToggleDoublePositionPhase(this, true));
|
||||
if (!availablePartyMembers[1].isOnField()) {
|
||||
@ -3041,7 +3054,7 @@ export default class BattleScene extends SceneBase {
|
||||
*/
|
||||
applyPartyExp(expValue: number, pokemonDefeated: boolean, useWaveIndexMultiplier?: boolean, pokemonParticipantIds?: Set<number>): void {
|
||||
const participantIds = pokemonParticipantIds ?? this.currentBattle.playerParticipantIds;
|
||||
const party = this.getParty();
|
||||
const party = this.getPlayerParty();
|
||||
const expShareModifier = this.findModifier(m => m instanceof ExpShareModifier) as ExpShareModifier;
|
||||
const expBalanceModifier = this.findModifier(m => m instanceof ExpBalanceModifier) as ExpBalanceModifier;
|
||||
const multipleParticipantExpBonusModifier = this.findModifier(m => m instanceof MultipleParticipantExpBonusModifier) as MultipleParticipantExpBonusModifier;
|
||||
|
286
src/battle.ts
286
src/battle.ts
@ -6,11 +6,13 @@ import { GameMode } from "./game-mode";
|
||||
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
|
||||
import { PokeballType } from "./data/pokeball";
|
||||
import { trainerConfigs } from "#app/data/trainer-config";
|
||||
import { SpeciesFormKey } from "#enums/species-form-key";
|
||||
import Pokemon, { EnemyPokemon, PlayerPokemon, QueuedMove } from "#app/field/pokemon";
|
||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||
import { BattleSpec } from "#enums/battle-spec";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { PlayerGender } from "#enums/player-gender";
|
||||
import { MusicPreference } from "#app/system/settings/settings";
|
||||
import { Species } from "#enums/species";
|
||||
import { TrainerType } from "#enums/trainer-type";
|
||||
import i18next from "#app/plugins/i18n";
|
||||
@ -212,7 +214,6 @@ export default class Battle {
|
||||
}
|
||||
|
||||
getBgmOverride(scene: BattleScene): string | null {
|
||||
const battlers = this.enemyParty.slice(0, this.getBattlerCount());
|
||||
if (this.isBattleMysteryEncounter() && this.mysteryEncounter?.encounterMode === MysteryEncounterMode.DEFAULT) {
|
||||
// Music is overridden for MEs during ME onInit()
|
||||
// Should not use any BGM overrides before swapping from DEFAULT mode
|
||||
@ -221,7 +222,7 @@ export default class Battle {
|
||||
if (!this.started && this.trainer?.config.encounterBgm && this.trainer?.getEncounterMessages()?.length) {
|
||||
return `encounter_${this.trainer?.getEncounterBgm()}`;
|
||||
}
|
||||
if (scene.musicPreference === 0) {
|
||||
if (scene.musicPreference === MusicPreference.CONSISTENT) {
|
||||
return this.trainer?.getBattleBgm() ?? null;
|
||||
} else {
|
||||
return this.trainer?.getMixedBattleBgm() ?? null;
|
||||
@ -229,147 +230,168 @@ export default class Battle {
|
||||
} else if (this.gameMode.isClassic && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS) {
|
||||
return "end_summit";
|
||||
}
|
||||
for (const pokemon of battlers) {
|
||||
const wildOpponents = scene.getEnemyParty();
|
||||
for (const pokemon of wildOpponents) {
|
||||
if (this.battleSpec === BattleSpec.FINAL_BOSS) {
|
||||
if (pokemon.formIndex) {
|
||||
if (pokemon.species.getFormSpriteKey(pokemon.formIndex) === SpeciesFormKey.ETERNAMAX) {
|
||||
return "battle_final";
|
||||
}
|
||||
return "battle_final_encounter";
|
||||
}
|
||||
if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) {
|
||||
if (scene.musicPreference === 0) {
|
||||
if (pokemon.species.speciesId === Species.REGIROCK || pokemon.species.speciesId === Species.REGICE || pokemon.species.speciesId === Species.REGISTEEL || pokemon.species.speciesId === Species.REGIGIGAS || pokemon.species.speciesId === Species.REGIELEKI || pokemon.species.speciesId === Species.REGIDRAGO) {
|
||||
return "battle_legendary_regis_g5";
|
||||
if (scene.musicPreference === MusicPreference.CONSISTENT) {
|
||||
switch (pokemon.species.speciesId) {
|
||||
case Species.REGIROCK:
|
||||
case Species.REGICE:
|
||||
case Species.REGISTEEL:
|
||||
case Species.REGIGIGAS:
|
||||
case Species.REGIDRAGO:
|
||||
case Species.REGIELEKI:
|
||||
return "battle_legendary_regis_g5";
|
||||
case Species.KYUREM:
|
||||
return "battle_legendary_kyurem";
|
||||
default:
|
||||
if (pokemon.species.legendary) {
|
||||
return "battle_legendary_res_zek";
|
||||
}
|
||||
return "battle_legendary_unova";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.COBALION || pokemon.species.speciesId === Species.TERRAKION || pokemon.species.speciesId === Species.VIRIZION || pokemon.species.speciesId === Species.TORNADUS || pokemon.species.speciesId === Species.THUNDURUS || pokemon.species.speciesId === Species.LANDORUS || pokemon.species.speciesId === Species.KELDEO || pokemon.species.speciesId === Species.MELOETTA || pokemon.species.speciesId === Species.GENESECT) {
|
||||
return "battle_legendary_unova";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.KYUREM) {
|
||||
return "battle_legendary_kyurem";
|
||||
}
|
||||
if (pokemon.species.legendary) {
|
||||
return "battle_legendary_res_zek";
|
||||
}
|
||||
return "battle_legendary_unova";
|
||||
} else {
|
||||
if (pokemon.species.speciesId === Species.ARTICUNO || pokemon.species.speciesId === Species.ZAPDOS || pokemon.species.speciesId === Species.MOLTRES || pokemon.species.speciesId === Species.MEWTWO || pokemon.species.speciesId === Species.MEW) {
|
||||
return "battle_legendary_kanto";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.RAIKOU) {
|
||||
return "battle_legendary_raikou";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.ENTEI) {
|
||||
return "battle_legendary_entei";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.SUICUNE) {
|
||||
return "battle_legendary_suicune";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.LUGIA) {
|
||||
return "battle_legendary_lugia";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.HO_OH) {
|
||||
return "battle_legendary_ho_oh";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.REGIROCK || pokemon.species.speciesId === Species.REGICE || pokemon.species.speciesId === Species.REGISTEEL || pokemon.species.speciesId === Species.REGIGIGAS || pokemon.species.speciesId === Species.REGIELEKI || pokemon.species.speciesId === Species.REGIDRAGO) {
|
||||
return "battle_legendary_regis_g6";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.GROUDON || pokemon.species.speciesId === Species.KYOGRE) {
|
||||
return "battle_legendary_gro_kyo";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.RAYQUAZA) {
|
||||
return "battle_legendary_rayquaza";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.DEOXYS) {
|
||||
return "battle_legendary_deoxys";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.UXIE || pokemon.species.speciesId === Species.MESPRIT || pokemon.species.speciesId === Species.AZELF) {
|
||||
return "battle_legendary_lake_trio";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.HEATRAN || pokemon.species.speciesId === Species.CRESSELIA || pokemon.species.speciesId === Species.DARKRAI || pokemon.species.speciesId === Species.SHAYMIN) {
|
||||
return "battle_legendary_sinnoh";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.DIALGA || pokemon.species.speciesId === Species.PALKIA) {
|
||||
if (pokemon.getFormKey() === "") {
|
||||
} else if (scene.musicPreference === MusicPreference.MIXED) {
|
||||
switch (pokemon.species.speciesId) {
|
||||
case Species.ARTICUNO:
|
||||
case Species.ZAPDOS:
|
||||
case Species.MOLTRES:
|
||||
case Species.MEWTWO:
|
||||
case Species.MEW:
|
||||
return "battle_legendary_kanto";
|
||||
case Species.RAIKOU:
|
||||
return "battle_legendary_raikou";
|
||||
case Species.ENTEI:
|
||||
return "battle_legendary_entei";
|
||||
case Species.SUICUNE:
|
||||
return "battle_legendary_suicune";
|
||||
case Species.LUGIA:
|
||||
return "battle_legendary_lugia";
|
||||
case Species.HO_OH:
|
||||
return "battle_legendary_ho_oh";
|
||||
case Species.REGIROCK:
|
||||
case Species.REGICE:
|
||||
case Species.REGISTEEL:
|
||||
case Species.REGIGIGAS:
|
||||
case Species.REGIDRAGO:
|
||||
case Species.REGIELEKI:
|
||||
return "battle_legendary_regis_g6";
|
||||
case Species.GROUDON:
|
||||
case Species.KYOGRE:
|
||||
return "battle_legendary_gro_kyo";
|
||||
case Species.RAYQUAZA:
|
||||
return "battle_legendary_rayquaza";
|
||||
case Species.DEOXYS:
|
||||
return "battle_legendary_deoxys";
|
||||
case Species.UXIE:
|
||||
case Species.MESPRIT:
|
||||
case Species.AZELF:
|
||||
return "battle_legendary_lake_trio";
|
||||
case Species.HEATRAN:
|
||||
case Species.CRESSELIA:
|
||||
case Species.DARKRAI:
|
||||
case Species.SHAYMIN:
|
||||
return "battle_legendary_sinnoh";
|
||||
case Species.DIALGA:
|
||||
case Species.PALKIA:
|
||||
if (pokemon.species.getFormSpriteKey(pokemon.formIndex) === SpeciesFormKey.ORIGIN) {
|
||||
return "battle_legendary_origin_forme";
|
||||
}
|
||||
return "battle_legendary_dia_pal";
|
||||
}
|
||||
if (pokemon.getFormKey() === "origin") {
|
||||
return "battle_legendary_origin_forme";
|
||||
}
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.GIRATINA) {
|
||||
return "battle_legendary_giratina";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.ARCEUS) {
|
||||
return "battle_legendary_arceus";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.COBALION || pokemon.species.speciesId === Species.TERRAKION || pokemon.species.speciesId === Species.VIRIZION || pokemon.species.speciesId === Species.TORNADUS || pokemon.species.speciesId === Species.THUNDURUS || pokemon.species.speciesId === Species.LANDORUS || pokemon.species.speciesId === Species.KELDEO || pokemon.species.speciesId === Species.MELOETTA || pokemon.species.speciesId === Species.GENESECT) {
|
||||
return "battle_legendary_unova";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.KYUREM) {
|
||||
return "battle_legendary_kyurem";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.XERNEAS || pokemon.species.speciesId === Species.YVELTAL || pokemon.species.speciesId === Species.ZYGARDE) {
|
||||
return "battle_legendary_xern_yvel";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.TAPU_KOKO || pokemon.species.speciesId === Species.TAPU_LELE || pokemon.species.speciesId === Species.TAPU_BULU || pokemon.species.speciesId === Species.TAPU_FINI) {
|
||||
return "battle_legendary_tapu";
|
||||
}
|
||||
if ([ Species.COSMOG, Species.COSMOEM, Species.SOLGALEO, Species.LUNALA ].includes(pokemon.species.speciesId)) {
|
||||
return "battle_legendary_sol_lun";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.NECROZMA) {
|
||||
if (pokemon.getFormKey() === "") {
|
||||
case Species.GIRATINA:
|
||||
return "battle_legendary_giratina";
|
||||
case Species.ARCEUS:
|
||||
return "battle_legendary_arceus";
|
||||
case Species.COBALION:
|
||||
case Species.TERRAKION:
|
||||
case Species.VIRIZION:
|
||||
case Species.KELDEO:
|
||||
case Species.TORNADUS:
|
||||
case Species.LANDORUS:
|
||||
case Species.THUNDURUS:
|
||||
case Species.MELOETTA:
|
||||
case Species.GENESECT:
|
||||
return "battle_legendary_unova";
|
||||
case Species.KYUREM:
|
||||
return "battle_legendary_kyurem";
|
||||
case Species.XERNEAS:
|
||||
case Species.YVELTAL:
|
||||
case Species.ZYGARDE:
|
||||
return "battle_legendary_xern_yvel";
|
||||
case Species.TAPU_KOKO:
|
||||
case Species.TAPU_LELE:
|
||||
case Species.TAPU_BULU:
|
||||
case Species.TAPU_FINI:
|
||||
return "battle_legendary_tapu";
|
||||
case Species.SOLGALEO:
|
||||
case Species.LUNALA:
|
||||
return "battle_legendary_sol_lun";
|
||||
}
|
||||
if (pokemon.getFormKey() === "dusk-mane" || pokemon.getFormKey() === "dawn-wings") {
|
||||
return "battle_legendary_dusk_dawn";
|
||||
}
|
||||
if (pokemon.getFormKey() === "ultra") {
|
||||
return "battle_legendary_ultra_nec";
|
||||
}
|
||||
}
|
||||
if ([ Species.NIHILEGO, Species.BUZZWOLE, Species.PHEROMOSA, Species.XURKITREE, Species.CELESTEELA, Species.KARTANA, Species.GUZZLORD, Species.POIPOLE, Species.NAGANADEL, Species.STAKATAKA, Species.BLACEPHALON ].includes(pokemon.species.speciesId)) {
|
||||
return "battle_legendary_ub";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.ZACIAN || pokemon.species.speciesId === Species.ZAMAZENTA) {
|
||||
return "battle_legendary_zac_zam";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.GLASTRIER || pokemon.species.speciesId === Species.SPECTRIER) {
|
||||
return "battle_legendary_glas_spec";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.CALYREX) {
|
||||
if (pokemon.getFormKey() === "") {
|
||||
case Species.NECROZMA:
|
||||
switch (pokemon.getFormKey()) {
|
||||
case "dusk-mane":
|
||||
case "dawn-wings":
|
||||
return "battle_legendary_dusk_dawn";
|
||||
case "ultra":
|
||||
return "battle_legendary_ultra_nec";
|
||||
default:
|
||||
return "battle_legendary_sol_lun";
|
||||
}
|
||||
case Species.NIHILEGO:
|
||||
case Species.PHEROMOSA:
|
||||
case Species.BUZZWOLE:
|
||||
case Species.XURKITREE:
|
||||
case Species.CELESTEELA:
|
||||
case Species.KARTANA:
|
||||
case Species.GUZZLORD:
|
||||
case Species.POIPOLE:
|
||||
case Species.NAGANADEL:
|
||||
case Species.STAKATAKA:
|
||||
case Species.BLACEPHALON:
|
||||
return "battle_legendary_ub";
|
||||
case Species.ZACIAN:
|
||||
case Species.ZAMAZENTA:
|
||||
return "battle_legendary_zac_zam";
|
||||
case Species.GLASTRIER:
|
||||
case Species.SPECTRIER:
|
||||
return "battle_legendary_glas_spec";
|
||||
case Species.CALYREX:
|
||||
if (pokemon.getFormKey() === "ice" || pokemon.getFormKey() === "shadow") {
|
||||
return "battle_legendary_riders";
|
||||
}
|
||||
return "battle_legendary_calyrex";
|
||||
}
|
||||
if (pokemon.getFormKey() === "ice" || pokemon.getFormKey() === "shadow") {
|
||||
return "battle_legendary_riders";
|
||||
}
|
||||
case Species.GALAR_ARTICUNO:
|
||||
case Species.GALAR_ZAPDOS:
|
||||
case Species.GALAR_MOLTRES:
|
||||
return "battle_legendary_birds_galar";
|
||||
case Species.WO_CHIEN:
|
||||
case Species.CHIEN_PAO:
|
||||
case Species.TING_LU:
|
||||
case Species.CHI_YU:
|
||||
return "battle_legendary_ruinous";
|
||||
case Species.KORAIDON:
|
||||
case Species.MIRAIDON:
|
||||
return "battle_legendary_kor_mir";
|
||||
case Species.OKIDOGI:
|
||||
case Species.MUNKIDORI:
|
||||
case Species.FEZANDIPITI:
|
||||
return "battle_legendary_loyal_three";
|
||||
case Species.OGERPON:
|
||||
return "battle_legendary_ogerpon";
|
||||
case Species.TERAPAGOS:
|
||||
return "battle_legendary_terapagos";
|
||||
case Species.PECHARUNT:
|
||||
return "battle_legendary_pecharunt";
|
||||
default:
|
||||
if (pokemon.species.legendary) {
|
||||
return "battle_legendary_res_zek";
|
||||
}
|
||||
return "battle_legendary_unova";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.GALAR_ARTICUNO || pokemon.species.speciesId === Species.GALAR_ZAPDOS || pokemon.species.speciesId === Species.GALAR_MOLTRES) {
|
||||
return "battle_legendary_birds_galar";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.WO_CHIEN || pokemon.species.speciesId === Species.CHIEN_PAO || pokemon.species.speciesId === Species.TING_LU || pokemon.species.speciesId === Species.CHI_YU) {
|
||||
return "battle_legendary_ruinous";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.KORAIDON || pokemon.species.speciesId === Species.MIRAIDON) {
|
||||
return "battle_legendary_kor_mir";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.OKIDOGI || pokemon.species.speciesId === Species.MUNKIDORI || pokemon.species.speciesId === Species.FEZANDIPITI) {
|
||||
return "battle_legendary_loyal_three";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.OGERPON) {
|
||||
return "battle_legendary_ogerpon";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.TERAPAGOS) {
|
||||
return "battle_legendary_terapagos";
|
||||
}
|
||||
if (pokemon.species.speciesId === Species.PECHARUNT) {
|
||||
return "battle_legendary_pecharunt";
|
||||
}
|
||||
if (pokemon.species.legendary) {
|
||||
return "battle_legendary_res_zek";
|
||||
}
|
||||
return "battle_legendary_unova";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1956,6 +1956,10 @@ export class CopyFaintedAllyAbilityAbAttr extends PostKnockOutAbAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ability attribute for ignoring the opponent's stat changes
|
||||
* @param stats the stats that should be ignored
|
||||
*/
|
||||
export class IgnoreOpponentStatStagesAbAttr extends AbAttr {
|
||||
private stats: readonly BattleStat[];
|
||||
|
||||
@ -1965,6 +1969,15 @@ export class IgnoreOpponentStatStagesAbAttr extends AbAttr {
|
||||
this.stats = stats ?? BATTLE_STATS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies a BooleanHolder and returns the result to see if a stat is ignored or not
|
||||
* @param _pokemon n/a
|
||||
* @param _passive n/a
|
||||
* @param simulated n/a
|
||||
* @param _cancelled n/a
|
||||
* @param args A BooleanHolder that represents whether or not to ignore a stat's stat changes
|
||||
* @returns true if the stat is ignored, false otherwise
|
||||
*/
|
||||
apply(_pokemon: Pokemon, _passive: boolean, simulated: boolean, _cancelled: Utils.BooleanHolder, args: any[]) {
|
||||
if (this.stats.includes(args[0])) {
|
||||
(args[1] as Utils.BooleanHolder).value = true;
|
||||
@ -3844,6 +3857,41 @@ export class PostDancingMoveAbAttr extends PostMoveUsedAbAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers after the Pokemon loses or consumes an item
|
||||
* @extends AbAttr
|
||||
*/
|
||||
export class PostItemLostAbAttr extends AbAttr {
|
||||
applyPostItemLost(pokemon: Pokemon, simulated: boolean, args: any[]): boolean | Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a Battler Tag to the Pokemon after it loses or consumes item
|
||||
* @extends PostItemLostAbAttr
|
||||
*/
|
||||
export class PostItemLostApplyBattlerTagAbAttr extends PostItemLostAbAttr {
|
||||
private tagType: BattlerTagType;
|
||||
constructor(tagType: BattlerTagType) {
|
||||
super(true);
|
||||
this.tagType = tagType;
|
||||
}
|
||||
/**
|
||||
* Adds the last used Pokeball back into the player's inventory
|
||||
* @param pokemon {@linkcode Pokemon} with this ability
|
||||
* @param args N/A
|
||||
* @returns true if BattlerTag was applied
|
||||
*/
|
||||
applyPostItemLost(pokemon: Pokemon, simulated: boolean, args: any[]): boolean | Promise<boolean> {
|
||||
if (!pokemon.getTag(this.tagType) && !simulated) {
|
||||
pokemon.addTag(this.tagType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export class StatStageChangeMultiplierAbAttr extends AbAttr {
|
||||
private multiplier: integer;
|
||||
|
||||
@ -4856,7 +4904,7 @@ class ForceSwitchOutHelper {
|
||||
* - If the Pokémon is still alive (hp > 0), and if so, it leaves the field and a new SwitchPhase is initiated.
|
||||
*/
|
||||
if (switchOutTarget instanceof PlayerPokemon) {
|
||||
if (switchOutTarget.scene.getParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) {
|
||||
if (switchOutTarget.scene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4937,7 +4985,7 @@ class ForceSwitchOutHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
const party = player ? pokemon.scene.getParty() : pokemon.scene.getEnemyParty();
|
||||
const party = player ? pokemon.scene.getPlayerParty() : pokemon.scene.getEnemyParty();
|
||||
return (!player && pokemon.scene.currentBattle.battleType === BattleType.WILD)
|
||||
|| party.filter(p => p.isAllowedInBattle()
|
||||
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > pokemon.scene.currentBattle.getBattlerCount();
|
||||
@ -4969,7 +5017,7 @@ class ForceSwitchOutHelper {
|
||||
function calculateShellBellRecovery(pokemon: Pokemon): number {
|
||||
const shellBellModifier = pokemon.getHeldItems().find(m => m instanceof HitHealModifier);
|
||||
if (shellBellModifier) {
|
||||
return Utils.toDmgValue(pokemon.turnData.damageDealt / 8) * shellBellModifier.stackCount;
|
||||
return Utils.toDmgValue(pokemon.turnData.totalDamageDealt / 8) * shellBellModifier.stackCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -5215,6 +5263,11 @@ export function applyPostFaintAbAttrs(attrType: Constructor<PostFaintAbAttr>,
|
||||
return applyAbAttrsInternal<PostFaintAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPostFaint(pokemon, passive, simulated, attacker, move, hitResult, args), args, false, simulated);
|
||||
}
|
||||
|
||||
export function applyPostItemLostAbAttrs(attrType: Constructor<PostItemLostAbAttr>,
|
||||
pokemon: Pokemon, simulated: boolean = false, ...args: any[]): Promise<void> {
|
||||
return applyAbAttrsInternal<PostItemLostAbAttr>(attrType, pokemon, (attr, passive) => attr.applyPostItemLost(pokemon, simulated, args), args);
|
||||
}
|
||||
|
||||
function queueShowAbility(pokemon: Pokemon, passive: boolean): void {
|
||||
pokemon.scene.unshiftPhase(new ShowAbilityPhase(pokemon.scene, pokemon.id, passive));
|
||||
pokemon.scene.clearPhaseQueueSplice();
|
||||
@ -5361,6 +5414,7 @@ export function initAbilities() {
|
||||
new Ability(Abilities.ILLUMINATE, 3)
|
||||
.attr(ProtectStatAbAttr, Stat.ACC)
|
||||
.attr(DoubleBattleChanceAbAttr)
|
||||
.attr(IgnoreOpponentStatStagesAbAttr, [ Stat.EVA ])
|
||||
.ignorable(),
|
||||
new Ability(Abilities.TRACE, 3)
|
||||
.attr(PostSummonCopyAbilityAbAttr)
|
||||
@ -5507,7 +5561,7 @@ export function initAbilities() {
|
||||
new Ability(Abilities.ANGER_POINT, 4)
|
||||
.attr(PostDefendCritStatStageChangeAbAttr, Stat.ATK, 6),
|
||||
new Ability(Abilities.UNBURDEN, 4)
|
||||
.unimplemented(),
|
||||
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN),
|
||||
new Ability(Abilities.HEATPROOF, 4)
|
||||
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
|
||||
.attr(ReduceBurnDamageAbAttr, 0.5)
|
||||
@ -5580,7 +5634,7 @@ export function initAbilities() {
|
||||
new Ability(Abilities.FOREWARN, 4)
|
||||
.attr(ForewarnAbAttr),
|
||||
new Ability(Abilities.UNAWARE, 4)
|
||||
.attr(IgnoreOpponentStatStagesAbAttr)
|
||||
.attr(IgnoreOpponentStatStagesAbAttr, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA ])
|
||||
.ignorable(),
|
||||
new Ability(Abilities.TINTED_LENS, 4)
|
||||
.attr(DamageBoostAbAttr, 2, (user, target, move) => (target?.getMoveEffectiveness(user!, move) ?? 1) <= 0.5),
|
||||
|
@ -313,8 +313,8 @@ export class ConditionalProtectTag extends ArenaTag {
|
||||
* protection effect.
|
||||
* @param arena {@linkcode Arena} The arena containing the protection effect
|
||||
* @param moveId {@linkcode Moves} The move to check against this condition
|
||||
* @returns `true` if the incoming move's priority is greater than 0. This includes
|
||||
* moves with modified priorities from abilities (e.g. Prankster)
|
||||
* @returns `true` if the incoming move's priority is greater than 0.
|
||||
* This includes moves with modified priorities from abilities (e.g. Prankster)
|
||||
*/
|
||||
const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => {
|
||||
const move = allMoves[moveId];
|
||||
@ -322,9 +322,11 @@ const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => {
|
||||
const effectPhase = arena.scene.getCurrentPhase();
|
||||
|
||||
if (effectPhase instanceof MoveEffectPhase) {
|
||||
const attacker = effectPhase.getUserPokemon()!;
|
||||
const attacker = effectPhase.getUserPokemon();
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, priority);
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, false, move, priority);
|
||||
if (attacker) {
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, false, move, priority);
|
||||
}
|
||||
}
|
||||
return priority.value > 0;
|
||||
};
|
||||
@ -1203,6 +1205,24 @@ class GrassWaterPledgeTag extends ArenaTag {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Arena Tag class for {@link https://bulbapedia.bulbagarden.net/wiki/Fairy_Lock_(move) Fairy Lock}.
|
||||
* Fairy Lock prevents all Pokémon (except Ghost types) on the field from switching out or
|
||||
* fleeing during their next turn.
|
||||
* If a Pokémon that's on the field when Fairy Lock is used goes on to faint later in the same turn,
|
||||
* the Pokémon that replaces it will still be unable to switch out in the following turn.
|
||||
*/
|
||||
export class FairyLockTag extends ArenaTag {
|
||||
constructor(turnCount: number, sourceId: number) {
|
||||
super(ArenaTagType.FAIRY_LOCK, turnCount, Moves.FAIRY_LOCK, sourceId);
|
||||
}
|
||||
|
||||
onAdd(arena: Arena): void {
|
||||
arena.scene.queueMessage(i18next.t("arenaTag:fairyLockOnAdd"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter
|
||||
export function getArenaTag(tagType: ArenaTagType, turnCount: number, sourceMove: Moves | undefined, sourceId: number, targetIndex?: BattlerIndex, side: ArenaTagSide = ArenaTagSide.BOTH): ArenaTag | null {
|
||||
switch (tagType) {
|
||||
@ -1261,6 +1281,8 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: number, sourceMove
|
||||
return new WaterFirePledgeTag(sourceId, side);
|
||||
case ArenaTagType.GRASS_WATER_PLEDGE:
|
||||
return new GrassWaterPledgeTag(sourceId, side);
|
||||
case ArenaTagType.FAIRY_LOCK:
|
||||
return new FairyLockTag(turnCount, sourceId);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
],
|
||||
[Species.NINCADA]: [
|
||||
new SpeciesEvolution(Species.NINJASK, 20, null, null),
|
||||
new SpeciesEvolution(Species.SHEDINJA, 20, null, new SpeciesEvolutionCondition(p => p.scene.getParty().length < 6 && p.scene.pokeballCounts[PokeballType.POKEBALL] > 0))
|
||||
new SpeciesEvolution(Species.SHEDINJA, 20, null, new SpeciesEvolutionCondition(p => p.scene.getPlayerParty().length < 6 && p.scene.pokeballCounts[PokeballType.POKEBALL] > 0))
|
||||
],
|
||||
[Species.WHISMUR]: [
|
||||
new SpeciesEvolution(Species.LOUDRED, 20, null, null)
|
||||
@ -890,7 +890,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
||||
new SpeciesEvolution(Species.GOGOAT, 32, null, null)
|
||||
],
|
||||
[Species.PANCHAM]: [
|
||||
new SpeciesEvolution(Species.PANGORO, 32, null, new SpeciesEvolutionCondition(p => !!p.scene.getParty().find(p => p.getTypes(false, false, true).indexOf(Type.DARK) > -1)), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
new SpeciesEvolution(Species.PANGORO, 32, null, new SpeciesEvolutionCondition(p => !!p.scene.getPlayerParty().find(p => p.getTypes(false, false, true).indexOf(Type.DARK) > -1)), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.ESPURR]: [
|
||||
new SpeciesFormEvolution(Species.MEOWSTIC, "", "female", 25, null, new SpeciesEvolutionCondition(p => p.gender === Gender.FEMALE, p => p.gender = Gender.FEMALE)),
|
||||
|
@ -428,7 +428,7 @@ class AnimTimedAddBgEvent extends AnimTimedBgEvent {
|
||||
moveAnim.bgSprite.setScale(1.25);
|
||||
moveAnim.bgSprite.setAlpha(this.opacity / 255);
|
||||
scene.field.add(moveAnim.bgSprite);
|
||||
const fieldPokemon = scene.getNonSwitchedEnemyPokemon() || scene.getNonSwitchedPlayerPokemon();
|
||||
const fieldPokemon = scene.getEnemyPokemon(false) ?? scene.getPlayerPokemon(false);
|
||||
if (!isNullOrUndefined(priority)) {
|
||||
scene.field.moveTo(moveAnim.bgSprite as Phaser.GameObjects.GameObject, priority);
|
||||
} else if (fieldPokemon?.isOnField()) {
|
||||
@ -999,7 +999,7 @@ export abstract class BattleAnim {
|
||||
const setSpritePriority = (priority: integer) => {
|
||||
switch (priority) {
|
||||
case 0:
|
||||
scene.field.moveBelow(moveSprite as Phaser.GameObjects.GameObject, scene.getNonSwitchedEnemyPokemon() || scene.getNonSwitchedPlayerPokemon()!); // This bang assumes that if (the EnemyPokemon is undefined, then the PlayerPokemon function must return an object), correct assumption?
|
||||
scene.field.moveBelow(moveSprite as Phaser.GameObjects.GameObject, scene.getEnemyPokemon(false) ?? scene.getPlayerPokemon(false)!); // TODO: is this bang correct?
|
||||
break;
|
||||
case 1:
|
||||
scene.field.moveTo(moveSprite, scene.field.getAll().length - 1);
|
||||
|
@ -1573,6 +1573,22 @@ export class AbilityBattlerTag extends BattlerTag {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag used by Unburden to double speed
|
||||
* @extends AbilityBattlerTag
|
||||
*/
|
||||
export class UnburdenTag extends AbilityBattlerTag {
|
||||
constructor() {
|
||||
super(BattlerTagType.UNBURDEN, Abilities.UNBURDEN, BattlerTagLapseType.CUSTOM, 1);
|
||||
}
|
||||
onAdd(pokemon: Pokemon): void {
|
||||
super.onAdd(pokemon);
|
||||
}
|
||||
onRemove(pokemon: Pokemon): void {
|
||||
super.onRemove(pokemon);
|
||||
}
|
||||
}
|
||||
|
||||
export class TruantTag extends AbilityBattlerTag {
|
||||
constructor() {
|
||||
super(BattlerTagType.TRUANT, Abilities.TRUANT, BattlerTagLapseType.MOVE, 1);
|
||||
@ -2480,7 +2496,10 @@ export class SubstituteTag extends BattlerTag {
|
||||
onHit(pokemon: Pokemon): void {
|
||||
const moveEffectPhase = pokemon.scene.getCurrentPhase();
|
||||
if (moveEffectPhase instanceof MoveEffectPhase) {
|
||||
const attacker = moveEffectPhase.getUserPokemon()!;
|
||||
const attacker = moveEffectPhase.getUserPokemon();
|
||||
if (!attacker) {
|
||||
return;
|
||||
}
|
||||
const move = moveEffectPhase.move.getMove();
|
||||
const firstHit = (attacker.turnData.hitCount === attacker.turnData.hitsLeft);
|
||||
|
||||
@ -2934,6 +2953,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
|
||||
return new ThroatChoppedTag();
|
||||
case BattlerTagType.GORILLA_TACTICS:
|
||||
return new GorillaTacticsTag();
|
||||
case BattlerTagType.UNBURDEN:
|
||||
return new UnburdenTag();
|
||||
case BattlerTagType.SUBSTITUTE:
|
||||
return new SubstituteTag(sourceMove, sourceId);
|
||||
case BattlerTagType.AUTOTOMIZED:
|
||||
|
@ -2,7 +2,7 @@ import { getPokemonNameWithAffix } from "../messages";
|
||||
import Pokemon, { HitResult } from "../field/pokemon";
|
||||
import { getStatusEffectHealText } from "./status-effect";
|
||||
import * as Utils from "../utils";
|
||||
import { DoubleBerryEffectAbAttr, ReduceBerryUseThresholdAbAttr, applyAbAttrs } from "./ability";
|
||||
import { DoubleBerryEffectAbAttr, PostItemLostAbAttr, ReduceBerryUseThresholdAbAttr, applyAbAttrs, applyPostItemLostAbAttrs } from "./ability";
|
||||
import i18next from "i18next";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { BerryType } from "#enums/berry-type";
|
||||
@ -75,6 +75,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, hpHealed);
|
||||
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(),
|
||||
hpHealed.value, i18next.t("battle:hpHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), berryName: getBerryName(berryType) }), true));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
};
|
||||
case BerryType.LUM:
|
||||
return (pokemon: Pokemon) => {
|
||||
@ -86,6 +87,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
}
|
||||
pokemon.resetStatus(true, true);
|
||||
pokemon.updateInfo();
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
};
|
||||
case BerryType.LIECHI:
|
||||
case BerryType.GANLON:
|
||||
@ -101,6 +103,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
const statStages = new Utils.NumberHolder(1);
|
||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statStages);
|
||||
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], statStages.value));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
};
|
||||
case BerryType.LANSAT:
|
||||
return (pokemon: Pokemon) => {
|
||||
@ -108,6 +111,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
pokemon.battleData.berriesEaten.push(berryType);
|
||||
}
|
||||
pokemon.addTag(BattlerTagType.CRIT_BOOST);
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
};
|
||||
case BerryType.STARF:
|
||||
return (pokemon: Pokemon) => {
|
||||
@ -118,6 +122,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
const stages = new Utils.NumberHolder(2);
|
||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, stages);
|
||||
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ randStat ], stages.value));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
};
|
||||
case BerryType.LEPPA:
|
||||
return (pokemon: Pokemon) => {
|
||||
@ -128,6 +133,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
if (ppRestoreMove !== undefined) {
|
||||
ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0);
|
||||
pokemon.scene.queueMessage(i18next.t("battle:ppHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: ppRestoreMove!.getName(), berryName: getBerryName(berryType) }));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import { Constructor, NumberHolder } from "#app/utils";
|
||||
import * as Utils from "../utils";
|
||||
import { WeatherType } from "./weather";
|
||||
import { ArenaTagSide, ArenaTrapTag, WeakenMoveTypeTag } from "./arena-tag";
|
||||
import { allAbilities, AllyMoveCategoryPowerBoostAbAttr, applyAbAttrs, applyPostAttackAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, BlockItemTheftAbAttr, BlockNonDirectDamageAbAttr, BlockOneHitKOAbAttr, BlockRecoilDamageAttr, ConfusionOnStatusEffectAbAttr, FieldMoveTypePowerBoostAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, HealFromBerryUseAbAttr, IgnoreContactAbAttr, IgnoreMoveEffectsAbAttr, IgnoreProtectOnContactAbAttr, InfiltratorAbAttr, MaxMultiHitAbAttr, MoveAbilityBypassAbAttr, MoveEffectChanceMultiplierAbAttr, MoveTypeChangeAbAttr, PostDamageForceSwitchAbAttr, ReverseDrainAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, UnswappableAbilityAbAttr, UserFieldMoveTypePowerBoostAbAttr, VariableMovePowerAbAttr, WonderSkinAbAttr } from "./ability";
|
||||
import { allAbilities, AllyMoveCategoryPowerBoostAbAttr, applyAbAttrs, applyPostAttackAbAttrs, applyPostItemLostAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, BlockItemTheftAbAttr, BlockNonDirectDamageAbAttr, BlockOneHitKOAbAttr, BlockRecoilDamageAttr, ConfusionOnStatusEffectAbAttr, FieldMoveTypePowerBoostAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, HealFromBerryUseAbAttr, IgnoreContactAbAttr, IgnoreMoveEffectsAbAttr, IgnoreProtectOnContactAbAttr, InfiltratorAbAttr, MaxMultiHitAbAttr, MoveAbilityBypassAbAttr, MoveEffectChanceMultiplierAbAttr, MoveTypeChangeAbAttr, PostDamageForceSwitchAbAttr, PostItemLostAbAttr, ReverseDrainAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, UnswappableAbilityAbAttr, UserFieldMoveTypePowerBoostAbAttr, VariableMovePowerAbAttr, WonderSkinAbAttr } from "./ability";
|
||||
import { AttackTypeBoosterModifier, BerryModifier, PokemonHeldItemModifier, PokemonMoveAccuracyBoosterModifier, PokemonMultiHitModifier, PreserveBerryModifier } from "../modifier/modifier";
|
||||
import { BattlerIndex, BattleType } from "../battle";
|
||||
import { TerrainType } from "./terrain";
|
||||
@ -1474,8 +1474,8 @@ export class RecoilAttr extends MoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
const damageValue = (!this.useHp ? user.turnData.damageDealt : user.getMaxHp()) * this.damageRatio;
|
||||
const minValue = user.turnData.damageDealt ? 1 : 0;
|
||||
const damageValue = (!this.useHp ? user.turnData.totalDamageDealt : user.getMaxHp()) * this.damageRatio;
|
||||
const minValue = user.turnData.totalDamageDealt ? 1 : 0;
|
||||
const recoilDamage = Utils.toDmgValue(damageValue, minValue);
|
||||
if (!recoilDamage) {
|
||||
return false;
|
||||
@ -1743,7 +1743,7 @@ export class PartyStatusCureAttr extends MoveEffectAttr {
|
||||
if (!this.canApply(user, target, move, args)) {
|
||||
return false;
|
||||
}
|
||||
const partyPokemon = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty();
|
||||
const partyPokemon = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
|
||||
partyPokemon.forEach(p => this.cureStatus(p, user.id));
|
||||
|
||||
if (this.message) {
|
||||
@ -1815,7 +1815,7 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
|
||||
}
|
||||
|
||||
// We don't know which party member will be chosen, so pick the highest max HP in the party
|
||||
const maxPartyMemberHp = user.scene.getParty().map(p => p.getMaxHp()).reduce((maxHp: integer, hp: integer) => Math.max(hp, maxHp), 0);
|
||||
const maxPartyMemberHp = user.scene.getPlayerParty().map(p => p.getMaxHp()).reduce((maxHp: integer, hp: integer) => Math.max(hp, maxHp), 0);
|
||||
|
||||
user.scene.pushPhase(new PokemonHealPhase(user.scene, user.getBattlerIndex(),
|
||||
maxPartyMemberHp, i18next.t("moveTriggers:sacrificialFullRestore", { pokemonName: getPokemonNameWithAffix(user) }), true, false, false, true), true);
|
||||
@ -1828,7 +1828,7 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
|
||||
}
|
||||
|
||||
getCondition(): MoveConditionFunc {
|
||||
return (user, target, move) => user.scene.getParty().filter(p => p.isActive()).length > user.scene.currentBattle.getBattlerCount();
|
||||
return (user, _target, _move) => user.scene.getPlayerParty().filter(p => p.isActive()).length > user.scene.currentBattle.getBattlerCount();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2006,7 +2006,7 @@ export class HitHealAttr extends MoveEffectAttr {
|
||||
message = i18next.t("battle:drainMessage", { pokemonName: getPokemonNameWithAffix(target) });
|
||||
} else {
|
||||
// Default healing formula used by draining moves like Absorb, Draining Kiss, Bitter Blade, etc.
|
||||
healAmount = Utils.toDmgValue(user.turnData.currDamageDealt * this.healRatio);
|
||||
healAmount = Utils.toDmgValue(user.turnData.singleHitDamageDealt * this.healRatio);
|
||||
message = i18next.t("battle:regainHealth", { pokemonName: getPokemonNameWithAffix(user) });
|
||||
}
|
||||
if (reverseDrain) {
|
||||
@ -2158,7 +2158,7 @@ export class MultiHitAttr extends MoveAttr {
|
||||
case MultiHitType._10:
|
||||
return 10;
|
||||
case MultiHitType.BEAT_UP:
|
||||
const party = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty();
|
||||
const party = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
|
||||
// No status means the ally pokemon can contribute to Beat Up
|
||||
return party.reduce((total, pokemon) => {
|
||||
return total + (pokemon.id === user.id ? 1 : pokemon?.status && pokemon.status.effect !== StatusEffect.NONE ? 0 : 1);
|
||||
@ -2402,6 +2402,8 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
|
||||
// Decrease item amount and update icon
|
||||
!--removedItem.stackCount;
|
||||
target.scene.updateModifiers(target.isPlayer());
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false);
|
||||
|
||||
|
||||
if (this.berriesOnly) {
|
||||
user.scene.queueMessage(i18next.t("moveTriggers:incineratedItem", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target), itemName: removedItem.type.name }));
|
||||
@ -2481,6 +2483,7 @@ export class EatBerryAttr extends MoveEffectAttr {
|
||||
eatBerry(consumer: Pokemon) {
|
||||
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer); // consumer eats the berry
|
||||
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false));
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, consumer, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2516,6 +2519,7 @@ export class StealEatBerryAttr extends EatBerryAttr {
|
||||
}
|
||||
// if the target has berries, pick a random berry and steal it
|
||||
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
|
||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false);
|
||||
const message = i18next.t("battle:stealEatBerry", { pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name });
|
||||
user.scene.queueMessage(message);
|
||||
this.reduceBerryModifier(target);
|
||||
@ -3467,7 +3471,7 @@ export class MovePowerMultiplierAttr extends VariablePowerAttr {
|
||||
* @returns The base power of the Beat Up hit.
|
||||
*/
|
||||
const beatUpFunc = (user: Pokemon, allyIndex: number): number => {
|
||||
const party = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty();
|
||||
const party = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
|
||||
|
||||
for (let i = allyIndex; i < party.length; i++) {
|
||||
const pokemon = party[i];
|
||||
@ -3495,7 +3499,7 @@ export class BeatUpAttr extends VariablePowerAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const power = args[0] as Utils.NumberHolder;
|
||||
|
||||
const party = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty();
|
||||
const party = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
|
||||
const allyCount = party.filter(pokemon => {
|
||||
return pokemon.id === user.id || !pokemon.status?.effect;
|
||||
}).length;
|
||||
@ -4157,6 +4161,60 @@ export class CombinedPledgeStabBoostAttr extends MoveAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Variable Power attribute for {@link https://bulbapedia.bulbagarden.net/wiki/Round_(move) | Round}.
|
||||
* Doubles power if another Pokemon has previously selected Round this turn.
|
||||
* @extends VariablePowerAttr
|
||||
*/
|
||||
export class RoundPowerAttr extends VariablePowerAttr {
|
||||
override apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const power = args[0];
|
||||
if (!(power instanceof Utils.NumberHolder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (user.turnData?.joinedRound) {
|
||||
power.value *= 2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute for the "combo" effect of {@link https://bulbapedia.bulbagarden.net/wiki/Round_(move) | Round}.
|
||||
* Preempts the next move in the turn order with the first instance of any Pokemon
|
||||
* using Round. Also marks the Pokemon using the cued Round to double the move's power.
|
||||
* @extends MoveEffectAttr
|
||||
* @see {@linkcode RoundPowerAttr}
|
||||
*/
|
||||
export class CueNextRoundAttr extends MoveEffectAttr {
|
||||
constructor() {
|
||||
super(true, { lastHitOnly: true });
|
||||
}
|
||||
|
||||
override apply(user: Pokemon, target: Pokemon, move: Move, args?: any[]): boolean {
|
||||
const nextRoundPhase = user.scene.findPhase<MovePhase>(phase =>
|
||||
phase instanceof MovePhase && phase.move.moveId === Moves.ROUND
|
||||
);
|
||||
|
||||
if (!nextRoundPhase) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update the phase queue so that the next Pokemon using Round moves next
|
||||
const nextRoundIndex = user.scene.phaseQueue.indexOf(nextRoundPhase);
|
||||
const nextMoveIndex = user.scene.phaseQueue.findIndex(phase => phase instanceof MovePhase);
|
||||
if (nextRoundIndex !== nextMoveIndex) {
|
||||
user.scene.prependToPhase(user.scene.phaseQueue.splice(nextRoundIndex, 1)[0], MovePhase);
|
||||
}
|
||||
|
||||
// Mark the corresponding Pokemon as having "joined the Round" (for doubling power later)
|
||||
nextRoundPhase.pokemon.turnData.joinedRound = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class VariableAtkAttr extends MoveAttr {
|
||||
constructor() {
|
||||
super();
|
||||
@ -5720,7 +5778,7 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
|
||||
return new Promise(resolve => {
|
||||
// If user is player, checks if the user has fainted pokemon
|
||||
if (user instanceof PlayerPokemon
|
||||
&& user.scene.getParty().findIndex(p => p.isFainted()) > -1) {
|
||||
&& user.scene.getPlayerParty().findIndex(p => p.isFainted()) > -1) {
|
||||
(user as PlayerPokemon).revivalBlessing().then(() => {
|
||||
resolve(true);
|
||||
});
|
||||
@ -5794,7 +5852,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
}
|
||||
}
|
||||
// Switch out logic for the player's Pokemon
|
||||
if (switchOutTarget.scene.getParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) {
|
||||
if (switchOutTarget.scene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -5903,7 +5961,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
}
|
||||
}
|
||||
|
||||
const party = player ? user.scene.getParty() : user.scene.getEnemyParty();
|
||||
const party = player ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
|
||||
return (!player && !user.scene.currentBattle.battleType)
|
||||
|| party.filter(p => p.isAllowedInBattle()
|
||||
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > user.scene.currentBattle.getBattlerCount();
|
||||
@ -7254,7 +7312,7 @@ const targetSleptOrComatoseCondition: MoveConditionFunc = (user: Pokemon, target
|
||||
const failIfLastCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => user.scene.phaseQueue.find(phase => phase instanceof MovePhase) !== undefined;
|
||||
|
||||
const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => {
|
||||
const party: Pokemon[] = user.isPlayer() ? user.scene.getParty() : user.scene.getEnemyParty();
|
||||
const party: Pokemon[] = user.isPlayer() ? user.scene.getPlayerParty() : user.scene.getEnemyParty();
|
||||
return party.some(pokemon => pokemon.isActive() && !pokemon.isOnField());
|
||||
};
|
||||
|
||||
@ -8956,8 +9014,9 @@ export function initMoves() {
|
||||
.condition((user, target, move) => !target.turnData.acted)
|
||||
.attr(AfterYouAttr),
|
||||
new AttackMove(Moves.ROUND, Type.NORMAL, MoveCategory.SPECIAL, 60, 100, 15, -1, 0, 5)
|
||||
.soundBased()
|
||||
.partial(), // No effect implemented
|
||||
.attr(CueNextRoundAttr)
|
||||
.attr(RoundPowerAttr)
|
||||
.soundBased(),
|
||||
new AttackMove(Moves.ECHOED_VOICE, Type.NORMAL, MoveCategory.SPECIAL, 40, 100, 15, -1, 0, 5)
|
||||
.attr(ConsecutiveUseMultiBasePowerAttr, 5, false)
|
||||
.soundBased(),
|
||||
@ -9184,7 +9243,7 @@ export function initMoves() {
|
||||
.target(MoveTarget.ALL)
|
||||
.condition((user, target, move) => {
|
||||
// If any fielded pokémon is grass-type and grounded.
|
||||
return [ ...user.scene.getEnemyParty(), ...user.scene.getParty() ].some((poke) => poke.isOfType(Type.GRASS) && poke.isGrounded());
|
||||
return [ ...user.scene.getEnemyParty(), ...user.scene.getPlayerParty() ].some((poke) => poke.isOfType(Type.GRASS) && poke.isGrounded());
|
||||
})
|
||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => target.isOfType(Type.GRASS) && target.isGrounded() }),
|
||||
new StatusMove(Moves.STICKY_WEB, Type.BUG, -1, 20, -1, 0, 6)
|
||||
@ -9258,8 +9317,9 @@ export function initMoves() {
|
||||
.target(MoveTarget.ALL_NEAR_OTHERS),
|
||||
new StatusMove(Moves.FAIRY_LOCK, Type.FAIRY, -1, 10, -1, 0, 6)
|
||||
.ignoresSubstitute()
|
||||
.ignoresProtect()
|
||||
.target(MoveTarget.BOTH_SIDES)
|
||||
.unimplemented(),
|
||||
.attr(AddArenaTagAttr, ArenaTagType.FAIRY_LOCK, 2, true),
|
||||
new SelfStatusMove(Moves.KINGS_SHIELD, Type.STEEL, -1, 10, -1, 4, 6)
|
||||
.attr(ProtectAttr, BattlerTagType.KINGS_SHIELD)
|
||||
.condition(failIfLastCondition),
|
||||
|
@ -181,7 +181,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
|
||||
|
||||
// Sort berries by party member ID to more easily re-add later if necessary
|
||||
const berryItemsMap = new Map<number, BerryModifier[]>();
|
||||
scene.getParty().forEach(pokemon => {
|
||||
scene.getPlayerParty().forEach(pokemon => {
|
||||
const pokemonBerries = berryItems.filter(b => b.pokemonId === pokemon.id);
|
||||
if (pokemonBerries?.length > 0) {
|
||||
berryItemsMap.set(pokemon.id, pokemonBerries);
|
||||
@ -267,7 +267,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
|
||||
const revSeed = generateModifierType(scene, modifierTypes.REVIVER_SEED);
|
||||
encounter.setDialogueToken("foodReward", revSeed?.name ?? i18next.t("modifierType:ModifierType.REVIVER_SEED.name"));
|
||||
const givePartyPokemonReviverSeeds = () => {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
party.forEach(p => {
|
||||
const heldItems = p.getHeldItems();
|
||||
if (revSeed && !heldItems.some(item => item instanceof PokemonInstantReviveModifier)) {
|
||||
@ -308,7 +308,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
|
||||
const berryMap = encounter.misc.berryItemsMap;
|
||||
|
||||
// Returns 2/5 of the berries stolen to each Pokemon
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
party.forEach(pokemon => {
|
||||
const stolenBerries: BerryModifier[] = berryMap.get(pokemon.id);
|
||||
const berryTypesAsArray: BerryType[] = [];
|
||||
|
@ -58,7 +58,7 @@ export const BerriesAboundEncounter: MysteryEncounter =
|
||||
|
||||
// Calculate boss mon
|
||||
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
|
||||
encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon));
|
||||
const config: EnemyPartyConfig = {
|
||||
@ -77,7 +77,7 @@ export const BerriesAboundEncounter: MysteryEncounter =
|
||||
scene.currentBattle.waveIndex > 160 ? 7
|
||||
: scene.currentBattle.waveIndex > 120 ? 5
|
||||
: scene.currentBattle.waveIndex > 40 ? 4 : 2;
|
||||
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0);
|
||||
regenerateModifierPoolThresholds(scene.getPlayerParty(), ModifierPoolType.PLAYER, 0);
|
||||
encounter.misc = { numBerries };
|
||||
|
||||
const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon);
|
||||
@ -253,7 +253,7 @@ function tryGiveBerry(scene: BattleScene, prioritizedPokemon?: PlayerPokemon) {
|
||||
const berryType = randSeedInt(Object.keys(BerryType).filter(s => !isNaN(Number(s))).length) as BerryType;
|
||||
const berry = generateModifierType(scene, modifierTypes.BERRY, [ berryType ]) as BerryModifierType;
|
||||
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
|
||||
// Will try to apply to prioritized pokemon first, then do normal application method if it fails
|
||||
if (prioritizedPokemon) {
|
||||
|
@ -331,7 +331,7 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
|
||||
// Player gets different rewards depending on the number of bug types they have
|
||||
const numBugTypes = scene.getParty().filter(p => p.isOfType(Type.BUG, true)).length;
|
||||
const numBugTypes = scene.getPlayerParty().filter(p => p.isOfType(Type.BUG, true)).length;
|
||||
const numBugTypesText = i18next.t(`${namespace}:numBugTypes`, { count: numBugTypes });
|
||||
encounter.setDialogueToken("numBugTypes", numBugTypesText);
|
||||
|
||||
|
@ -245,7 +245,7 @@ export const ClowningAroundEncounter: MysteryEncounter =
|
||||
// So Vitamins, form change items, etc. are not included
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
let mostHeldItemsPokemon = party[0];
|
||||
let count = mostHeldItemsPokemon.getHeldItems()
|
||||
.filter(m => m.isTransferable && !(m instanceof BerryModifier))
|
||||
@ -328,7 +328,7 @@ export const ClowningAroundEncounter: MysteryEncounter =
|
||||
.withPreOptionPhase(async (scene: BattleScene) => {
|
||||
// Randomize the second type of all player's pokemon
|
||||
// If the pokemon does not normally have a second type, it will gain 1
|
||||
for (const pokemon of scene.getParty()) {
|
||||
for (const pokemon of scene.getPlayerParty()) {
|
||||
const originalTypes = pokemon.getTypes(false, false, true);
|
||||
|
||||
// If the Pokemon has non-status moves that don't match the Pokemon's type, prioritizes those as the new type
|
||||
|
@ -1,32 +1,32 @@
|
||||
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { Species } from "#enums/species";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { EncounterBattleAnim } from "#app/data/battle-anims";
|
||||
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
|
||||
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { TrainerSlot } from "#app/data/trainer-config";
|
||||
import PokemonData from "#app/system/pokemon-data";
|
||||
import { Biome } from "#enums/biome";
|
||||
import { EncounterBattleAnim } from "#app/data/battle-anims";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { getEncounterText, queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements";
|
||||
import { DANCING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups";
|
||||
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { getEncounterText, queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { catchPokemon, getEncounterPokemonLevelForWave, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import { PokeballType } from "#enums/pokeball";
|
||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { TrainerSlot } from "#app/data/trainer-config";
|
||||
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { LearnMovePhase } from "#app/phases/learn-move-phase";
|
||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||
import { Stat } from "#enums/stat";
|
||||
import PokemonData from "#app/system/pokemon-data";
|
||||
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { Biome } from "#enums/biome";
|
||||
import { EncounterAnim } from "#enums/encounter-anims";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { PokeballType } from "#enums/pokeball";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import i18next from "i18next";
|
||||
|
||||
/** the i18n namespace for this encounter */
|
||||
@ -92,7 +92,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
|
||||
.withCatchAllowed(true)
|
||||
.withFleeAllowed(false)
|
||||
.withOnVisualsStart((scene: BattleScene) => {
|
||||
const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getParty()[0]);
|
||||
const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getPlayerPokemon()!);
|
||||
danceAnim.play(scene);
|
||||
|
||||
return true;
|
||||
@ -217,7 +217,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
|
||||
|
||||
const onPokemonSelected = (pokemon: PlayerPokemon) => {
|
||||
encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender());
|
||||
scene.unshiftPhase(new LearnMovePhase(scene, scene.getParty().indexOf(pokemon), Moves.REVELATION_DANCE));
|
||||
scene.unshiftPhase(new LearnMovePhase(scene, scene.getPlayerParty().indexOf(pokemon), Moves.REVELATION_DANCE));
|
||||
|
||||
// Play animation again to "learn" the dance
|
||||
const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, scene.getEnemyPokemon()!, scene.getPlayerPokemon());
|
||||
|
@ -1,22 +1,22 @@
|
||||
import { generateModifierType, leaveEncounterWithoutBattle, selectPokemonForOption, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
|
||||
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { Species } from "#enums/species";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
|
||||
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||
import { CombinationPokemonRequirement, HeldItemRequirement, MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements";
|
||||
import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PreserveBerryModifier } from "#app/modifier/modifier";
|
||||
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
||||
import { generateModifierType, leaveEncounterWithoutBattle, selectPokemonForOption, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import i18next from "#app/plugins/i18n";
|
||||
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
|
||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PreserveBerryModifier } from "#app/modifier/modifier";
|
||||
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
|
||||
import i18next from "#app/plugins/i18n";
|
||||
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { Species } from "#enums/species";
|
||||
|
||||
/** the i18n namespace for this encounter */
|
||||
const namespace = "mysteryEncounters/delibirdy";
|
||||
@ -133,7 +133,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
||||
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
|
||||
// At max stacks, give the first party pokemon a Shell Bell instead
|
||||
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell);
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerPokemon()!, shellBell);
|
||||
scene.playSound("item_fanfare");
|
||||
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
|
||||
} else {
|
||||
@ -207,7 +207,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
||||
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
|
||||
// At max stacks, give the first party pokemon a Shell Bell instead
|
||||
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell);
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerPokemon()!, shellBell);
|
||||
scene.playSound("item_fanfare");
|
||||
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
|
||||
} else {
|
||||
@ -220,7 +220,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
||||
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
|
||||
// At max stacks, give the first party pokemon a Shell Bell instead
|
||||
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell);
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerPokemon()!, shellBell);
|
||||
scene.playSound("item_fanfare");
|
||||
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
|
||||
} else {
|
||||
@ -299,7 +299,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
||||
if (existing && existing.getStackCount() >= existing.getMaxStackCount(scene)) {
|
||||
// At max stacks, give the first party pokemon a Shell Bell instead
|
||||
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getParty()[0], shellBell);
|
||||
await applyModifierTypeToPlayerPokemon(scene, scene.getPlayerParty()[0], shellBell);
|
||||
scene.playSound("item_fanfare");
|
||||
await showEncounterText(scene, i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true);
|
||||
} else {
|
||||
|
@ -214,7 +214,7 @@ function pokemonAndMoveChosen(scene: BattleScene, pokemon: PlayerPokemon, move:
|
||||
text: `${namespace}:incorrect_exp`,
|
||||
},
|
||||
];
|
||||
setEncounterExp(scene, scene.getParty().map((p) => p.id), 50);
|
||||
setEncounterExp(scene, scene.getPlayerParty().map((p) => p.id), 50);
|
||||
} else {
|
||||
encounter.selectedOption!.dialogue!.selected = [
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ export const FieryFalloutEncounter: MysteryEncounter =
|
||||
async (scene: BattleScene) => {
|
||||
// Damage non-fire types and burn 1 random non-fire type member + give it Heatproof
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
const nonFireTypes = scene.getParty().filter((p) => p.isAllowedInBattle() && !p.getTypes().includes(Type.FIRE));
|
||||
const nonFireTypes = scene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.getTypes().includes(Type.FIRE));
|
||||
|
||||
for (const pkm of nonFireTypes) {
|
||||
const percentage = DAMAGE_PERCENTAGE / 100;
|
||||
@ -257,7 +257,7 @@ export const FieryFalloutEncounter: MysteryEncounter =
|
||||
|
||||
function giveLeadPokemonAttackTypeBoostItem(scene: BattleScene) {
|
||||
// Give first party pokemon attack type boost item for free at end of battle
|
||||
const leadPokemon = scene.getParty()?.[0];
|
||||
const leadPokemon = scene.getPlayerParty()?.[0];
|
||||
if (leadPokemon) {
|
||||
// Generate type booster held item, default to Charcoal if item fails to generate
|
||||
let boosterModifierType = generateModifierType(scene, modifierTypes.ATTACK_TYPE_BOOSTER) as AttackTypeBoosterModifierType;
|
||||
|
@ -56,7 +56,7 @@ export const FightOrFlightEncounter: MysteryEncounter =
|
||||
|
||||
// Calculate boss mon
|
||||
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
|
||||
encounter.setDialogueToken("enemyPokemon", bossPokemon.getNameToRender());
|
||||
const config: EnemyPartyConfig = {
|
||||
@ -86,11 +86,11 @@ export const FightOrFlightEncounter: MysteryEncounter =
|
||||
: scene.currentBattle.waveIndex > 40
|
||||
? ModifierTier.ULTRA
|
||||
: ModifierTier.GREAT;
|
||||
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0);
|
||||
regenerateModifierPoolThresholds(scene.getPlayerParty(), ModifierPoolType.PLAYER, 0);
|
||||
let item: ModifierTypeOption | null = null;
|
||||
// TMs and Candy Jar excluded from possible rewards as they're too swingy in value for a singular item reward
|
||||
while (!item || item.type.id.includes("TM_") || item.type.id === "CANDY_JAR") {
|
||||
item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0];
|
||||
item = getPlayerModifierTypeOptions(1, scene.getPlayerParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0];
|
||||
}
|
||||
encounter.setDialogueToken("itemName", item.type.name);
|
||||
encounter.misc = item;
|
||||
|
@ -165,7 +165,7 @@ async function summonPlayerPokemon(scene: BattleScene) {
|
||||
|
||||
const playerPokemon = encounter.misc.playerPokemon;
|
||||
// Swaps the chosen Pokemon and the first player's lead Pokemon in the party
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
const chosenIndex = party.indexOf(playerPokemon);
|
||||
if (chosenIndex !== 0) {
|
||||
const leadPokemon = party[0];
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { TrainerSlot, } from "#app/data/trainer-config";
|
||||
import { ModifierTier } from "#app/modifier/modifier-tier";
|
||||
import { MusicPreference } from "#app/system/settings/settings";
|
||||
import { getPlayerModifierTypeOptions, ModifierPoolType, ModifierTypeOption, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
@ -105,7 +106,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
|
||||
// Load bgm
|
||||
let bgmKey: string;
|
||||
if (scene.musicPreference === 0) {
|
||||
if (scene.musicPreference === MusicPreference.CONSISTENT) {
|
||||
bgmKey = "mystery_encounter_gen_5_gts";
|
||||
scene.loadBgm(bgmKey, `${bgmKey}.mp3`);
|
||||
} else {
|
||||
@ -191,7 +192,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
receivedPokemonData.pokeball = randInt(4) as PokeballType;
|
||||
const dataSource = new PokemonData(receivedPokemonData);
|
||||
const newPlayerPokemon = scene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource);
|
||||
scene.getParty().push(newPlayerPokemon);
|
||||
scene.getPlayerParty().push(newPlayerPokemon);
|
||||
await newPlayerPokemon.loadAssets();
|
||||
|
||||
for (const mod of modifiers) {
|
||||
@ -224,7 +225,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
const onPokemonSelected = (pokemon: PlayerPokemon) => {
|
||||
// Randomly generate a Wonder Trade pokemon
|
||||
const randomTradeOption = generateTradeOption(scene.getParty().map(p => p.species));
|
||||
const randomTradeOption = generateTradeOption(scene.getPlayerParty().map(p => p.species));
|
||||
const tradePokemon = new EnemyPokemon(scene, randomTradeOption, pokemon.level, TrainerSlot.NONE, false);
|
||||
// Extra shiny roll at 1/128 odds (boosted by events and charms)
|
||||
if (!tradePokemon.shiny) {
|
||||
@ -299,7 +300,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
receivedPokemonData.pokeball = randInt(4) as PokeballType;
|
||||
const dataSource = new PokemonData(receivedPokemonData);
|
||||
const newPlayerPokemon = scene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource);
|
||||
scene.getParty().push(newPlayerPokemon);
|
||||
scene.getPlayerParty().push(newPlayerPokemon);
|
||||
await newPlayerPokemon.loadAssets();
|
||||
|
||||
for (const mod of modifiers) {
|
||||
@ -384,11 +385,11 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
tier++;
|
||||
}
|
||||
|
||||
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0);
|
||||
regenerateModifierPoolThresholds(scene.getPlayerParty(), ModifierPoolType.PLAYER, 0);
|
||||
let item: ModifierTypeOption | null = null;
|
||||
// TMs excluded from possible rewards
|
||||
while (!item || item.type.id.includes("TM_")) {
|
||||
item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0];
|
||||
item = getPlayerModifierTypeOptions(1, scene.getPlayerParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0];
|
||||
}
|
||||
|
||||
encounter.setDialogueToken("itemName", item.type.name);
|
||||
@ -430,9 +431,9 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
function getPokemonTradeOptions(scene: BattleScene): Map<number, EnemyPokemon[]> {
|
||||
const tradeOptionsMap: Map<number, EnemyPokemon[]> = new Map<number, EnemyPokemon[]>();
|
||||
// Starts by filtering out any current party members as valid resulting species
|
||||
const alreadyUsedSpecies: PokemonSpecies[] = scene.getParty().map(p => p.species);
|
||||
const alreadyUsedSpecies: PokemonSpecies[] = scene.getPlayerParty().map(p => p.species);
|
||||
|
||||
scene.getParty().forEach(pokemon => {
|
||||
scene.getPlayerParty().forEach(pokemon => {
|
||||
// If the party member is legendary/mythical, the only trade options available are always pulled from generation-specific legendary trade pools
|
||||
if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) {
|
||||
const generation = pokemon.species.generation;
|
||||
|
@ -104,7 +104,7 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with
|
||||
],
|
||||
},
|
||||
async (scene: BattleScene) => {
|
||||
const allowedPokemon = scene.getParty().filter((p) => p.isAllowedInBattle());
|
||||
const allowedPokemon = scene.getPlayerParty().filter((p) => p.isAllowedInBattle());
|
||||
|
||||
for (const pkm of allowedPokemon) {
|
||||
const percentage = DAMAGE_PERCENTAGE / 100;
|
||||
|
@ -1,19 +1,19 @@
|
||||
import { queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { getHighestLevelPlayerPokemon, koPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import { ModifierTier } from "#app/modifier/modifier-tier";
|
||||
import { randSeedInt } from "#app/utils";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import MysteryEncounter, { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter";
|
||||
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { getHighestLevelPlayerPokemon, koPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { Species } from "#enums/species";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||
import { ModifierTier } from "#app/modifier/modifier-tier";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { randSeedInt } from "#app/utils";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { Species } from "#enums/species";
|
||||
|
||||
/** i18n namespace for encounter */
|
||||
const namespace = "mysteryEncounters/mysteriousChest";
|
||||
@ -177,7 +177,7 @@ export const MysteriousChestEncounter: MysteryEncounter =
|
||||
await showEncounterText(scene, `${namespace}:option.1.bad`);
|
||||
|
||||
// Handle game over edge case
|
||||
const allowedPokemon = scene.getParty().filter(p => p.isAllowedInBattle());
|
||||
const allowedPokemon = scene.getPokemonAllowedInBattle();
|
||||
if (allowedPokemon.length === 0) {
|
||||
// If there are no longer any legal pokemon in the party, game over.
|
||||
scene.clearPhaseQueue();
|
||||
|
@ -100,7 +100,7 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter =
|
||||
// Only Pokemon that can gain benefits are above half HP with no status
|
||||
const selectableFilter = (pokemon: Pokemon) => {
|
||||
// If pokemon meets primary pokemon reqs, it can be selected
|
||||
if (!pokemon.isAllowed()) {
|
||||
if (!pokemon.isAllowedInChallenge()) {
|
||||
return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null;
|
||||
}
|
||||
if (!encounter.pokemonMeetsPrimaryRequirements(scene, pokemon)) {
|
||||
|
@ -134,7 +134,7 @@ export const TeleportingHijinksEncounter: MysteryEncounter =
|
||||
|
||||
// Init enemy
|
||||
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
|
||||
encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon));
|
||||
const config: EnemyPartyConfig = {
|
||||
@ -170,7 +170,7 @@ async function doBiomeTransitionDialogueAndBattleInit(scene: BattleScene) {
|
||||
|
||||
// Init enemy
|
||||
const level = getEncounterPokemonLevelForWave(scene, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true);
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
const bossPokemon = new EnemyPokemon(scene, bossSpecies, level, TrainerSlot.NONE, true);
|
||||
encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon));
|
||||
|
||||
|
@ -126,7 +126,7 @@ export const TheExpertPokemonBreederEncounter: MysteryEncounter =
|
||||
];
|
||||
|
||||
// Determine the 3 pokemon the player can battle with
|
||||
let partyCopy = scene.getParty().slice(0);
|
||||
let partyCopy = scene.getPlayerParty().slice(0);
|
||||
partyCopy = partyCopy
|
||||
.filter(p => p.isAllowedInBattle())
|
||||
.sort((a, b) => a.friendship - b.friendship);
|
||||
@ -508,11 +508,11 @@ function getEggOptions(scene: BattleScene, commonEggs: number, rareEggs: number)
|
||||
}
|
||||
|
||||
function removePokemonFromPartyAndStoreHeldItems(scene: BattleScene, encounter: MysteryEncounter, chosenPokemon: PlayerPokemon) {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
const chosenIndex = party.indexOf(chosenPokemon);
|
||||
party[chosenIndex] = party[0];
|
||||
party[0] = chosenPokemon;
|
||||
encounter.misc.originalParty = scene.getParty().slice(1);
|
||||
encounter.misc.originalParty = scene.getPlayerParty().slice(1);
|
||||
encounter.misc.originalPartyHeldItems = encounter.misc.originalParty
|
||||
.map(p => p.getHeldItems());
|
||||
scene["party"] = [
|
||||
@ -529,7 +529,7 @@ function checkAchievement(scene: BattleScene) {
|
||||
function restorePartyAndHeldItems(scene: BattleScene) {
|
||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||
// Restore original party
|
||||
scene.getParty().push(...encounter.misc.originalParty);
|
||||
scene.getPlayerParty().push(...encounter.misc.originalParty);
|
||||
|
||||
// Restore held items
|
||||
const originalHeldItems = encounter.misc.originalPartyHeldItems;
|
||||
|
@ -140,7 +140,7 @@ export const TheStrongStuffEncounter: MysteryEncounter =
|
||||
|
||||
// -15 to all base stats of highest BST (halved for HP), +10 to all base stats of rest of party (halved for HP)
|
||||
// Sort party by bst
|
||||
const sortedParty = scene.getParty().slice(0)
|
||||
const sortedParty = scene.getPlayerParty().slice(0)
|
||||
.sort((pokemon1, pokemon2) => {
|
||||
const pokemon1Bst = pokemon1.calculateBaseStats().reduce((a, b) => a + b, 0);
|
||||
const pokemon2Bst = pokemon2.calculateBaseStats().reduce((a, b) => a + b, 0);
|
||||
|
@ -189,7 +189,7 @@ function endTrainerBattleAndShowDialogue(scene: BattleScene): Promise<void> {
|
||||
const playerField = scene.getPlayerField();
|
||||
playerField.forEach((_, p) => scene.unshiftPhase(new ReturnPhase(scene, p)));
|
||||
|
||||
for (const pokemon of scene.getParty()) {
|
||||
for (const pokemon of scene.getPlayerParty()) {
|
||||
// Only trigger form change when Eiscue is in Noice form
|
||||
// Hardcoded Eiscue for now in case it is fused with another pokemon
|
||||
if (pokemon.species.speciesId === Species.EISCUE && pokemon.hasAbility(Abilities.ICE_FACE) && pokemon.formIndex === 1) {
|
||||
|
@ -152,7 +152,7 @@ export const TrainingSessionEncounter: MysteryEncounter =
|
||||
}
|
||||
|
||||
// Add pokemon and mods back
|
||||
scene.getParty().push(playerPokemon);
|
||||
scene.getPlayerParty().push(playerPokemon);
|
||||
for (const mod of modifiers.value) {
|
||||
mod.pokemonId = playerPokemon.id;
|
||||
scene.addModifier(mod, true, false, false, true);
|
||||
@ -229,7 +229,7 @@ export const TrainingSessionEncounter: MysteryEncounter =
|
||||
scene.gameData.setPokemonCaught(playerPokemon, false);
|
||||
|
||||
// Add pokemon and modifiers back
|
||||
scene.getParty().push(playerPokemon);
|
||||
scene.getPlayerParty().push(playerPokemon);
|
||||
for (const mod of modifiers.value) {
|
||||
mod.pokemonId = playerPokemon.id;
|
||||
scene.addModifier(mod, true, false, false, true);
|
||||
@ -342,7 +342,7 @@ export const TrainingSessionEncounter: MysteryEncounter =
|
||||
scene.gameData.setPokemonCaught(playerPokemon, false);
|
||||
|
||||
// Add pokemon and mods back
|
||||
scene.getParty().push(playerPokemon);
|
||||
scene.getPlayerParty().push(playerPokemon);
|
||||
for (const mod of modifiers.value) {
|
||||
mod.pokemonId = playerPokemon.id;
|
||||
scene.addModifier(mod, true, false, false, true);
|
||||
|
@ -164,7 +164,7 @@ async function tryApplyDigRewardItems(scene: BattleScene) {
|
||||
const shellBell = generateModifierType(scene, modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType;
|
||||
const leftovers = generateModifierType(scene, modifierTypes.LEFTOVERS) as PokemonHeldItemModifierType;
|
||||
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
|
||||
// Iterate over the party until an item was successfully given
|
||||
// First leftovers
|
||||
|
@ -51,7 +51,7 @@ export const UncommonBreedEncounter: MysteryEncounter =
|
||||
// Calculate boss mon
|
||||
// Level equal to 2 below highest party member
|
||||
const level = getHighestLevelPlayerPokemon(scene, false, true).level - 2;
|
||||
const species = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getParty()), true);
|
||||
const species = scene.arena.randomSpecies(scene.currentBattle.waveIndex, level, 0, getPartyLuckValue(scene.getPlayerParty()), true);
|
||||
const pokemon = new EnemyPokemon(scene, species, level, TrainerSlot.NONE, true);
|
||||
|
||||
// Pokemon will always have one of its egg moves in its moveset
|
||||
|
@ -176,7 +176,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
|
||||
|
||||
for (const transformation of scene.currentBattle.mysteryEncounter!.misc.teamTransformations) {
|
||||
scene.removePokemonFromPlayerParty(transformation.previousPokemon, false);
|
||||
scene.getParty().push(transformation.newPokemon);
|
||||
scene.getPlayerParty().push(transformation.newPokemon);
|
||||
}
|
||||
})
|
||||
.withOptionPhase(async (scene: BattleScene) => {
|
||||
@ -280,7 +280,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
|
||||
const onBeforeRewards = () => {
|
||||
// Before battle rewards, unlock the passive on a pokemon in the player's team for the rest of the run (not permanently)
|
||||
// One random pokemon will get its passive unlocked
|
||||
const passiveDisabledPokemon = scene.getParty().filter(p => !p.passive);
|
||||
const passiveDisabledPokemon = scene.getPlayerParty().filter(p => !p.passive);
|
||||
if (passiveDisabledPokemon?.length > 0) {
|
||||
const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)];
|
||||
enablePassiveMon.passive = true;
|
||||
@ -306,7 +306,7 @@ export const WeirdDreamEncounter: MysteryEncounter =
|
||||
},
|
||||
async (scene: BattleScene) => {
|
||||
// Leave, reduce party levels by 10%
|
||||
for (const pokemon of scene.getParty()) {
|
||||
for (const pokemon of scene.getPlayerParty()) {
|
||||
pokemon.level = Math.max(Math.ceil((100 - PERCENT_LEVEL_LOSS_ON_REFUSE) / 100 * pokemon.level), 1);
|
||||
pokemon.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate);
|
||||
pokemon.levelExp = 0;
|
||||
@ -329,7 +329,7 @@ interface PokemonTransformation {
|
||||
}
|
||||
|
||||
function getTeamTransformations(scene: BattleScene): PokemonTransformation[] {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
// Removes all pokemon from the party
|
||||
const alreadyUsedSpecies: PokemonSpecies[] = party.map(p => p.species);
|
||||
const pokemonTransformations: PokemonTransformation[] = party.map(p => {
|
||||
@ -404,7 +404,7 @@ async function doNewTeamPostProcess(scene: BattleScene, transformations: Pokemon
|
||||
if (shouldGetOldGateau(newPokemon)) {
|
||||
const stats = getOldGateauBoostedStats(newPokemon);
|
||||
const modType = modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU()
|
||||
.generateType(scene.getParty(), [ OLD_GATEAU_STATS_UP, stats ])
|
||||
.generateType(scene.getPlayerParty(), [ OLD_GATEAU_STATS_UP, stats ])
|
||||
?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU);
|
||||
const modifier = modType?.newModifier(newPokemon);
|
||||
if (modifier) {
|
||||
@ -417,7 +417,7 @@ async function doNewTeamPostProcess(scene: BattleScene, transformations: Pokemon
|
||||
}
|
||||
|
||||
// One random pokemon will get its passive unlocked
|
||||
const passiveDisabledPokemon = scene.getParty().filter(p => !p.passive);
|
||||
const passiveDisabledPokemon = scene.getPlayerParty().filter(p => !p.passive);
|
||||
if (passiveDisabledPokemon?.length > 0) {
|
||||
const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)];
|
||||
enablePassiveMon.passive = true;
|
||||
|
@ -88,7 +88,7 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption {
|
||||
* @param pokemon
|
||||
*/
|
||||
pokemonMeetsPrimaryRequirements(scene: BattleScene, pokemon: Pokemon): boolean {
|
||||
return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getParty()).map(p => p.id).includes(pokemon.id));
|
||||
return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getPlayerParty()).map(p => p.id).includes(pokemon.id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,10 +102,10 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption {
|
||||
if (!this.primaryPokemonRequirements || this.primaryPokemonRequirements.length === 0) {
|
||||
return true;
|
||||
}
|
||||
let qualified: PlayerPokemon[] = scene.getParty();
|
||||
let qualified: PlayerPokemon[] = scene.getPlayerParty();
|
||||
for (const req of this.primaryPokemonRequirements) {
|
||||
if (req.meetsRequirement(scene)) {
|
||||
const queryParty = req.queryParty(scene.getParty());
|
||||
const queryParty = req.queryParty(scene.getPlayerParty());
|
||||
qualified = qualified.filter(pkmn => queryParty.includes(pkmn));
|
||||
} else {
|
||||
this.primaryPokemon = undefined;
|
||||
@ -162,10 +162,10 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption {
|
||||
return true;
|
||||
}
|
||||
|
||||
let qualified: PlayerPokemon[] = scene.getParty();
|
||||
let qualified: PlayerPokemon[] = scene.getPlayerParty();
|
||||
for (const req of this.secondaryPokemonRequirements) {
|
||||
if (req.meetsRequirement(scene)) {
|
||||
const queryParty = req.queryParty(scene.getParty());
|
||||
const queryParty = req.queryParty(scene.getPlayerParty());
|
||||
qualified = qualified.filter(pkmn => queryParty.includes(pkmn));
|
||||
} else {
|
||||
this.secondaryPokemon = [];
|
||||
|
@ -1,21 +1,21 @@
|
||||
import { PlayerPokemon } from "#app/field/pokemon";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { isNullOrUndefined } from "#app/utils";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { TimeOfDay } from "#enums/time-of-day";
|
||||
import { Nature } from "#app/data/nature";
|
||||
import { allAbilities } from "#app/data/ability";
|
||||
import { EvolutionItem, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
|
||||
import { Nature } from "#app/data/nature";
|
||||
import { FormChangeItem, pokemonFormChanges, SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms";
|
||||
import { StatusEffect } from "#app/data/status-effect";
|
||||
import { Type } from "#app/data/type";
|
||||
import { WeatherType } from "#app/data/weather";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { PlayerPokemon } from "#app/field/pokemon";
|
||||
import { AttackTypeBoosterModifier } from "#app/modifier/modifier";
|
||||
import { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type";
|
||||
import { isNullOrUndefined } from "#app/utils";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { Species } from "#enums/species";
|
||||
import { SpeciesFormKey } from "#enums/species-form-key";
|
||||
import { allAbilities } from "#app/data/ability";
|
||||
import { TimeOfDay } from "#enums/time-of-day";
|
||||
|
||||
export interface EncounterRequirement {
|
||||
meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met
|
||||
@ -333,7 +333,7 @@ export class PartySizeRequirement extends EncounterSceneRequirement {
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
if (!isNullOrUndefined(this.partySizeRange) && this.partySizeRange[0] <= this.partySizeRange[1]) {
|
||||
const partySize = this.excludeDisallowedPokemon ? scene.getParty().filter(p => p.isAllowedInBattle()).length : scene.getParty().length;
|
||||
const partySize = this.excludeDisallowedPokemon ? scene.getPokemonAllowedInBattle().length : scene.getPlayerParty().length;
|
||||
if (partySize >= 0 && (this.partySizeRange[0] >= 0 && this.partySizeRange[0] > partySize) || (this.partySizeRange[1] >= 0 && this.partySizeRange[1] < partySize)) {
|
||||
return false;
|
||||
}
|
||||
@ -343,7 +343,7 @@ export class PartySizeRequirement extends EncounterSceneRequirement {
|
||||
}
|
||||
|
||||
override getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return [ "partySize", scene.getParty().length.toString() ];
|
||||
return [ "partySize", scene.getPlayerParty().length.toString() ];
|
||||
}
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ export class PersistentModifierRequirement extends EncounterSceneRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredHeldItemModifiers?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -421,7 +421,7 @@ export class SpeciesRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredSpecies?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -459,7 +459,7 @@ export class NatureRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredNature?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -498,7 +498,7 @@ export class TypeRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
let partyPokemon = scene.getParty();
|
||||
let partyPokemon = scene.getPlayerParty();
|
||||
|
||||
if (isNullOrUndefined(partyPokemon)) {
|
||||
return false;
|
||||
@ -545,7 +545,7 @@ export class MoveRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -594,7 +594,7 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -635,7 +635,7 @@ export class AbilityRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredAbilities?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -677,7 +677,7 @@ export class StatusEffectRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredStatusEffect?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -746,7 +746,7 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredFormChangeItem?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -798,7 +798,7 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredEvolutionItem?.length < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -849,7 +849,7 @@ export class HeldItemRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon)) {
|
||||
return false;
|
||||
}
|
||||
@ -900,7 +900,7 @@ export class AttackTypeBoosterHeldItemTypeRequirement extends EncounterPokemonRe
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
if (isNullOrUndefined(partyPokemon)) {
|
||||
return false;
|
||||
}
|
||||
@ -957,7 +957,7 @@ export class LevelRequirement extends EncounterPokemonRequirement {
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
// Party Pokemon inside required level range
|
||||
if (!isNullOrUndefined(this.requiredLevelRange) && this.requiredLevelRange[0] <= this.requiredLevelRange[1]) {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
const pokemonInRange = this.queryParty(partyPokemon);
|
||||
if (pokemonInRange.length < this.minNumberOfPokemon) {
|
||||
return false;
|
||||
@ -995,7 +995,7 @@ export class FriendshipRequirement extends EncounterPokemonRequirement {
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
// Party Pokemon inside required friendship range
|
||||
if (!isNullOrUndefined(this.requiredFriendshipRange) && this.requiredFriendshipRange[0] <= this.requiredFriendshipRange[1]) {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
const pokemonInRange = this.queryParty(partyPokemon);
|
||||
if (pokemonInRange.length < this.minNumberOfPokemon) {
|
||||
return false;
|
||||
@ -1038,7 +1038,7 @@ export class HealthRatioRequirement extends EncounterPokemonRequirement {
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
// Party Pokemon's health inside required health range
|
||||
if (!isNullOrUndefined(this.requiredHealthRange) && this.requiredHealthRange[0] <= this.requiredHealthRange[1]) {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
const pokemonInRange = this.queryParty(partyPokemon);
|
||||
if (pokemonInRange.length < this.minNumberOfPokemon) {
|
||||
return false;
|
||||
@ -1082,7 +1082,7 @@ export class WeightRequirement extends EncounterPokemonRequirement {
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
// Party Pokemon's weight inside required weight range
|
||||
if (!isNullOrUndefined(this.requiredWeightRange) && this.requiredWeightRange[0] <= this.requiredWeightRange[1]) {
|
||||
const partyPokemon = scene.getParty();
|
||||
const partyPokemon = scene.getPlayerParty();
|
||||
const pokemonInRange = this.queryParty(partyPokemon);
|
||||
if (pokemonInRange.length < this.minNumberOfPokemon) {
|
||||
return false;
|
||||
|
@ -314,7 +314,7 @@ export default class MysteryEncounter implements IMysteryEncounter {
|
||||
* @param pokemon
|
||||
*/
|
||||
pokemonMeetsPrimaryRequirements(scene: BattleScene, pokemon: Pokemon): boolean {
|
||||
return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getParty()).map(p => p.id).includes(pokemon.id));
|
||||
return !this.primaryPokemonRequirements.some(req => !req.queryParty(scene.getPlayerParty()).map(p => p.id).includes(pokemon.id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,18 +326,18 @@ export default class MysteryEncounter implements IMysteryEncounter {
|
||||
*/
|
||||
private meetsPrimaryRequirementAndPrimaryPokemonSelected(scene: BattleScene): boolean {
|
||||
if (!this.primaryPokemonRequirements || this.primaryPokemonRequirements.length === 0) {
|
||||
const activeMon = scene.getParty().filter(p => p.isActive(true));
|
||||
const activeMon = scene.getPlayerParty().filter(p => p.isActive(true));
|
||||
if (activeMon.length > 0) {
|
||||
this.primaryPokemon = activeMon[0];
|
||||
} else {
|
||||
this.primaryPokemon = scene.getParty().filter(p => p.isAllowedInBattle())[0];
|
||||
this.primaryPokemon = scene.getPlayerParty().filter(p => p.isAllowedInBattle())[0];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
let qualified: PlayerPokemon[] = scene.getParty();
|
||||
let qualified: PlayerPokemon[] = scene.getPlayerParty();
|
||||
for (const req of this.primaryPokemonRequirements) {
|
||||
if (req.meetsRequirement(scene)) {
|
||||
qualified = qualified.filter(pkmn => req.queryParty(scene.getParty()).includes(pkmn));
|
||||
qualified = qualified.filter(pkmn => req.queryParty(scene.getPlayerParty()).includes(pkmn));
|
||||
} else {
|
||||
this.primaryPokemon = undefined;
|
||||
return false;
|
||||
@ -394,10 +394,10 @@ export default class MysteryEncounter implements IMysteryEncounter {
|
||||
return true;
|
||||
}
|
||||
|
||||
let qualified: PlayerPokemon[] = scene.getParty();
|
||||
let qualified: PlayerPokemon[] = scene.getPlayerParty();
|
||||
for (const req of this.secondaryPokemonRequirements) {
|
||||
if (req.meetsRequirement(scene)) {
|
||||
qualified = qualified.filter(pkmn => req.queryParty(scene.getParty()).includes(pkmn));
|
||||
qualified = qualified.filter(pkmn => req.queryParty(scene.getPlayerParty()).includes(pkmn));
|
||||
} else {
|
||||
this.secondaryPokemon = [];
|
||||
return false;
|
||||
|
@ -39,7 +39,7 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
|
||||
override meetsRequirement(scene: BattleScene): boolean {
|
||||
const partyPokemon = scene.getParty().filter((pkm) => (this.includeFainted ? pkm.isAllowed() : pkm.isAllowedInBattle()));
|
||||
const partyPokemon = scene.getPlayerParty().filter((pkm) => (this.includeFainted ? pkm.isAllowedInChallenge() : pkm.isAllowedInBattle()));
|
||||
|
||||
if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) {
|
||||
return false;
|
||||
|
@ -418,9 +418,9 @@ export function generateModifierType(scene: BattleScene, modifier: () => Modifie
|
||||
// Populates item id and tier (order matters)
|
||||
result = result
|
||||
.withIdFromFunc(modifierTypes[modifierId])
|
||||
.withTierFromPool(ModifierPoolType.PLAYER, scene.getParty());
|
||||
.withTierFromPool(ModifierPoolType.PLAYER, scene.getPlayerParty());
|
||||
|
||||
return result instanceof ModifierTypeGenerator ? result.generateType(scene.getParty(), pregenArgs) : result;
|
||||
return result instanceof ModifierTypeGenerator ? result.generateType(scene.getPlayerParty(), pregenArgs) : result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -451,9 +451,9 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p
|
||||
|
||||
// Open party screen to choose pokemon
|
||||
scene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => {
|
||||
if (slotIndex < scene.getParty().length) {
|
||||
if (slotIndex < scene.getPlayerParty().length) {
|
||||
scene.ui.setMode(modeToSetOnExit).then(() => {
|
||||
const pokemon = scene.getParty()[slotIndex];
|
||||
const pokemon = scene.getPlayerParty()[slotIndex];
|
||||
const secondaryOptions = onPokemonSelected(pokemon);
|
||||
if (!secondaryOptions) {
|
||||
scene.currentBattle.mysteryEncounter!.setDialogueToken("selectedPokemon", pokemon.getNameToRender());
|
||||
@ -563,7 +563,7 @@ export function selectOptionThenPokemon(scene: BattleScene, options: OptionSelec
|
||||
const selectPokemonAfterOption = (selectedOptionIndex: number) => {
|
||||
// Open party screen to choose a Pokemon
|
||||
scene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => {
|
||||
if (slotIndex < scene.getParty().length) {
|
||||
if (slotIndex < scene.getPlayerParty().length) {
|
||||
// Pokemon and option selected
|
||||
scene.ui.setMode(modeToSetOnExit).then(() => {
|
||||
const result: PokemonAndOptionSelected = { selectedPokemonIndex: slotIndex, selectedOptionIndex: selectedOptionIndex };
|
||||
@ -713,7 +713,7 @@ export function leaveEncounterWithoutBattle(scene: BattleScene, addHealPhase: bo
|
||||
* @param doNotContinue - default `false`. If set to true, will not end the battle and continue to next wave
|
||||
*/
|
||||
export function handleMysteryEncounterVictory(scene: BattleScene, addHealPhase: boolean = false, doNotContinue: boolean = false) {
|
||||
const allowedPkm = scene.getParty().filter((pkm) => pkm.isAllowedInBattle());
|
||||
const allowedPkm = scene.getPlayerParty().filter((pkm) => pkm.isAllowedInBattle());
|
||||
|
||||
if (allowedPkm.length === 0) {
|
||||
scene.clearPhaseQueue();
|
||||
@ -750,7 +750,7 @@ export function handleMysteryEncounterVictory(scene: BattleScene, addHealPhase:
|
||||
* @param addHealPhase
|
||||
*/
|
||||
export function handleMysteryEncounterBattleFailed(scene: BattleScene, addHealPhase: boolean = false, doNotContinue: boolean = false) {
|
||||
const allowedPkm = scene.getParty().filter((pkm) => pkm.isAllowedInBattle());
|
||||
const allowedPkm = scene.getPlayerParty().filter((pkm) => pkm.isAllowedInBattle());
|
||||
|
||||
if (allowedPkm.length === 0) {
|
||||
scene.clearPhaseQueue();
|
||||
|
@ -53,24 +53,24 @@ export function getSpriteKeysFromPokemon(pokemon: Pokemon): { spriteKey: string,
|
||||
}
|
||||
|
||||
/**
|
||||
* Will never remove the player's last non-fainted Pokemon (if they only have 1)
|
||||
* Will never remove the player's last non-fainted Pokemon (if they only have 1).
|
||||
* Otherwise, picks a Pokemon completely at random and removes from the party
|
||||
* @param scene
|
||||
* @param isAllowed Default false. If true, only picks from legal mons. If no legal mons are found (or there is 1, with `doNotReturnLastAllowedMon = true), will return a mon that is not allowed.
|
||||
* @param isFainted Default false. If true, includes fainted mons.
|
||||
* @param doNotReturnLastAllowedMon Default false. If true, will never return the last unfainted pokemon in the party. Useful when this function is being used to determine what Pokemon to remove from the party (Don't want to remove last unfainted)
|
||||
* @param isAllowed Default `false`. If `true`, only picks from legal mons. If no legal mons are found (or there is 1, with `doNotReturnLastAllowedMon = true`), will return a mon that is not allowed.
|
||||
* @param isFainted Default `false`. If `true`, includes fainted mons.
|
||||
* @param doNotReturnLastAllowedMon Default `false`. If `true`, will never return the last unfainted pokemon in the party. Useful when this function is being used to determine what Pokemon to remove from the party (Don't want to remove last unfainted)
|
||||
* @returns
|
||||
*/
|
||||
export function getRandomPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false, doNotReturnLastAllowedMon: boolean = false): PlayerPokemon {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
let chosenIndex: number;
|
||||
let chosenPokemon: PlayerPokemon | null = null;
|
||||
const fullyLegalMons = party.filter(p => (!isAllowed || p.isAllowed()) && (isFainted || !p.isFainted()));
|
||||
const allowedOnlyMons = party.filter(p => p.isAllowed());
|
||||
const fullyLegalMons = party.filter(p => (!isAllowed || p.isAllowedInChallenge()) && (isFainted || !p.isFainted()));
|
||||
const allowedOnlyMons = party.filter(p => p.isAllowedInChallenge());
|
||||
|
||||
if (doNotReturnLastAllowedMon && fullyLegalMons.length === 1) {
|
||||
// If there is only 1 legal/unfainted mon left, select from fainted legal mons
|
||||
const faintedLegalMons = party.filter(p => (!isAllowed || p.isAllowed()) && p.isFainted());
|
||||
const faintedLegalMons = party.filter(p => (!isAllowed || p.isAllowedInChallenge()) && p.isFainted());
|
||||
if (faintedLegalMons.length > 0) {
|
||||
chosenIndex = randSeedInt(faintedLegalMons.length);
|
||||
chosenPokemon = faintedLegalMons[chosenIndex];
|
||||
@ -101,11 +101,11 @@ export function getRandomPlayerPokemon(scene: BattleScene, isAllowed: boolean =
|
||||
* @returns
|
||||
*/
|
||||
export function getHighestLevelPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
let pokemon: PlayerPokemon | null = null;
|
||||
|
||||
for (const p of party) {
|
||||
if (isAllowed && !p.isAllowed()) {
|
||||
if (isAllowed && !p.isAllowedInChallenge()) {
|
||||
continue;
|
||||
}
|
||||
if (!isFainted && p.isFainted()) {
|
||||
@ -127,11 +127,11 @@ export function getHighestLevelPlayerPokemon(scene: BattleScene, isAllowed: bool
|
||||
* @returns
|
||||
*/
|
||||
export function getHighestStatPlayerPokemon(scene: BattleScene, stat: PermanentStat, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
let pokemon: PlayerPokemon | null = null;
|
||||
|
||||
for (const p of party) {
|
||||
if (isAllowed && !p.isAllowed()) {
|
||||
if (isAllowed && !p.isAllowedInChallenge()) {
|
||||
continue;
|
||||
}
|
||||
if (!isFainted && p.isFainted()) {
|
||||
@ -152,11 +152,11 @@ export function getHighestStatPlayerPokemon(scene: BattleScene, stat: PermanentS
|
||||
* @returns
|
||||
*/
|
||||
export function getLowestLevelPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
let pokemon: PlayerPokemon | null = null;
|
||||
|
||||
for (const p of party) {
|
||||
if (isAllowed && !p.isAllowed()) {
|
||||
if (isAllowed && !p.isAllowedInChallenge()) {
|
||||
continue;
|
||||
}
|
||||
if (!isFainted && p.isFainted()) {
|
||||
@ -177,11 +177,11 @@ export function getLowestLevelPlayerPokemon(scene: BattleScene, isAllowed: boole
|
||||
* @returns
|
||||
*/
|
||||
export function getHighestStatTotalPlayerPokemon(scene: BattleScene, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon {
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
let pokemon: PlayerPokemon | null = null;
|
||||
|
||||
for (const p of party) {
|
||||
if (isAllowed && !p.isAllowed()) {
|
||||
if (isAllowed && !p.isAllowedInChallenge()) {
|
||||
continue;
|
||||
}
|
||||
if (!isFainted && p.isFainted()) {
|
||||
@ -315,7 +315,7 @@ export function applyHealToPokemon(scene: BattleScene, pokemon: PlayerPokemon, h
|
||||
*/
|
||||
export async function modifyPlayerPokemonBST(pokemon: PlayerPokemon, value: number) {
|
||||
const modType = modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE()
|
||||
.generateType(pokemon.scene.getParty(), [ value ])
|
||||
.generateType(pokemon.scene.getPlayerParty(), [ value ])
|
||||
?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE);
|
||||
const modifier = modType?.newModifier(pokemon);
|
||||
if (modifier) {
|
||||
@ -591,7 +591,7 @@ export async function catchPokemon(scene: BattleScene, pokemon: EnemyPokemon, po
|
||||
const addToParty = (slotIndex?: number) => {
|
||||
const newPokemon = pokemon.addToParty(pokeballType, slotIndex);
|
||||
const modifiers = scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
|
||||
if (scene.getParty().filter(p => p.isShiny()).length === 6) {
|
||||
if (scene.getPlayerParty().filter(p => p.isShiny()).length === 6) {
|
||||
scene.validateAchv(achvs.SHINY_PARTY);
|
||||
}
|
||||
Promise.all(modifiers.map(m => scene.addModifier(m, true))).then(() => {
|
||||
@ -605,7 +605,7 @@ export async function catchPokemon(scene: BattleScene, pokemon: EnemyPokemon, po
|
||||
});
|
||||
};
|
||||
Promise.all([ pokemon.hideInfo(), scene.gameData.setPokemonCaught(pokemon) ]).then(() => {
|
||||
if (scene.getParty().length === 6) {
|
||||
if (scene.getPlayerParty().length === 6) {
|
||||
const promptRelease = () => {
|
||||
scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => {
|
||||
scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true);
|
||||
@ -826,7 +826,7 @@ export async function addPokemonDataToDexAndValidateAchievements(scene: BattleSc
|
||||
* @param invalidSelectionKey
|
||||
*/
|
||||
export function isPokemonValidForEncounterOptionSelection(pokemon: Pokemon, scene: BattleScene, invalidSelectionKey: string): string | null {
|
||||
if (!pokemon.isAllowed()) {
|
||||
if (!pokemon.isAllowedInChallenge()) {
|
||||
return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null;
|
||||
}
|
||||
if (!pokemon.isAllowedInBattle()) {
|
||||
|
@ -460,7 +460,7 @@ export abstract class PokemonSpeciesForm {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return `cry/${ret}`;
|
||||
}
|
||||
|
||||
validateStarterMoveset(moveset: StarterMoveset, eggMoves: number): boolean {
|
||||
@ -488,7 +488,7 @@ export abstract class PokemonSpeciesForm {
|
||||
return new Promise(resolve => {
|
||||
const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant);
|
||||
scene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant));
|
||||
scene.load.audio(`cry/${this.getCryKey(formIndex)}`, `audio/cry/${this.getCryKey(formIndex)}.m4a`);
|
||||
scene.load.audio(`${this.getCryKey(formIndex)}`, `audio/${this.getCryKey(formIndex)}.m4a`);
|
||||
scene.load.once(Phaser.Loader.Events.COMPLETE, () => {
|
||||
const originalWarn = console.warn;
|
||||
// Ignore warnings for missing frames, because there will be a lot
|
||||
@ -546,7 +546,7 @@ export abstract class PokemonSpeciesForm {
|
||||
if (cry?.pendingRemove) {
|
||||
cry = null;
|
||||
}
|
||||
cry = scene.playSound(`cry/${(cry ?? cryKey)}`, soundConfig);
|
||||
cry = scene.playSound(cry ?? cryKey, soundConfig);
|
||||
if (ignorePlay) {
|
||||
cry.stop();
|
||||
}
|
||||
|
@ -28,4 +28,5 @@ export enum ArenaTagType {
|
||||
FIRE_GRASS_PLEDGE = "FIRE_GRASS_PLEDGE",
|
||||
WATER_FIRE_PLEDGE = "WATER_FIRE_PLEDGE",
|
||||
GRASS_WATER_PLEDGE = "GRASS_WATER_PLEDGE",
|
||||
FAIRY_LOCK = "FAIRY_LOCK",
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ export enum BattlerTagType {
|
||||
DRAGON_CHEER = "DRAGON_CHEER",
|
||||
NO_RETREAT = "NO_RETREAT",
|
||||
GORILLA_TACTICS = "GORILLA_TACTICS",
|
||||
UNBURDEN = "UNBURDEN",
|
||||
THROAT_CHOPPED = "THROAT_CHOPPED",
|
||||
TAR_SHOT = "TAR_SHOT",
|
||||
BURNED_UP = "BURNED_UP",
|
||||
|
@ -230,7 +230,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
if (this.variant === undefined) {
|
||||
this.variant = this.shiny ? this.generateVariant() : 0;
|
||||
this.variant = this.shiny ? this.generateShinyVariant() : 0;
|
||||
}
|
||||
|
||||
this.customPokemonData = new CustomPokemonData();
|
||||
@ -325,35 +325,45 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return this.scene.field.getIndex(this) > -1;
|
||||
}
|
||||
|
||||
isFainted(checkStatus?: boolean): boolean {
|
||||
return !this.hp && (!checkStatus || this.status?.effect === StatusEffect.FAINT);
|
||||
/**
|
||||
* Checks if a pokemon is fainted (ie: its `hp <= 0`).
|
||||
* It's usually better to call {@linkcode isAllowedInBattle()}
|
||||
* @param checkStatus `true` to also check that the pokemon's status is {@linkcode StatusEffect.FAINT}
|
||||
* @returns `true` if the pokemon is fainted
|
||||
*/
|
||||
public isFainted(checkStatus: boolean = false): boolean {
|
||||
return this.hp <= 0 && (!checkStatus || this.status?.effect === StatusEffect.FAINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this pokemon is both not fainted (or a fled wild pokemon) and allowed to be in battle.
|
||||
* This is frequently a better alternative to {@link isFainted}
|
||||
* @returns {boolean} True if pokemon is allowed in battle
|
||||
* Check if this pokemon is both not fainted and allowed to be in battle based on currently active challenges.
|
||||
* @returns {boolean} `true` if pokemon is allowed in battle
|
||||
*/
|
||||
isAllowedInBattle(): boolean {
|
||||
return !this.isFainted() && this.isAllowed();
|
||||
public isAllowedInBattle(): boolean {
|
||||
return !this.isFainted() && this.isAllowedInChallenge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this pokemon is allowed (no challenge exclusion)
|
||||
* This is frequently a better alternative to {@link isFainted}
|
||||
* @returns {boolean} True if pokemon is allowed in battle
|
||||
* Check if this pokemon is allowed based on any active challenges.
|
||||
* It's usually better to call {@linkcode isAllowedInBattle()}
|
||||
* @returns {boolean} `true` if pokemon is allowed in battle
|
||||
*/
|
||||
isAllowed(): boolean {
|
||||
public isAllowedInChallenge(): boolean {
|
||||
const challengeAllowed = new Utils.BooleanHolder(true);
|
||||
applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed);
|
||||
return challengeAllowed.value;
|
||||
}
|
||||
|
||||
isActive(onField?: boolean): boolean {
|
||||
/**
|
||||
* Checks if the pokemon is allowed in battle (ie: not fainted, and allowed under any active challenges).
|
||||
* @param onField `true` to also check if the pokemon is currently on the field, defaults to `false`
|
||||
* @returns `true` if the pokemon is "active". Returns `false` if there is no active {@linkcode BattleScene}
|
||||
*/
|
||||
public isActive(onField: boolean = false): boolean {
|
||||
if (!this.scene) {
|
||||
return false;
|
||||
}
|
||||
return this.isAllowedInBattle() && !!this.scene && (!onField || this.isOnField());
|
||||
return this.isAllowedInBattle() && (!onField || this.isOnField());
|
||||
}
|
||||
|
||||
getDexAttr(): bigint {
|
||||
@ -972,6 +982,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
if (this.status && this.status.effect === StatusEffect.PARALYSIS) {
|
||||
ret >>= 1;
|
||||
}
|
||||
if (this.getTag(BattlerTagType.UNBURDEN) && !this.scene.getField(true).some(pokemon => pokemon !== this && pokemon.hasAbilityWithAttr(SuppressFieldAbilitiesAbAttr))) {
|
||||
ret *= 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1186,7 +1199,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* @returns an array of {@linkcode Moves}, the length of which is determined
|
||||
* by how many learnable moves there are for the {@linkcode Pokemon}.
|
||||
*/
|
||||
getLearnableLevelMoves(): Moves[] {
|
||||
public getLearnableLevelMoves(): Moves[] {
|
||||
let levelMoves = this.getLevelMoves(1, true, false, true).map(lm => lm[1]);
|
||||
if (this.metBiome === -1 && !this.scene.gameMode.isFreshStartChallenge() && !this.scene.gameMode.isDaily) {
|
||||
levelMoves = this.getUnlockedEggMoves().concat(levelMoves);
|
||||
@ -1200,13 +1213,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
/**
|
||||
* Gets the types of a pokemon
|
||||
* @param includeTeraType boolean to include tera-formed type, default false
|
||||
* @param forDefend boolean if the pokemon is defending from an attack
|
||||
* @param ignoreOverride boolean if true, ignore ability changing effects
|
||||
* @param includeTeraType - `true` to include tera-formed type; Default: `false`
|
||||
* @param forDefend - `true` if the pokemon is defending from an attack; Default: `false`
|
||||
* @param ignoreOverride - If `true`, ignore ability changing effects; Default: `false`
|
||||
* @returns array of {@linkcode Type}
|
||||
*/
|
||||
getTypes(includeTeraType = false, forDefend: boolean = false, ignoreOverride?: boolean): Type[] {
|
||||
const types : Type[] = [];
|
||||
public getTypes(includeTeraType = false, forDefend: boolean = false, ignoreOverride: boolean = false): Type[] {
|
||||
const types: Type[] = [];
|
||||
|
||||
if (includeTeraType) {
|
||||
const teraType = this.getTeraType();
|
||||
@ -1271,14 +1284,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
}
|
||||
|
||||
// this.scene potentially can be undefined for a fainted pokemon in doubles
|
||||
// use optional chaining to avoid runtime errors
|
||||
|
||||
if (!types.length) { // become UNKNOWN if no types are present
|
||||
// become UNKNOWN if no types are present
|
||||
if (!types.length) {
|
||||
types.push(Type.UNKNOWN);
|
||||
}
|
||||
|
||||
if (types.length > 1 && types.includes(Type.UNKNOWN)) { // remove UNKNOWN if other types are present
|
||||
// remove UNKNOWN if other types are present
|
||||
if (types.length > 1 && types.includes(Type.UNKNOWN)) {
|
||||
const index = types.indexOf(Type.UNKNOWN);
|
||||
if (index !== -1) {
|
||||
types.splice(index, 1);
|
||||
@ -1298,19 +1310,27 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return types;
|
||||
}
|
||||
|
||||
isOfType(type: Type, includeTeraType: boolean = true, forDefend: boolean = false, ignoreOverride?: boolean): boolean {
|
||||
return !!this.getTypes(includeTeraType, forDefend, ignoreOverride).some(t => t === type);
|
||||
/**
|
||||
* Checks if the pokemon's typing includes the specified type
|
||||
* @param type - {@linkcode Type} to check
|
||||
* @param includeTeraType - `true` to include tera-formed type; Default: `true`
|
||||
* @param forDefend - `true` if the pokemon is defending from an attack; Default: `false`
|
||||
* @param ignoreOverride - If `true`, ignore ability changing effects; Default: `false`
|
||||
* @returns `true` if the Pokemon's type matches
|
||||
*/
|
||||
public isOfType(type: Type, includeTeraType: boolean = true, forDefend: boolean = false, ignoreOverride: boolean = false): boolean {
|
||||
return this.getTypes(includeTeraType, forDefend, ignoreOverride).some((t) => t === type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the non-passive ability of the pokemon. This accounts for fusions and ability changing effects.
|
||||
* This should rarely be called, most of the time {@link hasAbility} or {@link hasAbilityWithAttr} are better used as
|
||||
* This should rarely be called, most of the time {@linkcode hasAbility} or {@linkcode hasAbilityWithAttr} are better used as
|
||||
* those check both the passive and non-passive abilities and account for ability suppression.
|
||||
* @see {@link hasAbility} {@link hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||
* @param {boolean} ignoreOverride If true, ignore ability changing effects
|
||||
* @returns {Ability} The non-passive ability of the pokemon
|
||||
* @see {@linkcode hasAbility} {@linkcode hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||
* @param ignoreOverride - If `true`, ignore ability changing effects; Default: `false`
|
||||
* @returns The non-passive {@linkcode Ability} of the pokemon
|
||||
*/
|
||||
getAbility(ignoreOverride?: boolean): Ability {
|
||||
public getAbility(ignoreOverride: boolean = false): Ability {
|
||||
if (!ignoreOverride && this.summonData?.ability) {
|
||||
return allAbilities[this.summonData.ability];
|
||||
}
|
||||
@ -1339,12 +1359,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
/**
|
||||
* Gets the passive ability of the pokemon. This should rarely be called, most of the time
|
||||
* {@link hasAbility} or {@link hasAbilityWithAttr} are better used as those check both the passive and
|
||||
* {@linkcode hasAbility} or {@linkcode hasAbilityWithAttr} are better used as those check both the passive and
|
||||
* non-passive abilities and account for ability suppression.
|
||||
* @see {@link hasAbility} {@link hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||
* @returns {Ability} The passive ability of the pokemon
|
||||
* @see {@linkcode hasAbility} {@linkcode hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||
* @returns The passive {@linkcode Ability} of the pokemon
|
||||
*/
|
||||
getPassiveAbility(): Ability {
|
||||
public getPassiveAbility(): Ability {
|
||||
if (Overrides.PASSIVE_ABILITY_OVERRIDE && this.isPlayer()) {
|
||||
return allAbilities[Overrides.PASSIVE_ABILITY_OVERRIDE];
|
||||
}
|
||||
@ -1366,12 +1386,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* Gets a list of all instances of a given ability attribute among abilities this pokemon has.
|
||||
* Accounts for all the various effects which can affect whether an ability will be present or
|
||||
* in effect, and both passive and non-passive.
|
||||
* @param attrType {@linkcode AbAttr} The ability attribute to check for.
|
||||
* @param canApply {@linkcode Boolean} If false, it doesn't check whether the ability is currently active
|
||||
* @param ignoreOverride {@linkcode Boolean} If true, it ignores ability changing effects
|
||||
* @returns A list of all the ability attributes on this ability.
|
||||
* @param attrType - {@linkcode AbAttr} The ability attribute to check for.
|
||||
* @param canApply - If `false`, it doesn't check whether the ability is currently active; Default `true`
|
||||
* @param ignoreOverride - If `true`, it ignores ability changing effects; Default `false`
|
||||
* @returns An array of all the ability attributes on this ability.
|
||||
*/
|
||||
getAbilityAttrs<T extends AbAttr = AbAttr>(attrType: { new(...args: any[]): T }, canApply: boolean = true, ignoreOverride?: boolean): T[] {
|
||||
public getAbilityAttrs<T extends AbAttr = AbAttr>(attrType: { new(...args: any[]): T }, canApply: boolean = true, ignoreOverride: boolean = false): T[] {
|
||||
const abilityAttrs: T[] = [];
|
||||
|
||||
if (!canApply || this.canApplyAbility()) {
|
||||
@ -1390,12 +1410,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* - bought with starter candy
|
||||
* - set by override
|
||||
* - is a boss pokemon
|
||||
* @returns whether or not a pokemon should have a passive
|
||||
* @returns `true` if the Pokemon has a passive
|
||||
*/
|
||||
hasPassive(): boolean {
|
||||
public hasPassive(): boolean {
|
||||
// returns override if valid for current case
|
||||
if ((Overrides.PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE && this.isPlayer()) ||
|
||||
(Overrides.OPP_PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE && !this.isPlayer())) {
|
||||
if ((Overrides.PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE && this.isPlayer())
|
||||
|| (Overrides.OPP_PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE && !this.isPlayer())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1414,12 +1434,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
/**
|
||||
* Checks whether an ability of a pokemon can be currently applied. This should rarely be
|
||||
* directly called, as {@link hasAbility} and {@link hasAbilityWithAttr} already call this.
|
||||
* @see {@link hasAbility} {@link hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||
* @param {boolean} passive If true, check if passive can be applied instead of non-passive
|
||||
* @returns {Ability} The passive ability of the pokemon
|
||||
* directly called, as {@linkcode hasAbility} and {@linkcode hasAbilityWithAttr} already call this.
|
||||
* @see {@linkcode hasAbility} {@linkcode hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||
* @param passive If true, check if passive can be applied instead of non-passive
|
||||
* @returns `true` if the ability can be applied
|
||||
*/
|
||||
canApplyAbility(passive: boolean = false): boolean {
|
||||
public canApplyAbility(passive: boolean = false): boolean {
|
||||
if (passive && !this.hasPassive()) {
|
||||
return false;
|
||||
}
|
||||
@ -1448,7 +1468,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (!!this.hp || ability.isBypassFaint) && !ability.conditions.find(condition => !condition(this));
|
||||
return (this.hp > 0 || ability.isBypassFaint) && !ability.conditions.find(condition => !condition(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1460,7 +1480,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* @param {boolean} ignoreOverride If true, it ignores ability changing effects
|
||||
* @returns {boolean} Whether the ability is present and active
|
||||
*/
|
||||
hasAbility(ability: Abilities, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
||||
public hasAbility(ability: Abilities, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
||||
if (this.getAbility(ignoreOverride).id === ability && (!canApply || this.canApplyAbility())) {
|
||||
return true;
|
||||
}
|
||||
@ -1480,7 +1500,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* @param {boolean} ignoreOverride If true, it ignores ability changing effects
|
||||
* @returns {boolean} Whether an ability with that attribute is present and active
|
||||
*/
|
||||
hasAbilityWithAttr(attrType: Constructor<AbAttr>, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
||||
public hasAbilityWithAttr(attrType: Constructor<AbAttr>, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
||||
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).hasAttr(attrType)) {
|
||||
return true;
|
||||
}
|
||||
@ -1495,7 +1515,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* and then multiplicative modifiers happening after (Heavy Metal and Light Metal)
|
||||
* @returns the kg of the Pokemon (minimum of 0.1)
|
||||
*/
|
||||
getWeight(): number {
|
||||
public getWeight(): number {
|
||||
const autotomizedTag = this.getTag(AutotomizedTag);
|
||||
let weightRemoved = 0;
|
||||
if (!Utils.isNullOrUndefined(autotomizedTag)) {
|
||||
@ -1510,10 +1530,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tera-formed type of the pokemon, or UNKNOWN if not present
|
||||
* @returns the {@linkcode Type}
|
||||
* @returns The tera-formed type of the pokemon, or {@linkcode Type.UNKNOWN} if not present
|
||||
*/
|
||||
getTeraType(): Type {
|
||||
public getTeraType(): Type {
|
||||
// this.scene can be undefined for a fainted mon in doubles
|
||||
if (this.scene !== undefined) {
|
||||
const teraModifier = this.scene.findModifier(m => m instanceof TerastallizeModifier
|
||||
@ -1527,23 +1546,23 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return Type.UNKNOWN;
|
||||
}
|
||||
|
||||
isTerastallized(): boolean {
|
||||
public isTerastallized(): boolean {
|
||||
return this.getTeraType() !== Type.UNKNOWN;
|
||||
}
|
||||
|
||||
isGrounded(): boolean {
|
||||
public isGrounded(): boolean {
|
||||
return !!this.getTag(GroundedTag) || (!this.isOfType(Type.FLYING, true, true) && !this.hasAbility(Abilities.LEVITATE) && !this.getTag(BattlerTagType.FLOATING) && !this.getTag(SemiInvulnerableTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this Pokemon is prevented from running or switching due
|
||||
* to effects from moves and/or abilities.
|
||||
* @param trappedAbMessages `string[]` If defined, ability trigger messages
|
||||
* @param trappedAbMessages - If defined, ability trigger messages
|
||||
* (e.g. from Shadow Tag) are forwarded through this array.
|
||||
* @param simulated `boolean` if `true`, applies abilities via simulated calls.
|
||||
* @returns
|
||||
* @param simulated - If `true`, applies abilities via simulated calls.
|
||||
* @returns `true` if the pokemon is trapped
|
||||
*/
|
||||
isTrapped(trappedAbMessages: string[] = [], simulated: boolean = true): boolean {
|
||||
public isTrapped(trappedAbMessages: string[] = [], simulated: boolean = true): boolean {
|
||||
if (this.isOfType(Type.GHOST)) {
|
||||
return false;
|
||||
}
|
||||
@ -1551,21 +1570,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
const trappedByAbility = new Utils.BooleanHolder(false);
|
||||
const opposingField = this.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField();
|
||||
|
||||
opposingField.forEach(opponent =>
|
||||
opposingField.forEach((opponent) =>
|
||||
applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated)
|
||||
);
|
||||
|
||||
return (trappedByAbility.value || !!this.getTag(TrappedTag));
|
||||
const side = this.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY;
|
||||
return (trappedByAbility.value || !!this.getTag(TrappedTag) || !!this.scene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, side));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the type of a move when used by this Pokemon after
|
||||
* type-changing move and ability attributes have applied.
|
||||
* @param move {@linkcode Move} The move being used.
|
||||
* @param simulated If `true`, prevents showing abilities applied in this calculation.
|
||||
* @returns the {@linkcode Type} of the move after attributes are applied
|
||||
* @param move - {@linkcode Move} The move being used.
|
||||
* @param simulated - If `true`, prevents showing abilities applied in this calculation.
|
||||
* @returns The {@linkcode Type} of the move after attributes are applied
|
||||
*/
|
||||
getMoveType(move: Move, simulated: boolean = true): Type {
|
||||
public getMoveType(move: Move, simulated: boolean = true): Type {
|
||||
const moveTypeHolder = new Utils.NumberHolder(move.type);
|
||||
|
||||
applyMoveAttrs(VariableMoveTypeAttr, this, null, move, moveTypeHolder);
|
||||
@ -1930,13 +1950,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* Function that tries to set a Pokemon shiny based on seed.
|
||||
* For manual use only, usually to roll a Pokemon's shiny chance a second time.
|
||||
*
|
||||
* The base shiny odds are {@linkcode BASE_SHINY_CHANCE} / 65536
|
||||
* @param thresholdOverride number that is divided by 2^16 (65536) to get the shiny chance, overrides {@linkcode shinyThreshold} if set (bypassing shiny rate modifiers such as Shiny Charm)
|
||||
* The base shiny odds are {@linkcode BASE_SHINY_CHANCE} / `65536`
|
||||
* @param thresholdOverride number that is divided by `2^16` (`65536`) to get the shiny chance, overrides {@linkcode shinyThreshold} if set (bypassing shiny rate modifiers such as Shiny Charm)
|
||||
* @param applyModifiersToOverride If {@linkcode thresholdOverride} is set and this is true, will apply Shiny Charm and event modifiers to {@linkcode thresholdOverride}
|
||||
* @returns true if the Pokemon has been set as a shiny, false otherwise
|
||||
* @returns `true` if the Pokemon has been set as a shiny, `false` otherwise
|
||||
*/
|
||||
trySetShinySeed(thresholdOverride?: integer, applyModifiersToOverride?: boolean): boolean {
|
||||
const shinyThreshold = new Utils.IntegerHolder(BASE_SHINY_CHANCE);
|
||||
public trySetShinySeed(thresholdOverride?: number, applyModifiersToOverride?: boolean): boolean {
|
||||
const shinyThreshold = new Utils.NumberHolder(BASE_SHINY_CHANCE);
|
||||
if (thresholdOverride === undefined || applyModifiersToOverride) {
|
||||
if (thresholdOverride !== undefined && applyModifiersToOverride) {
|
||||
shinyThreshold.value = thresholdOverride;
|
||||
@ -1961,13 +1981,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a variant
|
||||
* Has a 10% of returning 2 (epic variant)
|
||||
* And a 30% of returning 1 (rare variant)
|
||||
* Returns 0 (basic shiny) if there is no variant or 60% of the time otherwise
|
||||
* @returns the shiny variant
|
||||
* Generates a shiny variant
|
||||
* @returns `0-2`, with the following probabilities:
|
||||
* - Has a 10% chance of returning `2` (epic variant)
|
||||
* - Has a 30% chance of returning `1` (rare variant)
|
||||
* - Has a 60% chance of returning `0` (basic shiny)
|
||||
*/
|
||||
generateVariant(): Variant {
|
||||
protected generateShinyVariant(): Variant {
|
||||
const formIndex: number = this.formIndex;
|
||||
let variantDataIndex: string | number = this.species.speciesId;
|
||||
if (this.species.forms.length > 0) {
|
||||
@ -1993,8 +2013,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
}
|
||||
|
||||
generateFusionSpecies(forStarter?: boolean): void {
|
||||
const hiddenAbilityChance = new Utils.IntegerHolder(BASE_HIDDEN_ABILITY_CHANCE);
|
||||
public generateFusionSpecies(forStarter?: boolean): void {
|
||||
const hiddenAbilityChance = new Utils.NumberHolder(BASE_HIDDEN_ABILITY_CHANCE);
|
||||
if (!this.hasTrainer()) {
|
||||
this.scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
|
||||
}
|
||||
@ -2043,7 +2063,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.generateName();
|
||||
}
|
||||
|
||||
clearFusionSpecies(): void {
|
||||
public clearFusionSpecies(): void {
|
||||
this.fusionSpecies = null;
|
||||
this.fusionFormIndex = 0;
|
||||
this.fusionAbilityIndex = 0;
|
||||
@ -2057,12 +2077,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.calculateStats();
|
||||
}
|
||||
|
||||
generateAndPopulateMoveset(): void {
|
||||
/** Generates a semi-random moveset for a Pokemon */
|
||||
public generateAndPopulateMoveset(): void {
|
||||
this.moveset = [];
|
||||
let movePool: [Moves, number][] = [];
|
||||
const allLevelMoves = this.getLevelMoves(1, true, true);
|
||||
if (!allLevelMoves) {
|
||||
console.log(this.species.speciesId, "ERROR");
|
||||
console.warn("Error encountered trying to generate moveset for:", this.species.name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2072,16 +2093,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
break;
|
||||
}
|
||||
let weight = levelMove[0];
|
||||
if (weight === 0) { // Evo Moves
|
||||
// Evolution Moves
|
||||
if (weight === 0) {
|
||||
weight = 50;
|
||||
}
|
||||
if (weight === 1 && allMoves[levelMove[1]].power >= 80) { // Assume level 1 moves with 80+ BP are "move reminder" moves and bump their weight
|
||||
// Assume level 1 moves with 80+ BP are "move reminder" moves and bump their weight
|
||||
if (weight === 1 && allMoves[levelMove[1]].power >= 80) {
|
||||
weight = 40;
|
||||
}
|
||||
if (allMoves[levelMove[1]].name.endsWith(" (N)")) {
|
||||
weight /= 100;
|
||||
} // Unimplemented level up moves are possible to generate, but 1% of their normal chance.
|
||||
if (!movePool.some(m => m[0] === levelMove[1])) {
|
||||
if (!movePool.some(m => m[0] === levelMove[1]) && !allMoves[levelMove[1]].name.endsWith(" (N)")) {
|
||||
movePool.push([ levelMove[1], weight ]);
|
||||
}
|
||||
}
|
||||
@ -2113,7 +2133,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.level >= 60) { // No egg moves below level 60
|
||||
// No egg moves below level 60
|
||||
if (this.level >= 60) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const moveId = speciesEggMoves[this.species.getRootSpeciesId()][i];
|
||||
if (!movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)")) {
|
||||
@ -2121,7 +2142,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
}
|
||||
const moveId = speciesEggMoves[this.species.getRootSpeciesId()][3];
|
||||
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) { // No rare egg moves before e4
|
||||
// No rare egg moves before e4
|
||||
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) {
|
||||
movePool.push([ moveId, 30 ]);
|
||||
}
|
||||
if (this.fusionSpecies) {
|
||||
@ -2132,14 +2154,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
}
|
||||
const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][3];
|
||||
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) {// No rare egg moves before e4
|
||||
// No rare egg moves before e4
|
||||
if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) {
|
||||
movePool.push([ moveId, 30 ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isBoss()) { // Bosses never get self ko moves
|
||||
// Bosses never get self ko moves
|
||||
if (this.isBoss()) {
|
||||
movePool = movePool.filter(m => !allMoves[m[0]].hasAttr(SacrificialAttr));
|
||||
}
|
||||
movePool = movePool.filter(m => !allMoves[m[0]].hasAttr(SacrificialAttrOnHit));
|
||||
@ -2168,7 +2192,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
const statRatio = worseCategory === MoveCategory.PHYSICAL ? atk / spAtk : spAtk / atk;
|
||||
movePool = movePool.map(m => [ m[0], m[1] * (allMoves[m[0]].category === worseCategory ? statRatio : 1) ]);
|
||||
|
||||
let weightMultiplier = 0.9; // The higher this is the more the game weights towards higher level moves. At 0 all moves are equal weight.
|
||||
/** The higher this is the more the game weights towards higher level moves. At `0` all moves are equal weight. */
|
||||
let weightMultiplier = 0.9;
|
||||
if (this.hasTrainer()) {
|
||||
weightMultiplier += 0.7;
|
||||
}
|
||||
@ -2177,7 +2202,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
const baseWeights: [Moves, number][] = movePool.map(m => [ m[0], Math.ceil(Math.pow(m[1], weightMultiplier) * 100) ]);
|
||||
|
||||
if (this.hasTrainer() || this.isBoss()) { // Trainers and bosses always force a stab move
|
||||
// Trainers and bosses always force a stab move
|
||||
if (this.hasTrainer() || this.isBoss()) {
|
||||
const stabMovePool = baseWeights.filter(m => allMoves[m[0]].category !== MoveCategory.STATUS && this.isOfType(allMoves[m[0]].type));
|
||||
|
||||
if (stabMovePool.length) {
|
||||
@ -2207,8 +2233,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
// Sqrt the weight of any damaging moves with overlapping types. This is about a 0.05 - 0.1 multiplier.
|
||||
// Other damaging moves 2x weight if 0-1 damaging moves, 0.5x if 2, 0.125x if 3. These weights double if STAB.
|
||||
// Status moves remain unchanged on weight, this encourages 1-2
|
||||
movePool = baseWeights.filter(m => !this.moveset.some(mo => m[0] === mo?.moveId)).map(m => [ m[0], this.moveset.some(mo => mo?.getMove().category !== MoveCategory.STATUS && mo?.getMove().type === allMoves[m[0]].type) ? Math.ceil(Math.sqrt(m[1])) : allMoves[m[0]].category !== MoveCategory.STATUS ? Math.ceil(m[1] / Math.max(Math.pow(4, this.moveset.filter(mo => (mo?.getMove().power!) > 1).length) / 8, 0.5) * (this.isOfType(allMoves[m[0]].type) ? 2 : 1)) : m[1] ]); // TODO: is this bang correct?
|
||||
} else { // Non-trainer pokemon just use normal weights
|
||||
movePool = baseWeights.filter(m => !this.moveset.some(mo => m[0] === mo?.moveId)).map((m) => {
|
||||
let ret: number;
|
||||
if (this.moveset.some(mo => mo?.getMove().category !== MoveCategory.STATUS && mo?.getMove().type === allMoves[m[0]].type)) {
|
||||
ret = Math.ceil(Math.sqrt(m[1]));
|
||||
} else if (allMoves[m[0]].category !== MoveCategory.STATUS) {
|
||||
ret = Math.ceil(m[1] / Math.max(Math.pow(4, this.moveset.filter(mo => (mo?.getMove().power ?? 0) > 1).length) / 8, 0.5) * (this.isOfType(allMoves[m[0]].type) ? 2 : 1));
|
||||
} else {
|
||||
ret = m[1];
|
||||
}
|
||||
return [ m[0], ret ];
|
||||
});
|
||||
} else {
|
||||
// Non-trainer pokemon just use normal weights
|
||||
movePool = baseWeights.filter(m => !this.moveset.some(mo => m[0] === mo?.moveId));
|
||||
}
|
||||
const totalWeight = movePool.reduce((v, m) => v + m[1], 0);
|
||||
@ -2226,11 +2263,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
}
|
||||
|
||||
trySelectMove(moveIndex: integer, ignorePp?: boolean): boolean {
|
||||
public trySelectMove(moveIndex: integer, ignorePp?: boolean): boolean {
|
||||
const move = this.getMoveset().length > moveIndex
|
||||
? this.getMoveset()[moveIndex]
|
||||
: null;
|
||||
return move?.isUsable(this, ignorePp)!; // TODO: is this bang correct?
|
||||
return move?.isUsable(this, ignorePp) ?? false;
|
||||
}
|
||||
|
||||
showInfo(): void {
|
||||
@ -2827,8 +2864,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.scene.gameData.gameStats.highestDamage = damage;
|
||||
}
|
||||
}
|
||||
source.turnData.damageDealt += damage;
|
||||
source.turnData.currDamageDealt = damage;
|
||||
source.turnData.totalDamageDealt += damage;
|
||||
source.turnData.singleHitDamageDealt = damage;
|
||||
this.turnData.damageTaken += damage;
|
||||
this.battleData.hitCount++;
|
||||
|
||||
@ -3229,7 +3266,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
try {
|
||||
SoundFade.fadeOut(scene, cry, Utils.fixedInt(Math.ceil(duration * 0.2)));
|
||||
fusionCry = this.getFusionSpeciesForm().cry(scene, Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0) }, soundConfig));
|
||||
SoundFade.fadeIn(scene, fusionCry, Utils.fixedInt(Math.ceil(duration * 0.2)), scene.masterVolume * scene.seVolume, 0);
|
||||
SoundFade.fadeIn(scene, fusionCry, Utils.fixedInt(Math.ceil(duration * 0.2)), scene.masterVolume * scene.fieldVolume, 0);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@ -3244,11 +3281,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return this.fusionFaintCry(callback);
|
||||
}
|
||||
|
||||
const key = `cry/${this.species.getCryKey(this.formIndex)}`;
|
||||
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
let i = 0;
|
||||
const key = this.species.getCryKey(this.formIndex);
|
||||
let rate = 0.85;
|
||||
const cry = this.scene.playSound(key, { rate: rate }) as AnySound;
|
||||
if (!cry || this.scene.fieldVolume === 0) {
|
||||
return callback();
|
||||
}
|
||||
const sprite = this.getSprite();
|
||||
const tintSprite = this.getTintSprite();
|
||||
const delay = Math.max(this.scene.sound.get(key).totalDuration * 50, 25);
|
||||
@ -3263,7 +3301,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
delay: Utils.fixedInt(delay),
|
||||
repeat: -1,
|
||||
callback: () => {
|
||||
++i;
|
||||
frameThreshold = sprite.anims.msPerFrame / rate;
|
||||
frameProgress += delay;
|
||||
while (frameProgress > frameThreshold) {
|
||||
@ -3302,7 +3339,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
private fusionFaintCry(callback: Function): void {
|
||||
const key = `cry/${this.species.getCryKey(this.formIndex)}`;
|
||||
const key = this.species.getCryKey(this.formIndex);
|
||||
let i = 0;
|
||||
let rate = 0.85;
|
||||
const cry = this.scene.playSound(key, { rate: rate }) as AnySound;
|
||||
@ -3310,12 +3347,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
const tintSprite = this.getTintSprite();
|
||||
let duration = cry.totalDuration * 1000;
|
||||
|
||||
const fusionCryKey = `cry/${this.fusionSpecies?.getCryKey(this.fusionFormIndex)}`;
|
||||
const fusionCryKey = this.fusionSpecies!.getCryKey(this.fusionFormIndex);
|
||||
let fusionCry = this.scene.playSound(fusionCryKey, { rate: rate }) as AnySound;
|
||||
if (!cry || !fusionCry || this.scene.fieldVolume === 0) {
|
||||
return callback();
|
||||
}
|
||||
fusionCry.stop();
|
||||
duration = Math.min(duration, fusionCry.totalDuration * 1000);
|
||||
fusionCry.destroy();
|
||||
|
||||
const delay = Math.max(duration * 0.05, 25);
|
||||
|
||||
let transitionIndex = 0;
|
||||
@ -3353,10 +3392,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
frameProgress -= frameThreshold;
|
||||
}
|
||||
if (i === transitionIndex) {
|
||||
if (i === transitionIndex && fusionCryKey) {
|
||||
SoundFade.fadeOut(this.scene, cry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2)));
|
||||
fusionCry = this.scene.playSound(fusionCryKey, Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0), rate: rate }));
|
||||
SoundFade.fadeIn(this.scene, fusionCry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2)), this.scene.masterVolume * this.scene.seVolume, 0);
|
||||
SoundFade.fadeIn(this.scene, fusionCry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2)), this.scene.masterVolume * this.scene.fieldVolume, 0);
|
||||
}
|
||||
rate *= 0.99;
|
||||
if (cry && !cry.pendingRemove) {
|
||||
@ -4198,7 +4237,7 @@ export class PlayerPokemon extends Pokemon {
|
||||
return new Promise(resolve => {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => {
|
||||
if (slotIndex >= 0 && slotIndex < 6) {
|
||||
const pokemon = this.scene.getParty()[slotIndex];
|
||||
const pokemon = this.scene.getPlayerParty()[slotIndex];
|
||||
if (!pokemon || !pokemon.isFainted()) {
|
||||
resolve();
|
||||
}
|
||||
@ -4208,7 +4247,7 @@ export class PlayerPokemon extends Pokemon {
|
||||
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
|
||||
this.scene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true);
|
||||
|
||||
if (this.scene.currentBattle.double && this.scene.getParty().length > 1) {
|
||||
if (this.scene.currentBattle.double && this.scene.getPlayerParty().length > 1) {
|
||||
const allyPokemon = this.getAlly();
|
||||
if (slotIndex <= 1) {
|
||||
// Revived ally pokemon
|
||||
@ -4350,7 +4389,7 @@ export class PlayerPokemon extends Pokemon {
|
||||
newPokemon.fusionLuck = this.fusionLuck;
|
||||
newPokemon.usedTMs = this.usedTMs;
|
||||
|
||||
this.scene.getParty().push(newPokemon);
|
||||
this.scene.getPlayerParty().push(newPokemon);
|
||||
newPokemon.evolve((!isFusion ? newEvolution : new FusionSpeciesFormEvolution(this.id, newEvolution)), evoSpecies);
|
||||
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& m.pokemonId === this.id, true) as PokemonHeldItemModifier[];
|
||||
@ -4466,8 +4505,8 @@ export class PlayerPokemon extends Pokemon {
|
||||
|
||||
this.generateCompatibleTms();
|
||||
this.updateInfo(true);
|
||||
const fusedPartyMemberIndex = this.scene.getParty().indexOf(pokemon);
|
||||
let partyMemberIndex = this.scene.getParty().indexOf(this);
|
||||
const fusedPartyMemberIndex = this.scene.getPlayerParty().indexOf(pokemon);
|
||||
let partyMemberIndex = this.scene.getPlayerParty().indexOf(this);
|
||||
if (partyMemberIndex > fusedPartyMemberIndex) {
|
||||
partyMemberIndex--;
|
||||
}
|
||||
@ -4480,8 +4519,8 @@ export class PlayerPokemon extends Pokemon {
|
||||
Promise.allSettled(transferModifiers).then(() => {
|
||||
this.scene.updateModifiers(true, true).then(() => {
|
||||
this.scene.removePartyMemberModifiers(fusedPartyMemberIndex);
|
||||
this.scene.getParty().splice(fusedPartyMemberIndex, 1)[0];
|
||||
const newPartyMemberIndex = this.scene.getParty().indexOf(this);
|
||||
this.scene.getPlayerParty().splice(fusedPartyMemberIndex, 1)[0];
|
||||
const newPartyMemberIndex = this.scene.getPlayerParty().indexOf(this);
|
||||
pokemon.getMoveset(true).map((m: PokemonMove) => this.scene.unshiftPhase(new LearnMovePhase(this.scene, newPartyMemberIndex, m.getMove().id)));
|
||||
pokemon.destroy();
|
||||
this.updateFusionPalette();
|
||||
@ -4562,7 +4601,7 @@ export class EnemyPokemon extends Pokemon {
|
||||
}
|
||||
|
||||
if (this.shiny) {
|
||||
this.variant = this.generateVariant();
|
||||
this.variant = this.generateShinyVariant();
|
||||
if (Overrides.OPP_VARIANT_OVERRIDE !== null) {
|
||||
this.variant = Overrides.OPP_VARIANT_OVERRIDE;
|
||||
}
|
||||
@ -5072,7 +5111,7 @@ export class EnemyPokemon extends Pokemon {
|
||||
* @returns the pokemon that was added or null if the pokemon could not be added
|
||||
*/
|
||||
addToParty(pokeballType: PokeballType, slotIndex: number = -1) {
|
||||
const party = this.scene.getParty();
|
||||
const party = this.scene.getPlayerParty();
|
||||
let ret: PlayerPokemon | null = null;
|
||||
|
||||
if (party.length < PLAYER_PARTY_MAX_SIZE) {
|
||||
@ -5130,7 +5169,6 @@ export class PokemonSummonData {
|
||||
public tags: BattlerTag[] = [];
|
||||
public abilitySuppressed: boolean = false;
|
||||
public abilitiesApplied: Abilities[] = [];
|
||||
|
||||
public speciesForm: PokemonSpeciesForm | null;
|
||||
public fusionSpeciesForm: PokemonSpeciesForm;
|
||||
public ability: Abilities = Abilities.NONE;
|
||||
@ -5170,8 +5208,8 @@ export class PokemonTurnData {
|
||||
* - `0` = Move is finished
|
||||
*/
|
||||
public hitsLeft: number = -1;
|
||||
public damageDealt: number = 0;
|
||||
public currDamageDealt: number = 0;
|
||||
public totalDamageDealt: number = 0;
|
||||
public singleHitDamageDealt: number = 0;
|
||||
public damageTaken: number = 0;
|
||||
public attacksReceived: AttackMoveResult[] = [];
|
||||
public order: number;
|
||||
@ -5181,6 +5219,7 @@ export class PokemonTurnData {
|
||||
public combiningPledge?: Moves;
|
||||
public switchedInThisTurn: boolean = false;
|
||||
public failedRunAway: boolean = false;
|
||||
public joinedRound: boolean = false;
|
||||
}
|
||||
|
||||
export enum AiType {
|
||||
|
@ -232,7 +232,7 @@ export class LoadingScene extends SceneBase {
|
||||
// Get current lang and load the types atlas for it. English will only load types while all other languages will load types and types_<lang>
|
||||
const lang = i18next.resolvedLanguage;
|
||||
if (lang !== "en") {
|
||||
if (Utils.verifyLang(lang)) {
|
||||
if (Utils.hasAllLocalizedSprites(lang)) {
|
||||
this.loadAtlas(`statuses_${lang}`, "");
|
||||
this.loadAtlas(`types_${lang}`, "");
|
||||
} else {
|
||||
|
@ -746,7 +746,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
|
||||
return 0;
|
||||
}
|
||||
if (pokemon.isPlayer() && forThreshold) {
|
||||
return scene.getParty().map(p => this.getMaxHeldItemCount(p)).reduce((stackCount: number, maxStackCount: number) => Math.max(stackCount, maxStackCount), 0);
|
||||
return scene.getPlayerParty().map(p => this.getMaxHeldItemCount(p)).reduce((stackCount: number, maxStackCount: number) => Math.max(stackCount, maxStackCount), 0);
|
||||
}
|
||||
return this.getMaxHeldItemCount(pokemon);
|
||||
}
|
||||
@ -1767,10 +1767,10 @@ export class HitHealModifier extends PokemonHeldItemModifier {
|
||||
* @returns `true` if the {@linkcode Pokemon} was healed
|
||||
*/
|
||||
override apply(pokemon: Pokemon): boolean {
|
||||
if (pokemon.turnData.damageDealt && !pokemon.isFullHp()) {
|
||||
if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) {
|
||||
const scene = pokemon.scene;
|
||||
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(),
|
||||
toDmgValue(pokemon.turnData.damageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true));
|
||||
toDmgValue(pokemon.turnData.totalDamageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -2022,7 +2022,7 @@ export abstract class ConsumablePokemonModifier extends ConsumableModifier {
|
||||
abstract override apply(playerPokemon: PlayerPokemon, ...args: unknown[]): boolean | Promise<boolean>;
|
||||
|
||||
getPokemon(scene: BattleScene) {
|
||||
return scene.getParty().find(p => p.id === this.pokemonId);
|
||||
return scene.getPlayerParty().find(p => p.id === this.pokemonId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2224,7 +2224,7 @@ export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier {
|
||||
|
||||
playerPokemon.addFriendship(FRIENDSHIP_GAIN_FROM_RARE_CANDY);
|
||||
|
||||
playerPokemon.scene.unshiftPhase(new LevelUpPhase(playerPokemon.scene, playerPokemon.scene.getParty().indexOf(playerPokemon), playerPokemon.level - levelCount.value, playerPokemon.level));
|
||||
playerPokemon.scene.unshiftPhase(new LevelUpPhase(playerPokemon.scene, playerPokemon.scene.getPlayerParty().indexOf(playerPokemon), playerPokemon.level - levelCount.value, playerPokemon.level));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2244,7 +2244,7 @@ export class TmModifier extends ConsumablePokemonModifier {
|
||||
*/
|
||||
override apply(playerPokemon: PlayerPokemon): boolean {
|
||||
|
||||
playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getParty().indexOf(playerPokemon), this.type.moveId, LearnMoveType.TM));
|
||||
playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getPlayerParty().indexOf(playerPokemon), this.type.moveId, LearnMoveType.TM));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2266,7 +2266,7 @@ export class RememberMoveModifier extends ConsumablePokemonModifier {
|
||||
*/
|
||||
override apply(playerPokemon: PlayerPokemon, cost?: number): boolean {
|
||||
|
||||
playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getParty().indexOf(playerPokemon), playerPokemon.getLearnableLevelMoves()[this.levelMoveIndex], LearnMoveType.MEMORY, cost));
|
||||
playerPokemon.scene.unshiftPhase(new LearnMovePhase(playerPokemon.scene, playerPokemon.scene.getPlayerParty().indexOf(playerPokemon), playerPokemon.getLearnableLevelMoves()[this.levelMoveIndex], LearnMoveType.MEMORY, cost));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2783,7 +2783,7 @@ export class MoneyRewardModifier extends ConsumableModifier {
|
||||
|
||||
battleScene.addMoney(moneyAmount.value);
|
||||
|
||||
battleScene.getParty().map(p => {
|
||||
battleScene.getPlayerParty().map(p => {
|
||||
if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) {
|
||||
p.evoCounter ? p.evoCounter++ : p.evoCounter = 1;
|
||||
const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier;
|
||||
|
@ -1,20 +1,20 @@
|
||||
import { type PokeballCounts } from "#app/battle-scene";
|
||||
import { Gender } from "#app/data/gender";
|
||||
import { Variant } from "#app/data/variant";
|
||||
import { type ModifierOverride } from "#app/modifier/modifier-type";
|
||||
import { Unlockables } from "#app/system/unlockables";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Biome } from "#enums/biome";
|
||||
import { EggTier } from "#enums/egg-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { PokeballType } from "#enums/pokeball";
|
||||
import { Species } from "#enums/species";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { TimeOfDay } from "#enums/time-of-day";
|
||||
import { VariantTier } from "#enums/variant-tier";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { type PokeballCounts } from "./battle-scene";
|
||||
import { Gender } from "./data/gender";
|
||||
import { Variant } from "./data/variant";
|
||||
import { type ModifierOverride } from "./modifier/modifier-type";
|
||||
import { Unlockables } from "./system/unlockables";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
|
||||
/**
|
||||
* Overrides that are using when testing different in game situations
|
||||
|
@ -1,21 +1,22 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { getPokeballCatchMultiplier, getPokeballAtlasKey, getPokeballTintColor, getCriticalCaptureChance, doPokeballBounceAnim } from "#app/data/pokeball";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
||||
import { SubstituteTag } from "#app/data/battler-tags";
|
||||
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, getCriticalCaptureChance } from "#app/data/pokeball";
|
||||
import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect";
|
||||
import { PokeballType } from "#app/enums/pokeball";
|
||||
import { StatusEffect } from "#app/enums/status-effect";
|
||||
import { addPokeballOpenParticles, addPokeballCaptureStars } from "#app/field/anims";
|
||||
import { addPokeballCaptureStars, addPokeballOpenParticles } from "#app/field/anims";
|
||||
import { EnemyPokemon } from "#app/field/pokemon";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { PokemonHeldItemModifier } from "#app/modifier/modifier";
|
||||
import { PokemonPhase } from "#app/phases/pokemon-phase";
|
||||
import { VictoryPhase } from "#app/phases/victory-phase";
|
||||
import { achvs } from "#app/system/achv";
|
||||
import { PartyUiMode, PartyOption } from "#app/ui/party-ui-handler";
|
||||
import { PartyOption, PartyUiMode } from "#app/ui/party-ui-handler";
|
||||
import { SummaryUiMode } from "#app/ui/summary-ui-handler";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import { PokeballType } from "#enums/pokeball";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import i18next from "i18next";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
import { VictoryPhase } from "./victory-phase";
|
||||
import { SubstituteTag } from "#app/data/battler-tags";
|
||||
|
||||
export class AttemptCapturePhase extends PokemonPhase {
|
||||
private pokeballType: PokeballType;
|
||||
@ -244,7 +245,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
const addToParty = (slotIndex?: number) => {
|
||||
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex);
|
||||
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
|
||||
if (this.scene.getParty().filter(p => p.isShiny()).length === 6) {
|
||||
if (this.scene.getPlayerParty().filter(p => p.isShiny()).length === PLAYER_PARTY_MAX_SIZE) {
|
||||
this.scene.validateAchv(achvs.SHINY_PARTY);
|
||||
}
|
||||
Promise.all(modifiers.map(m => this.scene.addModifier(m, true))).then(() => {
|
||||
@ -258,7 +259,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
});
|
||||
};
|
||||
Promise.all([ pokemon.hideInfo(), this.scene.gameData.setPokemonCaught(pokemon) ]).then(() => {
|
||||
if (this.scene.getParty().length === 6) {
|
||||
if (this.scene.getPlayerParty().length === PLAYER_PARTY_MAX_SIZE) {
|
||||
const promptRelease = () => {
|
||||
this.scene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => {
|
||||
this.scene.pokemonInfoContainer.makeRoomForConfirmUi(1, true);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { applyPostBattleAbAttrs, PostBattleAbAttr } from "#app/data/ability";
|
||||
import { LapsingPersistentModifier, LapsingPokemonHeldItemModifier } from "#app/modifier/modifier";
|
||||
import { BattlePhase } from "./battle-phase";
|
||||
import { GameOverPhase } from "./game-over-phase";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
|
||||
export class BattleEndPhase extends BattlePhase {
|
||||
/** If true, will increment battles won */
|
||||
@ -41,7 +41,7 @@ export class BattleEndPhase extends BattlePhase {
|
||||
}
|
||||
}
|
||||
|
||||
for (const pokemon of this.scene.getParty().filter(p => p.isAllowedInBattle())) {
|
||||
for (const pokemon of this.scene.getPokemonAllowedInBattle()) {
|
||||
applyPostBattleAbAttrs(PostBattleAbAttr, pokemon);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ export class CheckSwitchPhase extends BattlePhase {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.scene.getParty().slice(1).filter(p => p.isActive()).length) {
|
||||
if (!this.scene.getPlayerParty().slice(1).filter(p => p.isActive()).length) {
|
||||
super.end();
|
||||
return;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import { FieldPhase } from "./field-phase";
|
||||
import { SelectTargetPhase } from "./select-target-phase";
|
||||
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
|
||||
import { isNullOrUndefined } from "#app/utils";
|
||||
import { ArenaTagSide } from "#app/data/arena-tag";
|
||||
import { ArenaTagType } from "#app/enums/arena-tag-type";
|
||||
|
||||
export class CommandPhase extends FieldPhase {
|
||||
protected fieldIndex: integer;
|
||||
@ -228,32 +230,43 @@ export class CommandPhase extends FieldPhase {
|
||||
}, null, true);
|
||||
} else {
|
||||
const trapTag = playerPokemon.getTag(TrappedTag);
|
||||
const fairyLockTag = playerPokemon.scene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, ArenaTagSide.PLAYER);
|
||||
|
||||
// trapTag should be defined at this point, but just in case...
|
||||
if (!trapTag) {
|
||||
if (!trapTag && !fairyLockTag) {
|
||||
currentBattle.turnCommands[this.fieldIndex] = isSwitch
|
||||
? { command: Command.POKEMON, cursor: cursor, args: args }
|
||||
: { command: Command.RUN };
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isSwitch) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
}
|
||||
this.scene.ui.showText(
|
||||
i18next.t("battle:noEscapePokemon", {
|
||||
pokemonName: trapTag.sourceId && this.scene.getPokemonById(trapTag.sourceId) ? getPokemonNameWithAffix(this.scene.getPokemonById(trapTag.sourceId)!) : "",
|
||||
moveName: trapTag.getMoveName(),
|
||||
escapeVerb: isSwitch ? i18next.t("battle:escapeVerbSwitch") : i18next.t("battle:escapeVerbFlee")
|
||||
}),
|
||||
null,
|
||||
() => {
|
||||
this.scene.ui.showText("", 0);
|
||||
if (!isSwitch) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}
|
||||
}, null, true);
|
||||
const showNoEscapeText = (tag: any) => {
|
||||
this.scene.ui.showText(
|
||||
i18next.t("battle:noEscapePokemon", {
|
||||
pokemonName: tag.sourceId && this.scene.getPokemonById(tag.sourceId) ? getPokemonNameWithAffix(this.scene.getPokemonById(tag.sourceId)!) : "",
|
||||
moveName: tag.getMoveName(),
|
||||
escapeVerb: isSwitch ? i18next.t("battle:escapeVerbSwitch") : i18next.t("battle:escapeVerbFlee")
|
||||
}),
|
||||
null,
|
||||
() => {
|
||||
this.scene.ui.showText("", 0);
|
||||
if (!isSwitch) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}
|
||||
},
|
||||
null,
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
if (trapTag) {
|
||||
showNoEscapeText(trapTag);
|
||||
} else if (fairyLockTag) {
|
||||
showNoEscapeText(fairyLockTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1,40 +1,40 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { BattlerIndex, BattleType } from "#app/battle";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
||||
import { applyAbAttrs, SyncEncounterNatureAbAttr } from "#app/data/ability";
|
||||
import { initEncounterAnims, loadEncounterAnimAssets } from "#app/data/battle-anims";
|
||||
import { getCharVariantFromDialogue } from "#app/data/dialogue";
|
||||
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { doTrainerExclamation } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { getGoldenBugNetSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import { TrainerSlot } from "#app/data/trainer-config";
|
||||
import { getRandomWeatherType } from "#app/data/weather";
|
||||
import { BattleSpec } from "#app/enums/battle-spec";
|
||||
import { PlayerGender } from "#app/enums/player-gender";
|
||||
import { Species } from "#app/enums/species";
|
||||
import { EncounterPhaseEvent } from "#app/events/battle-scene";
|
||||
import Pokemon, { FieldPosition } from "#app/field/pokemon";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { ModifierPoolType, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
|
||||
import { BoostBugSpawnModifier, IvScannerModifier, TurnHeldItemTransferModifier } from "#app/modifier/modifier";
|
||||
import { ModifierPoolType, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
|
||||
import Overrides from "#app/overrides";
|
||||
import { BattlePhase } from "#app/phases/battle-phase";
|
||||
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
|
||||
import { PostSummonPhase } from "#app/phases/post-summon-phase";
|
||||
import { ReturnPhase } from "#app/phases/return-phase";
|
||||
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
|
||||
import { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase";
|
||||
import { SummonPhase } from "#app/phases/summon-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { achvs } from "#app/system/achv";
|
||||
import { handleTutorial, Tutorial } from "#app/tutorial";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import i18next from "i18next";
|
||||
import { BattlePhase } from "./battle-phase";
|
||||
import * as Utils from "#app/utils";
|
||||
import { randSeedInt } from "#app/utils";
|
||||
import { CheckSwitchPhase } from "./check-switch-phase";
|
||||
import { GameOverPhase } from "./game-over-phase";
|
||||
import { PostSummonPhase } from "./post-summon-phase";
|
||||
import { ReturnPhase } from "./return-phase";
|
||||
import { ScanIvsPhase } from "./scan-ivs-phase";
|
||||
import { ShinySparklePhase } from "./shiny-sparkle-phase";
|
||||
import { SummonPhase } from "./summon-phase";
|
||||
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
|
||||
import Overrides from "#app/overrides";
|
||||
import { initEncounterAnims, loadEncounterAnimAssets } from "#app/data/battle-anims";
|
||||
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
|
||||
import { doTrainerExclamation } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
|
||||
import { getGoldenBugNetSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import { randSeedInt, randSeedItem } from "#app/utils";
|
||||
import { BattleSpec } from "#enums/battle-spec";
|
||||
import { Biome } from "#enums/biome";
|
||||
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
|
||||
import { PlayerGender } from "#enums/player-gender";
|
||||
import { Species } from "#enums/species";
|
||||
import i18next from "i18next";
|
||||
import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters";
|
||||
|
||||
export class EncounterPhase extends BattlePhase {
|
||||
@ -116,7 +116,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
if (this.scene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
|
||||
battle.enemyParty[e].ivs = new Array(6).fill(31);
|
||||
}
|
||||
this.scene.getParty().slice(0, !battle.double ? 1 : 2).reverse().forEach(playerPokemon => {
|
||||
this.scene.getPlayerParty().slice(0, !battle.double ? 1 : 2).reverse().forEach(playerPokemon => {
|
||||
applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, false, battle.enemyParty[e]);
|
||||
});
|
||||
}
|
||||
@ -156,7 +156,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
return true;
|
||||
});
|
||||
|
||||
if (this.scene.getParty().filter(p => p.isShiny()).length === 6) {
|
||||
if (this.scene.getPlayerParty().filter(p => p.isShiny()).length === PLAYER_PARTY_MAX_SIZE) {
|
||||
this.scene.validateAchv(achvs.SHINY_PARTY);
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
|
||||
/*if (startingWave > 10) {
|
||||
for (let m = 0; m < Math.min(Math.floor(startingWave / 10), 99); m++)
|
||||
this.scene.addModifier(getPlayerModifierTypeOptionsForWave((m + 1) * 10, 1, this.scene.getParty())[0].type.newModifier(), true);
|
||||
this.scene.addModifier(getPlayerModifierTypeOptionsForWave((m + 1) * 10, 1, this.scene.getPlayerParty())[0].type.newModifier(), true);
|
||||
this.scene.updateModifiers(true);
|
||||
}*/
|
||||
|
||||
@ -259,7 +259,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
this.scene.mysteryEncounterSaveData.encounterSpawnChance += WEIGHT_INCREMENT_ON_SPAWN_MISS;
|
||||
}
|
||||
|
||||
for (const pokemon of this.scene.getParty()) {
|
||||
for (const pokemon of this.scene.getPlayerParty()) {
|
||||
if (pokemon) {
|
||||
pokemon.resetBattleData();
|
||||
}
|
||||
@ -338,7 +338,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
const doSummon = () => {
|
||||
this.scene.currentBattle.started = true;
|
||||
this.scene.playBgm(undefined);
|
||||
this.scene.pbTray.showPbTray(this.scene.getParty());
|
||||
this.scene.pbTray.showPbTray(this.scene.getPlayerParty());
|
||||
this.scene.pbTrayEnemy.showPbTray(this.scene.getEnemyParty());
|
||||
const doTrainerSummon = () => {
|
||||
this.hideEnemyTrainer();
|
||||
@ -362,7 +362,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
doSummon();
|
||||
} else {
|
||||
let message: string;
|
||||
this.scene.executeWithSeedOffset(() => message = Utils.randSeedItem(encounterMessages), this.scene.currentBattle.waveIndex);
|
||||
this.scene.executeWithSeedOffset(() => message = randSeedItem(encounterMessages), this.scene.currentBattle.waveIndex);
|
||||
message = message!; // tell TS compiler it's defined now
|
||||
const showDialogueAndSummon = () => {
|
||||
this.scene.ui.showDialogue(message, trainer?.getName(TrainerSlot.NONE, true), null, () => {
|
||||
@ -447,13 +447,13 @@ export class EncounterPhase extends BattlePhase {
|
||||
if (![ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(this.scene.currentBattle.battleType)) {
|
||||
enemyField.map(p => this.scene.pushConditionalPhase(new PostSummonPhase(this.scene, p.getBattlerIndex()), () => {
|
||||
// if there is not a player party, we can't continue
|
||||
if (!this.scene.getParty()?.length) {
|
||||
if (!this.scene.getPlayerParty().length) {
|
||||
return false;
|
||||
}
|
||||
// how many player pokemon are on the field ?
|
||||
const pokemonsOnFieldCount = this.scene.getParty().filter(p => p.isOnField()).length;
|
||||
const pokemonsOnFieldCount = this.scene.getPlayerParty().filter(p => p.isOnField()).length;
|
||||
// if it's a 2vs1, there will never be a 2nd pokemon on our field even
|
||||
const requiredPokemonsOnField = Math.min(this.scene.getParty().filter((p) => !p.isFainted()).length, 2);
|
||||
const requiredPokemonsOnField = Math.min(this.scene.getPlayerParty().filter((p) => !p.isFainted()).length, 2);
|
||||
// if it's a double, there should be 2, otherwise 1
|
||||
if (this.scene.currentBattle.double) {
|
||||
return pokemonsOnFieldCount === requiredPokemonsOnField;
|
||||
@ -467,7 +467,7 @@ export class EncounterPhase extends BattlePhase {
|
||||
}
|
||||
|
||||
if (!this.loaded) {
|
||||
const availablePartyMembers = this.scene.getParty().filter(p => p.isAllowedInBattle());
|
||||
const availablePartyMembers = this.scene.getPokemonAllowedInBattle();
|
||||
|
||||
if (!availablePartyMembers[0].isOnField()) {
|
||||
this.scene.pushPhase(new SummonPhase(this.scene, 0));
|
||||
|
@ -1,12 +1,12 @@
|
||||
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
|
||||
import { Phase } from "#app/phase";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import BattleScene, { AnySound } from "#app/battle-scene";
|
||||
import { SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions";
|
||||
import EvolutionSceneHandler from "#app/ui/evolution-scene-handler";
|
||||
import * as Utils from "#app/utils";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import { cos, sin } from "#app/field/anims";
|
||||
import { PlayerPokemon } from "#app/field/pokemon";
|
||||
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
|
||||
import { getTypeRgb } from "#app/data/type";
|
||||
import i18next from "i18next";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
@ -17,7 +17,11 @@ export class EvolutionPhase extends Phase {
|
||||
protected pokemon: PlayerPokemon;
|
||||
protected lastLevel: integer;
|
||||
|
||||
private preEvolvedPokemonName: string;
|
||||
|
||||
private evolution: SpeciesFormEvolution | null;
|
||||
private evolutionBgm: AnySound;
|
||||
private evolutionHandler: EvolutionSceneHandler;
|
||||
|
||||
protected evolutionContainer: Phaser.GameObjects.Container;
|
||||
protected evolutionBaseBg: Phaser.GameObjects.Image;
|
||||
@ -35,6 +39,8 @@ export class EvolutionPhase extends Phase {
|
||||
this.pokemon = pokemon;
|
||||
this.evolution = evolution;
|
||||
this.lastLevel = lastLevel;
|
||||
this.evolutionBgm = this.scene.playSoundWithoutBgm("evolution");
|
||||
this.preEvolvedPokemonName = getPokemonNameWithAffix(this.pokemon);
|
||||
}
|
||||
|
||||
validate(): boolean {
|
||||
@ -117,10 +123,9 @@ export class EvolutionPhase extends Phase {
|
||||
}
|
||||
|
||||
doEvolution(): void {
|
||||
const evolutionHandler = this.scene.ui.getHandler() as EvolutionSceneHandler;
|
||||
const preName = getPokemonNameWithAffix(this.pokemon);
|
||||
this.evolutionHandler = this.scene.ui.getHandler() as EvolutionSceneHandler;
|
||||
|
||||
this.scene.ui.showText(i18next.t("menu:evolving", { pokemonName: preName }), null, () => {
|
||||
this.scene.ui.showText(i18next.t("menu:evolving", { pokemonName: this.preEvolvedPokemonName }), null, () => {
|
||||
this.pokemon.cry();
|
||||
|
||||
this.pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => {
|
||||
@ -140,7 +145,6 @@ export class EvolutionPhase extends Phase {
|
||||
});
|
||||
|
||||
this.scene.time.delayedCall(1000, () => {
|
||||
const evolutionBgm = this.scene.playSoundWithoutBgm("evolution");
|
||||
this.scene.tweens.add({
|
||||
targets: this.evolutionBgOverlay,
|
||||
alpha: 1,
|
||||
@ -174,100 +178,13 @@ export class EvolutionPhase extends Phase {
|
||||
this.scene.time.delayedCall(1500, () => {
|
||||
this.pokemonEvoTintSprite.setScale(0.25);
|
||||
this.pokemonEvoTintSprite.setVisible(true);
|
||||
evolutionHandler.canCancel = true;
|
||||
this.evolutionHandler.canCancel = true;
|
||||
this.doCycle(1).then(success => {
|
||||
if (!success) {
|
||||
|
||||
this.pokemonSprite.setVisible(true);
|
||||
this.pokemonTintSprite.setScale(1);
|
||||
this.scene.tweens.add({
|
||||
targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ],
|
||||
alpha: 0,
|
||||
duration: 250,
|
||||
onComplete: () => {
|
||||
this.evolutionBg.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
SoundFade.fadeOut(this.scene, evolutionBgm, 100);
|
||||
|
||||
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
|
||||
|
||||
this.scene.ui.showText(i18next.t("menu:stoppedEvolving", { pokemonName: preName }), null, () => {
|
||||
this.scene.ui.showText(i18next.t("menu:pauseEvolutionsQuestion", { pokemonName: preName }), null, () => {
|
||||
const end = () => {
|
||||
this.scene.ui.showText("", 0);
|
||||
this.scene.playBgm();
|
||||
evolvedPokemon.destroy();
|
||||
this.end();
|
||||
};
|
||||
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
||||
this.scene.ui.revertMode();
|
||||
this.pokemon.pauseEvolutions = true;
|
||||
this.scene.ui.showText(i18next.t("menu:evolutionsPaused", { pokemonName: preName }), null, end, 3000);
|
||||
}, () => {
|
||||
this.scene.ui.revertMode();
|
||||
this.scene.time.delayedCall(3000, end);
|
||||
});
|
||||
});
|
||||
}, null, true);
|
||||
return;
|
||||
if (success) {
|
||||
this.handleSuccessEvolution(evolvedPokemon);
|
||||
} else {
|
||||
this.handleFailedEvolution(evolvedPokemon);
|
||||
}
|
||||
|
||||
this.scene.playSound("se/sparkle");
|
||||
this.pokemonEvoSprite.setVisible(true);
|
||||
this.doCircleInward();
|
||||
this.scene.time.delayedCall(900, () => {
|
||||
evolutionHandler.canCancel = false;
|
||||
|
||||
this.pokemon.evolve(this.evolution, this.pokemon.species).then(() => {
|
||||
const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true);
|
||||
for (const lm of levelMoves) {
|
||||
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getParty().indexOf(this.pokemon), lm[1]));
|
||||
}
|
||||
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
|
||||
|
||||
this.scene.playSound("se/shine");
|
||||
this.doSpray();
|
||||
this.scene.tweens.add({
|
||||
targets: this.evolutionOverlay,
|
||||
alpha: 1,
|
||||
duration: 250,
|
||||
easing: "Sine.easeIn",
|
||||
onComplete: () => {
|
||||
this.evolutionBgOverlay.setAlpha(1);
|
||||
this.evolutionBg.setVisible(false);
|
||||
this.scene.tweens.add({
|
||||
targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ],
|
||||
alpha: 0,
|
||||
duration: 2000,
|
||||
delay: 150,
|
||||
easing: "Sine.easeIn",
|
||||
onComplete: () => {
|
||||
this.scene.tweens.add({
|
||||
targets: this.evolutionBgOverlay,
|
||||
alpha: 0,
|
||||
duration: 250,
|
||||
onComplete: () => {
|
||||
SoundFade.fadeOut(this.scene, evolutionBgm, 100);
|
||||
this.scene.time.delayedCall(250, () => {
|
||||
this.pokemon.cry();
|
||||
this.scene.time.delayedCall(1250, () => {
|
||||
this.scene.playSoundWithoutBgm("evolution_fanfare");
|
||||
|
||||
evolvedPokemon.destroy();
|
||||
this.scene.ui.showText(i18next.t("menu:evolutionDone", { pokemonName: preName, evolvedPokemonName: this.pokemon.name }), null, () => this.end(), null, true, Utils.fixedInt(4000));
|
||||
this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm());
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -280,6 +197,110 @@ export class EvolutionPhase extends Phase {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a failed/stopped evolution
|
||||
* @param evolvedPokemon - The evolved Pokemon
|
||||
*/
|
||||
private handleFailedEvolution(evolvedPokemon: Pokemon): void {
|
||||
this.pokemonSprite.setVisible(true);
|
||||
this.pokemonTintSprite.setScale(1);
|
||||
this.scene.tweens.add({
|
||||
targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ],
|
||||
alpha: 0,
|
||||
duration: 250,
|
||||
onComplete: () => {
|
||||
this.evolutionBg.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
SoundFade.fadeOut(this.scene, this.evolutionBgm, 100);
|
||||
|
||||
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
|
||||
|
||||
this.scene.ui.showText(i18next.t("menu:stoppedEvolving", { pokemonName: this.preEvolvedPokemonName }), null, () => {
|
||||
this.scene.ui.showText(i18next.t("menu:pauseEvolutionsQuestion", { pokemonName: this.preEvolvedPokemonName }), null, () => {
|
||||
const end = () => {
|
||||
this.scene.ui.showText("", 0);
|
||||
this.scene.playBgm();
|
||||
evolvedPokemon.destroy();
|
||||
this.end();
|
||||
};
|
||||
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
||||
this.scene.ui.revertMode();
|
||||
this.pokemon.pauseEvolutions = true;
|
||||
this.scene.ui.showText(i18next.t("menu:evolutionsPaused", { pokemonName: this.preEvolvedPokemonName }), null, end, 3000);
|
||||
}, () => {
|
||||
this.scene.ui.revertMode();
|
||||
this.scene.time.delayedCall(3000, end);
|
||||
});
|
||||
});
|
||||
}, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a successful evolution
|
||||
* @param evolvedPokemon - The evolved Pokemon
|
||||
*/
|
||||
private handleSuccessEvolution(evolvedPokemon: Pokemon): void {
|
||||
this.scene.playSound("se/sparkle");
|
||||
this.pokemonEvoSprite.setVisible(true);
|
||||
this.doCircleInward();
|
||||
|
||||
const onEvolutionComplete = () => {
|
||||
SoundFade.fadeOut(this.scene, this.evolutionBgm, 100);
|
||||
this.scene.time.delayedCall(250, () => {
|
||||
this.pokemon.cry();
|
||||
this.scene.time.delayedCall(1250, () => {
|
||||
this.scene.playSoundWithoutBgm("evolution_fanfare");
|
||||
|
||||
evolvedPokemon.destroy();
|
||||
this.scene.ui.showText(i18next.t("menu:evolutionDone", { pokemonName: this.preEvolvedPokemonName, evolvedPokemonName: this.pokemon.name }), null, () => this.end(), null, true, Utils.fixedInt(4000));
|
||||
this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm());
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.scene.time.delayedCall(900, () => {
|
||||
this.evolutionHandler.canCancel = false;
|
||||
|
||||
this.pokemon.evolve(this.evolution, this.pokemon.species).then(() => {
|
||||
const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true);
|
||||
for (const lm of levelMoves) {
|
||||
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getPlayerParty().indexOf(this.pokemon), lm[1]));
|
||||
}
|
||||
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
|
||||
|
||||
this.scene.playSound("se/shine");
|
||||
this.doSpray();
|
||||
this.scene.tweens.add({
|
||||
targets: this.evolutionOverlay,
|
||||
alpha: 1,
|
||||
duration: 250,
|
||||
easing: "Sine.easeIn",
|
||||
onComplete: () => {
|
||||
this.evolutionBgOverlay.setAlpha(1);
|
||||
this.evolutionBg.setVisible(false);
|
||||
this.scene.tweens.add({
|
||||
targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ],
|
||||
alpha: 0,
|
||||
duration: 2000,
|
||||
delay: 150,
|
||||
easing: "Sine.easeIn",
|
||||
onComplete: () => {
|
||||
this.scene.tweens.add({
|
||||
targets: this.evolutionBgOverlay,
|
||||
alpha: 0,
|
||||
duration: 250,
|
||||
onComplete: onEvolutionComplete
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
doSpiralUpward() {
|
||||
let f = 0;
|
||||
|
||||
@ -320,7 +341,6 @@ export class EvolutionPhase extends Phase {
|
||||
|
||||
doCycle(l: number, lastCycle: integer = 15): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
const evolutionHandler = this.scene.ui.getHandler() as EvolutionSceneHandler;
|
||||
const isLastCycle = l === lastCycle;
|
||||
this.scene.tweens.add({
|
||||
targets: this.pokemonTintSprite,
|
||||
@ -336,7 +356,7 @@ export class EvolutionPhase extends Phase {
|
||||
duration: 500 / l,
|
||||
yoyo: !isLastCycle,
|
||||
onComplete: () => {
|
||||
if (evolutionHandler.cancelled) {
|
||||
if (this.evolutionHandler.cancelled) {
|
||||
return resolve(false);
|
||||
}
|
||||
if (l < lastCycle) {
|
||||
|
@ -1,24 +1,24 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { BattlerIndex, BattleType } from "#app/battle";
|
||||
import { applyPostFaintAbAttrs, PostFaintAbAttr, applyPostKnockOutAbAttrs, PostKnockOutAbAttr, applyPostVictoryAbAttrs, PostVictoryAbAttr } from "#app/data/ability";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { applyPostFaintAbAttrs, applyPostKnockOutAbAttrs, applyPostVictoryAbAttrs, PostFaintAbAttr, PostKnockOutAbAttr, PostVictoryAbAttr } from "#app/data/ability";
|
||||
import { BattlerTagLapseType, DestinyBondTag } from "#app/data/battler-tags";
|
||||
import { battleSpecDialogue } from "#app/data/dialogue";
|
||||
import { allMoves, PostVictoryStatStageChangeAttr } from "#app/data/move";
|
||||
import { SpeciesFormChangeActiveTrigger } from "#app/data/pokemon-forms";
|
||||
import { BattleSpec } from "#app/enums/battle-spec";
|
||||
import { StatusEffect } from "#app/enums/status-effect";
|
||||
import Pokemon, { PokemonMove, EnemyPokemon, PlayerPokemon, HitResult } from "#app/field/pokemon";
|
||||
import Pokemon, { EnemyPokemon, HitResult, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { PokemonInstantReviveModifier } from "#app/modifier/modifier";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import i18next from "i18next";
|
||||
import { DamagePhase } from "./damage-phase";
|
||||
import { GameOverPhase } from "./game-over-phase";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
import { SwitchPhase } from "./switch-phase";
|
||||
import { SwitchSummonPhase } from "./switch-summon-phase";
|
||||
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
|
||||
import { GameOverPhase } from "./game-over-phase";
|
||||
import { SwitchPhase } from "./switch-phase";
|
||||
import { VictoryPhase } from "./victory-phase";
|
||||
import { SpeciesFormChangeActiveTrigger } from "#app/data/pokemon-forms";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { isNullOrUndefined } from "#app/utils";
|
||||
import { FRIENDSHIP_LOSS_FROM_FAINT } from "#app/data/balance/starters";
|
||||
|
||||
@ -120,7 +120,7 @@ export class FaintPhase extends PokemonPhase {
|
||||
|
||||
if (this.player) {
|
||||
/** The total number of Pokemon in the player's party that can legally fight */
|
||||
const legalPlayerPokemon = this.scene.getParty().filter(p => p.isAllowedInBattle());
|
||||
const legalPlayerPokemon = this.scene.getPokemonAllowedInBattle();
|
||||
/** The total number of legal player Pokemon that aren't currently on the field */
|
||||
const legalPlayerPartyPokemon = legalPlayerPokemon.filter(p => !p.isActive(true));
|
||||
if (!legalPlayerPokemon.length) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { clientSessionId } from "#app/account";
|
||||
import { BattleType } from "#app/battle";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { getCharVariantFromDialogue } from "#app/data/dialogue";
|
||||
import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
|
||||
import { getCharVariantFromDialogue } from "#app/data/dialogue";
|
||||
import PokemonSpecies, { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { trainerConfigs } from "#app/data/trainer-config";
|
||||
import Pokemon from "#app/field/pokemon";
|
||||
@ -65,7 +65,7 @@ export class GameOverPhase extends BattlePhase {
|
||||
this.scene.gameData.loadSession(this.scene, this.scene.sessionSlotId).then(() => {
|
||||
this.scene.pushPhase(new EncounterPhase(this.scene, true));
|
||||
|
||||
const availablePartyMembers = this.scene.getParty().filter(p => p.isAllowedInBattle()).length;
|
||||
const availablePartyMembers = this.scene.getPokemonAllowedInBattle().length;
|
||||
|
||||
this.scene.pushPhase(new SummonPhase(this.scene, 0));
|
||||
if (this.scene.currentBattle.double && availablePartyMembers > 1) {
|
||||
@ -97,7 +97,7 @@ export class GameOverPhase extends BattlePhase {
|
||||
firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY);
|
||||
this.scene.validateAchv(achvs.UNEVOLVED_CLASSIC_VICTORY);
|
||||
this.scene.gameData.gameStats.sessionsWon++;
|
||||
for (const pokemon of this.scene.getParty()) {
|
||||
for (const pokemon of this.scene.getPlayerParty()) {
|
||||
this.awardRibbon(pokemon);
|
||||
|
||||
if (pokemon.species.getRootSpeciesId() !== pokemon.species.getRootSpeciesId(true)) {
|
||||
@ -195,13 +195,13 @@ export class GameOverPhase extends BattlePhase {
|
||||
if (!this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
|
||||
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.ENDLESS_MODE));
|
||||
}
|
||||
if (this.scene.getParty().filter(p => p.fusionSpecies).length && !this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) {
|
||||
if (this.scene.getPlayerParty().filter(p => p.fusionSpecies).length && !this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) {
|
||||
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.SPLICED_ENDLESS_MODE));
|
||||
}
|
||||
if (!this.scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE]) {
|
||||
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.MINI_BLACK_HOLE));
|
||||
}
|
||||
if (!this.scene.gameData.unlocks[Unlockables.EVIOLITE] && this.scene.getParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)) {
|
||||
if (!this.scene.gameData.unlocks[Unlockables.EVIOLITE] && this.scene.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)) {
|
||||
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.EVIOLITE));
|
||||
}
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ import {
|
||||
HitHealModifier,
|
||||
PokemonMultiHitModifier,
|
||||
} from "#app/modifier/modifier";
|
||||
import { PokemonPhase } from "#app/phases/pokemon-phase";
|
||||
import { BooleanHolder, executeIf, NumberHolder } from "#app/utils";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
import i18next from "i18next";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
|
||||
export class MoveEffectPhase extends PokemonPhase {
|
||||
public move: PokemonMove;
|
||||
@ -517,7 +517,11 @@ export class MoveEffectPhase extends PokemonPhase {
|
||||
return true;
|
||||
}
|
||||
|
||||
const user = this.getUserPokemon()!; // TODO: is this bang correct?
|
||||
const user = this.getUserPokemon();
|
||||
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Hit check only calculated on first hit for multi-hit moves unless flag is set to check all hits.
|
||||
// However, if an ability with the MaxMultiHitAbAttr, namely Skill Link, is present, act as a normal
|
||||
@ -566,9 +570,9 @@ export class MoveEffectPhase extends PokemonPhase {
|
||||
}
|
||||
|
||||
/** @returns The {@linkcode Pokemon} using this phase's invoked move */
|
||||
public getUserPokemon(): Pokemon | undefined {
|
||||
public getUserPokemon(): Pokemon | null {
|
||||
if (this.battlerIndex > BattlerIndex.ENEMY_2) {
|
||||
return this.scene.getPokemonById(this.battlerIndex) ?? undefined;
|
||||
return this.scene.getPokemonById(this.battlerIndex);
|
||||
}
|
||||
return (this.player ? this.scene.getPlayerField() : this.scene.getEnemyField())[this.fieldIndex];
|
||||
}
|
||||
@ -596,8 +600,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
||||
|
||||
/**
|
||||
* Prevents subsequent strikes of this phase's invoked move from occurring
|
||||
* @param target {@linkcode Pokemon} if defined, only stop subsequent
|
||||
* strikes against this Pokemon
|
||||
* @param target - If defined, only stop subsequent strikes against this {@linkcode Pokemon}
|
||||
*/
|
||||
public stopMultiHit(target?: Pokemon): void {
|
||||
// If given a specific target, remove the target from subsequent strikes
|
||||
|
@ -1,31 +1,31 @@
|
||||
import { BattlerTagLapseType } from "#app/data/battler-tags";
|
||||
import MysteryEncounterOption, { OptionPhaseCallback } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||
import { SeenEncounterData } from "#app/data/mystery-encounters/mystery-encounter-save-data";
|
||||
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
||||
import { PostTurnStatusEffectPhase } from "#app/phases/post-turn-status-effect-phase";
|
||||
import { ReturnPhase } from "#app/phases/return-phase";
|
||||
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
|
||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||
import { SummonPhase } from "#app/phases/summon-phase";
|
||||
import { SwitchPhase } from "#app/phases/switch-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { BattleSpec } from "#enums/battle-spec";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import i18next from "i18next";
|
||||
import BattleScene from "../battle-scene";
|
||||
import { getCharVariantFromDialogue } from "../data/dialogue";
|
||||
import { OptionSelectSettings, transitionMysteryEncounterIntroVisuals } from "../data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { TrainerSlot } from "../data/trainer-config";
|
||||
import { IvScannerModifier } from "../modifier/modifier";
|
||||
import { Phase } from "../phase";
|
||||
import { Mode } from "../ui/ui";
|
||||
import { transitionMysteryEncounterIntroVisuals, OptionSelectSettings } from "../data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import MysteryEncounterOption, { OptionPhaseCallback } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||
import { getCharVariantFromDialogue } from "../data/dialogue";
|
||||
import { TrainerSlot } from "../data/trainer-config";
|
||||
import { BattleSpec } from "#enums/battle-spec";
|
||||
import { IvScannerModifier } from "../modifier/modifier";
|
||||
import * as Utils from "../utils";
|
||||
import { isNullOrUndefined } from "../utils";
|
||||
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { BattlerTagLapseType } from "#app/data/battler-tags";
|
||||
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
|
||||
import { PostTurnStatusEffectPhase } from "#app/phases/post-turn-status-effect-phase";
|
||||
import { SummonPhase } from "#app/phases/summon-phase";
|
||||
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { ReturnPhase } from "#app/phases/return-phase";
|
||||
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
|
||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { SwitchPhase } from "#app/phases/switch-phase";
|
||||
import { SeenEncounterData } from "#app/data/mystery-encounters/mystery-encounter-save-data";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
|
||||
/**
|
||||
* Will handle (in order):
|
||||
@ -238,7 +238,7 @@ export class MysteryEncounterBattleStartCleanupPhase extends Phase {
|
||||
}
|
||||
|
||||
// The total number of Pokemon in the player's party that can legally fight
|
||||
const legalPlayerPokemon = this.scene.getParty().filter(p => p.isAllowedInBattle());
|
||||
const legalPlayerPokemon = this.scene.getPokemonAllowedInBattle();
|
||||
// The total number of legal player Pokemon that aren't currently on the field
|
||||
const legalPlayerPartyPokemon = legalPlayerPokemon.filter(p => !p.isActive(true));
|
||||
if (!legalPlayerPokemon.length) {
|
||||
@ -343,7 +343,7 @@ export class MysteryEncounterBattlePhase extends Phase {
|
||||
const doSummon = () => {
|
||||
scene.currentBattle.started = true;
|
||||
scene.playBgm(undefined);
|
||||
scene.pbTray.showPbTray(scene.getParty());
|
||||
scene.pbTray.showPbTray(scene.getPlayerParty());
|
||||
scene.pbTrayEnemy.showPbTray(scene.getEnemyParty());
|
||||
const doTrainerSummon = () => {
|
||||
this.hideEnemyTrainer();
|
||||
@ -402,7 +402,7 @@ export class MysteryEncounterBattlePhase extends Phase {
|
||||
}
|
||||
}
|
||||
|
||||
const availablePartyMembers = scene.getParty().filter(p => p.isAllowedInBattle());
|
||||
const availablePartyMembers = scene.getPlayerParty().filter(p => p.isAllowedInBattle());
|
||||
|
||||
if (!availablePartyMembers[0].isOnField()) {
|
||||
scene.pushPhase(new SummonPhase(scene, 0));
|
||||
|
@ -11,13 +11,13 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase {
|
||||
doEncounter(): void {
|
||||
this.scene.playBgm(undefined, true);
|
||||
|
||||
for (const pokemon of this.scene.getParty()) {
|
||||
for (const pokemon of this.scene.getPlayerParty()) {
|
||||
if (pokemon) {
|
||||
pokemon.resetBattleData();
|
||||
}
|
||||
}
|
||||
|
||||
for (const pokemon of this.scene.getParty().filter(p => p.isOnField())) {
|
||||
for (const pokemon of this.scene.getPlayerParty().filter(p => p.isOnField())) {
|
||||
applyAbAttrs(PostBiomeChangeAbAttr, pokemon, null);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ export class NextEncounterPhase extends EncounterPhase {
|
||||
doEncounter(): void {
|
||||
this.scene.playBgm(undefined, true);
|
||||
|
||||
for (const pokemon of this.scene.getParty()) {
|
||||
for (const pokemon of this.scene.getPlayerParty()) {
|
||||
if (pokemon) {
|
||||
pokemon.resetBattleData();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export class PartyHealPhase extends BattlePhase {
|
||||
this.scene.fadeOutBgm(1000, false);
|
||||
}
|
||||
this.scene.ui.fadeOut(1000).then(() => {
|
||||
for (const pokemon of this.scene.getParty()) {
|
||||
for (const pokemon of this.scene.getPlayerParty()) {
|
||||
pokemon.hp = pokemon.getMaxHp();
|
||||
pokemon.resetStatus();
|
||||
for (const move of pokemon.moveset) {
|
||||
|
@ -18,7 +18,7 @@ export abstract class PartyMemberPokemonPhase extends FieldPhase {
|
||||
}
|
||||
|
||||
getParty(): Pokemon[] {
|
||||
return this.player ? this.scene.getParty() : this.scene.getEnemyParty();
|
||||
return this.player ? this.scene.getPlayerParty() : this.scene.getEnemyParty();
|
||||
}
|
||||
|
||||
getPokemon(): Pokemon {
|
||||
|
@ -38,7 +38,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
this.scene.reroll = false;
|
||||
}
|
||||
|
||||
const party = this.scene.getParty();
|
||||
const party = this.scene.getPlayerParty();
|
||||
if (!this.isCopy) {
|
||||
regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount);
|
||||
}
|
||||
@ -289,7 +289,7 @@ export class SelectModifierPhase extends BattlePhase {
|
||||
}
|
||||
|
||||
getModifierTypeOptions(modifierCount: integer): ModifierTypeOption[] {
|
||||
return getPlayerModifierTypeOptions(modifierCount, this.scene.getParty(), this.scene.lockModifierTiers ? this.modifierTiers : undefined, this.customModifierSettings);
|
||||
return getPlayerModifierTypeOptions(modifierCount, this.scene.getPlayerParty(), this.scene.lockModifierTiers ? this.modifierTiers : undefined, this.customModifierSettings);
|
||||
}
|
||||
|
||||
copy(): SelectModifierPhase {
|
||||
|
@ -3,16 +3,15 @@ import { applyChallenges, ChallengeType } from "#app/data/challenge";
|
||||
import { Gender } from "#app/data/gender";
|
||||
import { SpeciesFormChangeMoveLearnedTrigger } from "#app/data/pokemon-forms";
|
||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { Species } from "#app/enums/species";
|
||||
import { PlayerPokemon } from "#app/field/pokemon";
|
||||
import { overrideModifiers, overrideHeldItems } from "#app/modifier/modifier";
|
||||
import { overrideHeldItems, overrideModifiers } from "#app/modifier/modifier";
|
||||
import Overrides from "#app/overrides";
|
||||
import { Phase } from "#app/phase";
|
||||
import { TitlePhase } from "#app/phases/title-phase";
|
||||
import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler";
|
||||
import { Starter } from "#app/ui/starter-select-ui-handler";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import { Species } from "#enums/species";
|
||||
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
|
||||
import { TitlePhase } from "./title-phase";
|
||||
import Overrides from "#app/overrides";
|
||||
|
||||
export class SelectStarterPhase extends Phase {
|
||||
|
||||
@ -44,7 +43,7 @@ export class SelectStarterPhase extends Phase {
|
||||
* @param starters {@linkcode Pokemon} with which to start the first battle
|
||||
*/
|
||||
initBattle(starters: Starter[]) {
|
||||
const party = this.scene.getParty();
|
||||
const party = this.scene.getPlayerParty();
|
||||
const loadPokemonAssets: Promise<void>[] = [];
|
||||
starters.forEach((starter: Starter, i: integer) => {
|
||||
if (!i && Overrides.STARTER_SPECIES_OVERRIDE) {
|
||||
@ -103,7 +102,7 @@ export class SelectStarterPhase extends Phase {
|
||||
this.scene.sessionPlayTime = 0;
|
||||
this.scene.lastSavePlayTime = 0;
|
||||
// Ensures Keldeo (or any future Pokemon that have this type of form change) starts in the correct form
|
||||
this.scene.getParty().forEach((p: PlayerPokemon) => {
|
||||
this.scene.getPlayerParty().forEach((p) => {
|
||||
this.scene.triggerPokemonFormChange(p, SpeciesFormChangeMoveLearnedTrigger);
|
||||
});
|
||||
this.end();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import PartyUiHandler, { PartyUiMode, PartyOption } from "#app/ui/party-ui-handler";
|
||||
import PartyUiHandler, { PartyOption, PartyUiMode } from "#app/ui/party-ui-handler";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { BattlePhase } from "./battle-phase";
|
||||
import { SwitchSummonPhase } from "./switch-summon-phase";
|
||||
|
||||
@ -38,7 +38,7 @@ export class SwitchPhase extends BattlePhase {
|
||||
super.start();
|
||||
|
||||
// Skip modal switch if impossible (no remaining party members that aren't in battle)
|
||||
if (this.isModal && !this.scene.getParty().filter(p => p.isAllowedInBattle() && !p.isActive(true)).length) {
|
||||
if (this.isModal && !this.scene.getPlayerParty().filter(p => p.isAllowedInBattle() && !p.isActive(true)).length) {
|
||||
return super.end();
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ export class SwitchPhase extends BattlePhase {
|
||||
* if the mon should have already been returned but is still alive and well
|
||||
* on the field. see also; battle.test.ts
|
||||
*/
|
||||
if (this.isModal && !this.doReturn && !this.scene.getParty()[this.fieldIndex].isFainted()) {
|
||||
if (this.isModal && !this.doReturn && !this.scene.getPlayerParty()[this.fieldIndex].isFainted()) {
|
||||
return super.end();
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ export class SwitchPhase extends BattlePhase {
|
||||
}
|
||||
|
||||
// Override field index to 0 in case of double battle where 2/3 remaining legal party members fainted at once
|
||||
const fieldIndex = this.scene.currentBattle.getBattlerCount() === 1 || this.scene.getParty().filter(p => p.isAllowedInBattle()).length > 1 ? this.fieldIndex : 0;
|
||||
const fieldIndex = this.scene.currentBattle.getBattlerCount() === 1 || this.scene.getPokemonAllowedInBattle().length > 1 ? this.fieldIndex : 0;
|
||||
|
||||
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => {
|
||||
if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
||||
|
@ -54,7 +54,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? this.scene.getParty() : this.scene.getEnemyParty())[this.slotIndex])) {
|
||||
if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? this.scene.getPlayerParty() : this.scene.getEnemyParty())[this.slotIndex])) {
|
||||
if (this.player) {
|
||||
return this.switchAndSummon();
|
||||
} else {
|
||||
|
@ -1,21 +1,21 @@
|
||||
import { loggedInUser } from "#app/account";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { BattleType } from "#app/battle";
|
||||
import { getDailyRunStarters, fetchDailyRunSeed } from "#app/data/daily-run";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { fetchDailyRunSeed, getDailyRunStarters } from "#app/data/daily-run";
|
||||
import { Gender } from "#app/data/gender";
|
||||
import { getBiomeKey } from "#app/field/arena";
|
||||
import { GameModes, GameMode, getGameMode } from "#app/game-mode";
|
||||
import { regenerateModifierPoolThresholds, ModifierPoolType, modifierTypes, getDailyRunStarterModifiers } from "#app/modifier/modifier-type";
|
||||
import { GameMode, GameModes, getGameMode } from "#app/game-mode";
|
||||
import { Modifier } from "#app/modifier/modifier";
|
||||
import { getDailyRunStarterModifiers, ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type";
|
||||
import { Phase } from "#app/phase";
|
||||
import { SessionSaveData } from "#app/system/game-data";
|
||||
import { Unlockables } from "#app/system/unlockables";
|
||||
import { vouchers } from "#app/system/voucher";
|
||||
import { OptionSelectItem, OptionSelectConfig } from "#app/ui/abstact-option-select-ui-handler";
|
||||
import { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
||||
import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import i18next from "i18next";
|
||||
import * as Utils from "#app/utils";
|
||||
import { Modifier } from "#app/modifier/modifier";
|
||||
import i18next from "i18next";
|
||||
import { CheckSwitchPhase } from "./check-switch-phase";
|
||||
import { EncounterPhase } from "./encounter-phase";
|
||||
import { SelectChallengePhase } from "./select-challenge-phase";
|
||||
@ -203,7 +203,7 @@ export class TitlePhase extends Phase {
|
||||
const starters = getDailyRunStarters(this.scene, seed);
|
||||
const startingLevel = this.scene.gameMode.getStartingLevel();
|
||||
|
||||
const party = this.scene.getParty();
|
||||
const party = this.scene.getPlayerParty();
|
||||
const loadPokemonAssets: Promise<void>[] = [];
|
||||
for (const starter of starters) {
|
||||
const starterProps = this.scene.gameData.getSpeciesDexAttrProps(starter.species, starter.dexAttr);
|
||||
@ -276,7 +276,7 @@ export class TitlePhase extends Phase {
|
||||
this.scene.pushPhase(new EncounterPhase(this.scene, this.loaded));
|
||||
|
||||
if (this.loaded) {
|
||||
const availablePartyMembers = this.scene.getParty().filter(p => p.isAllowedInBattle()).length;
|
||||
const availablePartyMembers = this.scene.getPokemonAllowedInBattle().length;
|
||||
|
||||
this.scene.pushPhase(new SummonPhase(this.scene, 0, true, true));
|
||||
if (this.scene.currentBattle.double && availablePartyMembers > 1) {
|
||||
|
@ -16,9 +16,9 @@ export class ToggleDoublePositionPhase extends BattlePhase {
|
||||
|
||||
const playerPokemon = this.scene.getPlayerField().find(p => p.isActive(true));
|
||||
if (playerPokemon) {
|
||||
playerPokemon.setFieldPosition(this.double && this.scene.getParty().filter(p => p.isAllowedInBattle()).length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER, 500).then(() => {
|
||||
playerPokemon.setFieldPosition(this.double && this.scene.getPokemonAllowedInBattle().length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER, 500).then(() => {
|
||||
if (playerPokemon.getFieldIndex() === 1) {
|
||||
const party = this.scene.getParty();
|
||||
const party = this.scene.getPlayerParty();
|
||||
party[1] = party[0];
|
||||
party[0] = playerPokemon;
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { handleMysteryEncounterBattleStartEffects, handleMysteryEncounterTurnStartEffects } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { TurnInitEvent } from "#app/events/battle-scene";
|
||||
import { PlayerPokemon } from "#app/field/pokemon";
|
||||
import i18next from "i18next";
|
||||
import { FieldPhase } from "./field-phase";
|
||||
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
|
||||
import { CommandPhase } from "./command-phase";
|
||||
import { EnemyCommandPhase } from "./enemy-command-phase";
|
||||
import { FieldPhase } from "./field-phase";
|
||||
import { GameOverPhase } from "./game-over-phase";
|
||||
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
|
||||
import { TurnStartPhase } from "./turn-start-phase";
|
||||
import { handleMysteryEncounterBattleStartEffects, handleMysteryEncounterTurnStartEffects } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
|
||||
export class TurnInitPhase extends FieldPhase {
|
||||
constructor(scene: BattleScene) {
|
||||
@ -24,7 +24,7 @@ export class TurnInitPhase extends FieldPhase {
|
||||
if (p.isOnField() && !p.isAllowedInBattle()) {
|
||||
this.scene.queueMessage(i18next.t("challenges:illegalEvolution", { "pokemon": p.name }), null, true);
|
||||
|
||||
const allowedPokemon = this.scene.getParty().filter(p => p.isAllowedInBattle());
|
||||
const allowedPokemon = this.scene.getPokemonAllowedInBattle();
|
||||
|
||||
if (!allowedPokemon.length) {
|
||||
// If there are no longer any legal pokemon in the party, game over.
|
||||
|
@ -328,7 +328,7 @@ export const achvs = {
|
||||
HIDDEN_ABILITY: new Achv("HIDDEN_ABILITY", "", "HIDDEN_ABILITY.description", "ability_charm", 75),
|
||||
PERFECT_IVS: new Achv("PERFECT_IVS", "", "PERFECT_IVS.description", "blunder_policy", 100),
|
||||
CLASSIC_VICTORY: new Achv("CLASSIC_VICTORY", "", "CLASSIC_VICTORY.description", "relic_crown", 150, c => c.gameData.gameStats.sessionsWon === 0),
|
||||
UNEVOLVED_CLASSIC_VICTORY: new Achv("UNEVOLVED_CLASSIC_VICTORY", "", "UNEVOLVED_CLASSIC_VICTORY.description", "eviolite", 175, c => c.getParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)),
|
||||
UNEVOLVED_CLASSIC_VICTORY: new Achv("UNEVOLVED_CLASSIC_VICTORY", "", "UNEVOLVED_CLASSIC_VICTORY.description", "eviolite", 175, c => c.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)),
|
||||
MONO_GEN_ONE_VICTORY: new ChallengeAchv("MONO_GEN_ONE", "", "MONO_GEN_ONE.description", "ribbon_gen1", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 1 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)),
|
||||
MONO_GEN_TWO_VICTORY: new ChallengeAchv("MONO_GEN_TWO", "", "MONO_GEN_TWO.description", "ribbon_gen2", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 2 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)),
|
||||
MONO_GEN_THREE_VICTORY: new ChallengeAchv("MONO_GEN_THREE", "", "MONO_GEN_THREE.description", "ribbon_gen3", 100, (c, scene) => c instanceof SingleGenerationChallenge && c.value === 3 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)),
|
||||
|
@ -949,7 +949,7 @@ export class GameData {
|
||||
seed: scene.seed,
|
||||
playTime: scene.sessionPlayTime,
|
||||
gameMode: scene.gameMode.modeId,
|
||||
party: scene.getParty().map(p => new PokemonData(p)),
|
||||
party: scene.getPlayerParty().map(p => new PokemonData(p)),
|
||||
enemyParty: scene.getEnemyParty().map(p => new PokemonData(p)),
|
||||
modifiers: scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)),
|
||||
enemyModifiers: scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
|
||||
@ -1028,7 +1028,7 @@ export class GameData {
|
||||
|
||||
const loadPokemonAssets: Promise<void>[] = [];
|
||||
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
party.splice(0, party.length);
|
||||
|
||||
for (const p of sessionData.party) {
|
||||
@ -1829,17 +1829,40 @@ export class GameData {
|
||||
return starterCount;
|
||||
}
|
||||
|
||||
getSpeciesDefaultDexAttr(species: PokemonSpecies, forSeen: boolean = false, optimistic: boolean = false): bigint {
|
||||
getSpeciesDefaultDexAttr(species: PokemonSpecies, _forSeen: boolean = false, optimistic: boolean = false): bigint {
|
||||
let ret = 0n;
|
||||
const dexEntry = this.dexData[species.speciesId];
|
||||
const attr = dexEntry.caughtAttr;
|
||||
ret |= optimistic
|
||||
? attr & DexAttr.SHINY ? DexAttr.SHINY : DexAttr.NON_SHINY
|
||||
: attr & DexAttr.NON_SHINY || !(attr & DexAttr.SHINY) ? DexAttr.NON_SHINY : DexAttr.SHINY;
|
||||
if (optimistic) {
|
||||
if (attr & DexAttr.SHINY) {
|
||||
ret |= DexAttr.SHINY;
|
||||
|
||||
if (attr & DexAttr.VARIANT_3) {
|
||||
ret |= DexAttr.VARIANT_3;
|
||||
} else if (attr & DexAttr.VARIANT_2) {
|
||||
ret |= DexAttr.VARIANT_2;
|
||||
} else {
|
||||
ret |= DexAttr.DEFAULT_VARIANT;
|
||||
}
|
||||
} else {
|
||||
ret |= DexAttr.NON_SHINY;
|
||||
ret |= DexAttr.DEFAULT_VARIANT;
|
||||
}
|
||||
} else {
|
||||
// Default to non shiny. Fallback to shiny if it's the only thing that's unlocked
|
||||
ret |= (attr & DexAttr.NON_SHINY || !(attr & DexAttr.SHINY)) ? DexAttr.NON_SHINY : DexAttr.SHINY;
|
||||
|
||||
if (attr & DexAttr.DEFAULT_VARIANT) {
|
||||
ret |= DexAttr.DEFAULT_VARIANT;
|
||||
} else if (attr & DexAttr.VARIANT_2) {
|
||||
ret |= DexAttr.VARIANT_2;
|
||||
} else if (attr & DexAttr.VARIANT_3) {
|
||||
ret |= DexAttr.VARIANT_3;
|
||||
} else {
|
||||
ret |= DexAttr.DEFAULT_VARIANT;
|
||||
}
|
||||
}
|
||||
ret |= attr & DexAttr.MALE || !(attr & DexAttr.FEMALE) ? DexAttr.MALE : DexAttr.FEMALE;
|
||||
ret |= optimistic
|
||||
? attr & DexAttr.SHINY ? attr & DexAttr.VARIANT_3 ? DexAttr.VARIANT_3 : attr & DexAttr.VARIANT_2 ? DexAttr.VARIANT_2 : DexAttr.DEFAULT_VARIANT : DexAttr.DEFAULT_VARIANT
|
||||
: attr & DexAttr.DEFAULT_VARIANT ? DexAttr.DEFAULT_VARIANT : attr & DexAttr.VARIANT_2 ? DexAttr.VARIANT_2 : attr & DexAttr.VARIANT_3 ? DexAttr.VARIANT_3 : DexAttr.DEFAULT_VARIANT;
|
||||
ret |= this.getFormAttr(this.getFormIndex(attr));
|
||||
return ret;
|
||||
}
|
||||
@ -1847,7 +1870,14 @@ export class GameData {
|
||||
getSpeciesDexAttrProps(species: PokemonSpecies, dexAttr: bigint): DexAttrProps {
|
||||
const shiny = !(dexAttr & DexAttr.NON_SHINY);
|
||||
const female = !(dexAttr & DexAttr.MALE);
|
||||
const variant = dexAttr & DexAttr.DEFAULT_VARIANT ? 0 : dexAttr & DexAttr.VARIANT_2 ? 1 : dexAttr & DexAttr.VARIANT_3 ? 2 : 0;
|
||||
let variant: Variant = 0;
|
||||
if (dexAttr & DexAttr.DEFAULT_VARIANT) {
|
||||
variant = 0;
|
||||
} else if (dexAttr & DexAttr.VARIANT_2) {
|
||||
variant = 1;
|
||||
} else if (dexAttr & DexAttr.VARIANT_3) {
|
||||
variant = 2;
|
||||
}
|
||||
const formIndex = this.getFormIndex(dexAttr);
|
||||
|
||||
return {
|
||||
|
@ -38,7 +38,7 @@ export default class ModifierData {
|
||||
type.id = this.typeId;
|
||||
|
||||
if (type instanceof ModifierTypeGenerator) {
|
||||
type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getParty() : scene.getEnemyField(), this.typePregenArgs);
|
||||
type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getPlayerParty() : scene.getEnemyField(), this.typePregenArgs);
|
||||
}
|
||||
|
||||
const ret = Reflect.construct(constructor, ([ type ] as any[]).concat(this.args).concat(this.stackCount)) as PersistentModifier;
|
||||
|
@ -163,6 +163,11 @@ export const SettingKeys = {
|
||||
Shop_Overlay_Opacity: "SHOP_OVERLAY_OPACITY"
|
||||
};
|
||||
|
||||
export enum MusicPreference {
|
||||
CONSISTENT,
|
||||
MIXED
|
||||
}
|
||||
|
||||
/**
|
||||
* All Settings not related to controls
|
||||
*/
|
||||
@ -634,7 +639,7 @@ export const Setting: Array<Setting> = [
|
||||
label: i18next.t("settings:mixed")
|
||||
}
|
||||
],
|
||||
default: 0,
|
||||
default: MusicPreference.MIXED,
|
||||
type: SettingType.AUDIO,
|
||||
requireReload: true
|
||||
},
|
||||
|
@ -36,7 +36,7 @@ describe("Moves - Aroma Veil", () => {
|
||||
it("Aroma Veil protects the Pokemon's side against most Move Restriction Battler Tags", async () => {
|
||||
await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]);
|
||||
|
||||
const party = game.scene.getParty()! as PlayerPokemon[];
|
||||
const party = game.scene.getPlayerParty()! as PlayerPokemon[];
|
||||
|
||||
game.move.select(Moves.GROWL);
|
||||
game.move.select(Moves.GROWL);
|
||||
@ -50,7 +50,7 @@ describe("Moves - Aroma Veil", () => {
|
||||
it("Aroma Veil does not protect against Imprison", async () => {
|
||||
await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]);
|
||||
|
||||
const party = game.scene.getParty()! as PlayerPokemon[];
|
||||
const party = game.scene.getPlayerParty()! as PlayerPokemon[];
|
||||
|
||||
game.move.select(Moves.GROWL);
|
||||
game.move.select(Moves.GROWL, 1);
|
||||
|
@ -40,7 +40,7 @@ describe("Abilities - BATTLE BOND", () => {
|
||||
it("check if fainted pokemon switches to base form on arena reset", async () => {
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP, Species.GRENINJA ]);
|
||||
|
||||
const greninja = game.scene.getParty()[1];
|
||||
const greninja = game.scene.getPlayerParty()[1];
|
||||
expect(greninja.formIndex).toBe(ashForm);
|
||||
|
||||
greninja.hp = 0;
|
||||
|
@ -138,7 +138,7 @@ describe("Abilities - Disguise", () => {
|
||||
});
|
||||
await game.classicMode.startBattle([ Species.FURRET, Species.MIMIKYU ]);
|
||||
|
||||
const mimikyu = game.scene.getParty()[1]!;
|
||||
const mimikyu = game.scene.getPlayerParty()[1]!;
|
||||
expect(mimikyu.formIndex).toBe(bustedForm);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
|
@ -81,7 +81,7 @@ describe("Abilities - Forecast", () => {
|
||||
});
|
||||
await game.startBattle([ Species.CASTFORM, Species.FEEBAS, Species.KYOGRE, Species.GROUDON, Species.RAYQUAZA, Species.ALTARIA ]);
|
||||
|
||||
vi.spyOn(game.scene.getParty()[5], "getAbility").mockReturnValue(allAbilities[Abilities.CLOUD_NINE]);
|
||||
vi.spyOn(game.scene.getPlayerParty()[5], "getAbility").mockReturnValue(allAbilities[Abilities.CLOUD_NINE]);
|
||||
|
||||
const castform = game.scene.getPlayerField()[0];
|
||||
expect(castform.formIndex).toBe(NORMAL_FORM);
|
||||
|
@ -192,7 +192,7 @@ describe("Abilities - Ice Face", () => {
|
||||
game.doSwitchPokemon(1);
|
||||
|
||||
await game.phaseInterceptor.to(TurnEndPhase);
|
||||
eiscue = game.scene.getParty()[1];
|
||||
eiscue = game.scene.getPlayerParty()[1];
|
||||
|
||||
expect(eiscue.formIndex).toBe(noiceForm);
|
||||
expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined();
|
||||
|
@ -35,7 +35,7 @@ describe("Abilities - Mimicry", () => {
|
||||
game.override.enemyAbility(Abilities.MISTY_SURGE);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS, Species.ABRA ]);
|
||||
|
||||
const [ playerPokemon1, playerPokemon2 ] = game.scene.getParty();
|
||||
const [ playerPokemon1, playerPokemon2 ] = game.scene.getPlayerParty();
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.toNextTurn();
|
||||
expect(playerPokemon1.getTypes().includes(Type.FAIRY)).toBe(true);
|
||||
|
@ -51,7 +51,7 @@ describe("Abilities - Pastel Veil", () => {
|
||||
|
||||
it("it heals the poisoned status condition of allies if user is sent out into battle", async () => {
|
||||
await game.startBattle([ Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA ]);
|
||||
const ponyta = game.scene.getParty()[2];
|
||||
const ponyta = game.scene.getPlayerParty()[2];
|
||||
const magikarp = game.scene.getPlayerField()[0];
|
||||
ponyta.abilityIndex = 1;
|
||||
|
||||
|
@ -43,7 +43,7 @@ describe("Abilities - POWER CONSTRUCT", () => {
|
||||
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]);
|
||||
|
||||
const zygarde = game.scene.getParty().find((p) => p.species.speciesId === Species.ZYGARDE);
|
||||
const zygarde = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.ZYGARDE);
|
||||
expect(zygarde).not.toBe(undefined);
|
||||
expect(zygarde!.formIndex).toBe(completeForm);
|
||||
|
||||
@ -73,7 +73,7 @@ describe("Abilities - POWER CONSTRUCT", () => {
|
||||
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]);
|
||||
|
||||
const zygarde = game.scene.getParty().find((p) => p.species.speciesId === Species.ZYGARDE);
|
||||
const zygarde = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.ZYGARDE);
|
||||
expect(zygarde).not.toBe(undefined);
|
||||
expect(zygarde!.formIndex).toBe(completeForm);
|
||||
|
||||
|
@ -43,7 +43,7 @@ describe("Abilities - SCHOOLING", () => {
|
||||
|
||||
await game.startBattle([ Species.MAGIKARP, Species.WISHIWASHI ]);
|
||||
|
||||
const wishiwashi = game.scene.getParty().find((p) => p.species.speciesId === Species.WISHIWASHI)!;
|
||||
const wishiwashi = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.WISHIWASHI)!;
|
||||
expect(wishiwashi).not.toBe(undefined);
|
||||
expect(wishiwashi.formIndex).toBe(schoolForm);
|
||||
|
||||
|
@ -43,7 +43,7 @@ describe("Abilities - Serene Grace", () => {
|
||||
|
||||
|
||||
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
expect(game.scene.getPlayerParty()[0].formIndex).toBe(0);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
|
||||
@ -70,7 +70,7 @@ describe("Abilities - Serene Grace", () => {
|
||||
]);
|
||||
|
||||
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
expect(game.scene.getPlayerParty()[0].formIndex).toBe(0);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
||||
import * as Utils from "#app/utils";
|
||||
import { NumberHolder } from "#app/utils";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { allMoves } from "#app/data/move";
|
||||
|
||||
|
||||
describe("Abilities - Sheer Force", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
@ -39,13 +38,10 @@ describe("Abilities - Sheer Force", () => {
|
||||
it("Sheer Force", async () => {
|
||||
const moveToUse = Moves.AIR_SLASH;
|
||||
game.override.ability(Abilities.SHEER_FORCE);
|
||||
await game.startBattle([
|
||||
Species.PIDGEOT
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.PIDGEOT ]);
|
||||
|
||||
|
||||
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
game.scene.getEnemyPokemon()!.stats[Stat.SPDEF] = 10000;
|
||||
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
|
||||
@ -57,8 +53,8 @@ describe("Abilities - Sheer Force", () => {
|
||||
expect(move.id).toBe(Moves.AIR_SLASH);
|
||||
|
||||
//Verify the move is boosted and has no chance of secondary effects
|
||||
const power = new Utils.IntegerHolder(move.power);
|
||||
const chance = new Utils.IntegerHolder(move.chance);
|
||||
const power = new NumberHolder(move.power);
|
||||
const chance = new NumberHolder(move.chance);
|
||||
|
||||
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
|
||||
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
|
||||
@ -72,13 +68,11 @@ describe("Abilities - Sheer Force", () => {
|
||||
it("Sheer Force with exceptions including binding moves", async () => {
|
||||
const moveToUse = Moves.BIND;
|
||||
game.override.ability(Abilities.SHEER_FORCE);
|
||||
await game.startBattle([
|
||||
Species.PIDGEOT
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.PIDGEOT ]);
|
||||
|
||||
|
||||
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
|
||||
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
|
||||
@ -90,8 +84,8 @@ describe("Abilities - Sheer Force", () => {
|
||||
expect(move.id).toBe(Moves.BIND);
|
||||
|
||||
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
|
||||
const power = new Utils.IntegerHolder(move.power);
|
||||
const chance = new Utils.IntegerHolder(move.chance);
|
||||
const power = new NumberHolder(move.power);
|
||||
const chance = new NumberHolder(move.chance);
|
||||
|
||||
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
|
||||
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
|
||||
@ -105,13 +99,11 @@ describe("Abilities - Sheer Force", () => {
|
||||
it("Sheer Force with moves with no secondary effect", async () => {
|
||||
const moveToUse = Moves.TACKLE;
|
||||
game.override.ability(Abilities.SHEER_FORCE);
|
||||
await game.startBattle([
|
||||
Species.PIDGEOT
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.PIDGEOT ]);
|
||||
|
||||
|
||||
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
|
||||
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
|
||||
@ -123,8 +115,8 @@ describe("Abilities - Sheer Force", () => {
|
||||
expect(move.id).toBe(Moves.TACKLE);
|
||||
|
||||
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
|
||||
const power = new Utils.IntegerHolder(move.power);
|
||||
const chance = new Utils.IntegerHolder(move.chance);
|
||||
const power = new NumberHolder(move.power);
|
||||
const chance = new NumberHolder(move.chance);
|
||||
|
||||
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
|
||||
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
|
||||
@ -140,13 +132,11 @@ describe("Abilities - Sheer Force", () => {
|
||||
game.override.enemyAbility(Abilities.COLOR_CHANGE);
|
||||
game.override.startingHeldItems([{ name: "KINGS_ROCK", count: 1 }]);
|
||||
game.override.ability(Abilities.SHEER_FORCE);
|
||||
await game.startBattle([
|
||||
Species.PIDGEOT
|
||||
]);
|
||||
await game.startBattle([ Species.PIDGEOT ]);
|
||||
|
||||
|
||||
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
game.scene.getEnemyPokemon()!.stats[Stat.DEF] = 10000;
|
||||
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
|
||||
@ -158,8 +148,8 @@ describe("Abilities - Sheer Force", () => {
|
||||
expect(move.id).toBe(Moves.CRUSH_CLAW);
|
||||
|
||||
//Disable color change due to being hit by Sheer Force
|
||||
const power = new Utils.IntegerHolder(move.power);
|
||||
const chance = new Utils.IntegerHolder(move.chance);
|
||||
const power = new NumberHolder(move.power);
|
||||
const chance = new NumberHolder(move.chance);
|
||||
const user = phase.getUserPokemon()!;
|
||||
const target = phase.getFirstTarget()!;
|
||||
const opponentType = target.getTypes()[0];
|
||||
@ -186,7 +176,7 @@ describe("Abilities - Sheer Force", () => {
|
||||
Species.PIDGEOT
|
||||
]);
|
||||
|
||||
const pidgeot = game.scene.getParty()[0];
|
||||
const pidgeot = game.scene.getPlayerParty()[0];
|
||||
const onix = game.scene.getEnemyParty()[0];
|
||||
|
||||
pidgeot.stats[Stat.DEF] = 10000;
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
||||
import * as Utils from "#app/utils";
|
||||
import { NumberHolder } from "#app/utils";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
@ -27,26 +27,22 @@ describe("Abilities - Shield Dust", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
const movesToUse = [ Moves.AIR_SLASH ];
|
||||
game.override.battleType("single");
|
||||
game.override.enemySpecies(Species.ONIX);
|
||||
game.override.enemyAbility(Abilities.SHIELD_DUST);
|
||||
game.override.startingLevel(100);
|
||||
game.override.moveset(movesToUse);
|
||||
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]);
|
||||
game.override.moveset(Moves.AIR_SLASH);
|
||||
game.override.enemyMoveset(Moves.TACKLE);
|
||||
});
|
||||
|
||||
it("Shield Dust", async () => {
|
||||
const moveToUse = Moves.AIR_SLASH;
|
||||
await game.startBattle([
|
||||
Species.PIDGEOT
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.PIDGEOT ]);
|
||||
|
||||
|
||||
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
game.scene.getEnemyPokemon()!.stats[Stat.SPDEF] = 10000;
|
||||
expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
game.move.select(Moves.AIR_SLASH);
|
||||
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
@ -56,7 +52,7 @@ describe("Abilities - Shield Dust", () => {
|
||||
const move = phase.move.getMove();
|
||||
expect(move.id).toBe(Moves.AIR_SLASH);
|
||||
|
||||
const chance = new Utils.IntegerHolder(move.chance);
|
||||
const chance = new NumberHolder(move.chance);
|
||||
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
|
||||
applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getFirstTarget()!, phase.getUserPokemon()!, null, null, false, chance);
|
||||
expect(chance.value).toBe(0);
|
||||
|
@ -43,7 +43,7 @@ describe("Abilities - SHIELDS DOWN", () => {
|
||||
|
||||
await game.startBattle([ Species.MAGIKARP, Species.MINIOR ]);
|
||||
|
||||
const minior = game.scene.getParty().find((p) => p.species.speciesId === Species.MINIOR)!;
|
||||
const minior = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.MINIOR)!;
|
||||
expect(minior).not.toBe(undefined);
|
||||
expect(minior.formIndex).toBe(coreForm);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { StatusEffect } from "#app/data/status-effect";
|
||||
import GameManager from "#app/test/utils/gameManager";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
@ -30,7 +30,7 @@ describe("Abilities - Synchronize", () => {
|
||||
.enemyAbility(Abilities.SYNCHRONIZE)
|
||||
.moveset([ Moves.SPLASH, Moves.THUNDER_WAVE, Moves.SPORE, Moves.PSYCHO_SHIFT ])
|
||||
.ability(Abilities.NO_GUARD);
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
it("does not trigger when no status is applied by opponent Pokemon", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
||||
@ -38,9 +38,9 @@ describe("Abilities - Synchronize", () => {
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(game.scene.getParty()[0].status).toBeUndefined();
|
||||
expect(game.scene.getPlayerPokemon()!.status).toBeUndefined();
|
||||
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
it("sets the status of the source pokemon to Paralysis when paralyzed by it", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
||||
@ -48,10 +48,10 @@ describe("Abilities - Synchronize", () => {
|
||||
game.move.select(Moves.THUNDER_WAVE);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(game.scene.getParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
it("does not trigger on Sleep", async () => {
|
||||
await game.classicMode.startBattle();
|
||||
@ -60,10 +60,10 @@ describe("Abilities - Synchronize", () => {
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(game.scene.getParty()[0].status?.effect).toBeUndefined();
|
||||
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.SLEEP);
|
||||
expect(game.scene.getPlayerPokemon()!.status?.effect).toBeUndefined();
|
||||
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP);
|
||||
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
it("does not trigger when Pokemon is statused by Toxic Spikes", async () => {
|
||||
game.override
|
||||
@ -79,10 +79,10 @@ describe("Abilities - Synchronize", () => {
|
||||
game.doSwitchPokemon(1);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(game.scene.getParty()[0].status?.effect).toBe(StatusEffect.POISON);
|
||||
expect(game.scene.getEnemyParty()[0].status?.effect).toBeUndefined();
|
||||
expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.POISON);
|
||||
expect(game.scene.getEnemyPokemon()!.status?.effect).toBeUndefined();
|
||||
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
it("shows ability even if it fails to set the status of the opponent Pokemon", async () => {
|
||||
await game.classicMode.startBattle([ Species.PIKACHU ]);
|
||||
@ -90,10 +90,10 @@ describe("Abilities - Synchronize", () => {
|
||||
game.move.select(Moves.THUNDER_WAVE);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(game.scene.getParty()[0].status?.effect).toBeUndefined();
|
||||
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.scene.getPlayerPokemon()!.status?.effect).toBeUndefined();
|
||||
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
it("should activate with Psycho Shift after the move clears the status", async () => {
|
||||
game.override.statusEffect(StatusEffect.PARALYSIS);
|
||||
@ -102,8 +102,8 @@ describe("Abilities - Synchronize", () => {
|
||||
game.move.select(Moves.PSYCHO_SHIFT);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(game.scene.getParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS); // keeping old gen < V impl for now since it's buggy otherwise
|
||||
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS); // keeping old gen < V impl for now since it's buggy otherwise
|
||||
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
|
||||
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
|
||||
}, 20000);
|
||||
});
|
||||
});
|
||||
|
245
src/test/abilities/unburden.test.ts
Normal file
245
src/test/abilities/unburden.test.ts
Normal file
@ -0,0 +1,245 @@
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { BerryType } from "#app/enums/berry-type";
|
||||
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
|
||||
|
||||
|
||||
describe("Abilities - Unburden", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.battleType("single")
|
||||
.starterSpecies(Species.TREECKO)
|
||||
.startingLevel(1)
|
||||
.moveset([ Moves.POPULATION_BOMB, Moves.KNOCK_OFF, Moves.PLUCK, Moves.THIEF ])
|
||||
.startingHeldItems([
|
||||
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
|
||||
{ name: "BERRY", count: 2, type: BerryType.APICOT },
|
||||
{ name: "BERRY", count: 2, type: BerryType.LUM },
|
||||
])
|
||||
.enemySpecies(Species.NINJASK)
|
||||
.enemyLevel(100)
|
||||
.enemyMoveset([ Moves.FALSE_SWIPE ])
|
||||
.enemyAbility(Abilities.UNBURDEN)
|
||||
.enemyPassiveAbility(Abilities.NO_GUARD)
|
||||
.enemyHeldItems([
|
||||
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
|
||||
{ name: "BERRY", type: BerryType.LUM, count: 1 },
|
||||
]);
|
||||
});
|
||||
|
||||
it("should activate when a berry is eaten", async () => {
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
playerPokemon.abilityIndex = 2;
|
||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.FALSE_SWIPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when a berry is stolen", async () => {
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.PLUCK);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is knocked off", async () => {
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.KNOCK_OFF);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via attacking ability", async () => {
|
||||
game.override
|
||||
.ability(Abilities.MAGICIAN)
|
||||
.startingHeldItems([
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.POPULATION_BOMB);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via defending ability", async () => {
|
||||
game.override
|
||||
.startingLevel(45)
|
||||
.enemyAbility(Abilities.PICKPOCKET)
|
||||
.startingHeldItems([
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
{ name: "SOUL_DEW", count: 1 },
|
||||
{ name: "LUCKY_EGG", count: 1 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
playerPokemon.abilityIndex = 2;
|
||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.POPULATION_BOMB);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via move", async () => {
|
||||
vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]); // give Thief 100% steal rate
|
||||
game.override.startingHeldItems([
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.THIEF);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should activate when an item is stolen via grip claw", async () => {
|
||||
game.override
|
||||
.startingLevel(5)
|
||||
.startingHeldItems([
|
||||
{ name: "GRIP_CLAW", count: 5 },
|
||||
{ name: "MULTI_LENS", count: 3 },
|
||||
])
|
||||
.enemyHeldItems([
|
||||
{ name: "SOUL_DEW", count: 1 },
|
||||
{ name: "LUCKY_EGG", count: 1 },
|
||||
{ name: "LEFTOVERS", count: 1 },
|
||||
{ name: "GRIP_CLAW", count: 1 },
|
||||
{ name: "MULTI_LENS", count: 1 },
|
||||
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
|
||||
{ name: "BERRY", type: BerryType.LUM, count: 1 },
|
||||
]);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
while (enemyPokemon.getHeldItems().length === enemyHeldItemCt) {
|
||||
game.move.select(Moves.POPULATION_BOMB);
|
||||
await game.toNextTurn();
|
||||
}
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should not activate when a neutralizing ability is present", async () => {
|
||||
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.FALSE_SWIPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
|
||||
});
|
||||
|
||||
it("should activate when a move that consumes a berry is used", async () => {
|
||||
game.override.enemyMoveset([ Moves.STUFF_CHEEKS ]);
|
||||
await game.classicMode.startBattle();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.STUFF_CHEEKS);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
||||
});
|
||||
|
||||
it("should deactivate when a neutralizing gas user enters the field", async () => {
|
||||
game.override
|
||||
.battleType("double")
|
||||
.moveset([ Moves.SPLASH ]);
|
||||
await game.classicMode.startBattle([ Species.TREECKO, Species.MEOWTH, Species.WEEZING ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerParty();
|
||||
const treecko = playerPokemon[0];
|
||||
const weezing = playerPokemon[2];
|
||||
treecko.abilityIndex = 2;
|
||||
weezing.abilityIndex = 1;
|
||||
const playerHeldItems = treecko.getHeldItems().length;
|
||||
const initialPlayerSpeed = treecko.getStat(Stat.SPD);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
||||
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
||||
|
||||
await game.toNextTurn();
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.doSwitchPokemon(2);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
|
||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
|
||||
});
|
||||
|
||||
});
|
@ -42,7 +42,7 @@ describe("Abilities - Wimp Out", () => {
|
||||
});
|
||||
|
||||
function confirmSwitch(): void {
|
||||
const [ pokemon1, pokemon2 ] = game.scene.getParty();
|
||||
const [ pokemon1, pokemon2 ] = game.scene.getPlayerParty();
|
||||
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
|
||||
@ -54,7 +54,7 @@ describe("Abilities - Wimp Out", () => {
|
||||
}
|
||||
|
||||
function confirmNoSwitch(): void {
|
||||
const [ pokemon1, pokemon2 ] = game.scene.getParty();
|
||||
const [ pokemon1, pokemon2 ] = game.scene.getPlayerParty();
|
||||
|
||||
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||
|
||||
@ -135,7 +135,7 @@ describe("Abilities - Wimp Out", () => {
|
||||
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()!.getTag(BattlerTagType.TRAPPED)).toBeUndefined();
|
||||
expect(game.scene.getParty()[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined();
|
||||
expect(game.scene.getPlayerParty()[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined();
|
||||
confirmSwitch();
|
||||
});
|
||||
|
||||
@ -263,7 +263,7 @@ describe("Abilities - Wimp Out", () => {
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(game.scene.getParty()[1].getHpRatio()).toBeGreaterThan(0.5);
|
||||
expect(game.scene.getPlayerParty()[1].getHpRatio()).toBeGreaterThan(0.5);
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.TYRUNT);
|
||||
});
|
||||
@ -424,7 +424,7 @@ describe("Abilities - Wimp Out", () => {
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(game.scene.getParty()[0].getHpRatio()).toEqual(0.51);
|
||||
expect(game.scene.getPlayerParty()[0].getHpRatio()).toEqual(0.51);
|
||||
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.WIMPOD);
|
||||
});
|
||||
@ -522,7 +522,7 @@ describe("Abilities - Wimp Out", () => {
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(game.scene.getParty()[1].status?.effect).toEqual(StatusEffect.POISON);
|
||||
expect(game.scene.getPlayerParty()[1].status?.effect).toEqual(StatusEffect.POISON);
|
||||
confirmSwitch();
|
||||
});
|
||||
|
||||
|
@ -1,29 +1,23 @@
|
||||
import { Stat } from "#enums/stat";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { Status, StatusEffect } from "#app/data/status-effect";
|
||||
import { DamagePhase } from "#app/phases/damage-phase";
|
||||
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
|
||||
import { MessagePhase } from "#app/phases/message-phase";
|
||||
import { PostSummonPhase } from "#app/phases/post-summon-phase";
|
||||
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
|
||||
import { SwitchPhase } from "#app/phases/switch-phase";
|
||||
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
||||
import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
||||
import { TurnStartPhase } from "#app/phases/turn-start-phase";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
||||
import { Status, StatusEffect } from "#app/data/status-effect";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
|
||||
describe("Abilities - ZEN MODE", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
const baseForm = 0;
|
||||
const zenForm = 1;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
@ -37,121 +31,104 @@ describe("Abilities - ZEN MODE", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
const moveToUse = Moves.SPLASH;
|
||||
game.override.battleType("single");
|
||||
game.override.enemySpecies(Species.RATTATA);
|
||||
game.override.enemyAbility(Abilities.HYDRATION);
|
||||
game.override.ability(Abilities.ZEN_MODE);
|
||||
game.override.startingLevel(100);
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]);
|
||||
game.override
|
||||
.battleType("single")
|
||||
.enemySpecies(Species.RATTATA)
|
||||
.enemyAbility(Abilities.HYDRATION)
|
||||
.ability(Abilities.ZEN_MODE)
|
||||
.startingLevel(100)
|
||||
.moveset(Moves.SPLASH)
|
||||
.enemyMoveset(Moves.TACKLE);
|
||||
});
|
||||
|
||||
test(
|
||||
"not enough damage to change form",
|
||||
async () => {
|
||||
const moveToUse = Moves.SPLASH;
|
||||
await game.startBattle([ Species.DARMANITAN ]);
|
||||
game.scene.getParty()[0].stats[Stat.HP] = 100;
|
||||
game.scene.getParty()[0].hp = 100;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
it("shouldn't change form when taking damage if not dropping below 50% HP", async () => {
|
||||
await game.classicMode.startBattle([ Species.DARMANITAN ]);
|
||||
const player = game.scene.getPlayerPokemon()!;
|
||||
player.stats[Stat.HP] = 100;
|
||||
player.hp = 100;
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to(DamagePhase, false);
|
||||
// await game.phaseInterceptor.runFrom(DamagePhase).to(DamagePhase, false);
|
||||
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
|
||||
damagePhase.updateAmount(40);
|
||||
await game.phaseInterceptor.runFrom(DamagePhase).to(TurnEndPhase, false);
|
||||
expect(game.scene.getParty()[0].hp).toBeLessThan(100);
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
},
|
||||
);
|
||||
expect(player.hp).toBeLessThan(100);
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
});
|
||||
|
||||
test(
|
||||
"enough damage to change form",
|
||||
async () => {
|
||||
const moveToUse = Moves.SPLASH;
|
||||
await game.startBattle([ Species.DARMANITAN ]);
|
||||
game.scene.getParty()[0].stats[Stat.HP] = 1000;
|
||||
game.scene.getParty()[0].hp = 100;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
it("should change form when falling below 50% HP", async () => {
|
||||
await game.classicMode.startBattle([ Species.DARMANITAN ]);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
const player = game.scene.getPlayerPokemon()!;
|
||||
player.stats[Stat.HP] = 1000;
|
||||
player.hp = 100;
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to(QuietFormChangePhase);
|
||||
await game.phaseInterceptor.to(TurnInitPhase, false);
|
||||
expect(game.scene.getParty()[0].hp).not.toBe(100);
|
||||
expect(game.scene.getParty()[0].formIndex).not.toBe(0);
|
||||
},
|
||||
);
|
||||
game.move.select(Moves.SPLASH);
|
||||
|
||||
test(
|
||||
"kill pokemon while on zen mode",
|
||||
async () => {
|
||||
const moveToUse = Moves.SPLASH;
|
||||
await game.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]);
|
||||
game.scene.getParty()[0].stats[Stat.HP] = 1000;
|
||||
game.scene.getParty()[0].hp = 100;
|
||||
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to("QuietFormChangePhase");
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
expect(player.hp).not.toBe(100);
|
||||
expect(player.formIndex).toBe(zenForm);
|
||||
});
|
||||
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to(DamagePhase, false);
|
||||
// await game.phaseInterceptor.runFrom(DamagePhase).to(DamagePhase, false);
|
||||
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
|
||||
damagePhase.updateAmount(80);
|
||||
await game.phaseInterceptor.runFrom(DamagePhase).to(QuietFormChangePhase);
|
||||
expect(game.scene.getParty()[0].hp).not.toBe(100);
|
||||
expect(game.scene.getParty()[0].formIndex).not.toBe(0);
|
||||
await game.killPokemon(game.scene.getParty()[0]);
|
||||
expect(game.scene.getParty()[0].isFainted()).toBe(true);
|
||||
await game.phaseInterceptor.run(MessagePhase);
|
||||
await game.phaseInterceptor.run(EnemyCommandPhase);
|
||||
await game.phaseInterceptor.run(TurnStartPhase);
|
||||
game.onNextPrompt("SwitchPhase", Mode.PARTY, () => {
|
||||
game.scene.unshiftPhase(new SwitchSummonPhase(game.scene, SwitchType.SWITCH, 0, 1, false));
|
||||
game.scene.ui.setMode(Mode.MESSAGE);
|
||||
});
|
||||
game.onNextPrompt("SwitchPhase", Mode.MESSAGE, () => {
|
||||
game.endPhase();
|
||||
});
|
||||
await game.phaseInterceptor.run(SwitchPhase);
|
||||
await game.phaseInterceptor.to(PostSummonPhase);
|
||||
expect(game.scene.getParty()[1].formIndex).toBe(1);
|
||||
},
|
||||
);
|
||||
it("should stay zen mode when fainted", async () => {
|
||||
await game.classicMode.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]);
|
||||
const player = game.scene.getPlayerPokemon()!;
|
||||
player.stats[Stat.HP] = 1000;
|
||||
player.hp = 100;
|
||||
expect(player.formIndex).toBe(baseForm);
|
||||
|
||||
test(
|
||||
"check if fainted pokemon switches to base form on arena reset",
|
||||
async () => {
|
||||
const baseForm = 0,
|
||||
zenForm = 1;
|
||||
game.override.startingWave(4);
|
||||
game.override.starterForms({
|
||||
[Species.DARMANITAN]: zenForm,
|
||||
});
|
||||
game.move.select(Moves.SPLASH);
|
||||
|
||||
await game.startBattle([ Species.MAGIKARP, Species.DARMANITAN ]);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to(DamagePhase, false);
|
||||
const damagePhase = game.scene.getCurrentPhase() as DamagePhase;
|
||||
damagePhase.updateAmount(80);
|
||||
await game.phaseInterceptor.to("QuietFormChangePhase");
|
||||
|
||||
const darmanitan = game.scene.getParty().find((p) => p.species.speciesId === Species.DARMANITAN)!;
|
||||
expect(darmanitan).not.toBe(undefined);
|
||||
expect(darmanitan.formIndex).toBe(zenForm);
|
||||
expect(player.hp).not.toBe(100);
|
||||
expect(player.formIndex).toBe(zenForm);
|
||||
|
||||
darmanitan.hp = 0;
|
||||
darmanitan.status = new Status(StatusEffect.FAINT);
|
||||
expect(darmanitan.isFainted()).toBe(true);
|
||||
await game.killPokemon(player);
|
||||
expect(player.isFainted()).toBe(true);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.doKillOpponents();
|
||||
await game.phaseInterceptor.to(TurnEndPhase);
|
||||
game.doSelectModifier();
|
||||
await game.phaseInterceptor.to(QuietFormChangePhase);
|
||||
await game.phaseInterceptor.to("TurnStartPhase");
|
||||
game.onNextPrompt("SwitchPhase", Mode.PARTY, () => {
|
||||
game.scene.unshiftPhase(new SwitchSummonPhase(game.scene, SwitchType.SWITCH, 0, 1, false));
|
||||
game.scene.ui.setMode(Mode.MESSAGE);
|
||||
});
|
||||
game.onNextPrompt("SwitchPhase", Mode.MESSAGE, () => {
|
||||
game.endPhase();
|
||||
});
|
||||
await game.phaseInterceptor.to("PostSummonPhase");
|
||||
|
||||
expect(darmanitan.formIndex).toBe(baseForm);
|
||||
},
|
||||
);
|
||||
expect(game.scene.getPlayerParty()[1].formIndex).toBe(zenForm);
|
||||
});
|
||||
|
||||
it("should switch to base form on arena reset", async () => {
|
||||
game.override.startingWave(4);
|
||||
game.override.starterForms({
|
||||
[Species.DARMANITAN]: zenForm,
|
||||
});
|
||||
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP, Species.DARMANITAN ]);
|
||||
|
||||
const darmanitan = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.DARMANITAN)!;
|
||||
expect(darmanitan.formIndex).toBe(zenForm);
|
||||
|
||||
darmanitan.hp = 0;
|
||||
darmanitan.status = new Status(StatusEffect.FAINT);
|
||||
expect(darmanitan.isFainted()).toBe(true);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.doKillOpponents();
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
game.doSelectModifier();
|
||||
await game.phaseInterceptor.to("QuietFormChangePhase");
|
||||
|
||||
expect(darmanitan.formIndex).toBe(baseForm);
|
||||
});
|
||||
});
|
||||
|
@ -41,8 +41,8 @@ describe("Abilities - ZERO TO HERO", () => {
|
||||
|
||||
await game.startBattle([ Species.FEEBAS, Species.PALAFIN, Species.PALAFIN ]);
|
||||
|
||||
const palafin1 = game.scene.getParty()[1];
|
||||
const palafin2 = game.scene.getParty()[2];
|
||||
const palafin1 = game.scene.getPlayerParty()[1];
|
||||
const palafin2 = game.scene.getPlayerParty()[2];
|
||||
expect(palafin1.formIndex).toBe(heroForm);
|
||||
expect(palafin2.formIndex).toBe(heroForm);
|
||||
palafin2.hp = 0;
|
||||
|
@ -136,9 +136,9 @@ describe("Test Battle Phase", () => {
|
||||
Species.CHANSEY,
|
||||
Species.MEW
|
||||
]);
|
||||
expect(game.scene.getParty()[0].species.speciesId).toBe(Species.CHARIZARD);
|
||||
expect(game.scene.getParty()[1].species.speciesId).toBe(Species.CHANSEY);
|
||||
expect(game.scene.getParty()[2].species.speciesId).toBe(Species.MEW);
|
||||
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(Species.CHARIZARD);
|
||||
expect(game.scene.getPlayerParty()[1].species.speciesId).toBe(Species.CHANSEY);
|
||||
expect(game.scene.getPlayerParty()[2].species.speciesId).toBe(Species.MEW);
|
||||
}, 20000);
|
||||
|
||||
it("test remove random battle seed int", async () => {
|
||||
|
@ -49,7 +49,7 @@ describe("Double Battles", () => {
|
||||
await game.phaseInterceptor.to(BattleEndPhase);
|
||||
game.doSelectModifier();
|
||||
|
||||
const charizard = game.scene.getParty().findIndex(p => p.species.speciesId === Species.CHARIZARD);
|
||||
const charizard = game.scene.getPlayerParty().findIndex(p => p.species.speciesId === Species.CHARIZARD);
|
||||
game.doRevivePokemon(charizard);
|
||||
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
@ -30,7 +30,7 @@ describe("Daily Mode", () => {
|
||||
it("should initialize properly", async () => {
|
||||
await game.dailyMode.runToSummon();
|
||||
|
||||
const party = game.scene.getParty();
|
||||
const party = game.scene.getPlayerParty();
|
||||
expect(party).toHaveLength(3);
|
||||
party.forEach(pkm => {
|
||||
expect(pkm.level).toBe(20);
|
||||
|
@ -35,8 +35,8 @@ describe("Evolution", () => {
|
||||
it("should keep hidden ability after evolving", async () => {
|
||||
await game.classicMode.runToSummon([ Species.EEVEE, Species.TRAPINCH ]);
|
||||
|
||||
const eevee = game.scene.getParty()[0];
|
||||
const trapinch = game.scene.getParty()[1];
|
||||
const eevee = game.scene.getPlayerParty()[0];
|
||||
const trapinch = game.scene.getPlayerParty()[1];
|
||||
eevee.abilityIndex = 2;
|
||||
trapinch.abilityIndex = 2;
|
||||
|
||||
@ -50,8 +50,8 @@ describe("Evolution", () => {
|
||||
it("should keep same ability slot after evolving", async () => {
|
||||
await game.classicMode.runToSummon([ Species.BULBASAUR, Species.CHARMANDER ]);
|
||||
|
||||
const bulbasaur = game.scene.getParty()[0];
|
||||
const charmander = game.scene.getParty()[1];
|
||||
const bulbasaur = game.scene.getPlayerParty()[0];
|
||||
const charmander = game.scene.getPlayerParty()[1];
|
||||
bulbasaur.abilityIndex = 0;
|
||||
charmander.abilityIndex = 1;
|
||||
|
||||
@ -80,8 +80,8 @@ describe("Evolution", () => {
|
||||
nincada.metBiome = -1;
|
||||
|
||||
nincada.evolve(pokemonEvolutions[Species.NINCADA][0], nincada.getSpeciesForm());
|
||||
const ninjask = game.scene.getParty()[0];
|
||||
const shedinja = game.scene.getParty()[1];
|
||||
const ninjask = game.scene.getPlayerParty()[0];
|
||||
const shedinja = game.scene.getPlayerParty()[1];
|
||||
expect(ninjask.abilityIndex).toBe(2);
|
||||
expect(shedinja.abilityIndex).toBe(1);
|
||||
// Regression test for https://github.com/pagefaultgames/pokerogue/issues/3842
|
||||
|
@ -45,7 +45,7 @@ describe("Spec - Pokemon", () => {
|
||||
const zubat = scene.getEnemyPokemon()!;
|
||||
zubat.addToParty(PokeballType.LUXURY_BALL);
|
||||
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
expect(party).toHaveLength(6);
|
||||
party.forEach((pkm, index) =>{
|
||||
expect(pkm.species.speciesId).toBe(index === 5 ? Species.ZUBAT : Species.ABRA);
|
||||
@ -57,7 +57,7 @@ describe("Spec - Pokemon", () => {
|
||||
const zubat = scene.getEnemyPokemon()!;
|
||||
zubat.addToParty(PokeballType.LUXURY_BALL, slotIndex);
|
||||
|
||||
const party = scene.getParty();
|
||||
const party = scene.getPlayerParty();
|
||||
expect(party).toHaveLength(6);
|
||||
party.forEach((pkm, index) =>{
|
||||
expect(pkm.species.speciesId).toBe(index === slotIndex ? Species.ZUBAT : Species.ABRA);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { Stat } from "#enums/stat";
|
||||
import { StatBoosterModifier } from "#app/modifier/modifier";
|
||||
import { NumberHolder, randItem } from "#app/utils";
|
||||
import { Species } from "#enums/species";
|
||||
import { Stat } from "#enums/stat";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phase from "phaser";
|
||||
import * as Utils from "#app/utils";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { StatBoosterModifier } from "#app/modifier/modifier";
|
||||
|
||||
describe("Items - Eviolite", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
@ -28,14 +28,12 @@ describe("Items - Eviolite", () => {
|
||||
});
|
||||
|
||||
it("should provide 50% boost to DEF and SPDEF for unevolved, unfused pokemon", async() => {
|
||||
await game.classicMode.startBattle([
|
||||
Species.PICHU
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.PICHU ]);
|
||||
|
||||
const partyMember = game.scene.getPlayerPokemon()!;
|
||||
|
||||
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
|
||||
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
|
||||
const statValue = new NumberHolder(partyMember.getStat(stat, false));
|
||||
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
|
||||
|
||||
// Ignore other calculations for simplicity
|
||||
@ -51,14 +49,12 @@ describe("Items - Eviolite", () => {
|
||||
});
|
||||
|
||||
it("should not provide a boost for fully evolved, unfused pokemon", async() => {
|
||||
await game.classicMode.startBattle([
|
||||
Species.RAICHU,
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.RAICHU ]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerPokemon()!;
|
||||
|
||||
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
|
||||
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
|
||||
const statValue = new NumberHolder(partyMember.getStat(stat, false));
|
||||
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
|
||||
|
||||
// Ignore other calculations for simplicity
|
||||
@ -75,12 +71,9 @@ describe("Items - Eviolite", () => {
|
||||
});
|
||||
|
||||
it("should provide 50% boost to DEF and SPDEF for completely unevolved, fused pokemon", async() => {
|
||||
await game.classicMode.startBattle([
|
||||
Species.PICHU,
|
||||
Species.CLEFFA
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.PICHU, Species.CLEFFA ]);
|
||||
|
||||
const [ partyMember, ally ] = game.scene.getParty();
|
||||
const [ partyMember, ally ] = game.scene.getPlayerParty();
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -92,7 +85,7 @@ describe("Items - Eviolite", () => {
|
||||
partyMember.fusionLuck = ally.luck;
|
||||
|
||||
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
|
||||
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
|
||||
const statValue = new NumberHolder(partyMember.getStat(stat, false));
|
||||
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
|
||||
|
||||
// Ignore other calculations for simplicity
|
||||
@ -108,12 +101,9 @@ describe("Items - Eviolite", () => {
|
||||
});
|
||||
|
||||
it("should provide 25% boost to DEF and SPDEF for partially unevolved (base), fused pokemon", async() => {
|
||||
await game.classicMode.startBattle([
|
||||
Species.PICHU,
|
||||
Species.CLEFABLE
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.PICHU, Species.CLEFABLE ]);
|
||||
|
||||
const [ partyMember, ally ] = game.scene.getParty();
|
||||
const [ partyMember, ally ] = game.scene.getPlayerParty();
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -125,7 +115,7 @@ describe("Items - Eviolite", () => {
|
||||
partyMember.fusionLuck = ally.luck;
|
||||
|
||||
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
|
||||
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
|
||||
const statValue = new NumberHolder(partyMember.getStat(stat, false));
|
||||
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
|
||||
|
||||
// Ignore other calculations for simplicity
|
||||
@ -141,12 +131,9 @@ describe("Items - Eviolite", () => {
|
||||
});
|
||||
|
||||
it("should provide 25% boost to DEF and SPDEF for partially unevolved (fusion), fused pokemon", async() => {
|
||||
await game.classicMode.startBattle([
|
||||
Species.RAICHU,
|
||||
Species.CLEFFA
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.RAICHU, Species.CLEFFA ]);
|
||||
|
||||
const [ partyMember, ally ] = game.scene.getParty();
|
||||
const [ partyMember, ally ] = game.scene.getPlayerParty();
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -158,7 +145,7 @@ describe("Items - Eviolite", () => {
|
||||
partyMember.fusionLuck = ally.luck;
|
||||
|
||||
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
|
||||
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
|
||||
const statValue = new NumberHolder(partyMember.getStat(stat, false));
|
||||
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
|
||||
|
||||
// Ignore other calculations for simplicity
|
||||
@ -174,12 +161,9 @@ describe("Items - Eviolite", () => {
|
||||
});
|
||||
|
||||
it("should not provide a boost for fully evolved, fused pokemon", async() => {
|
||||
await game.classicMode.startBattle([
|
||||
Species.RAICHU,
|
||||
Species.CLEFABLE
|
||||
]);
|
||||
await game.classicMode.startBattle([ Species.RAICHU, Species.CLEFABLE ]);
|
||||
|
||||
const [ partyMember, ally ] = game.scene.getParty();
|
||||
const [ partyMember, ally ] = game.scene.getPlayerParty();
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -191,7 +175,7 @@ describe("Items - Eviolite", () => {
|
||||
partyMember.fusionLuck = ally.luck;
|
||||
|
||||
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
|
||||
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
|
||||
const statValue = new NumberHolder(partyMember.getStat(stat, false));
|
||||
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
|
||||
|
||||
// Ignore other calculations for simplicity
|
||||
@ -216,14 +200,12 @@ describe("Items - Eviolite", () => {
|
||||
|
||||
const gMaxablePokemon = [ Species.PIKACHU, Species.EEVEE, Species.DURALUDON, Species.MEOWTH ];
|
||||
|
||||
await game.classicMode.startBattle([
|
||||
Utils.randItem(gMaxablePokemon)
|
||||
]);
|
||||
await game.classicMode.startBattle([ randItem(gMaxablePokemon) ]);
|
||||
|
||||
const partyMember = game.scene.getPlayerPokemon()!;
|
||||
|
||||
vi.spyOn(partyMember, "getEffectiveStat").mockImplementation((stat, _opponent?, _move?, _isCritical?) => {
|
||||
const statValue = new Utils.NumberHolder(partyMember.getStat(stat, false));
|
||||
const statValue = new NumberHolder(partyMember.getStat(stat, false));
|
||||
game.scene.applyModifiers(StatBoosterModifier, partyMember.isPlayer(), partyMember, stat, statValue);
|
||||
|
||||
// Ignore other calculations for simplicity
|
||||
|
@ -89,7 +89,7 @@ describe("Items - Leek", () => {
|
||||
Species.PIKACHU,
|
||||
]);
|
||||
|
||||
const [ partyMember, ally ] = game.scene.getParty();
|
||||
const [ partyMember, ally ] = game.scene.getPlayerParty();
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -120,7 +120,7 @@ describe("Items - Leek", () => {
|
||||
species[Utils.randInt(species.length)]
|
||||
]);
|
||||
|
||||
const [ partyMember, ally ] = game.scene.getParty();
|
||||
const [ partyMember, ally ] = game.scene.getPlayerParty();
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
|
@ -35,7 +35,7 @@ describe("Items - Light Ball", () => {
|
||||
Species.PIKACHU
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
// Checking console log to make sure Light Ball is applied when getEffectiveStat (with the appropriate stat) is called
|
||||
partyMember.getEffectiveStat(Stat.DEF);
|
||||
@ -68,7 +68,7 @@ describe("Items - Light Ball", () => {
|
||||
Species.PIKACHU
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const atkStat = partyMember.getStat(Stat.ATK);
|
||||
const spAtkStat = partyMember.getStat(Stat.SPATK);
|
||||
@ -97,8 +97,8 @@ describe("Items - Light Ball", () => {
|
||||
Species.MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -136,8 +136,8 @@ describe("Items - Light Ball", () => {
|
||||
Species.PIKACHU
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -174,7 +174,7 @@ describe("Items - Light Ball", () => {
|
||||
Species.MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const atkStat = partyMember.getStat(Stat.ATK);
|
||||
const spAtkStat = partyMember.getStat(Stat.SPATK);
|
||||
|
@ -35,7 +35,7 @@ describe("Items - Metal Powder", () => {
|
||||
Species.DITTO
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
// Checking console log to make sure Metal Powder is applied when getEffectiveStat (with the appropriate stat) is called
|
||||
partyMember.getEffectiveStat(Stat.DEF);
|
||||
@ -68,7 +68,7 @@ describe("Items - Metal Powder", () => {
|
||||
Species.DITTO
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const defStat = partyMember.getStat(Stat.DEF);
|
||||
|
||||
@ -91,8 +91,8 @@ describe("Items - Metal Powder", () => {
|
||||
Species.MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -124,8 +124,8 @@ describe("Items - Metal Powder", () => {
|
||||
Species.DITTO
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -156,7 +156,7 @@ describe("Items - Metal Powder", () => {
|
||||
Species.MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const defStat = partyMember.getStat(Stat.DEF);
|
||||
|
||||
|
@ -35,7 +35,7 @@ describe("Items - Quick Powder", () => {
|
||||
Species.DITTO
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
// Checking console log to make sure Quick Powder is applied when getEffectiveStat (with the appropriate stat) is called
|
||||
partyMember.getEffectiveStat(Stat.DEF);
|
||||
@ -68,7 +68,7 @@ describe("Items - Quick Powder", () => {
|
||||
Species.DITTO
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const spdStat = partyMember.getStat(Stat.SPD);
|
||||
|
||||
@ -91,8 +91,8 @@ describe("Items - Quick Powder", () => {
|
||||
Species.MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -124,8 +124,8 @@ describe("Items - Quick Powder", () => {
|
||||
Species.DITTO
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -156,7 +156,7 @@ describe("Items - Quick Powder", () => {
|
||||
Species.MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const spdStat = partyMember.getStat(Stat.SPD);
|
||||
|
||||
|
@ -35,7 +35,7 @@ describe("Items - Thick Club", () => {
|
||||
Species.CUBONE
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
// Checking console log to make sure Thick Club is applied when getEffectiveStat (with the appropriate stat) is called
|
||||
partyMember.getEffectiveStat(Stat.DEF);
|
||||
@ -68,7 +68,7 @@ describe("Items - Thick Club", () => {
|
||||
Species.CUBONE
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const atkStat = partyMember.getStat(Stat.ATK);
|
||||
|
||||
@ -90,7 +90,7 @@ describe("Items - Thick Club", () => {
|
||||
Species.MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const atkStat = partyMember.getStat(Stat.ATK);
|
||||
|
||||
@ -112,7 +112,7 @@ describe("Items - Thick Club", () => {
|
||||
Species.ALOLA_MAROWAK
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const atkStat = partyMember.getStat(Stat.ATK);
|
||||
|
||||
@ -139,8 +139,8 @@ describe("Items - Thick Club", () => {
|
||||
Species.PIKACHU
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -176,8 +176,8 @@ describe("Items - Thick Club", () => {
|
||||
species[randSpecies]
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const ally = game.scene.getParty()[1];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
const ally = game.scene.getPlayerParty()[1];
|
||||
|
||||
// Fuse party members (taken from PlayerPokemon.fuse(...) function)
|
||||
partyMember.fusionSpecies = ally.species;
|
||||
@ -208,7 +208,7 @@ describe("Items - Thick Club", () => {
|
||||
Species.PIKACHU
|
||||
]);
|
||||
|
||||
const partyMember = game.scene.getParty()[0];
|
||||
const partyMember = game.scene.getPlayerParty()[0];
|
||||
|
||||
const atkStat = partyMember.getStat(Stat.ATK);
|
||||
|
||||
|
@ -33,7 +33,7 @@ describe("Moves - Aromatherapy", () => {
|
||||
|
||||
it("should cure status effect of the user, its ally, and all party pokemon", async () => {
|
||||
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
|
||||
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getParty();
|
||||
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
|
||||
|
||||
vi.spyOn(leftPlayer, "resetStatus");
|
||||
vi.spyOn(rightPlayer, "resetStatus");
|
||||
@ -79,7 +79,7 @@ describe("Moves - Aromatherapy", () => {
|
||||
it("should not cure status effect of allies ON FIELD with Sap Sipper, should still cure allies in party", async () => {
|
||||
game.override.ability(Abilities.SAP_SIPPER);
|
||||
await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]);
|
||||
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getParty();
|
||||
const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty();
|
||||
|
||||
vi.spyOn(leftPlayer, "resetStatus");
|
||||
vi.spyOn(rightPlayer, "resetStatus");
|
||||
|
@ -95,7 +95,7 @@ describe("Moves - Baton Pass", () => {
|
||||
game.override.enemyMoveset([ Moves.SALT_CURE ]);
|
||||
await game.classicMode.startBattle([ Species.PIKACHU, Species.FEEBAS ]);
|
||||
|
||||
const [ player1, player2 ] = game.scene.getParty();
|
||||
const [ player1, player2 ] = game.scene.getPlayerParty();
|
||||
|
||||
game.move.select(Moves.BATON_PASS);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user