fix ID lookup for pre-validation

This commit is contained in:
xeals 2023-04-27 11:17:22 +10:00
parent c75258a868
commit c239aadfaf
Signed by: xeals
GPG Key ID: A498C7AF27EC6B5C

View File

@ -1,5 +1,6 @@
import { import {
calculate, calculate,
toID,
Field, Field,
Generations, Generations,
Move, Move,
@ -266,11 +267,11 @@ function parseAndCalculate(line) {
} }
// Pre-checking before the calculator throws unreadable errors. // Pre-checking before the calculator throws unreadable errors.
if (!gen.species.get(attacker.toLowerCase())) if (!gen.species.get(toID(attacker)))
throw Error(`No species named ${attacker}`); throw Error(`No species named ${attacker}`);
if (!gen.species.get(defender.toLowerCase())) if (!gen.species.get(toID(defender)))
throw Error(`No species named ${defender}`); throw Error(`No species named ${defender}`);
if (!gen.moves.get(move.toLowerCase())) throw Error(`No move named ${move}`); if (!gen.moves.get(toID(move))) throw Error(`No move named ${move}`);
return calculate( return calculate(
gen, gen,