Implemented 3 Swap moves

This commit is contained in:
QUENTIN PELLERIN 2024-05-17 17:28:59 +02:00
parent 3cc9c93643
commit cae352c75a

View File

@ -1964,7 +1964,14 @@ export class ResetStatsAttr extends MoveEffectAttr {
*/
export class SwapStatsAttr extends MoveEffectAttr
{
/**
public statsToSwap: BattleStat[];
constructor(statToSwap: BattleStat[] = [...Array(7).keys()]) {
super();
this.statsToSwap = statToSwap;
}
/**
* Swaps the user and the target's stat changes.
* @param user Pokemon that used the move
* @param target The target of the move
@ -1972,22 +1979,58 @@ export class SwapStatsAttr extends MoveEffectAttr
* @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; //Exits if the move can't apply
let priorBoost : integer; //For storing a stat boost
for (let s = 0; s < target.summonData.battleStats.length; s++)
{
priorBoost = user.summonData.battleStats[s]; //Store user stat boost
user.summonData.battleStats[s] = target.summonData.battleStats[s]; //Applies target boost to self
target.summonData.battleStats[s] = priorBoost; //Applies stored boost to target
}
target.updateInfo();
user.updateInfo();
target.scene.queueMessage(getPokemonMessage(user, ' switched stat changes with the target!'));
return true;
apply(user: Pokemon, target: Pokemon, move: Move, args: any []): boolean
{
if (!super.apply(user, target, move, args))
return false;
const userBattleStat = user.summonData.battleStats;
const targetBattleStat = target.summonData.battleStats;
this.statsToSwap.forEach(stat => {
let userStat = userBattleStat[stat];
userBattleStat[stat] = targetBattleStat[stat];
targetBattleStat[stat] = userStat;
});
user.updateInfo();
target.updateInfo();
if (this.statsToSwap.length === 7) {
target.scene.queueMessage(getPokemonMessage(user, ' switched stat changes with the target!'));
}
else {
const statsName = this.statsToSwap.map(stat => getBattleStatName(stat));
target.scene.queueMessage(getPokemonMessage(user, ' switched all changes to its ' + statsName.join(' and ') + ' with its target!'));
}
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 {
@ -5482,9 +5525,9 @@ export function initMoves() {
.attr(CopyMoveAttr)
.ignoresVirtual(),
new StatusMove(Moves.POWER_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4)
.unimplemented(),
.attr(SwapStatsAttr, [BattleStat.ATK, BattleStat.SPATK]),
new StatusMove(Moves.GUARD_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4)
.unimplemented(),
.attr(SwapStatsAttr, [BattleStat.DEF, BattleStat.SPDEF]),
new AttackMove(Moves.PUNISHMENT, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 4)
.unimplemented(),
new AttackMove(Moves.LAST_RESORT, Type.NORMAL, MoveCategory.PHYSICAL, 140, 100, 5, -1, 0, 4)
@ -6321,7 +6364,7 @@ export function initMoves() {
user.scene.queueMessage(getPokemonMessage(user, ` burned itself out!`));
}),
new StatusMove(Moves.SPEED_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 7)
.unimplemented(),
.attr(SpeedSwapAttr),
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)
.triageMove()