Skip to content

Commit

Permalink
Add support for Steely Spirit in npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Oct 22, 2024
1 parent 27df82c commit d809ba0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions calc/src/desc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface RawDesc {
isAuroraVeil?: boolean;
isFlowerGiftAttacker?: boolean;
isFlowerGiftDefender?: boolean;
isSteelySpiritAttacker?: boolean;
isFriendGuard?: boolean;
isHelpingHand?: boolean;
isCritical?: boolean;
Expand Down Expand Up @@ -939,6 +940,9 @@ function buildDescription(description: RawDesc, attacker: Pokemon, defender: Pok
if (description.isFlowerGiftAttacker) {
output += 'with an ally\'s Flower Gift ';
}
if (description.isSteelySpiritAttacker) {
output += 'with an ally\'s Steely Spirit ';
}
if (description.isBattery) {
output += 'Battery boosted ';
}
Expand Down
2 changes: 2 additions & 0 deletions calc/src/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class Side implements State.Side {
isAuroraVeil: boolean;
isBattery: boolean;
isPowerSpot: boolean;
isSteelySpirit: boolean;
isSwitching?: 'out' | 'in';

constructor(side: State.Side = {}) {
Expand All @@ -113,6 +114,7 @@ export class Side implements State.Side {
this.isAuroraVeil = !!side.isAuroraVeil;
this.isBattery = !!side.isBattery;
this.isPowerSpot = !!side.isPowerSpot;
this.isSteelySpirit = !!side.isSteelySpirit;
this.isSwitching = side.isSwitching;
}

Expand Down
8 changes: 8 additions & 0 deletions calc/src/mechanics/gen789.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,14 @@ export function calculateAtModsSMSSSV(
desc.isFlowerGiftAttacker = true;
}

if (
field.attackerSide.isSteelySpirit &&
move.hasType('Steel')
) {
atMods.push(6144);
desc.isSteelySpiritAttacker = true;
}

if ((defender.hasAbility('Thick Fat') && move.hasType('Fire', 'Ice')) ||
(defender.hasAbility('Water Bubble') && move.hasType('Fire')) ||
(defender.hasAbility('Purifying Salt') && move.hasType('Ghost'))) {
Expand Down
1 change: 1 addition & 0 deletions calc/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export namespace State {
isAuroraVeil?: boolean;
isBattery?: boolean;
isPowerSpot?: boolean;
isSteelySpirit?: boolean;
isSwitching?: 'out' | 'in';
}
}
32 changes: 32 additions & 0 deletions calc/src/test/calc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,38 @@ describe('calc', () => {
});
});
});

inGens(8, 9, ({gen, calculate, Pokemon, Move, Field}) => {
test('Steely Spirit should boost Steel-type moves as a field effect.', () => {
const pokemon = Pokemon('Perrserker', {
ability: 'Battle Armor',
});

const move = Move('Iron Head');

let result = calculate(pokemon, pokemon, move);

expect(result.desc()).toBe(
'0 Atk Perrserker Iron Head vs. 0 HP / 0 Def Perrserker: 46-55 (16.3 - 19.5%) -- possible 6HKO'
);

const field = Field({attackerSide: {isSteelySpirit: true}});

result = calculate(pokemon, pokemon, move, field);

expect(result.desc()).toBe(
'0 Atk Perrserker with an ally\'s Steely Spirit Iron Head vs. 0 HP / 0 Def Perrserker: 70-83 (24.9 - 29.5%) -- 99.9% chance to 4HKO'
);

pokemon.ability = 'Steely Spirit' as AbilityName;

result = calculate(pokemon, pokemon, move, field);

expect(result.desc()).toBe(
'0 Atk Steely Spirit Perrserker with an ally\'s Steely Spirit Iron Head vs. 0 HP / 0 Def Perrserker: 105-124 (37.3 - 44.1%) -- guaranteed 3HKO'
);
});
});
});


Expand Down

0 comments on commit d809ba0

Please sign in to comment.