fix parsing of Thunder / Thunder Punch
This commit is contained in:
parent
ce70a9fb4d
commit
5f5603fff7
11
calc.js
11
calc.js
@ -63,7 +63,10 @@ function buildLexer() {
|
|||||||
const Move = createToken({
|
const Move = createToken({
|
||||||
name: "Move",
|
name: "Move",
|
||||||
pattern: new RegExp(
|
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");
|
res = parseAndCalculate("Zoroark-Hisui Night Slash vs Golem");
|
||||||
assert(res.attacker.name === "Zoroark-Hisui", "should parse regional forme");
|
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 };
|
export { parseAndCalculate, test };
|
||||||
|
Loading…
Reference in New Issue
Block a user