Remove Object.assign(function) pattern from TeamValidator{Async}

This commit is contained in:
Kirk Scheibelhut 2019-07-01 08:16:42 -07:00
parent 65aeec5c1d
commit df083d7528
11 changed files with 79 additions and 86 deletions

View File

@ -101,8 +101,8 @@ if (!process.argv[2] || /^[0-9]+$/.test(process.argv[2])) {
case 'validate-team':
{
var Dex = require('./.sim-dist/dex').Dex;
var TeamValidator = require('./.sim-dist/team-validator');
var validator = TeamValidator(process.argv[3]);
var TeamValidator = require('./.sim-dist/team-validator').TeamValidator;
var validator = TeamValidator.get(process.argv[3]);
var Streams = require('./.lib-dist/streams');
var stdin = new Streams.ReadStream(process.stdin);

View File

@ -4321,7 +4321,7 @@ const commands = {
let format = originalFormat.effectType === 'Format' ? originalFormat : Dex.getFormat('[Gen 7] Pokebank Anything Goes');
if (format.effectType !== 'Format') return this.popupReply("Please provide a valid format.");
TeamValidatorAsync(format.id).validateTeam(user.team).then(result => {
TeamValidatorAsync.get(format.id).validateTeam(user.team).then(result => {
let matchMessage = (originalFormat === format ? "" : `The format '${originalFormat.name}' was not found.`);
if (result.charAt(0) === '1') {
connection.popup(`${(matchMessage ? matchMessage + "\n\n" : "")}Your team is valid for ${format.name}.`);

View File

@ -723,7 +723,7 @@ function runDexsearch(target, cmd, canAll, message) {
for (let move in alts.moves) {
if (!lsetData[mon]) lsetData[mon] = {fastCheck: true, sources: [], sourcesBefore: maxGen};
if (!TeamValidator(`gen${maxGen}ou`).checkLearnset(move, mon, lsetData[mon]) === alts.moves[move]) {
if (!TeamValidator.get(`gen${maxGen}ou`).checkLearnset(move, mon, lsetData[mon]) === alts.moves[move]) {
matched = true;
break;
}
@ -1567,7 +1567,7 @@ function runLearn(target, cmd) {
}
let lsetData = {set: {}, sources: [], sourcesBefore: gen};
const validator = TeamValidator(format);
const validator = TeamValidator.get(format);
let template = validator.dex.getTemplate(targets.shift());
let move = {};
let all = (cmd === 'learnall');

View File

@ -137,7 +137,7 @@ class Ladder extends LadderStore {
if (isRated && !Ladders.disabled) {
let userid = user.userid;
[valResult, rating] = await Promise.all([
TeamValidatorAsync(this.formatid).validateTeam(team, !!(user.locked || user.namelocked)),
TeamValidatorAsync.get(this.formatid).validateTeam(team, !!(user.locked || user.namelocked)),
this.getRating(userid),
]);
if (userid !== user.userid) {
@ -150,7 +150,7 @@ class Ladder extends LadderStore {
connection.popup(`The ladder is temporarily disabled due to technical difficulties - you will not receive ladder rating for this game.`);
rating = 1;
}
valResult = await TeamValidatorAsync(this.formatid).validateTeam(team, !!(user.locked || user.namelocked));
valResult = await TeamValidatorAsync.get(this.formatid).validateTeam(team, !!(user.locked || user.namelocked));
}
if (valResult.charAt(0) !== '1') {

View File

@ -12,7 +12,7 @@
/** @type {typeof import('../lib/crashlogger').crashlogger} */
let crashlogger = require(/** @type {any} */('../.lib-dist/crashlogger')).crashlogger;
class ValidatorAsync {
class TeamValidatorAsync {
/**
* @param {string} format
*/
@ -29,6 +29,13 @@ class ValidatorAsync {
if (this.format.customRules) formatid += '@@@' + this.format.customRules.join(',');
return PM.query({formatid, removeNicknames, team});
}
/**
* @param {string} format
*/
static get(format) {
return new TeamValidatorAsync(format);
}
}
/*********************************************************
@ -46,7 +53,7 @@ const PM = new QueryProcessManager(module, async message => {
let problems;
try {
problems = TeamValidator(formatid).validateTeam(parsedTeam, removeNicknames);
problems = TeamValidator.get(formatid).validateTeam(parsedTeam, removeNicknames);
} catch (err) {
crashlogger(err, 'A team validation', {
formatid: formatid,
@ -110,13 +117,4 @@ if (!PM.isParentProcess) {
* Exports
*********************************************************/
function getAsyncValidator(/** @type {string} */ format) {
return new ValidatorAsync(format);
}
let TeamValidatorAsync = Object.assign(getAsyncValidator, {
ValidatorAsync,
PM,
});
module.exports = TeamValidatorAsync;
module.exports = {get: TeamValidatorAsync.get, TeamValidatorAsync, PM};

View File

@ -1218,7 +1218,7 @@ const commands = {
if (Monitor.countPrepBattle(connection.ip, connection)) {
return;
}
TeamValidatorAsync(tournament.teambuilderFormat).validateTeam(user.team).then(result => {
TeamValidatorAsync.get(tournament.teambuilderFormat).validateTeam(user.team).then(result => {
if (result.charAt(0) === '1') {
connection.popup("Your team is valid for this tournament.");
} else {

1
sim/global.d.ts vendored
View File

@ -28,7 +28,6 @@ declare global {
const Side: SideType
const Sim: typeof SimType
const TeamValidator: typeof TeamValidatorType
const Validator: typeof TeamValidatorType.Validator
const Ability: DataType.Ability
const BasicEffect: DataType.BasicEffect

View File

@ -4,7 +4,7 @@ type ModdedDex = import('./dex').ModdedDex
type Pokemon = import('./pokemon').Pokemon
type PRNGSeed = import('./prng').PRNGSeed;
type Side = import('./side').Side
type Validator = import('./team-validator').Validator
type TeamValidator = import('./team-validator').TeamValidator
type ID = '' | string & {__isID: true};
interface AnyObject {[k: string]: any}
@ -1053,7 +1053,7 @@ interface FormatsData extends EventMethods {
timer?: Partial<GameTimerSettings>
tournamentShow?: boolean
unbanlist?: string[]
checkLearnset?: (this: Validator, move: Move, template: Template, lsetData: PokemonSources, set: PokemonSet) => {type: string, [any: string]: any} | null
checkLearnset?: (this: TeamValidator, move: Move, template: Template, lsetData: PokemonSources, set: PokemonSet) => {type: string, [any: string]: any} | null
onAfterMega?: (this: Battle, pokemon: Pokemon) => void
onBegin?: (this: Battle) => void
onChangeSet?: (this: ModdedDex, set: PokemonSet, format: Format, setHas?: AnyObject, teamHas?: AnyObject) => string[] | void
@ -1062,8 +1062,8 @@ interface FormatsData extends EventMethods {
onTeamPreview?: (this: Battle) => void
onValidateSet?: (this: ModdedDex, set: PokemonSet, format: Format, setHas: AnyObject, teamHas: AnyObject) => string[] | void
onValidateTeam?: (this: ModdedDex, team: PokemonSet[], format: Format, teamHas: AnyObject) => string[] | void
validateSet?: (this: Validator, set: PokemonSet, teamHas: AnyObject) => string[] | null
validateTeam?: (this: Validator, team: PokemonSet[], removeNicknames: boolean) => string[] | void,
validateSet?: (this: TeamValidator, set: PokemonSet, teamHas: AnyObject) => string[] | null
validateTeam?: (this: TeamValidator, team: PokemonSet[], removeNicknames: boolean) => string[] | void,
trunc?: (n: number) => number;
section?: string,
column?: number

View File

@ -9,7 +9,7 @@
import {Dex} from './dex';
export class Validator {
export class TeamValidator {
readonly format: Format;
readonly dex: ModdedDex;
readonly ruleTable: RuleTable;
@ -311,7 +311,7 @@ export class Validator {
return problems;
}
set.ivs = Validator.fillStats(set.ivs, 31);
set.ivs = TeamValidator.fillStats(set.ivs, 31);
let ivs: StatsTable = set.ivs;
const maxedIVs = Object.values(ivs).every(stat => stat === 31);
@ -358,7 +358,7 @@ export class Validator {
}
ivs.hp = -1;
} else if (!canBottleCap) {
ivs = set.ivs = Validator.fillStats(dex.getType(set.hpType).HPivs, 31);
ivs = set.ivs = TeamValidator.fillStats(dex.getType(set.hpType).HPivs, 31);
}
}
if (set.hpType === 'Fighting' && ruleTable.has('pokemon')) {
@ -415,7 +415,7 @@ export class Validator {
}
}
if (dex.gen <= 2 || dex.gen !== 6 && (format.id.endsWith('hackmons') || format.name.includes('BH'))) {
if (!set.evs) set.evs = Validator.fillStats(null, 252);
if (!set.evs) set.evs = TeamValidator.fillStats(null, 252);
const evTotal = (set.evs.hp || 0) + (set.evs.atk || 0) + (set.evs.def || 0) +
(set.evs.spa || 0) + (set.evs.spd || 0) + (set.evs.spe || 0);
if (evTotal === 508 || evTotal === 510) {
@ -676,7 +676,7 @@ export class Validator {
}
} else {
requiredIVs = eventData.perfectIVs || 0;
if (eventData.generation >= 6 && eventData.perfectIVs === undefined && Validator.hasLegendaryIVs(template)) {
if (eventData.generation >= 6 && eventData.perfectIVs === undefined && TeamValidator.hasLegendaryIVs(template)) {
requiredIVs = 3;
}
}
@ -1296,12 +1296,8 @@ export class Validator {
}
return filledStats;
}
}
function getValidator(format: string | Format) {
return new Validator(format);
static get(format: string | Format) {
return new TeamValidator(format);
}
}
export const TeamValidator = Object.assign(getValidator, {
Validator,
});

View File

@ -28,7 +28,7 @@ function isValidSet(gen, set) {
}
function validLearnset(move, set, tier) {
const validator = TeamValidator(`gen7${tier}`);
const validator = TeamValidator.get(`gen7${tier}`);
const template = validator.dex.getTemplate(set.species || set.name);
return !validator.checkLearnset(move, template);
}

View File

@ -19,7 +19,7 @@ describe('Team Validator', function () {
let team = [
{species: 'nonexistentPokemon', moves: ['thunderbolt'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7customgame').validateTeam(team);
let illegal = TeamValidator.get('gen7customgame').validateTeam(team);
assert(illegal);
});
@ -27,7 +27,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', moves: ['thunderbolt'], ability: 'static', item: 'nonexistentItem', evs: {hp: 1}},
];
let illegal = TeamValidator('gen7customgame').validateTeam(team);
let illegal = TeamValidator.get('gen7customgame').validateTeam(team);
assert(illegal);
});
@ -35,7 +35,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', moves: ['thunderbolt'], ability: 'nonexistentAbility', evs: {hp: 1}},
];
let illegal = TeamValidator('gen7customgame').validateTeam(team);
let illegal = TeamValidator.get('gen7customgame').validateTeam(team);
assert(illegal);
});
@ -43,21 +43,21 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['nonexistentMove'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7customgame').validateTeam(team);
let illegal = TeamValidator.get('gen7customgame').validateTeam(team);
assert(illegal);
});
it('should validate Gen 2 IVs', function () {
let team = Dex.fastUnpackTeam('|raikou|||hiddenpowerwater||||14,28,26,,,|||');
let illegal = TeamValidator('gen2ou').validateTeam(team);
let illegal = TeamValidator.get('gen2ou').validateTeam(team);
assert.strictEqual(illegal, null);
team = Dex.fastUnpackTeam('|raikou|||hiddenpowerfire||||14,28,26,,,|||');
illegal = TeamValidator('gen2ou').validateTeam(team);
illegal = TeamValidator.get('gen2ou').validateTeam(team);
assert(illegal);
team = Dex.fastUnpackTeam('|raikou|||hiddenpowerwater||||16,28,26,,,|||');
illegal = TeamValidator('gen2ou').validateTeam(team);
illegal = TeamValidator.get('gen2ou').validateTeam(team);
assert(illegal);
});
@ -65,7 +65,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['thunderbolt'], nature: 'nonexistentNature', evs: {hp: 1}},
];
let illegal = TeamValidator('gen7customgame').validateTeam(team);
let illegal = TeamValidator.get('gen7customgame').validateTeam(team);
assert(illegal);
});
@ -73,7 +73,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['thunderbolt'], happiness: 'invalidHappinessValue', evs: {hp: 1}},
];
let illegal = TeamValidator('gen7customgame').validateTeam(team);
let illegal = TeamValidator.get('gen7customgame').validateTeam(team);
assert(illegal);
});
@ -81,13 +81,13 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'meowstic', ability: 'prankster', moves: ['trick', 'magiccoat'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
});
@ -95,7 +95,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['blastburn', 'frenzyplant', 'hydrocannon', 'dragonascent'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert(illegal);
});
@ -103,7 +103,7 @@ describe('Team Validator', function () {
let team = [
{species: 'arceus', ability: 'multitype', item: 'dragoniumz', moves: ['judgment'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen71v1').validateTeam(team);
let illegal = TeamValidator.get('gen71v1').validateTeam(team);
assert(illegal);
});
@ -111,49 +111,49 @@ describe('Team Validator', function () {
let team = [
{species: 'azumarill', ability: 'hugepower', moves: ['bellydrum', 'aquajet'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen5ou').validateTeam(team);
let illegal = TeamValidator.get('gen5ou').validateTeam(team);
assert(illegal);
team = [
{species: 'cloyster', moves: ['rapidspin', 'explosion']},
];
illegal = TeamValidator('gen2ou').validateTeam(team);
illegal = TeamValidator.get('gen2ou').validateTeam(team);
assert(illegal);
team = [
{species: 'blissey', moves: ['present', 'healbell']},
];
illegal = TeamValidator('gen2ou').validateTeam(team);
illegal = TeamValidator.get('gen2ou').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'marowak', moves: ['swordsdance', 'rockslide', 'bodyslam']},
];
illegal = TeamValidator('gen2ou').validateTeam(team);
illegal = TeamValidator.get('gen2ou').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'skarmory', ability: 'keeneye', moves: ['curse', 'drillpeck'], evs: {hp: 1}},
];
illegal = TeamValidator('gen3ou').validateTeam(team);
illegal = TeamValidator.get('gen3ou').validateTeam(team);
assert(illegal);
team = [
{species: 'skarmory', ability: 'keeneye', moves: ['whirlwind', 'drillpeck'], evs: {hp: 1}},
];
illegal = TeamValidator('gen3ou').validateTeam(team);
illegal = TeamValidator.get('gen3ou').validateTeam(team);
assert(illegal);
team = [
{species: 'armaldo', ability: 'battlearmor', moves: ['knockoff', 'rapidspin'], evs: {hp: 1}},
];
illegal = TeamValidator('gen3ou').validateTeam(team);
illegal = TeamValidator.get('gen3ou').validateTeam(team);
assert(illegal);
team = [
{species: 'snorlax', ability: 'immunity', moves: ['curse', 'pursuit'], evs: {hp: 1}},
];
illegal = TeamValidator('gen4ou').validateTeam(team);
illegal = TeamValidator.get('gen4ou').validateTeam(team);
assert.strictEqual(illegal, null);
});
@ -161,28 +161,28 @@ describe('Team Validator', function () {
let team = [
{species: 'machamp', ability: 'steadfast', moves: ['fissure'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'tauros', ability: 'sheerforce', moves: ['bodyslam'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'tauros', ability: 'intimidate', ivs: {hp: 31, atk: 31, def: 30, spa: 30, spd: 30, spe: 30}, moves: ['bodyslam'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'machamp', ability: 'noguard', moves: ['fissure'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert(illegal);
team = [
{species: 'tauros', ability: 'sheerforce', ivs: {hp: 31, atk: 31, def: 30, spa: 30, spd: 30, spe: 30}, moves: ['bodyslam'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert(illegal);
});
@ -190,33 +190,33 @@ describe('Team Validator', function () {
let team = [
{species: 'rockruff', ability: 'owntempo', moves: ['happyhour'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'rockruff', level: 9, ability: 'owntempo', moves: ['happyhour'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert(illegal);
team = [
{species: 'rockruff', level: 9, ability: 'owntempo', moves: ['tackle'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'rockruff', level: 9, ability: 'steadfast', moves: ['happyhour'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert(illegal);
team = [
{species: 'lycanrocdusk', ability: 'toughclaws', moves: ['happyhour'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
team = [
{species: 'lycanroc', ability: 'steadfast', moves: ['happyhour'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert(illegal);
});
@ -225,14 +225,14 @@ describe('Team Validator', function () {
let team = [
{species: 'gyaradosmega', item: 'gyaradosite', ability: 'intimidate', moves: ['dragondance', 'crunch', 'waterfall', 'icefang'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
// mega forme ability
team = [
{species: 'gyaradosmega', item: 'gyaradosite', ability: 'moldbreaker', moves: ['dragondance', 'crunch', 'waterfall', 'icefang'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7anythinggoes').validateTeam(team);
illegal = TeamValidator.get('gen7anythinggoes').validateTeam(team);
assert.strictEqual(illegal, null);
});
@ -240,7 +240,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pichu', ability: 'static', moves: ['thunderbolt']},
];
let illegal = TeamValidator('gen1ou').validateTeam(team);
let illegal = TeamValidator.get('gen1ou').validateTeam(team);
assert(illegal);
});
@ -251,7 +251,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes@@@-Pikachu').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes@@@-Pikachu').validateTeam(team);
assert(illegal);
});
@ -259,7 +259,7 @@ describe('Team Validator', function () {
let team = [
{species: 'blaziken', ability: 'blaze', moves: ['skyuppercut'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7ou@@@+Blaziken').validateTeam(team);
let illegal = TeamValidator.get('gen7ou@@@+Blaziken').validateTeam(team);
assert(!illegal);
});
@ -267,7 +267,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes@@@-Agility').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes@@@-Agility').validateTeam(team);
assert(illegal);
});
@ -275,7 +275,7 @@ describe('Team Validator', function () {
let team = [
{species: 'absol', ability: 'pressure', moves: ['batonpass'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7ou@@@+Baton Pass').validateTeam(team);
let illegal = TeamValidator.get('gen7ou@@@+Baton Pass').validateTeam(team);
assert(!illegal);
});
@ -283,7 +283,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], item: 'lightball', evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes@@@-Light Ball').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes@@@-Light Ball').validateTeam(team);
assert(illegal);
});
@ -291,7 +291,7 @@ describe('Team Validator', function () {
let team = [
{species: 'eevee', ability: 'runaway', moves: ['tackle'], item: 'eeviumz', evs: {hp: 1}},
];
let illegal = TeamValidator('gen7lc@@@+Eevium Z').validateTeam(team);
let illegal = TeamValidator.get('gen7lc@@@+Eevium Z').validateTeam(team);
assert(!illegal);
});
@ -299,7 +299,7 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes@@@-Static').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes@@@-Static').validateTeam(team);
assert(illegal);
});
@ -307,7 +307,7 @@ describe('Team Validator', function () {
let team = [
{species: 'wobbuffet', ability: 'shadowtag', moves: ['counter'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7ou@@@+Shadow Tag').validateTeam(team);
let illegal = TeamValidator.get('gen7ou@@@+Shadow Tag').validateTeam(team);
assert(!illegal);
});
@ -315,14 +315,14 @@ describe('Team Validator', function () {
let team = [
{species: 'pikachu', ability: 'static', moves: ['agility', 'protect', 'thunder', 'thunderbolt'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7anythinggoes@@@-Pikachu + Agility').validateTeam(team);
let illegal = TeamValidator.get('gen7anythinggoes@@@-Pikachu + Agility').validateTeam(team);
assert(illegal);
team = [
{species: 'smeargle', ability: 'owntempo', moves: ['gravity'], evs: {hp: 1}},
{species: 'pikachu', ability: 'static', moves: ['thunderbolt'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7doublesou@@@-Gravity ++ Thunderbolt').validateTeam(team);
illegal = TeamValidator.get('gen7doublesou@@@-Gravity ++ Thunderbolt').validateTeam(team);
assert(illegal);
});
@ -331,7 +331,7 @@ describe('Team Validator', function () {
{species: 'smeargle', ability: 'owntempo', moves: ['gravity'], evs: {hp: 1}},
{species: 'abomasnow', ability: 'snowwarning', moves: ['grasswhistle'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7doublesou@@@-Gravity ++ Grass Whistle > 2').validateTeam(team);
let illegal = TeamValidator.get('gen7doublesou@@@-Gravity ++ Grass Whistle > 2').validateTeam(team);
assert(!illegal);
team = [
@ -339,7 +339,7 @@ describe('Team Validator', function () {
{species: 'abomasnow', ability: 'snowwarning', moves: ['grasswhistle'], evs: {hp: 1}},
{species: 'cacturne', ability: 'sandveil', moves: ['grasswhistle'], evs: {hp: 1}},
];
illegal = TeamValidator('gen7doublesou@@@-Gravity ++ Grass Whistle > 2').validateTeam(team);
illegal = TeamValidator.get('gen7doublesou@@@-Gravity ++ Grass Whistle > 2').validateTeam(team);
assert(illegal);
});
@ -348,7 +348,7 @@ describe('Team Validator', function () {
{species: 'smeargle', ability: 'owntempo', moves: ['gravity'], evs: {hp: 1}},
{species: 'abomasnow', ability: 'snowwarning', moves: ['grasswhistle'], evs: {hp: 1}},
];
let illegal = TeamValidator('gen7doublesou@@@+Gravity ++ Grass Whistle').validateTeam(team);
let illegal = TeamValidator.get('gen7doublesou@@@+Gravity ++ Grass Whistle').validateTeam(team);
assert(!illegal);
});
});