Fixes from reviews

This commit is contained in:
QUENTIN PELLERIN 2024-05-18 15:43:05 +02:00
parent cae352c75a
commit 62d250865a

View File

@ -1960,9 +1960,9 @@ export class ResetStatsAttr extends MoveEffectAttr {
} }
/** /**
* Attribute used for moves which swap the user and the target's stat changes. * Attribute used for moves which swap the user and the target's battle stat changes.
*/ */
export class SwapStatsAttr extends MoveEffectAttr export class SwapBattleStatsAttr extends MoveEffectAttr
{ {
public statsToSwap: BattleStat[]; public statsToSwap: BattleStat[];
@ -1972,7 +1972,7 @@ export class SwapStatsAttr extends MoveEffectAttr
this.statsToSwap = statToSwap; this.statsToSwap = statToSwap;
} }
/** /**
* Swaps the user and the target's stat changes. * Swaps the user and the target's battle stat changes.
* @param user Pokemon that used the move * @param user Pokemon that used the move
* @param target The target of the move * @param target The target of the move
* @param move Move with this attribute * @param move Move with this attribute
@ -1988,7 +1988,7 @@ export class SwapStatsAttr extends MoveEffectAttr
const targetBattleStat = target.summonData.battleStats; const targetBattleStat = target.summonData.battleStats;
this.statsToSwap.forEach(stat => { this.statsToSwap.forEach(stat => {
let userStat = userBattleStat[stat]; const userStat = userBattleStat[stat];
userBattleStat[stat] = targetBattleStat[stat]; userBattleStat[stat] = targetBattleStat[stat];
targetBattleStat[stat] = userStat; targetBattleStat[stat] = userStat;
}); });
@ -2000,39 +2000,24 @@ export class SwapStatsAttr extends MoveEffectAttr
target.scene.queueMessage(getPokemonMessage(user, ' switched stat changes with the target!')); target.scene.queueMessage(getPokemonMessage(user, ' switched stat changes with the target!'));
} }
else { else {
const statsName = this.statsToSwap.map(stat => getBattleStatName(stat)); const statsNames = this.statsToSwap.map(stat => getBattleStatName(stat));
target.scene.queueMessage(getPokemonMessage(user, ' switched all changes to its ' + statsName.join(' and ') + ' with its target!')); const lastStat = statsNames.pop();
let statsMessage = '';
if (statsNames.length) {
statsMessage = statsNames.join(', ') + ` and ${lastStat}`;
}
else {
statsMessage = lastStat;
}
target.scene.queueMessage(getPokemonMessage(user, ` switched all changes to its ${statsMessage} with its target!`));
} }
return true; return true;
} }
} }
export class SpeedSwapAttr extends MoveEffectAttr
{
/**
* Swaps the user and the target's stat changes.
* @param user Pokemon that used the move
* @param target The target of the move
* @param move Move with this attribute
* @param args N/A
* @returns true if the function succeeds
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any []): boolean
{
if (!super.apply(user, target, move, args))
return false;
const userSpeed = user.stats[Stat.SPD];
user.stats[Stat.SPD] = target.stats[BattleStat.SPD];
target.stats[Stat.SPD] = userSpeed;
target.scene.queueMessage(getPokemonMessage(user, ' switched Speed with its target!'));
return true;
}
}
export class HpSplitAttr extends MoveEffectAttr { export class HpSplitAttr extends MoveEffectAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise(resolve => { return new Promise(resolve => {
@ -5525,9 +5510,9 @@ export function initMoves() {
.attr(CopyMoveAttr) .attr(CopyMoveAttr)
.ignoresVirtual(), .ignoresVirtual(),
new StatusMove(Moves.POWER_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4) new StatusMove(Moves.POWER_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4)
.attr(SwapStatsAttr, [BattleStat.ATK, BattleStat.SPATK]), .attr(SwapBattleStatsAttr, [BattleStat.ATK, BattleStat.SPATK]),
new StatusMove(Moves.GUARD_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4) new StatusMove(Moves.GUARD_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4)
.attr(SwapStatsAttr, [BattleStat.DEF, BattleStat.SPDEF]), .attr(SwapBattleStatsAttr, [BattleStat.DEF, BattleStat.SPDEF]),
new AttackMove(Moves.PUNISHMENT, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 4) new AttackMove(Moves.PUNISHMENT, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 4)
.unimplemented(), .unimplemented(),
new AttackMove(Moves.LAST_RESORT, Type.NORMAL, MoveCategory.PHYSICAL, 140, 100, 5, -1, 0, 4) new AttackMove(Moves.LAST_RESORT, Type.NORMAL, MoveCategory.PHYSICAL, 140, 100, 5, -1, 0, 4)
@ -5540,7 +5525,7 @@ export function initMoves() {
.attr(AddArenaTrapTagAttr, ArenaTagType.TOXIC_SPIKES) .attr(AddArenaTrapTagAttr, ArenaTagType.TOXIC_SPIKES)
.target(MoveTarget.ENEMY_SIDE), .target(MoveTarget.ENEMY_SIDE),
new StatusMove(Moves.HEART_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4) new StatusMove(Moves.HEART_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4)
.attr(SwapStatsAttr), .attr(SwapBattleStatsAttr),
new SelfStatusMove(Moves.AQUA_RING, Type.WATER, -1, 20, -1, 0, 4) new SelfStatusMove(Moves.AQUA_RING, Type.WATER, -1, 20, -1, 0, 4)
.attr(AddBattlerTagAttr, BattlerTagType.AQUA_RING, true, true), .attr(AddBattlerTagAttr, BattlerTagType.AQUA_RING, true, true),
new SelfStatusMove(Moves.MAGNET_RISE, Type.ELECTRIC, -1, 10, -1, 0, 4) new SelfStatusMove(Moves.MAGNET_RISE, Type.ELECTRIC, -1, 10, -1, 0, 4)
@ -6364,7 +6349,7 @@ export function initMoves() {
user.scene.queueMessage(getPokemonMessage(user, ` burned itself out!`)); user.scene.queueMessage(getPokemonMessage(user, ` burned itself out!`));
}), }),
new StatusMove(Moves.SPEED_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 7) new StatusMove(Moves.SPEED_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 7)
.attr(SpeedSwapAttr), .unimplemented(),
new AttackMove(Moves.SMART_STRIKE, Type.STEEL, MoveCategory.PHYSICAL, 70, -1, 10, -1, 0, 7), new AttackMove(Moves.SMART_STRIKE, Type.STEEL, MoveCategory.PHYSICAL, 70, -1, 10, -1, 0, 7),
new StatusMove(Moves.PURIFY, Type.POISON, -1, 20, -1, 0, 7) new StatusMove(Moves.PURIFY, Type.POISON, -1, 20, -1, 0, 7)
.triageMove() .triageMove()