[Refactor/Documentation] Beta Merge 27/07 Cleanup (#3163)

Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
Co-authored-by: torranx <68144167+torranx@users.noreply.github.com>
Co-authored-by: DustinLin <39450497+DustinLin@users.noreply.github.com>
This commit is contained in:
Amani H. 2024-07-29 16:47:37 -04:00 committed by GitHub
parent 4cf445b780
commit 9ce5453054
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 64 additions and 64 deletions

View File

@ -230,7 +230,7 @@ export default class BattleScene extends SceneBase {
private fieldOverlay: Phaser.GameObjects.Rectangle; private fieldOverlay: Phaser.GameObjects.Rectangle;
private shopOverlay: Phaser.GameObjects.Rectangle; private shopOverlay: Phaser.GameObjects.Rectangle;
private shopOverlayShown: boolean = false; private shopOverlayShown: boolean = false;
private shopOverlayOpacity: number = .80; private shopOverlayOpacity: number = .8;
public modifiers: PersistentModifier[]; public modifiers: PersistentModifier[];
private enemyModifiers: PersistentModifier[]; private enemyModifiers: PersistentModifier[];
@ -1056,7 +1056,7 @@ export default class BattleScene extends SceneBase {
playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, doubleChance)); playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, doubleChance));
doubleTrainer = !Utils.randSeedInt(doubleChance.value); doubleTrainer = !Utils.randSeedInt(doubleChance.value);
// Add a check that special trainers can't be double except for tate and liza - they should use the normal double chance // Add a check that special trainers can't be double except for tate and liza - they should use the normal double chance
if (trainerConfigs[trainerType].trainerTypeDouble && !(trainerType === TrainerType.TATE || trainerType === TrainerType.LIZA)) { if (trainerConfigs[trainerType].trainerTypeDouble && ![ TrainerType.TATE, TrainerType.LIZA ].includes(trainerType)) {
doubleTrainer = false; doubleTrainer = false;
} }
} }

View File

@ -294,7 +294,7 @@ export default class Battle {
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) { 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"; return "battle_legendary_tapu";
} }
if (pokemon.species.speciesId === Species.COSMOG || pokemon.species.speciesId === Species.COSMOEM || pokemon.species.speciesId === Species.SOLGALEO || pokemon.species.speciesId === Species.LUNALA) { if ([ Species.COSMOG, Species.COSMOEM, Species.SOLGALEO, Species.LUNALA ].includes(pokemon.species.speciesId)) {
return "battle_legendary_sol_lun"; return "battle_legendary_sol_lun";
} }
if (pokemon.species.speciesId === Species.NECROZMA) { if (pokemon.species.speciesId === Species.NECROZMA) {
@ -308,7 +308,7 @@ export default class Battle {
return "battle_legendary_ultra_nec"; return "battle_legendary_ultra_nec";
} }
} }
if (pokemon.species.speciesId === Species.NIHILEGO || pokemon.species.speciesId === Species.BUZZWOLE || pokemon.species.speciesId === Species.PHEROMOSA || pokemon.species.speciesId === Species.XURKITREE || pokemon.species.speciesId === Species.CELESTEELA || pokemon.species.speciesId === Species.KARTANA || pokemon.species.speciesId === Species.GUZZLORD || pokemon.species.speciesId === Species.POIPOLE || pokemon.species.speciesId === Species.NAGANADEL || pokemon.species.speciesId === Species.STAKATAKA || pokemon.species.speciesId === Species.BLACEPHALON) { 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"; return "battle_legendary_ub";
} }
if (pokemon.species.speciesId === Species.ZACIAN || pokemon.species.speciesId === Species.ZAMAZENTA) { if (pokemon.species.speciesId === Species.ZACIAN || pokemon.species.speciesId === Species.ZAMAZENTA) {

View File

@ -286,7 +286,7 @@ export class BlockItemTheftAbAttr extends AbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]) { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]) {
return i18next.t("abilityTriggers:blockItemTheft", { return i18next.t("abilityTriggers:blockItemTheft", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName
}); });
} }
} }
@ -405,7 +405,7 @@ export class TypeImmunityHealAbAttr extends TypeImmunityAbAttr {
if (!simulated) { if (!simulated) {
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(),
Math.max(Math.floor(pokemon.getMaxHp() / 4), 1), i18next.t("abilityTriggers:typeImmunityHeal", {pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName}), true)); Math.max(Math.floor(pokemon.getMaxHp() / 4), 1), i18next.t("abilityTriggers:typeImmunityHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true));
} }
} }
return true; return true;
@ -485,7 +485,7 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:nonSuperEffectiveImmunity", { return i18next.t("abilityTriggers:nonSuperEffectiveImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName
}); });
} }
} }
@ -777,7 +777,7 @@ export class PostDefendTypeChangeAbAttr extends PostDefendAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postDefendTypeChange", { return i18next.t("abilityTriggers:postDefendTypeChange", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName,
typeName: i18next.t(`pokemonInfo:Type.${Type[pokemon.getTypes(true)[0]]}`) typeName: i18next.t(`pokemonInfo:Type.${Type[pokemon.getTypes(true)[0]]}`)
}); });
} }
@ -901,7 +901,7 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postDefendContactDamage", { return i18next.t("abilityTriggers:postDefendContactDamage", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName
}); });
} }
} }
@ -999,7 +999,7 @@ export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postDefendAbilityGive", { return i18next.t("abilityTriggers:postDefendAbilityGive", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName
}); });
} }
} }
@ -1083,9 +1083,8 @@ export class MoveEffectChanceMultiplierAbAttr extends AbAttr {
* [1]: {@linkcode Moves } Move used by the ability user. * [1]: {@linkcode Moves } Move used by the ability user.
*/ */
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
//Disable showAbility during getTargetBenefitScore // Disable showAbility during getTargetBenefitScore
const showAbility = args[4]; this.showAbility = args[4];
this.showAbility = showAbility;
if ((args[0] as Utils.NumberHolder).value <= 0 || (args[1] as Move).id === Moves.ORDER_UP) { if ((args[0] as Utils.NumberHolder).value <= 0 || (args[1] as Move).id === Moves.ORDER_UP) {
return false; return false;
} }
@ -1797,7 +1796,7 @@ export class IntimidateImmunityAbAttr extends AbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:intimidateImmunity", { return i18next.t("abilityTriggers:intimidateImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName
}); });
} }
} }
@ -2354,8 +2353,8 @@ export class ProtectStatAbAttr extends PreStatChangeAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:protectStat", { return i18next.t("abilityTriggers:protectStat", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName,
statName: this.protectedStat !== undefined ? getBattleStatName(this.protectedStat) : "stats", // TODO : Change "stats" to i18next.t("battle:stats") after PR#2600 merged to 'main' statName: this.protectedStat !== undefined ? getBattleStatName(this.protectedStat) : i18next.t("battle:stats")
}); });
} }
} }
@ -2421,12 +2420,12 @@ export class StatusEffectImmunityAbAttr extends PreSetStatusAbAttr {
return this.immuneEffects.length ? return this.immuneEffects.length ?
i18next.t("abilityTriggers:statusEffectImmunityWithName", { i18next.t("abilityTriggers:statusEffectImmunityWithName", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName,
statusEffectName: getStatusEffectDescriptor(args[0] as StatusEffect) statusEffectName: getStatusEffectDescriptor(args[0] as StatusEffect)
}) : }) :
i18next.t("abilityTriggers:statusEffectImmunity", { i18next.t("abilityTriggers:statusEffectImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName
}); });
} }
} }
@ -2458,7 +2457,7 @@ export class BattlerTagImmunityAbAttr extends PreApplyBattlerTagAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:battlerTagImmunity", { return i18next.t("abilityTriggers:battlerTagImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName, abilityName,
battlerTagName: (args[0] as BattlerTag).getDescriptor() battlerTagName: (args[0] as BattlerTag).getDescriptor()
}); });
} }
@ -2844,7 +2843,7 @@ export class PostWeatherLapseHealAbAttr extends PostWeatherLapseAbAttr {
const scene = pokemon.scene; const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(),
Math.max(Math.floor(pokemon.getMaxHp() / (16 / this.healFactor)), 1), i18next.t("abilityTriggers:postWeatherLapseHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName }), true)); Math.max(Math.floor(pokemon.getMaxHp() / (16 / this.healFactor)), 1), i18next.t("abilityTriggers:postWeatherLapseHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true));
return true; return true;
} }
@ -2864,7 +2863,7 @@ export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr {
applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, weather: Weather, args: any[]): boolean { applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, weather: Weather, args: any[]): boolean {
const scene = pokemon.scene; const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
scene.queueMessage(i18next.t("abilityTriggers:postWeatherLapseDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName })); scene.queueMessage(i18next.t("abilityTriggers:postWeatherLapseDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }));
pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER); pokemon.damageAndUpdate(Math.ceil(pokemon.getMaxHp() / (16 / this.damageFactor)), HitResult.OTHER);
return true; return true;
} }
@ -2938,7 +2937,7 @@ export class PostTurnStatusHealAbAttr extends PostTurnAbAttr {
const scene = pokemon.scene; const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(),
Math.max(Math.floor(pokemon.getMaxHp() / 8), 1), i18next.t("abilityTriggers:poisonHeal", { pokemonName: getPokemonNameWithAffix(pokemon), abilityName: abilityName}), true)); Math.max(Math.floor(pokemon.getMaxHp() / 8), 1), i18next.t("abilityTriggers:poisonHeal", { pokemonName: getPokemonNameWithAffix(pokemon), abilityName }), true));
return true; return true;
} }
} }
@ -3031,10 +3030,11 @@ export class PostTurnLootAbAttr extends PostTurnAbAttr {
) as BerryModifier | undefined; ) as BerryModifier | undefined;
if (!berryModifier) { if (!berryModifier) {
const newBerry = new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1);
if (pokemon.isPlayer()) { if (pokemon.isPlayer()) {
pokemon.scene.addModifier(new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1)); pokemon.scene.addModifier(newBerry);
} else { } else {
pokemon.scene.addEnemyModifier(new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1)); pokemon.scene.addEnemyModifier(newBerry);
} }
} else if (berryModifier.stackCount < berryModifier.getMaxHeldItemCount(pokemon)) { } else if (berryModifier.stackCount < berryModifier.getMaxHeldItemCount(pokemon)) {
berryModifier.stackCount++; berryModifier.stackCount++;
@ -3095,7 +3095,7 @@ export class PostTurnHealAbAttr extends PostTurnAbAttr {
const scene = pokemon.scene; const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name; const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(),
Math.max(Math.floor(pokemon.getMaxHp() / 16), 1), i18next.t("abilityTriggers:postTurnHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName }), true)); Math.max(Math.floor(pokemon.getMaxHp() / 16), 1), i18next.t("abilityTriggers:postTurnHeal", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }), true));
return true; return true;
} }
@ -3347,7 +3347,7 @@ export class HealFromBerryUseAbAttr extends AbAttr {
pokemon.scene, pokemon.scene,
pokemon.getBattlerIndex(), pokemon.getBattlerIndex(),
Math.max(Math.floor(pokemon.getMaxHp() * this.healPercent), 1), Math.max(Math.floor(pokemon.getMaxHp() * this.healPercent), 1),
i18next.t("abilityTriggers:healFromBerryUse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName }), i18next.t("abilityTriggers:healFromBerryUse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName }),
true true
) )
); );
@ -3422,7 +3422,7 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr {
} }
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:arenaTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName }); return i18next.t("abilityTriggers:arenaTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName });
} }
} }
@ -3540,7 +3540,7 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr {
} }
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postFaintContactDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName }); return i18next.t("abilityTriggers:postFaintContactDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName });
} }
} }
@ -3560,7 +3560,7 @@ export class PostFaintHPDamageAbAttr extends PostFaintAbAttr {
} }
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postFaintHpDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: abilityName }); return i18next.t("abilityTriggers:postFaintHpDamage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName });
} }
} }
@ -3918,7 +3918,7 @@ export class IceFaceBlockPhysicalAbAttr extends ReceivedMoveDamageMultiplierAbAt
* @returns {string} - The trigger message. * @returns {string} - The trigger message.
*/ */
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:iceFaceAvoidedDamage", { pokemonName: getPokemonNameWithAffix(pokemon), abilityName: abilityName }); return i18next.t("abilityTriggers:iceFaceAvoidedDamage", { pokemonName: getPokemonNameWithAffix(pokemon), abilityName });
} }
} }
@ -3993,7 +3993,7 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
pokemon.scene.setPhaseQueueSplice(); pokemon.scene.setPhaseQueueSplice();
let result = applyFunc(attr, passive); let result = applyFunc(attr, passive);
// TODO Remove this when promises get reworked PR#924 // TODO Remove this when promises get reworked
if (result instanceof Promise) { if (result instanceof Promise) {
result = await result; result = await result;
} }

View File

@ -1,4 +1,4 @@
import i18next, {ParseKeys} from "i18next"; import i18next, { ParseKeys } from "i18next";
export enum BattleStat { export enum BattleStat {
ATK, ATK,
@ -32,7 +32,7 @@ export function getBattleStatName(stat: BattleStat) {
} }
} }
export function getBattleStatLevelChangeDescription(pokemonNameWithAffix: string, stats: string, levels: integer, up: boolean, count: integer = 1) { export function getBattleStatLevelChangeDescription(pokemonNameWithAffix: string, stats: string, levels: integer, up: boolean, count: number = 1) {
const stringKey = (() => { const stringKey = (() => {
if (up) { if (up) {
switch (levels) { switch (levels) {

View File

@ -31,14 +31,14 @@ export enum BattlerTagLapseType {
export class BattlerTag { export class BattlerTag {
public tagType: BattlerTagType; public tagType: BattlerTagType;
public lapseType: BattlerTagLapseType[]; public lapseTypes: BattlerTagLapseType[];
public turnCount: number; public turnCount: number;
public sourceMove: Moves; public sourceMove: Moves;
public sourceId?: number; public sourceId?: number;
constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType | BattlerTagLapseType[], turnCount: number, sourceMove: Moves, sourceId?: number) { constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType | BattlerTagLapseType[], turnCount: number, sourceMove: Moves, sourceId?: number) {
this.tagType = tagType; this.tagType = tagType;
this.lapseType = typeof lapseType === "number" ? [ lapseType ] : lapseType; this.lapseTypes = Array.isArray(lapseType) ? lapseType : [ lapseType ];
this.turnCount = turnCount; this.turnCount = turnCount;
this.sourceMove = sourceMove; this.sourceMove = sourceMove;
this.sourceId = sourceId; this.sourceId = sourceId;
@ -650,8 +650,7 @@ export class OctolockTag extends TrappedTag {
} }
canAdd(pokemon: Pokemon): boolean { canAdd(pokemon: Pokemon): boolean {
const isOctolocked = pokemon.getTag(BattlerTagType.OCTOLOCK); return !pokemon.getTag(BattlerTagType.OCTOLOCK);
return !isOctolocked;
} }
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
@ -1628,8 +1627,8 @@ export class StockpilingTag extends BattlerTag {
super.loadTag(source); super.loadTag(source);
this.stockpiledCount = source.stockpiledCount || 0; this.stockpiledCount = source.stockpiledCount || 0;
this.statChangeCounts = { this.statChangeCounts = {
[BattleStat.DEF]: source.statChangeCounts?.[BattleStat.DEF] || 0, [ BattleStat.DEF ]: source.statChangeCounts?.[ BattleStat.DEF ] ?? 0,
[BattleStat.SPDEF]: source.statChangeCounts?.[BattleStat.SPDEF] || 0, [ BattleStat.SPDEF ]: source.statChangeCounts?.[ BattleStat.SPDEF ] ?? 0,
}; };
} }

View File

@ -17,6 +17,9 @@ import { Gender } from "./gender";
import { pokemonEvolutions } from "./pokemon-evolutions"; import { pokemonEvolutions } from "./pokemon-evolutions";
import { pokemonFormChanges } from "./pokemon-forms"; import { pokemonFormChanges } from "./pokemon-forms";
/** A constant for the default max cost of the starting party before a run */
const DEFAULT_PARTY_MAX_COST = 10;
/** /**
* An enum for all the challenge types. The parameter entries on these describe the * An enum for all the challenge types. The parameter entries on these describe the
* parameters to use when calling the applyChallenges function. * parameters to use when calling the applyChallenges function.
@ -689,11 +692,11 @@ export class LowerStarterMaxCostChallenge extends Challenge {
if (overrideValue === undefined) { if (overrideValue === undefined) {
overrideValue = this.value; overrideValue = this.value;
} }
return (10 - overrideValue).toString(); return (DEFAULT_PARTY_MAX_COST - overrideValue).toString();
} }
applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder): boolean { applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder): boolean {
if (speciesStarters[pokemon.speciesId] > 10 - this.value) { if (speciesStarters[pokemon.speciesId] > DEFAULT_PARTY_MAX_COST - this.value) {
valid.value = false; valid.value = false;
return true; return true;
} }
@ -723,7 +726,7 @@ export class LowerStarterPointsChallenge extends Challenge {
if (overrideValue === undefined) { if (overrideValue === undefined) {
overrideValue = this.value; overrideValue = this.value;
} }
return (10 - overrideValue).toString(); return (DEFAULT_PARTY_MAX_COST - overrideValue).toString();
} }
applyStarterPoints(points: Utils.NumberHolder): boolean { applyStarterPoints(points: Utils.NumberHolder): boolean {

View File

@ -5825,7 +5825,7 @@ export class ResistLastMoveTypeAttr extends MoveEffectAttr {
getCondition(): MoveConditionFunc { getCondition(): MoveConditionFunc {
return (user, target, move) => { return (user, target, move) => {
const moveHistory = target.getLastXMoves(); const moveHistory = target.getLastXMoves();
return !!moveHistory.length; return moveHistory.length !== 0;
}; };
} }
} }
@ -8691,8 +8691,8 @@ export function initMoves() {
new AttackMove(Moves.MALIGNANT_CHAIN, Type.POISON, MoveCategory.SPECIAL, 100, 100, 5, 50, 0, 9) new AttackMove(Moves.MALIGNANT_CHAIN, Type.POISON, MoveCategory.SPECIAL, 100, 100, 5, 50, 0, 9)
.attr(StatusEffectAttr, StatusEffect.TOXIC) .attr(StatusEffectAttr, StatusEffect.TOXIC)
); );
allMoves.map(m=>{ allMoves.map(m => {
if (m.getAttrs(StatChangeAttr).some(a=> a.selfTarget && a.levels < 0)) { if (m.getAttrs(StatChangeAttr).some(a => a.selfTarget && a.levels < 0)) {
selfStatLowerMoves.push(m.id); selfStatLowerMoves.push(m.id);
} }
}); });

View File

@ -138,7 +138,7 @@ export class SpeciesFormChange {
public formKey: string; public formKey: string;
public trigger: SpeciesFormChangeTrigger; public trigger: SpeciesFormChangeTrigger;
public quiet: boolean; public quiet: boolean;
public conditions: SpeciesFormChangeCondition[]; public readonly conditions: SpeciesFormChangeCondition[];
constructor(speciesId: Species, preFormKey: string, evoFormKey: string, trigger: SpeciesFormChangeTrigger, quiet: boolean = false, ...conditions: SpeciesFormChangeCondition[]) { constructor(speciesId: Species, preFormKey: string, evoFormKey: string, trigger: SpeciesFormChangeTrigger, quiet: boolean = false, ...conditions: SpeciesFormChangeCondition[]) {
this.speciesId = speciesId; this.speciesId = speciesId;
@ -378,7 +378,7 @@ export function getSpeciesFormChangeMessage(pokemon: Pokemon, formChange: Specie
/** /**
* Gives a condition for form changing checking if a species is registered as caught in the player's dex data. * Gives a condition for form changing checking if a species is registered as caught in the player's dex data.
* Used for fusion forms such as Kyurem and Necrozma. * Used for fusion forms such as Kyurem and Necrozma.
* @param species * @param species {@linkcode Species}
* @returns A {@linkcode SpeciesFormChangeCondition} checking if that species is registered as caught * @returns A {@linkcode SpeciesFormChangeCondition} checking if that species is registered as caught
*/ */
function getSpeciesDependentFormChangeCondition(species: Species): SpeciesFormChangeCondition { function getSpeciesDependentFormChangeCondition(species: Species): SpeciesFormChangeCondition {

View File

@ -61,7 +61,7 @@ export class Terrain {
const priority = new Utils.IntegerHolder(move.priority); const priority = new Utils.IntegerHolder(move.priority);
applyAbAttrs(IncrementMovePriorityAbAttr, user, null, move, priority); applyAbAttrs(IncrementMovePriorityAbAttr, user, null, move, priority);
// Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain // Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain
return priority.value > 0 && user.getOpponents().filter(o => targets.includes(o.getBattlerIndex()) && o.isGrounded()).length > 0; return priority.value > 0 && user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded());
} }
} }

View File

@ -505,7 +505,7 @@ export function getTypeDamageMultiplier(attackType: integer, defType: integer):
* Retrieve the types resisting a given type * Retrieve the types resisting a given type
* @returns An array populated with Types, or an empty array if no resistances exist (Unknown or Stellar type) * @returns An array populated with Types, or an empty array if no resistances exist (Unknown or Stellar type)
*/ */
export function getTypeResistances(type: integer): Type[] { export function getTypeResistances(type: number): Type[] {
switch (type) { switch (type) {
case Type.NORMAL: case Type.NORMAL:
return [Type.ROCK, Type.STEEL, Type.GHOST]; return [Type.ROCK, Type.STEEL, Type.GHOST];

View File

@ -638,7 +638,9 @@ export class Arena {
} }
} }
/** Clears terrain and arena tags when entering new biome or trainer battle. */ /**
* Clears terrain and arena tags when entering new biome or trainer battle.
*/
resetArenaEffects(): void { resetArenaEffects(): void {
this.trySetTerrain(TerrainType.NONE, false, true); this.trySetTerrain(TerrainType.NONE, false, true);
this.removeAllTags(); this.removeAllTags();

View File

@ -1241,14 +1241,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
const immuneTags = this.findTags(tag => tag instanceof TypeImmuneTag && tag.immuneType === moveType); const immuneTags = this.findTags(tag => tag instanceof TypeImmuneTag && tag.immuneType === moveType);
immuneTags.forEach(tag => { for (const tag of immuneTags) {
if (move !== undefined) { if (move && !move.getAttrs(HitsTagAttr).some(attr => attr.tagType === tag.tagType)) {
const hitsTagAttrs = move.getAttrs(HitsTagAttr).filter(attr => attr.tagType === tag.tagType); multiplier = 0;
if (hitsTagAttrs.length === 0) { break;
multiplier = 0;
}
} }
}); }
return multiplier; return multiplier;
} }
@ -1949,7 +1947,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
const targetCount = getMoveTargets(source, move.id).targets.length; const targetCount = getMoveTargets(source, move.id).targets.length;
const targetMultiplier = targetCount > 1 ? 0.75 : 1; const targetMultiplier = targetCount > 1 ? 0.75 : 1; // 25% damage debuff on multi-target hits (even if it's immune)
applyMoveAttrs(VariableAtkAttr, source, this, move, sourceAtk); applyMoveAttrs(VariableAtkAttr, source, this, move, sourceAtk);
applyMoveAttrs(VariableDefAttr, source, this, move, targetDef); applyMoveAttrs(VariableDefAttr, source, this, move, targetDef);
@ -2282,7 +2280,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
lapseTags(lapseType: BattlerTagLapseType): void { lapseTags(lapseType: BattlerTagLapseType): void {
const tags = this.summonData.tags; const tags = this.summonData.tags;
tags.filter(t => lapseType === BattlerTagLapseType.FAINT || ((t.lapseType.some(lType => lType === lapseType)) && !(t.lapse(this, lapseType)))).forEach(t => { tags.filter(t => lapseType === BattlerTagLapseType.FAINT || ((t.lapseTypes.some(lType => lType === lapseType)) && !(t.lapse(this, lapseType)))).forEach(t => {
t.onRemove(this); t.onRemove(this);
tags.splice(tags.indexOf(t), 1); tags.splice(tags.indexOf(t), 1);
}); });

View File

@ -572,7 +572,7 @@ export class PokemonLevelIncrementModifierType extends PokemonModifierType {
if (hasCandyJar) { if (hasCandyJar) {
levels += hasCandyJar.stackCount; levels += hasCandyJar.stackCount;
} }
return i18next.t("modifierType:ModifierType.PokemonLevelIncrementModifierType.description", {levels }); return i18next.t("modifierType:ModifierType.PokemonLevelIncrementModifierType.description", { levels });
} }
} }
@ -1569,7 +1569,7 @@ const modifierPool: ModifierPool = {
p => !p.getHeldItems().some(i => i instanceof Modifiers.PokemonResetNegativeStatStageModifier && i.stackCount >= i.getMaxHeldItemCount(p)) && p => !p.getHeldItems().some(i => i instanceof Modifiers.PokemonResetNegativeStatStageModifier && i.stackCount >= i.getMaxHeldItemCount(p)) &&
(checkedAbilities.some(a => p.hasAbility(a, false, true)) || p.getMoveset(true).some(m => selfStatLowerMoves.includes(m.moveId)))).length; (checkedAbilities.some(a => p.hasAbility(a, false, true)) || p.getMoveset(true).some(m => selfStatLowerMoves.includes(m.moveId)))).length;
// If a party member has one of the above moves or abilities and doesn't have max herbs, the herb will appear more frequently // If a party member has one of the above moves or abilities and doesn't have max herbs, the herb will appear more frequently
return 3*(weightMultiplier? 2: 1)+(weightMultiplier? weightMultiplier-1: 0); return 3 * (weightMultiplier ? 2: 1) + (weightMultiplier ? weightMultiplier - 1 : 0);
}, 10), }, 10),
new WeightedModifierType(modifierTypes.REVIVER_SEED, 4), new WeightedModifierType(modifierTypes.REVIVER_SEED, 4),
new WeightedModifierType(modifierTypes.CANDY_JAR, 5), new WeightedModifierType(modifierTypes.CANDY_JAR, 5),

View File

@ -1588,8 +1588,6 @@ export class SwitchSummonPhase extends SummonPhase {
} }
} }
// if doReturn === False OR slotIndex !== -1 (slotIndex is valid) and the pokemon doesn't exist/is false
// then switchAndSummon(), manually pick pokemon to switch into
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.getParty() : this.scene.getEnemyParty())[this.slotIndex])) {
if (this.player) { if (this.player) {
return this.switchAndSummon(); return this.switchAndSummon();
@ -3321,7 +3319,7 @@ export class StatChangePhase extends PokemonPhase {
applyPostStatChangeAbAttrs(PostStatChangeAbAttr, pokemon, filteredStats, this.levels, this.selfTarget); applyPostStatChangeAbAttrs(PostStatChangeAbAttr, pokemon, filteredStats, this.levels, this.selfTarget);
//Look for any other stat change phases; if this is the last one, do White Herb check // Look for any other stat change phases; if this is the last one, do White Herb check
const existingPhase = this.scene.findPhase(p => p instanceof StatChangePhase && p.battlerIndex === this.battlerIndex); const existingPhase = this.scene.findPhase(p => p instanceof StatChangePhase && p.battlerIndex === this.battlerIndex);
if (!(existingPhase instanceof StatChangePhase)) { if (!(existingPhase instanceof StatChangePhase)) {
// Apply White Herb if needed // Apply White Herb if needed