add pre-checking

This commit is contained in:
xeals 2023-04-27 09:51:42 +10:00
parent 32e142b8cb
commit 6d92cb4deb
Signed by: xeals
GPG Key ID: A498C7AF27EC6B5C

View File

@ -268,6 +268,11 @@ function parseAndCalculate(line) {
}
}
// 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(
gen,
new Pokemon(gen, attacker, attackerOpts),