mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-10-02 06:07:10 -05:00
Format volatiles consistently (#7314)
This commit is contained in:
@@ -1944,7 +1944,7 @@ export const Abilities: {[abilityid: string]: AbilityData} = {
|
||||
shortDesc: "This Pokemon's sound-based moves become Water type.",
|
||||
onModifyTypePriority: -1,
|
||||
onModifyType(move, pokemon) {
|
||||
if (move.flags['sound'] && !pokemon.volatiles.dynamax) { // hardcode
|
||||
if (move.flags['sound'] && !pokemon.volatiles['dynamax']) { // hardcode
|
||||
move.type = 'Water';
|
||||
}
|
||||
},
|
||||
|
||||
@@ -162,8 +162,8 @@ export const Conditions: {[k: string]: ConditionData} = {
|
||||
},
|
||||
onBeforeMovePriority: 3,
|
||||
onBeforeMove(pokemon) {
|
||||
pokemon.volatiles.confusion.time--;
|
||||
if (!pokemon.volatiles.confusion.time) {
|
||||
pokemon.volatiles['confusion'].time--;
|
||||
if (!pokemon.volatiles['confusion'].time) {
|
||||
pokemon.removeVolatile('confusion');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ export const Items: {[itemid: string]: ItemData} = {
|
||||
},
|
||||
onStart(pokemon) {
|
||||
if (pokemon.volatiles['choicelock']) {
|
||||
this.debug('removing choicelock: ' + pokemon.volatiles.choicelock);
|
||||
this.debug('removing choicelock: ' + pokemon.volatiles['choicelock']);
|
||||
}
|
||||
pokemon.removeVolatile('choicelock');
|
||||
},
|
||||
@@ -911,7 +911,7 @@ export const Items: {[itemid: string]: ItemData} = {
|
||||
},
|
||||
onStart(pokemon) {
|
||||
if (pokemon.volatiles['choicelock']) {
|
||||
this.debug('removing choicelock: ' + pokemon.volatiles.choicelock);
|
||||
this.debug('removing choicelock: ' + pokemon.volatiles['choicelock']);
|
||||
}
|
||||
pokemon.removeVolatile('choicelock');
|
||||
},
|
||||
@@ -935,7 +935,7 @@ export const Items: {[itemid: string]: ItemData} = {
|
||||
},
|
||||
onStart(pokemon) {
|
||||
if (pokemon.volatiles['choicelock']) {
|
||||
this.debug('removing choicelock: ' + pokemon.volatiles.choicelock);
|
||||
this.debug('removing choicelock: ' + pokemon.volatiles['choicelock']);
|
||||
}
|
||||
pokemon.removeVolatile('choicelock');
|
||||
},
|
||||
@@ -1232,7 +1232,7 @@ export const Items: {[itemid: string]: ItemData} = {
|
||||
onAttract(target, source) {
|
||||
this.debug('attract intercepted: ' + target + ' from ' + source);
|
||||
if (!source || source === target) return;
|
||||
if (!source.volatiles.attract) source.addVolatile('attract', target);
|
||||
if (!source.volatiles['attract']) source.addVolatile('attract', target);
|
||||
},
|
||||
num: 280,
|
||||
gen: 4,
|
||||
|
||||
@@ -138,8 +138,8 @@ export const Conditions: {[k: string]: ModdedConditionData} = {
|
||||
},
|
||||
onBeforeMovePriority: 3,
|
||||
onBeforeMove(pokemon, target) {
|
||||
pokemon.volatiles.confusion.time--;
|
||||
if (!pokemon.volatiles.confusion.time) {
|
||||
pokemon.volatiles['confusion'].time--;
|
||||
if (!pokemon.volatiles['confusion'].time) {
|
||||
pokemon.removeVolatile('confusion');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ export const Conditions: {[k: string]: ModdedConditionData} = {
|
||||
}
|
||||
},
|
||||
onBeforeMove(pokemon, target, move) {
|
||||
pokemon.volatiles.confusion.time--;
|
||||
if (!pokemon.volatiles.confusion.time) {
|
||||
pokemon.volatiles['confusion'].time--;
|
||||
if (!pokemon.volatiles['confusion'].time) {
|
||||
pokemon.removeVolatile('confusion');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ export const Items: {[k: string]: ModdedItemData} = {
|
||||
},
|
||||
},
|
||||
onUpdate(pokemon) {
|
||||
if (pokemon.volatiles.attract && pokemon.useItem()) {
|
||||
if (pokemon.volatiles['attract'] && pokemon.useItem()) {
|
||||
pokemon.removeVolatile('attract');
|
||||
this.add('-end', pokemon, 'move: Attract', '[from] item: Mental Herb');
|
||||
}
|
||||
|
||||
@@ -1570,7 +1570,7 @@ export const Moves: {[k: string]: ModdedMoveData} = {
|
||||
desc: "Fails if the target did not select a physical or special attack for use this turn, or if the target moves before the user.",
|
||||
onTry(source, target) {
|
||||
const action = this.queue.willMove(target);
|
||||
if (!action || action.choice !== 'move' || action.move.category === 'Status' || target.volatiles.mustrecharge) {
|
||||
if (!action || action.choice !== 'move' || action.move.category === 'Status' || target.volatiles['mustrecharge']) {
|
||||
this.add('-fail', source);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ export const Conditions: {[k: string]: ModdedConditionData} = {
|
||||
confusion: {
|
||||
inherit: true,
|
||||
onBeforeMove(pokemon) {
|
||||
pokemon.volatiles.confusion.time--;
|
||||
if (!pokemon.volatiles.confusion.time) {
|
||||
pokemon.volatiles['confusion'].time--;
|
||||
if (!pokemon.volatiles['confusion'].time) {
|
||||
pokemon.removeVolatile('confusion');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ export const Abilities: {[k: string]: ModdedAbilityData} = {
|
||||
inherit: true,
|
||||
onResidualPriority: -1,
|
||||
onResidual(pokemon) {
|
||||
if (pokemon.activeTurns && !pokemon.volatiles.stall) {
|
||||
if (pokemon.activeTurns && !pokemon.volatiles['stall']) {
|
||||
this.boost({spe: 1});
|
||||
}
|
||||
},
|
||||
@@ -677,7 +677,7 @@ export const Abilities: {[k: string]: ModdedAbilityData} = {
|
||||
onFoeMaybeTrapPokemon(pokemon, source) {
|
||||
if (!source) source = this.effectData.target;
|
||||
if (!source || !this.isAdjacent(pokemon, source)) return;
|
||||
if (pokemon.ability !== 'shadowtag' && !source.volatiles.shadowtag) {
|
||||
if (pokemon.ability !== 'shadowtag' && !source.volatiles['shadowtag']) {
|
||||
pokemon.maybeTrapped = true;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -62,8 +62,8 @@ export const Conditions: {[k: string]: ModdedConditionData} = {
|
||||
this.add('-end', target, 'confusion');
|
||||
},
|
||||
onBeforeMove(pokemon) {
|
||||
pokemon.volatiles.confusion.time--;
|
||||
if (!pokemon.volatiles.confusion.time) {
|
||||
pokemon.volatiles['confusion'].time--;
|
||||
if (!pokemon.volatiles['confusion'].time) {
|
||||
pokemon.removeVolatile('confusion');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ export const Moves: {[k: string]: ModdedMoveData} = {
|
||||
},
|
||||
onTryHitPriority: 3,
|
||||
onTryHit(target, source, move) {
|
||||
if (target.volatiles.substitute || !move.flags['protect']) return;
|
||||
if (target.volatiles['substitute'] || !move.flags['protect']) return;
|
||||
this.add('-activate', target, 'Protect');
|
||||
const lockedmove = source.getVolatile('lockedmove');
|
||||
if (lockedmove) {
|
||||
@@ -216,7 +216,7 @@ export const Moves: {[k: string]: ModdedMoveData} = {
|
||||
},
|
||||
onTryHitPriority: 3,
|
||||
onTryHit(target, source, move) {
|
||||
if (target.volatiles.substitute || !move.flags['protect'] || move.category === 'Status') return;
|
||||
if (target.volatiles['substitute'] || !move.flags['protect'] || move.category === 'Status') return;
|
||||
this.add('-activate', target, 'Protect');
|
||||
const lockedmove = source.getVolatile('lockedmove');
|
||||
if (lockedmove) {
|
||||
@@ -241,7 +241,7 @@ export const Moves: {[k: string]: ModdedMoveData} = {
|
||||
},
|
||||
onTryHitPriority: 3,
|
||||
onTryHit(target, source, move) {
|
||||
if (target.volatiles.substitute || !move.flags['protect']) return;
|
||||
if (target.volatiles['substitute'] || !move.flags['protect']) return;
|
||||
if (move && (move.target === 'self' || move.id === 'suckerpunch')) return;
|
||||
this.add('-activate', target, 'move: Protect');
|
||||
if (move.flags['contact']) {
|
||||
|
||||
@@ -68,7 +68,7 @@ export const Scripts: ModdedBattleScriptsData = {
|
||||
|
||||
// Dancer Petal Dance hack
|
||||
// TODO: implement properly
|
||||
const noLock = externalMove && !pokemon.volatiles.lockedmove;
|
||||
const noLock = externalMove && !pokemon.volatiles['lockedmove'];
|
||||
|
||||
if (zMove) {
|
||||
if (pokemon.illusion) {
|
||||
@@ -104,7 +104,7 @@ export const Scripts: ModdedBattleScriptsData = {
|
||||
this.runMove(move.id, dancer, 0, this.dex.getAbility('dancer'), undefined, true);
|
||||
}
|
||||
}
|
||||
if (noLock && pokemon.volatiles.lockedmove) delete pokemon.volatiles.lockedmove;
|
||||
if (noLock && pokemon.volatiles['lockedmove']) delete pokemon.volatiles['lockedmove'];
|
||||
},
|
||||
// Modded to allow arrays as Mega Stone options
|
||||
canMegaEvo(pokemon) {
|
||||
|
||||
@@ -3140,7 +3140,7 @@ export const Moves: {[moveid: string]: MoveData} = {
|
||||
delete move.volatileStatus;
|
||||
delete move.onHit;
|
||||
move.self = {boosts: {spe: -1, atk: 1, def: 1}};
|
||||
} else if (move.volatileStatus && target.volatiles.curse) {
|
||||
} else if (move.volatileStatus && target.volatiles['curse']) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@@ -6176,10 +6176,10 @@ export const Moves: {[moveid: string]: MoveData} = {
|
||||
accuracy: 95,
|
||||
basePower: 40,
|
||||
basePowerCallback(pokemon, target, move) {
|
||||
if (!pokemon.volatiles.furycutter || move.hit === 1) {
|
||||
if (!pokemon.volatiles['furycutter'] || move.hit === 1) {
|
||||
pokemon.addVolatile('furycutter');
|
||||
}
|
||||
return this.clampIntRange(move.basePower * pokemon.volatiles.furycutter.multiplier, 1, 160);
|
||||
return this.clampIntRange(move.basePower * pokemon.volatiles['furycutter'].multiplier, 1, 160);
|
||||
},
|
||||
category: "Physical",
|
||||
desc: "Power doubles with each successful hit, up to a maximum of 160 power. The power is reset if this move misses or another move is used.",
|
||||
@@ -9274,11 +9274,11 @@ export const Moves: {[moveid: string]: MoveData} = {
|
||||
basePower: 30,
|
||||
basePowerCallback(pokemon, target, move) {
|
||||
let bp = move.basePower;
|
||||
if (pokemon.volatiles.iceball && pokemon.volatiles.iceball.hitCount) {
|
||||
bp *= Math.pow(2, pokemon.volatiles.iceball.hitCount);
|
||||
if (pokemon.volatiles['iceball'] && pokemon.volatiles['iceball'].hitCount) {
|
||||
bp *= Math.pow(2, pokemon.volatiles['iceball'].hitCount);
|
||||
}
|
||||
if (pokemon.status !== 'slp') pokemon.addVolatile('iceball');
|
||||
if (pokemon.volatiles.defensecurl) {
|
||||
if (pokemon.volatiles['defensecurl']) {
|
||||
bp *= 2;
|
||||
}
|
||||
this.debug("Ice Ball bp: " + bp);
|
||||
@@ -15433,11 +15433,11 @@ export const Moves: {[moveid: string]: MoveData} = {
|
||||
basePower: 30,
|
||||
basePowerCallback(pokemon, target, move) {
|
||||
let bp = move.basePower;
|
||||
if (pokemon.volatiles.rollout && pokemon.volatiles.rollout.hitCount) {
|
||||
bp *= Math.pow(2, pokemon.volatiles.rollout.hitCount);
|
||||
if (pokemon.volatiles['rollout'] && pokemon.volatiles['rollout'].hitCount) {
|
||||
bp *= Math.pow(2, pokemon.volatiles['rollout'].hitCount);
|
||||
}
|
||||
if (pokemon.status !== 'slp') pokemon.addVolatile('rollout');
|
||||
if (pokemon.volatiles.defensecurl) {
|
||||
if (pokemon.volatiles['defensecurl']) {
|
||||
bp *= 2;
|
||||
}
|
||||
this.debug("Rollout bp: " + bp);
|
||||
@@ -18503,7 +18503,7 @@ export const Moves: {[moveid: string]: MoveData} = {
|
||||
onTry(source, target) {
|
||||
const action = this.queue.willMove(target);
|
||||
const move = action?.choice === 'move' ? action.move : null;
|
||||
if (!move || (move.category === 'Status' && move.id !== 'mefirst') || target.volatiles.mustrecharge) {
|
||||
if (!move || (move.category === 'Status' && move.id !== 'mefirst') || target.volatiles['mustrecharge']) {
|
||||
this.add('-fail', source);
|
||||
this.attrLastMove('[still]');
|
||||
return null;
|
||||
|
||||
@@ -86,7 +86,7 @@ export const Scripts: BattleScriptsData = {
|
||||
|
||||
// Dancer Petal Dance hack
|
||||
// TODO: implement properly
|
||||
const noLock = externalMove && !pokemon.volatiles.lockedmove;
|
||||
const noLock = externalMove && !pokemon.volatiles['lockedmove'];
|
||||
|
||||
if (zMove) {
|
||||
if (pokemon.illusion) {
|
||||
@@ -127,7 +127,7 @@ export const Scripts: BattleScriptsData = {
|
||||
this.runMove(move.id, dancer, this.getTargetLoc(dancersTarget, dancer), this.dex.getAbility('dancer'), undefined, true);
|
||||
}
|
||||
}
|
||||
if (noLock && pokemon.volatiles.lockedmove) delete pokemon.volatiles.lockedmove;
|
||||
if (noLock && pokemon.volatiles['lockedmove']) delete pokemon.volatiles['lockedmove'];
|
||||
},
|
||||
/**
|
||||
* useMove is the "inside" move caller. It handles effects of the
|
||||
|
||||
@@ -1071,7 +1071,7 @@ export class Pokemon {
|
||||
this.weighthg = pokemon.weighthg;
|
||||
|
||||
const types = pokemon.getTypes(true);
|
||||
this.setType(pokemon.volatiles.roost ? pokemon.volatiles.roost.typeWas : types, true);
|
||||
this.setType(pokemon.volatiles['roost'] ? pokemon.volatiles['roost'].typeWas : types, true);
|
||||
this.addedType = pokemon.addedType;
|
||||
this.knownType = this.side === pokemon.side && pokemon.knownType;
|
||||
this.apparentType = pokemon.apparentType;
|
||||
@@ -1275,8 +1275,8 @@ export class Pokemon {
|
||||
this.removeLinkedVolatiles(this.volatiles[i].linkedStatus, this.volatiles[i].linkedPokemon);
|
||||
}
|
||||
}
|
||||
if (this.species.name === 'Eternatus-Eternamax' && this.volatiles.dynamax) {
|
||||
this.volatiles = {dynamax: this.volatiles.dynamax};
|
||||
if (this.species.name === 'Eternatus-Eternamax' && this.volatiles['dynamax']) {
|
||||
this.volatiles = {dynamax: this.volatiles['dynamax']};
|
||||
} else {
|
||||
this.volatiles = {};
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ describe('Dazzling', function () {
|
||||
battle.makeChoices('move swordsdance', 'move perishsong');
|
||||
battle.makeChoices('move sleeptalk', 'move haze');
|
||||
assert.equal(battle.p1.active[0].boosts.atk, 0);
|
||||
assert.false(battle.p1.active[0].volatiles.perishsong);
|
||||
assert.false(battle.p1.active[0].volatiles['perishsong']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('Prankster', function () {
|
||||
|
||||
battle.makeChoices('move encore 1, move calmmind', 'move frustration 2, move agility');
|
||||
battle.makeChoices('move encore 1, move calmmind', 'move leer, move agility');
|
||||
assert(battle.p2.active[0].volatiles.encore, `Meowstic should be encored`);
|
||||
assert(battle.p2.active[0].volatiles['encore'], `Meowstic should be encored`);
|
||||
assert.fullHP(battle.p1.active[0]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user