Fix Neutralizing Gas ending issues (#7860)

This commit is contained in:
Adam Tran 2021-01-01 18:39:19 -05:00 committed by GitHub
parent 4ef46f2688
commit 0f724acb03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 2 deletions

View File

@ -2312,8 +2312,11 @@ export const Abilities: {[abilityid: string]: AbilityData} = {
// (If your tackling this, do note extreme weathers have the same issue)
// Mark this pokemon's ability as ending so Pokemon#ignoringAbility skips it
if (source.abilityData.ending) return;
source.abilityData.ending = true;
for (const pokemon of this.getAllActive()) {
const sortedActive = this.getAllActive();
this.speedSort(sortedActive);
for (const pokemon of sortedActive) {
if (pokemon !== source) {
// Will be suppressed by Pokemon#ignoringAbility if needed
this.singleEvent('Start', pokemon.getAbility(), pokemon.abilityData, pokemon);

View File

@ -190,7 +190,7 @@ describe('Neutralizing Gas', function () {
assert.equal(wynaut.hp, Math.floor(wynaut.maxhp / 2) - 1 + Math.floor(wynaut.maxhp * 0.33));
});
it.skip(`should not trigger twice if negated then replaced`, function () {
it(`should not trigger twice if negated then replaced`, function () {
battle = common.createBattle([[
{species: "Weezing", ability: 'neutralizinggas', moves: ['sleeptalk']},
], [
@ -205,4 +205,75 @@ describe('Neutralizing Gas', function () {
battle.makeChoices('auto', 'move simplebeam');
assert.statStage(wynaut, 'atk', 1);
});
it(`should not re-trigger Unnerve if the ability was already triggered before`, function () {
battle = common.createBattle({gameType: 'doubles'}, [[
{species: "Bisharp", ability: 'defiant', moves: ['sleeptalk']},
{species: "Eternatus", ability: 'pressure', moves: ['sleeptalk']},
], [
{species: "Rookidee", ability: 'unnerve', moves: ['sleeptalk']},
{species: "Diglett", moves: ['sleeptalk']},
{species: "Weezing", ability: 'neutralizinggas', moves: ['sleeptalk']},
]]);
// Unnerve activates properly on lead
battle.makeChoices('auto', 'move sleeptalk, switch 3');
battle.makeChoices('auto', 'move sleeptalk, switch 3');
// It will become active again after a Neutralizing Gas cycle, but without the Ability message
battle.makeChoices('auto', 'move sleeptalk, switch 3');
const log = battle.getDebugLog();
const firstUnnerveIndex = log.indexOf('|-ability|p2a: Rookidee|Unnerve');
const secondUnnerveIndex = log.lastIndexOf('|-ability|p2a: Rookidee|Unnerve');
assert.equal(firstUnnerveIndex, secondUnnerveIndex, 'Unnerve should have only activated once.');
});
describe(`Ability reactivation order`, function () {
it(`should cause entrance Abilities to reactivate in order of Speed`, function () {
battle = common.createBattle({gameType: 'doubles'}, [[
{species: "Pincurchin", ability: 'electricsurge', moves: ['sleeptalk']},
{species: "Eternatus", moves: ['sleeptalk']},
], [
{species: "Rillaboom", ability: 'grassysurge', moves: ['sleeptalk']},
{species: "Weezing", ability: 'neutralizinggas', moves: ['sleeptalk']},
{species: "Diglett", moves: ['sleeptalk']},
]]);
battle.makeChoices('auto', 'move sleeptalk, switch 3');
assert(battle.field.isTerrain('electricterrain'));
});
it(`should cause non-entrance abilities to be active immediately`, function () {
battle = common.createBattle({gameType: 'doubles'}, [[
{species: "Bisharp", ability: 'defiant', moves: ['sleeptalk']},
{species: "Eternatus", moves: ['sleeptalk']},
], [
{species: "Salamence", ability: 'intimidate', moves: ['sleeptalk']},
{species: "Weezing", ability: 'neutralizinggas', moves: ['sleeptalk']},
{species: "Diglett", moves: ['sleeptalk']},
]]);
battle.makeChoices('auto', 'move sleeptalk, switch 3');
assert.statStage(battle.p1.active[0], 'atk', 1);
});
it.skip(`should not give Unnerve priority in activation`, function () {
battle = common.createBattle({gameType: 'doubles'}, [[
{species: "Bisharp", ability: 'defiant', moves: ['sleeptalk']},
{species: "Eternatus", ability: 'pressure', moves: ['sleeptalk']},
], [
{species: "Rookidee", ability: 'unnerve', moves: ['sleeptalk']},
{species: "Weezing", ability: 'neutralizinggas', moves: ['sleeptalk']},
{species: "Diglett", moves: ['sleeptalk']},
]]);
battle.makeChoices('auto', 'move sleeptalk, switch 3');
const log = battle.getDebugLog();
const pressureIndex = log.indexOf('|-ability|p1b: Eternatus|Pressure');
const unnerveIndex = log.indexOf('|-ability|p2a: Rookidee|Unnerve');
assert(pressureIndex < unnerveIndex, 'Faster Pressure should activate before slower Unnerve');
});
});
});