From 9da05b86351e9aaeadd90b1e6ca3ac5ef13fbf62 Mon Sep 17 00:00:00 2001 From: MacChaeger Date: Sat, 22 Apr 2017 02:19:39 -0500 Subject: [PATCH] Refactor nonstandard banlists into rulesets (#3470) --- config/formats.js | 29 +++++++---------------------- data/rulesets.js | 34 ++++++++++++++++++++++++++++++++-- team-validator.js | 5 +++-- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/config/formats.js b/config/formats.js index ad12f28363..d08c635b82 100644 --- a/config/formats.js +++ b/config/formats.js @@ -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", diff --git a/data/rulesets.js b/data/rulesets.js index 54398a575f..1c3efb152c 100644 --- a/data/rulesets.js +++ b/data/rulesets.js @@ -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 + }, }; diff --git a/team-validator.js b/team-validator.js index a32dc6f2ac..6d33c9af40 100644 --- a/team-validator.js +++ b/team-validator.js @@ -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; }