From 6d92cb4deba9e3107d14aad65b6e3d99ac8e94a4 Mon Sep 17 00:00:00 2001 From: xeals Date: Thu, 27 Apr 2023 09:51:42 +1000 Subject: [PATCH] add pre-checking --- calc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/calc.js b/calc.js index 3265688..24b893c 100644 --- a/calc.js +++ b/calc.js @@ -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),