From 0486221a78a6828c71efdf15b2d7b7e9e6d85f5d Mon Sep 17 00:00:00 2001 From: Jerick Date: Thu, 16 May 2024 04:04:10 +0530 Subject: [PATCH 1/4] fix redundant string slicing and explicit checks for protosynthesis and quarkdrive in -start case --- play.pokemonshowdown.com/src/battle-text-parser.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle-text-parser.ts b/play.pokemonshowdown.com/src/battle-text-parser.ts index af84ecb006..f5c2001fa6 100644 --- a/play.pokemonshowdown.com/src/battle-text-parser.ts +++ b/play.pokemonshowdown.com/src/battle-text-parser.ts @@ -602,11 +602,6 @@ class BattleTextParser { const template = this.template('activate', 'perishsong'); return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[NUMBER]', num); } - if (id.startsWith('protosynthesis') || id.startsWith('quarkdrive')) { - const stat = id.slice(-3); - const template = this.template('start', id.slice(0, id.length - 3)); - return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[STAT]', BattleTextParser.stat(stat)); - } let templateId = 'start'; if (kwArgs.already) templateId = 'alreadyStarted'; if (kwArgs.fatigue) templateId = 'startFromFatigue'; @@ -620,7 +615,7 @@ class BattleTextParser { templateId += 'FromItem'; } const template = this.template(templateId, kwArgs.from, effect); - return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[EFFECT]', this.effect(effect)).replace('[MOVE]', arg3).replace('[SOURCE]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(kwArgs.from)); + return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[EFFECT]', this.effect(effect)).replace('[MOVE]', arg3).replace('[STAT]', BattleTextParser.stat(arg3)).replace('[SOURCE]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(kwArgs.from)); } case '-end': { From a0e3a459b18c6cb540c681e1d1fa3da86f447630 Mon Sep 17 00:00:00 2001 From: Jerick Date: Thu, 16 May 2024 05:15:35 +0530 Subject: [PATCH 2/4] fix typo --- play.pokemonshowdown.com/src/battle-text-parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/battle-text-parser.ts b/play.pokemonshowdown.com/src/battle-text-parser.ts index f5c2001fa6..a858f8308a 100644 --- a/play.pokemonshowdown.com/src/battle-text-parser.ts +++ b/play.pokemonshowdown.com/src/battle-text-parser.ts @@ -615,7 +615,7 @@ class BattleTextParser { templateId += 'FromItem'; } const template = this.template(templateId, kwArgs.from, effect); - return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[EFFECT]', this.effect(effect)).replace('[MOVE]', arg3).replace('[STAT]', BattleTextParser.stat(arg3)).replace('[SOURCE]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(kwArgs.from)); + return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[EFFECT]', this.effect(effect)).replace('[MOVE]', arg3).replace('[STAT]', this.stat(arg3)).replace('[SOURCE]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(kwArgs.from)); } case '-end': { From d839843ca6ff9c2274106909f57f284e1cf49981 Mon Sep 17 00:00:00 2001 From: Jerick120 <52036765+Jerick120@users.noreply.github.com> Date: Thu, 16 May 2024 10:19:05 +0530 Subject: [PATCH 3/4] Update play.pokemonshowdown.com/src/battle-text-parser.ts Co-authored-by: Guangcong Luo --- play.pokemonshowdown.com/src/battle-text-parser.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/play.pokemonshowdown.com/src/battle-text-parser.ts b/play.pokemonshowdown.com/src/battle-text-parser.ts index a858f8308a..ad32d99012 100644 --- a/play.pokemonshowdown.com/src/battle-text-parser.ts +++ b/play.pokemonshowdown.com/src/battle-text-parser.ts @@ -602,6 +602,11 @@ class BattleTextParser { const template = this.template('activate', 'perishsong'); return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[NUMBER]', num); } + if (id.startsWith('protosynthesis') || id.startsWith('quarkdrive')) { + const stat = id.slice(-3); + id = id.slice(0, 3); + if (stat) arg3 = stat; + } let templateId = 'start'; if (kwArgs.already) templateId = 'alreadyStarted'; if (kwArgs.fatigue) templateId = 'startFromFatigue'; From f118b4ed549f60feb81469fef8bab771ab3d322a Mon Sep 17 00:00:00 2001 From: Jerick120 <52036765+Jerick120@users.noreply.github.com> Date: Thu, 16 May 2024 10:19:15 +0530 Subject: [PATCH 4/4] Update play.pokemonshowdown.com/src/battle-text-parser.ts Co-authored-by: Guangcong Luo --- play.pokemonshowdown.com/src/battle-text-parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/battle-text-parser.ts b/play.pokemonshowdown.com/src/battle-text-parser.ts index ad32d99012..8d4a4a1158 100644 --- a/play.pokemonshowdown.com/src/battle-text-parser.ts +++ b/play.pokemonshowdown.com/src/battle-text-parser.ts @@ -620,7 +620,7 @@ class BattleTextParser { templateId += 'FromItem'; } const template = this.template(templateId, kwArgs.from, effect); - return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[EFFECT]', this.effect(effect)).replace('[MOVE]', arg3).replace('[STAT]', this.stat(arg3)).replace('[SOURCE]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(kwArgs.from)); + return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[EFFECT]', this.effect(effect)).replace('[MOVE]', arg3).replace('[STAT]', BattleTextParser.stat(arg3)).replace('[SOURCE]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(kwArgs.from)); } case '-end': {