Refactor nonstandard banlists into rulesets (#3470)

This commit is contained in:
MacChaeger 2017-04-22 02:19:39 -05:00 committed by Guangcong Luo
parent a1ccee96e3
commit 9da05b8635
3 changed files with 42 additions and 26 deletions

View File

@ -109,8 +109,7 @@ exports.Formats = [
],
mod: 'gen7',
ruleset: ['[Gen 7] OU'],
banlist: ['Allow CAP'],
ruleset: ['[Gen 7] OU', 'Allow CAP'],
},
{
name: "[Gen 7] CAP LC",
@ -119,8 +118,7 @@ exports.Formats = [
mod: 'gen7',
searchShow: false,
maxLevel: 5,
ruleset: ['[Gen 7] LC'],
banlist: ['Allow CAP'],
ruleset: ['[Gen 7] LC', 'Allow CAP'],
},
{
name: "[Gen 7] Battle Spot Singles",
@ -507,9 +505,8 @@ exports.Formats = [
],
mod: 'gen7',
ruleset: ['Pokemon', 'Standard', 'Ability Clause', 'Baton Pass Clause', 'Swagger Clause', 'Team Preview'],
banlist: ['Ignore Illegal Abilities',
'Aegislash', 'Arceus', 'Archeops', 'Blaziken', 'Darkrai', 'Deoxys', 'Dialga', 'Dragonite', 'Dugtrio-Base', 'Giratina', 'Groudon',
ruleset: ['Pokemon', 'Standard', 'Ability Clause', 'Ignore Illegal Abilities', 'Baton Pass Clause', 'Swagger Clause', 'Team Preview'],
banlist: ['Aegislash', 'Arceus', 'Archeops', 'Blaziken', 'Darkrai', 'Deoxys', 'Dialga', 'Dragonite', 'Dugtrio-Base', 'Giratina', 'Groudon',
'Ho-Oh', 'Kartana', 'Keldeo', 'Kyogre', 'Kyurem-Black', 'Kyurem-White', 'Lugia', 'Lunala', 'Mewtwo', 'Palkia', 'Pheromosa',
'Rayquaza', 'Regigigas', 'Reshiram', 'Shaymin-Sky', 'Shedinja', 'Slaking', 'Solgaleo', 'Xerneas', 'Yveltal', 'Zekrom',
'Power Construct', 'Shadow Tag', 'Gengarite', 'Kangaskhanite', 'Lucarionite', 'Salamencite',
@ -535,20 +532,9 @@ exports.Formats = [
],
mod: 'gen7',
ruleset: ['[Gen 7] OU'],
banlist: ['Allow One Sketch', 'Dugtrio-Base'],
ruleset: ['[Gen 7] OU', 'Allow One Sketch', 'Sketch Clause'],
banlist: ['Dugtrio-Base'],
noSketch: ['Belly Drum', 'Celebrate', 'Conversion', "Forest's Curse", 'Geomancy', 'Happy Hour', 'Hold Hands', 'Lovely Kiss', 'Purify', 'Shell Smash', 'Shift Gear', 'Sketch', 'Spore', 'Trick-or-Treat'],
onValidateTeam: function (team) {
let sketchedMoves = {};
for (let i = 0; i < team.length; i++) {
let move = team[i].sketchmonsMove;
if (!move) continue;
if (move in sketchedMoves) {
return ["You are limited to sketching one of each move by Move Clause.", "(You have sketched " + this.getMove(move).name + " more than once)"];
}
sketchedMoves[move] = (team[i].name || team[i].species);
}
},
},
{
name: "[Gen 7] Hidden Type",
@ -761,8 +747,7 @@ exports.Formats = [
],
searchShow: false,
ruleset: ['OU'],
banlist: ['Allow CAP'],
ruleset: ['OU', 'Allow CAP'],
},
{
name: "Battle Spot Singles",

View File

@ -76,7 +76,7 @@ exports.BattleFormats = {
let template = this.getTemplate(set.species);
let problems = [];
let totalEV = 0;
let allowCAP = !!(format && format.banlistTable && format.banlistTable['allowcap']);
let allowCAP = !!(format && format.banlistTable && format.banlistTable['Rule:allowcap']);
if (set.species === set.name) delete set.name;
if (template.gen > this.gen) {
@ -228,7 +228,7 @@ exports.BattleFormats = {
// Autofixed forme.
template = this.getTemplate(set.species);
if (!format.banlistTable['ignoreillegalabilities'] && !format.noChangeAbility) {
if (!format.banlistTable['Rule:ignoreillegalabilities'] && !format.noChangeAbility) {
// Ensure that the ability is (still) legal.
let legalAbility = false;
for (let i in template.abilities) {
@ -702,4 +702,34 @@ exports.BattleFormats = {
return -typeMod;
},
},
sketchclause: {
effectType: 'ValidatorRule',
name: 'Sketch Clause',
onValidateTeam: function (team) {
let sketchedMoves = {};
for (let i = 0; i < team.length; i++) {
let move = team[i].sketchmonsMove;
if (!move) continue;
if (move in sketchedMoves) {
return ["You are limited to sketching one of each move by the Sketch Clause.", "(You have sketched " + this.getMove(move).name + " more than once)"];
}
sketchedMoves[move] = (team[i].name || team[i].species);
}
},
},
ignoreillegalabilities: {
effectType: 'ValidatorRule',
name: 'Ignore Illegal Abilities',
// Implemented in the 'pokemon' ruleset and in teamvalidator.js
},
allowonesketch: {
effectType: 'ValidorRule',
name: 'Allow One Sketch',
// Implemented in teamvalidator.js
},
allowcap: {
effectType: 'ValidatorRule',
name: 'Allow CAP',
// Implemented in the 'pokemon' ruleset
},
};

View File

@ -277,7 +277,7 @@ class Validator {
// Don't check abilities for metagames with All Abilities
if (tools.gen <= 2) {
set.ability = 'None';
} else if (!banlistTable['ignoreillegalabilities']) {
} else if (!banlistTable['Rule:ignoreillegalabilities']) {
if (!ability.name) {
problems.push(`${name} needs to have an ability.`);
} else if (!Object.values(template.abilities).includes(ability.name)) {
@ -341,7 +341,8 @@ class Validator {
let problem = this.checkLearnset(move, template, lsetData);
if (problem) {
// Sketchmons hack
if (banlistTable['allowonesketch'] && format.noSketch.indexOf(move.name) < 0 && !set.sketchmonsMove && !move.noSketch && !move.isZ) {
const noSketch = format.noSketch || tools.getFormat('gen7sketchmons').noSketch;
if (banlistTable['Rule:allowonesketch'] && noSketch.indexOf(move.name) < 0 && !set.sketchmonsMove && !move.noSketch && !move.isZ) {
set.sketchmonsMove = move.id;
continue;
}