Skip to content

Commit

Permalink
[Refactor/Documentation] Beta Merge 27/07 Cleanup (#3163)
Browse files Browse the repository at this point in the history
Co-authored-by: flx-sta <[email protected]>
Co-authored-by: torranx <[email protected]>
Co-authored-by: DustinLin <[email protected]>
  • Loading branch information
4 people authored Jul 29, 2024
1 parent 4cf445b commit 9ce5453
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default class BattleScene extends SceneBase {
private fieldOverlay: Phaser.GameObjects.Rectangle;
private shopOverlay: Phaser.GameObjects.Rectangle;
private shopOverlayShown: boolean = false;
private shopOverlayOpacity: number = .80;
private shopOverlayOpacity: number = .8;

public modifiers: PersistentModifier[];
private enemyModifiers: PersistentModifier[];
Expand Down Expand Up @@ -1056,7 +1056,7 @@ export default class BattleScene extends SceneBase {
playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, doubleChance));
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
if (trainerConfigs[trainerType].trainerTypeDouble && !(trainerType === TrainerType.TATE || trainerType === TrainerType.LIZA)) {
if (trainerConfigs[trainerType].trainerTypeDouble && ![ TrainerType.TATE, TrainerType.LIZA ].includes(trainerType)) {
doubleTrainer = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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";
}
if (pokemon.species.speciesId === Species.NECROZMA) {
Expand All @@ -308,7 +308,7 @@ export default class Battle {
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";
}
if (pokemon.species.speciesId === Species.ZACIAN || pokemon.species.speciesId === Species.ZAMAZENTA) {
Expand Down
54 changes: 27 additions & 27 deletions src/data/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class BlockItemTheftAbAttr extends AbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]) {
return i18next.t("abilityTriggers:blockItemTheft", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName
});
}
}
Expand Down Expand Up @@ -405,7 +405,7 @@ export class TypeImmunityHealAbAttr extends TypeImmunityAbAttr {
if (!simulated) {
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
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;
Expand Down Expand Up @@ -485,7 +485,7 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:nonSuperEffectiveImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName
});
}
}
Expand Down Expand Up @@ -777,7 +777,7 @@ export class PostDefendTypeChangeAbAttr extends PostDefendAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postDefendTypeChange", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName,
typeName: i18next.t(`pokemonInfo:Type.${Type[pokemon.getTypes(true)[0]]}`)
});
}
Expand Down Expand Up @@ -901,7 +901,7 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postDefendContactDamage", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName
});
}
}
Expand Down Expand Up @@ -999,7 +999,7 @@ export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:postDefendAbilityGive", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName
});
}
}
Expand Down Expand Up @@ -1083,9 +1083,8 @@ export class MoveEffectChanceMultiplierAbAttr extends AbAttr {
* [1]: {@linkcode Moves } Move used by the ability user.
*/
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
//Disable showAbility during getTargetBenefitScore
const showAbility = args[4];
this.showAbility = showAbility;
// Disable showAbility during getTargetBenefitScore
this.showAbility = args[4];
if ((args[0] as Utils.NumberHolder).value <= 0 || (args[1] as Move).id === Moves.ORDER_UP) {
return false;
}
Expand Down Expand Up @@ -1797,7 +1796,7 @@ export class IntimidateImmunityAbAttr extends AbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:intimidateImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName
});
}
}
Expand Down Expand Up @@ -2354,8 +2353,8 @@ export class ProtectStatAbAttr extends PreStatChangeAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:protectStat", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
statName: this.protectedStat !== undefined ? getBattleStatName(this.protectedStat) : "stats", // TODO : Change "stats" to i18next.t("battle:stats") after PR#2600 merged to 'main'
abilityName,
statName: this.protectedStat !== undefined ? getBattleStatName(this.protectedStat) : i18next.t("battle:stats")
});
}
}
Expand Down Expand Up @@ -2421,12 +2420,12 @@ export class StatusEffectImmunityAbAttr extends PreSetStatusAbAttr {
return this.immuneEffects.length ?
i18next.t("abilityTriggers:statusEffectImmunityWithName", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName,
statusEffectName: getStatusEffectDescriptor(args[0] as StatusEffect)
}) :
i18next.t("abilityTriggers:statusEffectImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName
});
}
}
Expand Down Expand Up @@ -2458,7 +2457,7 @@ export class BattlerTagImmunityAbAttr extends PreApplyBattlerTagAbAttr {
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
return i18next.t("abilityTriggers:battlerTagImmunity", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
abilityName: abilityName,
abilityName,
battlerTagName: (args[0] as BattlerTag).getDescriptor()
});
}
Expand Down Expand Up @@ -2844,7 +2843,7 @@ export class PostWeatherLapseHealAbAttr extends PostWeatherLapseAbAttr {
const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
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;
}

Expand All @@ -2864,7 +2863,7 @@ export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr {
applyPostWeatherLapse(pokemon: Pokemon, passive: boolean, weather: Weather, args: any[]): boolean {
const scene = pokemon.scene;
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);
return true;
}
Expand Down Expand Up @@ -2938,7 +2937,7 @@ export class PostTurnStatusHealAbAttr extends PostTurnAbAttr {
const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
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;
}
}
Expand Down Expand Up @@ -3031,10 +3030,11 @@ export class PostTurnLootAbAttr extends PostTurnAbAttr {
) as BerryModifier | undefined;

if (!berryModifier) {
const newBerry = new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1);
if (pokemon.isPlayer()) {
pokemon.scene.addModifier(new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1));
pokemon.scene.addModifier(newBerry);
} else {
pokemon.scene.addEnemyModifier(new BerryModifier(chosenBerry, pokemon.id, chosenBerryType, 1));
pokemon.scene.addEnemyModifier(newBerry);
}
} else if (berryModifier.stackCount < berryModifier.getMaxHeldItemCount(pokemon)) {
berryModifier.stackCount++;
Expand Down Expand Up @@ -3095,7 +3095,7 @@ export class PostTurnHealAbAttr extends PostTurnAbAttr {
const scene = pokemon.scene;
const abilityName = (!passive ? pokemon.getAbility() : pokemon.getPassiveAbility()).name;
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;
}

Expand Down Expand Up @@ -3347,7 +3347,7 @@ export class HealFromBerryUseAbAttr extends AbAttr {
pokemon.scene,
pokemon.getBattlerIndex(),
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
)
);
Expand Down Expand Up @@ -3422,7 +3422,7 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr {
}

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 });
}
}

Expand Down Expand Up @@ -3540,7 +3540,7 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr {
}

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 });
}
}

Expand All @@ -3560,7 +3560,7 @@ export class PostFaintHPDamageAbAttr extends PostFaintAbAttr {
}

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 });
}
}

Expand Down Expand Up @@ -3918,7 +3918,7 @@ export class IceFaceBlockPhysicalAbAttr extends ReceivedMoveDamageMultiplierAbAt
* @returns {string} - The trigger message.
*/
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 });
}
}

Expand Down Expand Up @@ -3993,7 +3993,7 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
pokemon.scene.setPhaseQueueSplice();

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) {
result = await result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/data/battle-stat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import i18next, {ParseKeys} from "i18next";
import i18next, { ParseKeys } from "i18next";

export enum BattleStat {
ATK,
Expand Down Expand Up @@ -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 = (() => {
if (up) {
switch (levels) {
Expand Down
11 changes: 5 additions & 6 deletions src/data/battler-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export enum BattlerTagLapseType {

export class BattlerTag {
public tagType: BattlerTagType;
public lapseType: BattlerTagLapseType[];
public lapseTypes: BattlerTagLapseType[];
public turnCount: number;
public sourceMove: Moves;
public sourceId?: number;

constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType | BattlerTagLapseType[], turnCount: number, sourceMove: Moves, sourceId?: number) {
this.tagType = tagType;
this.lapseType = typeof lapseType === "number" ? [ lapseType ] : lapseType;
this.lapseTypes = Array.isArray(lapseType) ? lapseType : [ lapseType ];
this.turnCount = turnCount;
this.sourceMove = sourceMove;
this.sourceId = sourceId;
Expand Down Expand Up @@ -650,8 +650,7 @@ export class OctolockTag extends TrappedTag {
}

canAdd(pokemon: Pokemon): boolean {
const isOctolocked = pokemon.getTag(BattlerTagType.OCTOLOCK);
return !isOctolocked;
return !pokemon.getTag(BattlerTagType.OCTOLOCK);
}

lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
Expand Down Expand Up @@ -1628,8 +1627,8 @@ export class StockpilingTag extends BattlerTag {
super.loadTag(source);
this.stockpiledCount = source.stockpiledCount || 0;
this.statChangeCounts = {
[BattleStat.DEF]: source.statChangeCounts?.[BattleStat.DEF] || 0,
[BattleStat.SPDEF]: source.statChangeCounts?.[BattleStat.SPDEF] || 0,
[ BattleStat.DEF ]: source.statChangeCounts?.[ BattleStat.DEF ] ?? 0,
[ BattleStat.SPDEF ]: source.statChangeCounts?.[ BattleStat.SPDEF ] ?? 0,
};
}

Expand Down
9 changes: 6 additions & 3 deletions src/data/challenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { Gender } from "./gender";
import { pokemonEvolutions } from "./pokemon-evolutions";
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
* parameters to use when calling the applyChallenges function.
Expand Down Expand Up @@ -689,11 +692,11 @@ export class LowerStarterMaxCostChallenge extends Challenge {
if (overrideValue === undefined) {
overrideValue = this.value;
}
return (10 - overrideValue).toString();
return (DEFAULT_PARTY_MAX_COST - overrideValue).toString();
}

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;
return true;
}
Expand Down Expand Up @@ -723,7 +726,7 @@ export class LowerStarterPointsChallenge extends Challenge {
if (overrideValue === undefined) {
overrideValue = this.value;
}
return (10 - overrideValue).toString();
return (DEFAULT_PARTY_MAX_COST - overrideValue).toString();
}

applyStarterPoints(points: Utils.NumberHolder): boolean {
Expand Down
6 changes: 3 additions & 3 deletions src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5825,7 +5825,7 @@ export class ResistLastMoveTypeAttr extends MoveEffectAttr {
getCondition(): MoveConditionFunc {
return (user, target, move) => {
const moveHistory = target.getLastXMoves();
return !!moveHistory.length;
return moveHistory.length !== 0;
};
}
}
Expand Down Expand Up @@ -8691,8 +8691,8 @@ export function initMoves() {
new AttackMove(Moves.MALIGNANT_CHAIN, Type.POISON, MoveCategory.SPECIAL, 100, 100, 5, 50, 0, 9)
.attr(StatusEffectAttr, StatusEffect.TOXIC)
);
allMoves.map(m=>{
if (m.getAttrs(StatChangeAttr).some(a=> a.selfTarget && a.levels < 0)) {
allMoves.map(m => {
if (m.getAttrs(StatChangeAttr).some(a => a.selfTarget && a.levels < 0)) {
selfStatLowerMoves.push(m.id);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/data/pokemon-forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class SpeciesFormChange {
public formKey: string;
public trigger: SpeciesFormChangeTrigger;
public quiet: boolean;
public conditions: SpeciesFormChangeCondition[];
public readonly conditions: SpeciesFormChangeCondition[];

constructor(speciesId: Species, preFormKey: string, evoFormKey: string, trigger: SpeciesFormChangeTrigger, quiet: boolean = false, ...conditions: SpeciesFormChangeCondition[]) {
this.speciesId = speciesId;
Expand Down Expand Up @@ -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.
* 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
*/
function getSpeciesDependentFormChangeCondition(species: Species): SpeciesFormChangeCondition {
Expand Down
Loading

0 comments on commit 9ce5453

Please sign in to comment.