mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-21 06:37:09 -05:00
The old code tried to validate by changing incorrect values to correct values, but had lots of bugs. Even if it didn't have bugs, it would have various flaws like stats being different from what you would expect from the teambuilder, so the new code just tells you when your HP DV, shininess, gender, and Hidden Power type are inconsistent with your other DVs. (The one exception is SD Thick Club Marowak, which still automatically fixes its Atk IV, since we still don't have teambuilder UI for that.)
87 lines
2.6 KiB
JavaScript
87 lines
2.6 KiB
JavaScript
'use strict';
|
|
|
|
exports.BattleFormats = {
|
|
pokemon: {
|
|
effectType: 'ValidatorRule',
|
|
name: 'Pokemon',
|
|
onValidateSet: function (set, format) {
|
|
let template = this.getTemplate(set.species);
|
|
let problems = [];
|
|
if (set.species === set.name) delete set.name;
|
|
|
|
if (template.gen > this.gen) {
|
|
problems.push(set.species + ' does not exist in gen ' + this.gen + '.');
|
|
} else if (template.isNonstandard) {
|
|
problems.push(set.species + ' is not a real Pokemon.');
|
|
}
|
|
let hasSD = false;
|
|
if (set.item) {
|
|
let item = this.getItem(set.item);
|
|
if (item.gen > this.gen) {
|
|
problems.push(item.name + ' does not exist in gen ' + this.gen + '.');
|
|
} else if (item.isNonstandard) {
|
|
problems.push(item.name + ' is not a real item.');
|
|
}
|
|
}
|
|
if (set.moves) {
|
|
for (let i = 0; i < set.moves.length; i++) {
|
|
let move = this.getMove(set.moves[i]);
|
|
if (move.gen > this.gen) {
|
|
problems.push(move.name + ' does not exist in gen ' + this.gen + '.');
|
|
} else if (move.isNonstandard) {
|
|
problems.push(move.name + ' is not a real move.');
|
|
}
|
|
if (move.id === 'swordsdance') hasSD = true;
|
|
}
|
|
}
|
|
if (set.moves && set.moves.length > 4) {
|
|
problems.push((set.name || set.species) + ' has more than four moves.');
|
|
}
|
|
|
|
// Automatically set ability to None
|
|
set.ability = 'None';
|
|
|
|
if (toId(set.item) === 'thickclub' && set.species === 'Marowak' && hasSD) {
|
|
set.ivs.atk = 26;
|
|
}
|
|
|
|
// They all also get a useless nature, since that didn't exist
|
|
set.nature = 'Serious';
|
|
|
|
return problems;
|
|
},
|
|
},
|
|
standard: {
|
|
effectType: 'ValidatorRule',
|
|
name: 'Standard',
|
|
ruleset: ['Sleep Clause Mod', 'Species Clause', 'OHKO Clause', 'Evasion Moves Clause', 'HP Percentage Mod', 'Cancel Mod'],
|
|
banlist: ['Unreleased', 'Illegal',
|
|
'Hypnosis + Perish Song + Mean Look',
|
|
'Hypnosis + Perish Song + Spider Web',
|
|
'Lovely Kiss + Perish Song + Mean Look',
|
|
'Lovely Kiss + Perish Song + Spider Web',
|
|
'Sing + Perish Song + Mean Look',
|
|
'Sing + Perish Song + Spider Web',
|
|
'Sleep Powder + Perish Song + Mean Look',
|
|
'Sleep Powder + Perish Song + Spider Web',
|
|
'Spore + Perish Song + Mean Look',
|
|
'Spore + Perish Song + Spider Web',
|
|
],
|
|
onValidateSet: function (set) {
|
|
// limit one of each move in Standard
|
|
let moves = [];
|
|
if (set.moves) {
|
|
let hasMove = {};
|
|
for (let i = 0; i < set.moves.length; i++) {
|
|
let move = this.getMove(set.moves[i]);
|
|
let moveid = move.id;
|
|
if (hasMove[moveid]) continue;
|
|
hasMove[moveid] = true;
|
|
moves.push(set.moves[i]);
|
|
}
|
|
}
|
|
set.moves = moves;
|
|
},
|
|
},
|
|
};
|