Gen IV: Make Download ignore foes behind substitutes (#10310)

This commit is contained in:
Alex "Mathy 2024-06-02 20:56:30 -05:00 committed by GitHub
parent 717ef95c32
commit 44ea4080b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 109 additions and 0 deletions

View File

@ -72,6 +72,23 @@ export const Abilities: {[k: string]: ModdedAbilityData} = {
}
},
},
download: {
inherit: true,
onStart(pokemon) {
let totaldef = 0;
let totalspd = 0;
for (const target of pokemon.foes()) {
if (target.volatiles.substitute) continue;
totaldef += target.getStat('def', false, true);
totalspd += target.getStat('spd', false, true);
}
if (totaldef && totaldef >= totalspd) {
this.boost({spa: 1});
} else if (totalspd) {
this.boost({atk: 1});
}
},
},
effectspore: {
inherit: true,
onDamagingHit(damage, target, source, move) {

View File

@ -0,0 +1,92 @@
'use strict';
const assert = require('./../../assert');
const common = require('./../../common');
let battle;
describe('Download', () => {
afterEach(() => battle.destroy());
it('should boost based on which defensive stat is higher', () => {
battle = common.createBattle([[
{species: 'porygon', moves: ['sleeptalk'], ability: 'download'},
{species: 'furret', moves: ['sleeptalk']},
], [
{species: 'stonjourner', moves: ['sleeptalk']},
{species: 'chansey', moves: ['sleeptalk']},
]]);
assert.statStage(battle.p1.active[0], 'spa', 1);
battle.makeChoices('switch 2', 'switch 2');
battle.makeChoices('switch 2', 'auto');
assert.statStage(battle.p1.active[0], 'atk', 1);
});
it('should boost Special Attack if both stats are tied', () => {
battle = common.createBattle([[
{species: 'porygon', moves: ['sleeptalk'], ability: 'download'},
], [
{species: 'mew', moves: ['sleeptalk']},
]]);
assert.statStage(battle.p1.active[0], 'spa', 1);
assert.statStage(battle.p1.active[0], 'atk', 0);
});
it('should boost based on the total of both foes in a Double Battle', () => {
battle = common.createBattle({gameType: 'doubles'}, [[
{species: 'porygon', moves: ['sleeptalk'], ability: 'download'},
{species: 'blissey', moves: ['sleeptalk']},
], [
{species: 'blissey', level: 1, moves: ['sleeptalk']},
{species: 'stonjourner', moves: ['sleeptalk']},
]]);
assert.statStage(battle.p1.active[0], 'spa', 1);
assert.statStage(battle.p1.active[0], 'atk', 0);
});
it('should trigger even if the foe is behind a Substitute', () => {
battle = common.createBattle([[
{species: 'furret', moves: ['sleeptalk']},
{species: 'porygon', ability: 'download', moves: ['sleeptalk']},
], [
{species: 'blissey', moves: ['substitute']},
]]);
battle.makeChoices();
battle.makeChoices('switch 2', 'auto');
assert.statStage(battle.p1.active[0], 'atk', 1);
});
describe('Gen 4', () => {
it('should not trigger if the foe is behind a Substitute', () => {
battle = common.gen(4).createBattle([[
{species: 'furret', moves: ['sleeptalk']},
{species: 'porygon', ability: 'download', moves: ['sleeptalk']},
], [
{species: 'ampharos', moves: ['substitute']},
]]);
battle.makeChoices();
battle.makeChoices('switch 2', 'auto');
assert.statStage(battle.p1.active[0], 'atk', 0);
assert.statStage(battle.p1.active[0], 'spa', 0);
});
it('in Double Battles, should only account for foes not behind a Substitute', () => {
battle = common.gen(4).createBattle({gameType: 'doubles'}, [[
{species: 'furret', moves: ['sleeptalk']},
{species: 'ampharos', moves: ['sleeptalk']},
{species: 'porygon', ability: 'download', moves: ['sleeptalk']},
], [
{species: 'blissey', moves: ['substitute']},
{species: 'furret', moves: ['sleeptalk', 'substitute']},
]]);
battle.makeChoices();
battle.makeChoices('move 1, switch 3', 'auto');
assert.statStage(battle.p1.active[1], 'atk', 0);
assert.statStage(battle.p1.active[1], 'spa', 1);
battle.makeChoices('move 1, switch 3', 'move 1, move 2');
battle.makeChoices('move 1, switch 3', 'auto');
assert.statStage(battle.p1.active[1], 'atk', 0);
assert.statStage(battle.p1.active[1], 'spa', 0);
});
});
});