From e9392e60e1db46713163466e5ef92096e936b548 Mon Sep 17 00:00:00 2001 From: Shriansh Chari <30420527+shrianshChari@users.noreply.github.com> Date: Thu, 3 Aug 2023 18:23:37 -0700 Subject: [PATCH] Fixed root issue with double spaces --- calc/src/desc.ts | 9 ++++----- calc/src/test/calc.test.ts | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/calc/src/desc.ts b/calc/src/desc.ts index 57530fd25..c1a543aff 100644 --- a/calc/src/desc.ts +++ b/calc/src/desc.ts @@ -873,16 +873,16 @@ function buildDescription(description: RawDesc, attacker: Pokemon, defender: Pok output += 'Helping Hand '; } if (description.isFlowerGiftAttacker) { - output += ' with an ally\'s Flower Gift '; + output += 'with an ally\'s Flower Gift '; } if (description.isBattery) { - output += ' Battery boosted '; + output += 'Battery boosted '; } if (description.isPowerSpot) { - output += ' Power Spot boosted '; + output += 'Power Spot boosted '; } if (description.isSwitching) { - output += ' switching boosted '; + output += 'switching boosted '; } output += description.moveName + ' '; if (description.moveBP && description.moveType) { @@ -953,7 +953,6 @@ function buildDescription(description: RawDesc, attacker: Pokemon, defender: Pok if (description.isWonderRoom) { output += ' in Wonder Room'; } - output = output.replace(/[ ]{2}/g, ' '); return output; } diff --git a/calc/src/test/calc.test.ts b/calc/src/test/calc.test.ts index 1a2e7411b..4f73bad74 100644 --- a/calc/src/test/calc.test.ts +++ b/calc/src/test/calc.test.ts @@ -1000,6 +1000,26 @@ describe('calc', () => { result = calculate(attacker, defender, Move('Revelation Dance')); expect(result.move.type).toBe('Water'); }); + + test('Flower Gift, Power Spot, Battery, and switching boosts shouldn\'t have double spaces', () => { + const attacker = Pokemon('Weavile'); + const defender = Pokemon('Vulpix'); + const field = Field({ + weather: 'Sun', + attackerSide: { + isFlowerGift: true, + isPowerSpot: true, + }, + defenderSide: { + isSwitching: 'out', + }, + }); + const result = calculate(attacker, defender, Move('Pursuit'), field); + + expect(result.desc()).toBe( + "0 Atk Weavile with an ally's Flower Gift Power Spot boosted switching boosted Pursuit (80 BP) vs. 0 HP / 0 Def Vulpix in Sun: 399-469 (183.8 - 216.1%) -- guaranteed OHKO" + ); + }); }); }); });