Heart Swap implementation. (#712)
* Heart Swap implementation. Simply switches the values in 3 arrays. * Fixed missing space * Removed some lines. Removed a for loop. * Removed an unneccesary line * TSDoc commentation added * Changed message method to be more descriptive * Adjusted message line to be consistent with Pokemon Showdown * Adjusted priorBoostArray to priorBoost integer Only one values is relevant at a time, so the array was pointless, woops.
This commit is contained in:
parent
8707213e88
commit
ea459826d0
|
@ -1775,6 +1775,37 @@ export class ResetStatsAttr extends MoveEffectAttr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute used for moves which swap the user and the target's stat changes.
|
||||||
|
*/
|
||||||
|
export class SwapStatsAttr 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; //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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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 => {
|
||||||
|
@ -5181,7 +5212,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)
|
||||||
.unimplemented(),
|
.attr(SwapStatsAttr),
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue