From efb0433dbe06dfd544cf1de21fb0cc09ef090948 Mon Sep 17 00:00:00 2001 From: Kris Johnson <11083252+KrisXV@users.noreply.github.com> Date: Tue, 14 Mar 2023 17:44:50 -0600 Subject: [PATCH] FIx crash with Force Monotype (#9467) --- data/rulesets.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/data/rulesets.ts b/data/rulesets.ts index 8585a18682..dcf553a982 100644 --- a/data/rulesets.ts +++ b/data/rulesets.ts @@ -441,13 +441,21 @@ export const Rulesets: {[k: string]: FormatData} = { desc: `Forces all teams to have the same type. Usage: Force Monotype = [Type], e.g. "Force Monotype = Water"`, hasValue: true, onValidateRule(value) { - if (!this.dex.types.get(value).exists) throw new Error(`Misspelled type "${value}"`); + const type = this.dex.types.get(value); + if (!type.exists) throw new Error(`Misspelled type "${value}"`); + // Temporary hardcode until types support generations + if ( + (['Dark', 'Steel'].includes(type.name) && this.dex.gen < 2) || + (type.name === 'Fairy' && this.dex.gen < 6) + ) { + throw new Error(`Invalid type "${type.name}" in Generation ${this.dex.gen}`); + } }, onValidateSet(set) { const species = this.dex.species.get(set.species); const type = this.dex.types.get(this.ruleTable.valueRules.get('forcemonotype')!); if (!species.types.map(this.toID).includes(type.id)) { - return [`${set.species} must have type ${type.name}`]; + return [`${set.species} must have ${type.name} type.`]; } }, },