Skip to content

Commit

Permalink
Fixed root issue with double spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Aug 4, 2023
1 parent e19a6d6 commit e9392e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
9 changes: 4 additions & 5 deletions calc/src/desc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
20 changes: 20 additions & 0 deletions calc/src/test/calc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
});
});
});
});
Expand Down

0 comments on commit e9392e6

Please sign in to comment.