mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-24 06:49:11 -05:00
Also move mods/ to data/mods/ This makes PS more monorepo-like. The intent is to further separate the sim and the server code, but without fully committing to splitting the repository itself. We now support `./pokemon-showdown start` in addition to `./pokemon-showdown`. I'm not clear which I want to be the default yet.
97 lines
2.9 KiB
JavaScript
97 lines
2.9 KiB
JavaScript
'use strict';
|
|
|
|
/**@type {ModdedBattleScriptsData} */
|
|
exports.BattleScripts = {
|
|
getEffect(name) {
|
|
if (name && typeof name !== 'string') {
|
|
return name;
|
|
}
|
|
let id = toId(name);
|
|
if (id.startsWith('ability')) return Object.assign(Object.create(this.getAbility(id.slice(7))), {id});
|
|
return Object.getPrototypeOf(this).getEffect.call(this, name);
|
|
},
|
|
suppressingWeather() {
|
|
let pokemon;
|
|
for (let i = 0; i < this.sides.length; i++) {
|
|
for (let j = 0; j < this.sides[i].active.length; j++) {
|
|
pokemon = this.sides[i].active[j];
|
|
if (pokemon && !pokemon.ignoringAbility() && pokemon.hasAbility('Cloud Nine')) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
pokemon: {
|
|
hasAbility(ability) {
|
|
if (this.ignoringAbility()) return false;
|
|
if (Array.isArray(ability)) return ability.some(ability => this.hasAbility(ability));
|
|
ability = toId(ability);
|
|
return this.ability === ability || !!this.volatiles['ability' + ability];
|
|
},
|
|
transformInto(pokemon, effect) {
|
|
let template = pokemon.template;
|
|
if (pokemon.fainted || pokemon.illusion || (pokemon.volatiles['substitute'] && this.battle.gen >= 5)) {
|
|
return false;
|
|
}
|
|
if (!template.abilities || (pokemon && pokemon.transformed && this.battle.gen >= 2) || (this.transformed && this.battle.gen >= 5)) {
|
|
return false;
|
|
}
|
|
if (!this.formeChange(template, null)) {
|
|
return false;
|
|
}
|
|
this.transformed = true;
|
|
|
|
this.types = pokemon.types;
|
|
this.addedType = pokemon.addedType;
|
|
this.knownType = this.side === pokemon.side && pokemon.knownType;
|
|
|
|
for (let statName in this.stats) {
|
|
this.stats[statName] = pokemon.stats[statName];
|
|
}
|
|
this.moveSlots = [];
|
|
this.set.ivs = (this.battle.gen >= 5 ? this.set.ivs : pokemon.set.ivs);
|
|
this.hpType = (this.battle.gen >= 5 ? this.hpType : pokemon.hpType);
|
|
this.hpPower = (this.battle.gen >= 5 ? this.hpPower : pokemon.hpPower);
|
|
for (let i = 0; i < pokemon.moveSlots.length; i++) {
|
|
let moveData = pokemon.moveSlots[i];
|
|
let moveName = moveData.move;
|
|
if (moveData.id === 'hiddenpower') {
|
|
moveName = 'Hidden Power ' + this.hpType;
|
|
}
|
|
this.moveSlots.push({
|
|
move: moveName,
|
|
id: moveData.id,
|
|
pp: moveData.maxpp === 1 ? 1 : 5,
|
|
maxpp: this.battle.gen >= 5 ? (moveData.maxpp === 1 ? 1 : 5) : moveData.maxpp,
|
|
target: moveData.target,
|
|
disabled: false,
|
|
used: false,
|
|
virtual: true,
|
|
});
|
|
}
|
|
for (let j in pokemon.boosts) {
|
|
// @ts-ignore
|
|
this.boosts[j] = pokemon.boosts[j];
|
|
}
|
|
if (effect) {
|
|
this.battle.add('-transform', this, pokemon, '[from] ' + effect.fullname);
|
|
} else {
|
|
this.battle.add('-transform', this, pokemon);
|
|
}
|
|
this.setAbility(pokemon.ability, this, true);
|
|
if (this.innates) {
|
|
for (let innate of this.innates) {
|
|
this.removeVolatile('ability' + innate);
|
|
}
|
|
}
|
|
if (pokemon.innates) {
|
|
for (let innate of pokemon.innates) {
|
|
this.addVolatile('ability' + innate, this);
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
},
|
|
};
|