Compare commits

..

2 Commits

Author SHA1 Message Date
6d92cb4deb
add pre-checking 2023-04-27 09:51:42 +10:00
32e142b8cb
fix gen 2023-04-27 09:51:41 +10:00

View File

@ -8,6 +8,8 @@ import calc, {
import assert from "assert"; import assert from "assert";
import chev, { Lexer } from "chevrotain"; import chev, { Lexer } from "chevrotain";
const gen = Generations.get(9);
/** /**
* Creates a lexer. * Creates a lexer.
* *
@ -266,7 +268,11 @@ function parseAndCalculate(line) {
} }
} }
const gen = Generations.get(8); // Pre-checking before the calculator throws unreadable errors.
if (!gen.species.get(attacker)) throw Error(`No species ${attacker}`);
if (!gen.species.get(defender)) throw Error(`No species ${attacker}`);
if (!gen.moves.get(move)) throw Error(`No move ${move}`);
return calculate( return calculate(
gen, gen,
new Pokemon(gen, attacker, attackerOpts), new Pokemon(gen, attacker, attackerOpts),