End Dynamax before start of 4th turn (#8719)

This commit is contained in:
Karthik 2022-04-18 12:15:31 -04:00 committed by GitHub
parent 0165daab9f
commit 70acfb1d0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 7 deletions

View File

@ -697,8 +697,8 @@ export const Conditions: {[k: string]: ConditionData} = {
dynamax: {
name: 'Dynamax',
noCopy: true,
duration: 3,
onStart(pokemon) {
this.effectState.turns = 0;
pokemon.removeVolatile('minimize');
pokemon.removeVolatile('substitute');
if (pokemon.volatiles['torment']) {
@ -736,6 +736,9 @@ export const Conditions: {[k: string]: ConditionData} = {
return null;
},
onResidualPriority: -100,
onResidual() {
this.effectState.turns++;
},
onEnd(pokemon) {
this.add('-end', pokemon, 'Dynamax');
if (pokemon.baseSpecies.name === 'Shedinja') return;

View File

@ -1515,6 +1515,20 @@ export class Battle {
}
}
const dynamaxEnding: Pokemon[] = [];
for (const pokemon of this.getAllActive()) {
if (pokemon.volatiles['dynamax']?.turns === 3) {
dynamaxEnding.push(pokemon);
}
}
if (dynamaxEnding.length > 1) {
this.updateSpeed();
this.speedSort(dynamaxEnding);
}
for (const pokemon of dynamaxEnding) {
pokemon.removeVolatile('dynamax');
}
this.add('turn', this.turn);
if (this.gameType === 'multi') {
for (const side of this.sides) {

View File

@ -69,19 +69,20 @@ describe("Dynamax", function () {
assert.equal(battle.p2.active[0].hp, battle.p2.active[0].maxhp);
});
it.skip('should revert before the start of the 4th turn, not as an end-of-turn effect on the 3rd turn', function () {
it('should revert before the start of the 4th turn, not as an end-of-turn effect on the 3rd turn', function () {
battle = common.createBattle([[
{species: 'wynaut', moves: ['sleeptalk', 'psychic']},
], [
{species: 'weedle', level: 1, moves: ['sleeptalk']},
{species: 'weedle', moves: ['sleeptalk']},
]]);
battle.makeChoices('move sleep talk dynamax');
const dynamaxedHP = battle.p1.active[0].hp;
battle.makeChoices('move sleeptalk dynamax', 'auto');
battle.makeChoices();
battle.makeChoices('move psychic');
assert.equal(battle.requestState, 'switch');
assert.equal(battle.p1.active[0].hp, dynamaxedHP);
battle.makeChoices('move psychic', 'auto');
const wynaut = battle.p1.active[0];
assert(wynaut.volatiles['dynamax'], 'End of 3rd turn, Wynaut should still be Dynamaxed.');
battle.makeChoices('', 'switch 2');
assert.false(wynaut.volatiles['dynamax'], 'Start of 4th turn, Wynaut should not be Dynamaxed.');
});
it('should be impossible to Dynamax when all the base moves are disabled', function () {