fix parsing of Thunder / Thunder Punch
This commit is contained in:
		
							
								
								
									
										11
									
								
								calc.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								calc.js
									
									
									
									
									
								
							| @@ -63,7 +63,10 @@ function buildLexer() { | ||||
|   const Move = createToken({ | ||||
|     name: "Move", | ||||
|     pattern: new RegExp( | ||||
|       [...gen.moves].map((m) => escapeRegExp(m.name)).join("|") | ||||
|       [...gen.moves] | ||||
|         .map((m) => escapeRegExp(m.name)) | ||||
|         .sort((a, b) => b.length - a.length) | ||||
|         .join("|") | ||||
|     ), | ||||
|   }); | ||||
|  | ||||
| @@ -350,6 +353,12 @@ function test() { | ||||
|  | ||||
|   res = parseAndCalculate("Zoroark-Hisui Night Slash vs Golem"); | ||||
|   assert(res.attacker.name === "Zoroark-Hisui", "should parse regional forme"); | ||||
|  | ||||
|   res = parseAndCalculate("Ditto Thunder Punch vs. Avalugg"); | ||||
|   assert( | ||||
|     res.move.name === "Thunder Punch", | ||||
|     "should match entire move that is a superset of another move" | ||||
|   ); | ||||
| } | ||||
|  | ||||
| export { parseAndCalculate, test }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user