mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-08-20 10:02:05 -05:00
Fix Confusion message grouping
This commit is contained in:
@@ -110,9 +110,13 @@ class BattleTextParser {
|
||||
return {args, kwArgs};
|
||||
}
|
||||
|
||||
extractMessage(line: string) {
|
||||
const {args, kwArgs} = BattleTextParser.parseLine(line);
|
||||
return this.parseArgs(args, kwArgs) || '';
|
||||
extractMessage(buf: string) {
|
||||
let out = '';
|
||||
for (const line of buf.split('\n')) {
|
||||
const {args, kwArgs} = BattleTextParser.parseLine(line);
|
||||
out += this.parseArgs(args, kwArgs) || '';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
fixLowercase(input: string) {
|
||||
@@ -267,18 +271,22 @@ class BattleTextParser {
|
||||
case '-damage': {
|
||||
const id = BattleTextParser.effectId(kwArgs.from);
|
||||
if (id === 'confusion') return 'major';
|
||||
return 'postMajor';
|
||||
}
|
||||
case '-curestatus': {
|
||||
const id = BattleTextParser.effectId(kwArgs.from);
|
||||
if (id === 'naturalcure') return 'preMajor';
|
||||
return 'postMajor';
|
||||
}
|
||||
case '-start': {
|
||||
const id = BattleTextParser.effectId(kwArgs.from);
|
||||
if (id === 'protean') return 'preMajor';
|
||||
return 'postMajor';
|
||||
}
|
||||
case '-activate': {
|
||||
const id = BattleTextParser.effectId(args[2]);
|
||||
if (id === 'confusion' || id === 'attract') return 'preMajor';
|
||||
return 'postMajor';
|
||||
}
|
||||
}
|
||||
return (cmd.charAt(0) === '-' ? 'postMajor' : '');
|
||||
|
||||
@@ -99,13 +99,26 @@ describe('Text parser', () => {
|
||||
it('should process messages correctly', () => {
|
||||
let parser = new BattleTextParser();
|
||||
|
||||
assert.equal(parser.extractMessage('|-activate|p2a: Cool.|move: Skill Swap|Speed Boost|Cute Charm|[of] p1a: Speedy'), ` [The opposing Cool.'s Speed Boost]
|
||||
assert.equal(parser.extractMessage(`|-activate|p2a: Cool.|move: Skill Swap|Speed Boost|Cute Charm|[of] p1a: Speedy`), ` [The opposing Cool.'s Speed Boost]
|
||||
[Speedy's Cute Charm]
|
||||
The opposing Cool. swapped Abilities with its target!
|
||||
`);
|
||||
assert.equal(parser.extractMessage('|-activate|p2a: Cool.|move: Skill Swap|p1a: Speedy|[ability]Speed Boost|[ability2]Cute Charm'), ` [The opposing Cool.'s Speed Boost]
|
||||
assert.equal(parser.extractMessage(`|-activate|p2a: Cool.|move: Skill Swap|p1a: Speedy|[ability]Speed Boost|[ability2]Cute Charm`), ` [The opposing Cool.'s Speed Boost]
|
||||
[Speedy's Cute Charm]
|
||||
The opposing Cool. swapped Abilities with its target!
|
||||
`);
|
||||
assert.equal(parser.extractMessage(`|move|p2a: Palkia|Swagger|p1a: Shroomish
|
||||
|-boost|p1a: Shroomish|atk|2
|
||||
|-start|p1a: Shroomish|confusion
|
||||
|-activate|p1a: Shroomish|confusion
|
||||
|move|p1a: Shroomish|Power-Up Punch|p2a: Palkia
|
||||
`), `
|
||||
The opposing Palkia used **Swagger**!
|
||||
Shroomish's Attack rose sharply!
|
||||
Shroomish became confused!
|
||||
|
||||
Shroomish is confused!
|
||||
Shroomish used **Power-Up Punch**!
|
||||
`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user