Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc][Move] Add waveTurnCount to PokemonBattleData #4168

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6371,7 +6371,7 @@ export class MoveCondition {

export class FirstMoveCondition extends MoveCondition {
constructor() {
super((user, target, move) => user.battleSummonData?.turnCount === 1);
super((user, target, move) => user.battleSummonData?.waveTurnCount === 1);
}

getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
Expand Down
2 changes: 2 additions & 0 deletions src/field/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4559,6 +4559,8 @@ export class PokemonBattleData {
export class PokemonBattleSummonData {
/** The number of turns the pokemon has passed since entering the battle */
public turnCount: number = 1;
/** The number of turns the pokemon has passed since the start of the wave */
public waveTurnCount: number = 1;
/** The list of moves the pokemon has used since entering the battle */
public moveHistory: TurnMove[] = [];
}
Expand Down
6 changes: 6 additions & 0 deletions src/phases/battle-end-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export class BattleEndPhase extends BattlePhase {
this.scene.unshiftPhase(new GameOverPhase(this.scene, true));
}

for (const pokemon of this.scene.getField()) {
if (pokemon && pokemon.battleSummonData) {
pokemon.battleSummonData.waveTurnCount = 1;
}
}

for (const pokemon of this.scene.getParty().filter(p => p.isAllowedInBattle())) {
applyPostBattleAbAttrs(PostBattleAbAttr, pokemon);
}
Expand Down
1 change: 1 addition & 0 deletions src/phases/switch-summon-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class SwitchSummonPhase extends SummonPhase {
// Or compensate for force switch move if switched out pokemon is not fainted
if (currentCommand === Command.POKEMON || lastPokemonIsForceSwitchedAndNotFainted) {
pokemon.battleSummonData.turnCount--;
pokemon.battleSummonData.waveTurnCount--;
}

if (this.batonPass && pokemon) {
Expand Down
1 change: 1 addition & 0 deletions src/phases/turn-end-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class TurnEndPhase extends FieldPhase {
this.scene.applyModifiers(TurnHeldItemTransferModifier, pokemon.isPlayer(), pokemon);

pokemon.battleSummonData.turnCount++;
pokemon.battleSummonData.waveTurnCount++;
};

this.executeForAll(handlePokemon);
Expand Down
36 changes: 27 additions & 9 deletions src/test/moves/fake_out.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ describe("Moves - Fake Out", () => {
game.override
.battleType("single")
.enemySpecies(Species.CORVIKNIGHT)
.starterSpecies(Species.FEEBAS)
.moveset([Moves.FAKE_OUT, Moves.SPLASH])
.enemyMoveset(Moves.SPLASH)
.enemyLevel(10)
.startingLevel(10) // prevent LevelUpPhase from happening
.disableCrits();
});

it("can only be used on the first turn a pokemon is sent out", async() => {
await game.classicMode.startBattle();
it("can only be used on the first turn a pokemon is sent out in a battle", async() => {
await game.classicMode.startBattle([Species.FEEBAS]);

const enemy = game.scene.getEnemyPokemon()!;

Expand All @@ -44,22 +45,27 @@ describe("Moves - Fake Out", () => {
await game.toNextTurn();

expect(enemy.hp).toBe(postTurnOneHp);
}, 20000);

game.move.select(Moves.SPLASH);
await game.doKillOpponents();
await game.toNextWave();
// This is a PokeRogue buff to Fake Out
it("can be used at the start of every wave even if the pokemon wasn't recalled", async() => {
await game.classicMode.startBattle([Species.FEEBAS]);

const enemy = game.scene.getEnemyPokemon()!;
enemy.damageAndUpdate(enemy.getMaxHp() - 1);

const newEnemy = game.scene.getEnemyPokemon()!;
game.move.select(Moves.FAKE_OUT);
await game.toNextWave();

game.move.select(Moves.FAKE_OUT);
await game.toNextTurn();

expect(newEnemy.hp).toBe(newEnemy.getMaxHp());
expect(game.scene.getEnemyPokemon()!.isFullHp()).toBe(false);
}, 20000);

it("can be used again if recalled and sent back out", async() => {
game.override.startingWave(4);
await game.classicMode.startBattle();
await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]);

const enemy1 = game.scene.getEnemyPokemon()!;

Expand All @@ -76,6 +82,18 @@ describe("Moves - Fake Out", () => {

const enemy2 = game.scene.getEnemyPokemon()!;

expect(enemy2.hp).toBeLessThan(enemy2.getMaxHp());
enemy2.hp = enemy2.getMaxHp();

game.doSwitchPokemon(1);
await game.toNextTurn();

game.doSwitchPokemon(1);
await game.toNextTurn();

game.move.select(Moves.FAKE_OUT);
await game.toNextTurn();

expect(enemy2.hp).toBeLessThan(enemy2.getMaxHp());
}, 20000);
});
Loading