Skip to content

Commit

Permalink
Add Flying Press and Ring Target tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaD173 committed Sep 29, 2024
1 parent 4034706 commit a4e1340
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions calc/src/test/calc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,43 @@ describe('calc', () => {
});
});

inGens(6, 9, ({gen, calculate, Pokemon, Move}) => {
test(`Flying Press (gen ${gen})`, () => {
const attacker = Pokemon('Hawlucha');
const flyingPress = Move('Flying Press');
// Test it is 4x dmg if weak to flying and fighting
const result = calculate(attacker, Pokemon('Cacturne'), flyingPress);
if (gen === 6) {
expect(result.range()).toEqual([484, 576]);
expect(result.desc()).toBe(
'0 Atk Hawlucha Flying Press vs. 0 HP / 0 Def Cacturne: 484-576 (172.2 - 204.9%) -- guaranteed OHKO'
);
} else {
expect(result.range()).toEqual([612, 720]);
expect(result.desc()).toBe(
'0 Atk Hawlucha Flying Press vs. 0 HP / 0 Def Cacturne: 612-720 (217.7 - 256.2%) -- guaranteed OHKO'
);
}

// Test still maintains fighting immunities
const result2 = calculate(attacker, Pokemon('Spiritomb'), flyingPress);
expect(result2.range()).toEqual([0, 0]);

// Test fighting immunities can be overridden
const scrappyAttacker = Pokemon('Hawlucha', {'ability': 'Scrappy'});
const ringTargetSpiritomb = Pokemon('Spiritomb', {'item': 'Ring Target'});
const result3 = calculate(attacker, ringTargetSpiritomb, flyingPress);
const result4 = calculate(scrappyAttacker, Pokemon('Spiritomb'), flyingPress);
if (gen === 6) {
expect(result3.range()).toEqual([152, 180]);
expect(result4.range()).toEqual([152, 180]);
} else {
expect(result3.range()).toEqual([188, 224]);
expect(result4.range()).toEqual([188, 224]);
}
});
});

inGens(6, 9, ({gen, calculate, Pokemon, Move}) => {
test(`Thousand Arrows and Ring Target Should negate damage nullfiers (gen ${gen})`, () => {
const result = calculate(Pokemon('Zygarde'), Pokemon('Swellow'), Move('Thousand Arrows'));
Expand All @@ -208,6 +245,23 @@ describe('calc', () => {
});
});

inGens(5, 9, ({gen, calculate, Pokemon, Move}) => {
test(`Ring Target should negate type nullfiers (gen ${gen})`, () => {
const attacker = Pokemon('Mew');
const defender = Pokemon('Skarmory', {'item': 'Ring Target'});
const result = calculate(attacker, defender, Move('Sludge Bomb'));
expect(result.range()).toEqual([87, 103]);
expect(result.desc()).toBe(
'0 SpA Mew Sludge Bomb vs. 0 HP / 0 SpD Skarmory: 87-103 (32.1 - 38%) -- 94.6% chance to 3HKO'
);
const result2 = calculate(attacker, defender, Move('Earth Power'));
expect(result2.range()).toEqual([174, 206]);
expect(result2.desc()).toBe(
'0 SpA Mew Earth Power vs. 0 HP / 0 SpD Skarmory: 174-206 (64.2 - 76%) -- guaranteed 2HKO'
);
});
});

describe('IVs are shown if applicable', () => {
inGens(3, 9, ({gen, calculate, Pokemon, Move}) => {
test(`Gen ${gen}`, () => {
Expand Down

0 comments on commit a4e1340

Please sign in to comment.