add pre-checking
This commit is contained in:
parent
32e142b8cb
commit
6d92cb4deb
5
calc.js
5
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(
|
return calculate(
|
||||||
gen,
|
gen,
|
||||||
new Pokemon(gen, attacker, attackerOpts),
|
new Pokemon(gen, attacker, attackerOpts),
|
||||||
|
Loading…
Reference in New Issue
Block a user