add pre-checking
This commit is contained in:
		
							
								
								
									
										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( | ||||
|     gen, | ||||
|     new Pokemon(gen, attacker, attackerOpts), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user