Update ability.ts

This commit is contained in:
NxKarim 2024-04-17 18:14:40 -06:00
parent 80673b14b1
commit c866cecca4

View File

@ -362,7 +362,7 @@ class TypeImmunityStatChangeAbAttr extends TypeImmunityAbAttr {
cancelled.value = true; cancelled.value = true;
const simulated = args.length > 1 && args[1]; const simulated = args.length > 1 && args[1];
if (!simulated) if (!simulated)
pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [this.stat], this.levels)); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels));
} }
return ret; return ret;
@ -462,7 +462,7 @@ export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr {
const attackPriority = new Utils.IntegerHolder(move.getMove().priority); const attackPriority = new Utils.IntegerHolder(move.getMove().priority);
applyAbAttrs(IncrementMovePriorityAbAttr, attacker, null, move.getMove(), attackPriority); applyAbAttrs(IncrementMovePriorityAbAttr, attacker, null, move.getMove(), attackPriority);
if (attackPriority.value > 0 && !move.getMove().isMultiTarget()) { if(attackPriority.value > 0 && !move.getMove().isMultiTarget()) {
cancelled.value = true; cancelled.value = true;
return true; return true;
} }
@ -513,7 +513,7 @@ export class MoveImmunityStatChangeAbAttr extends MoveImmunityAbAttr {
applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean { applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const ret = super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args) const ret = super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args)
if (ret) { if (ret) {
pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [this.stat], this.levels)); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels));
} }
return ret; return ret;
@ -537,7 +537,7 @@ export class PostDefendStatChangeAbAttr extends PostDefendAbAttr {
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean {
if (this.condition(pokemon, attacker, move.getMove())) { if (this.condition(pokemon, attacker, move.getMove())) {
pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, (this.selfTarget ? pokemon : attacker).getBattlerIndex(), true, [this.stat], this.levels)); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, (this.selfTarget ? pokemon : attacker).getBattlerIndex(), true, [ this.stat ], this.levels));
return true; return true;
} }
@ -570,7 +570,7 @@ export class PostDefendTypeChangeAbAttr extends PostDefendAbAttr {
const type = move.getMove().type; const type = move.getMove().type;
const pokemonTypes = pokemon.getTypes(true); const pokemonTypes = pokemon.getTypes(true);
if (pokemonTypes.length !== 1 || pokemonTypes[0] !== type) { if (pokemonTypes.length !== 1 || pokemonTypes[0] !== type) {
pokemon.summonData.types = [type]; pokemon.summonData.types = [ type ];
return true; return true;
} }
} }
@ -793,7 +793,7 @@ export class MoveTypeChangePowerMultiplierAbAttr extends VariableMoveTypeAbAttr
private newType: Type; private newType: Type;
private powerMultiplier: number; private powerMultiplier: number;
constructor(matchType: Type, newType: Type, powerMultiplier: number) { constructor(matchType: Type, newType: Type, powerMultiplier: number){
super(true); super(true);
this.matchType = matchType; this.matchType = matchType;
this.newType = newType; this.newType = newType;
@ -817,7 +817,7 @@ export class MoveTypeChangeAttr extends PreAttackAbAttr {
private powerMultiplier: number; private powerMultiplier: number;
private condition: PokemonAttackCondition; private condition: PokemonAttackCondition;
constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition) { constructor(newType: Type, powerMultiplier: number, condition: PokemonAttackCondition){
super(true); super(true);
this.newType = newType; this.newType = newType;
this.powerMultiplier = powerMultiplier; this.powerMultiplier = powerMultiplier;
@ -1050,7 +1050,7 @@ class PostVictoryStatChangeAbAttr extends PostVictoryAbAttr {
const stat = typeof this.stat === 'function' const stat = typeof this.stat === 'function'
? this.stat(pokemon) ? this.stat(pokemon)
: this.stat; : this.stat;
pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [stat], this.levels)); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], this.levels));
return true; return true;
} }
@ -1077,7 +1077,7 @@ export class PostKnockOutStatChangeAbAttr extends PostKnockOutAbAttr {
const stat = typeof this.stat === 'function' const stat = typeof this.stat === 'function'
? this.stat(pokemon) ? this.stat(pokemon)
: this.stat; : this.stat;
pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [stat], this.levels)); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], this.levels));
return true; return true;
} }
@ -1157,8 +1157,8 @@ export class PostSummonStatChangeAbAttr extends PostSummonAbAttr {
constructor(stats: BattleStat | BattleStat[], levels: integer, selfTarget?: boolean) { constructor(stats: BattleStat | BattleStat[], levels: integer, selfTarget?: boolean) {
super(); super();
this.stats = typeof (stats) === 'number' this.stats = typeof(stats) === 'number'
? [stats as BattleStat] ? [ stats as BattleStat ]
: stats as BattleStat[]; : stats as BattleStat[];
this.levels = levels; this.levels = levels;
this.selfTarget = !!selfTarget; this.selfTarget = !!selfTarget;
@ -1303,7 +1303,7 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
pokemon.summonData.ability = target.getAbility().id; pokemon.summonData.ability = target.getAbility().id;
pokemon.summonData.gender = target.getGender(); pokemon.summonData.gender = target.getGender();
pokemon.summonData.fusionGender = target.getFusionGender(); pokemon.summonData.fusionGender = target.getFusionGender();
pokemon.summonData.stats = [pokemon.stats[Stat.HP]].concat(target.stats.slice(1)); pokemon.summonData.stats = [ pokemon.stats[Stat.HP] ].concat(target.stats.slice(1));
pokemon.summonData.battleStats = target.summonData.battleStats.slice(0); pokemon.summonData.battleStats = target.summonData.battleStats.slice(0);
pokemon.summonData.moveset = target.getMoveset().map(m => new PokemonMove(m.moveId, m.ppUsed, m.ppUp)); pokemon.summonData.moveset = target.getMoveset().map(m => new PokemonMove(m.moveId, m.ppUsed, m.ppUp));
pokemon.summonData.types = target.getTypes(); pokemon.summonData.types = target.getTypes();
@ -1342,7 +1342,7 @@ export class PreSwitchOutResetStatusAbAttr extends PreSwitchOutAbAttr {
export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr { export class PreSwitchOutHealAbAttr extends PreSwitchOutAbAttr {
applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> { applyPreSwitchOut(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
if (pokemon.getHpRatio() < 1) { if (pokemon.getHpRatio() < 1 ) {
const healAmount = Math.floor(pokemon.getMaxHp() * 0.33); const healAmount = Math.floor(pokemon.getMaxHp() * 0.33);
pokemon.heal(healAmount); pokemon.heal(healAmount);
pokemon.updateInfo(); pokemon.updateInfo();
@ -1696,7 +1696,7 @@ export class PostTurnStatChangeAbAttr extends PostTurnAbAttr {
this.stats = Array.isArray(stats) this.stats = Array.isArray(stats)
? stats ? stats
: [stats]; : [ stats ];
this.levels = levels; this.levels = levels;
} }
@ -1925,7 +1925,7 @@ export class RedirectMoveAbAttr extends AbAttr {
canRedirect(moveId: Moves): boolean { canRedirect(moveId: Moves): boolean {
const move = allMoves[moveId]; const move = allMoves[moveId];
return !![MoveTarget.NEAR_OTHER, MoveTarget.OTHER].find(t => move.moveTarget === t); return !![ MoveTarget.NEAR_OTHER, MoveTarget.OTHER ].find(t => move.moveTarget === t);
} }
} }
@ -1976,7 +1976,7 @@ export class FlinchStatChangeAbAttr extends FlinchEffectAbAttr {
this.stats = Array.isArray(stats) this.stats = Array.isArray(stats)
? stats ? stats
: [stats]; : [ stats ];
this.levels = levels; this.levels = levels;
} }
@ -2258,7 +2258,7 @@ function queueShowAbility(pokemon: Pokemon, passive: boolean): void {
pokemon.scene.clearPhaseQueueSplice(); pokemon.scene.clearPhaseQueueSplice();
} }
export const allAbilities = [new Ability(Abilities.NONE, "-", "", 3)]; export const allAbilities = [ new Ability(Abilities.NONE, "-", "", 3) ];
export function initAbilities() { export function initAbilities() {
allAbilities.push( allAbilities.push(
@ -2531,7 +2531,7 @@ export function initAbilities() {
new Ability(Abilities.SUPER_LUCK, "Super Luck (P)", "The Pokémon is so lucky that the critical-hit ratios of its moves are boosted.", 4) new Ability(Abilities.SUPER_LUCK, "Super Luck (P)", "The Pokémon is so lucky that the critical-hit ratios of its moves are boosted.", 4)
.attr(BonusCritAbAttr), .attr(BonusCritAbAttr),
new Ability(Abilities.AFTERMATH, "Aftermath", "Damages the attacker if it contacts the Pokémon with a finishing hit.", 4) new Ability(Abilities.AFTERMATH, "Aftermath", "Damages the attacker if it contacts the Pokémon with a finishing hit.", 4)
.attr(PostFaintContactDamageAbAttr, 4) .attr(PostFaintContactDamageAbAttr,4)
.bypassFaint(), .bypassFaint(),
new Ability(Abilities.ANTICIPATION, "Anticipation (N)", "The Pokémon can sense an opposing Pokémon's dangerous moves.", 4), new Ability(Abilities.ANTICIPATION, "Anticipation (N)", "The Pokémon can sense an opposing Pokémon's dangerous moves.", 4),
new Ability(Abilities.FOREWARN, "Forewarn (N)", "When it enters a battle, the Pokémon can tell one of the moves an opposing Pokémon has.", 4), new Ability(Abilities.FOREWARN, "Forewarn (N)", "When it enters a battle, the Pokémon can tell one of the moves an opposing Pokémon has.", 4),
@ -2541,7 +2541,7 @@ export function initAbilities() {
new Ability(Abilities.TINTED_LENS, "Tinted Lens", "The Pokémon can use \"not very effective\" moves to deal regular damage.", 4) new Ability(Abilities.TINTED_LENS, "Tinted Lens", "The Pokémon can use \"not very effective\" moves to deal regular damage.", 4)
.attr(MovePowerBoostAbAttr, (user, target, move) => target.getAttackTypeEffectiveness(move.type) <= 0.5, 2), .attr(MovePowerBoostAbAttr, (user, target, move) => target.getAttackTypeEffectiveness(move.type) <= 0.5, 2),
new Ability(Abilities.FILTER, "Filter", "Reduces the power of supereffective attacks taken.", 4) new Ability(Abilities.FILTER, "Filter", "Reduces the power of supereffective attacks taken.", 4)
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 0.75) .attr(ReceivedMoveDamageMultiplierAbAttr,(target, user, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 0.75)
.ignorable(), .ignorable(),
new Ability(Abilities.SLOW_START, "Slow Start", "For five turns, the Pokémon's Attack and Speed stats are halved.", 4) new Ability(Abilities.SLOW_START, "Slow Start", "For five turns, the Pokémon's Attack and Speed stats are halved.", 4)
.attr(PostSummonAddBattlerTagAbAttr, BattlerTagType.SLOW_START, 5), .attr(PostSummonAddBattlerTagAbAttr, BattlerTagType.SLOW_START, 5),
@ -2554,7 +2554,7 @@ export function initAbilities() {
.attr(BlockWeatherDamageAttr, WeatherType.HAIL) .attr(BlockWeatherDamageAttr, WeatherType.HAIL)
.attr(PostWeatherLapseHealAbAttr, 1, WeatherType.HAIL, WeatherType.SNOW), .attr(PostWeatherLapseHealAbAttr, 1, WeatherType.HAIL, WeatherType.SNOW),
new Ability(Abilities.SOLID_ROCK, "Solid Rock", "Reduces the power of supereffective attacks taken.", 4) new Ability(Abilities.SOLID_ROCK, "Solid Rock", "Reduces the power of supereffective attacks taken.", 4)
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 0.75) .attr(ReceivedMoveDamageMultiplierAbAttr,(target, user, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 0.75)
.ignorable(), .ignorable(),
new Ability(Abilities.SNOW_WARNING, "Snow Warning", "The Pokémon makes it snow when it enters a battle.", 4) new Ability(Abilities.SNOW_WARNING, "Snow Warning", "The Pokémon makes it snow when it enters a battle.", 4)
.attr(PostSummonWeatherChangeAbAttr, WeatherType.SNOW) .attr(PostSummonWeatherChangeAbAttr, WeatherType.SNOW)
@ -2601,7 +2601,7 @@ export function initAbilities() {
.attr(WeightMultiplierAbAttr, 0.5) .attr(WeightMultiplierAbAttr, 0.5)
.ignorable(), .ignorable(),
new Ability(Abilities.MULTISCALE, "Multiscale", "Reduces the amount of damage the Pokémon takes while its HP is full.", 5) new Ability(Abilities.MULTISCALE, "Multiscale", "Reduces the amount of damage the Pokémon takes while its HP is full.", 5)
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getHpRatio() === 1, 0.5) .attr(ReceivedMoveDamageMultiplierAbAttr,(target, user, move) => target.getHpRatio() === 1, 0.5)
.ignorable(), .ignorable(),
new Ability(Abilities.TOXIC_BOOST, "Toxic Boost", "Powers up physical attacks when the Pokémon is poisoned.", 5) new Ability(Abilities.TOXIC_BOOST, "Toxic Boost", "Powers up physical attacks when the Pokémon is poisoned.", 5)
.attr(MovePowerBoostAbAttr, (user, target, move) => move.category === MoveCategory.PHYSICAL && (user.status?.effect === StatusEffect.POISON || user.status?.effect === StatusEffect.TOXIC), 1.5), .attr(MovePowerBoostAbAttr, (user, target, move) => move.category === MoveCategory.PHYSICAL && (user.status?.effect === StatusEffect.POISON || user.status?.effect === StatusEffect.TOXIC), 1.5),
@ -2865,9 +2865,9 @@ export function initAbilities() {
new Ability(Abilities.FULL_METAL_BODY, "Full Metal Body", "Prevents other Pokémon's moves or Abilities from lowering the Pokémon's stats.", 7) new Ability(Abilities.FULL_METAL_BODY, "Full Metal Body", "Prevents other Pokémon's moves or Abilities from lowering the Pokémon's stats.", 7)
.attr(ProtectStatAbAttr), .attr(ProtectStatAbAttr),
new Ability(Abilities.SHADOW_SHIELD, "Shadow Shield", "Reduces the amount of damage the Pokémon takes while its HP is full.", 7) new Ability(Abilities.SHADOW_SHIELD, "Shadow Shield", "Reduces the amount of damage the Pokémon takes while its HP is full.", 7)
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getHpRatio() === 1, 0.5), .attr(ReceivedMoveDamageMultiplierAbAttr,(target, user, move) => target.getHpRatio() === 1, 0.5),
new Ability(Abilities.PRISM_ARMOR, "Prism Armor", "Reduces the power of supereffective attacks taken.", 7) new Ability(Abilities.PRISM_ARMOR, "Prism Armor", "Reduces the power of supereffective attacks taken.", 7)
.attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 0.75), .attr(ReceivedMoveDamageMultiplierAbAttr,(target, user, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 0.75),
new Ability(Abilities.NEUROFORCE, "Neuroforce", "Powers up moves that are super effective.", 7) new Ability(Abilities.NEUROFORCE, "Neuroforce", "Powers up moves that are super effective.", 7)
.attr(MovePowerBoostAbAttr, (user, target, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 1.25), .attr(MovePowerBoostAbAttr, (user, target, move) => target.getAttackTypeEffectiveness(move.type) >= 2, 1.25),
new Ability(Abilities.INTREPID_SWORD, "Intrepid Sword", "Boosts the Pokémon's Attack stat when the Pokémon enters a battle.", 8) new Ability(Abilities.INTREPID_SWORD, "Intrepid Sword", "Boosts the Pokémon's Attack stat when the Pokémon enters a battle.", 8)