Skip to content

Commit

Permalink
Merge branch 'beta' into session-clear-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MokaStitcher authored Oct 8, 2024
2 parents b5c0017 + f5fa478 commit 7da5a73
Show file tree
Hide file tree
Showing 14 changed files with 4,201 additions and 10,696 deletions.
3,685 changes: 1,019 additions & 2,666 deletions public/images/pokemon/436.json

Large diffs are not rendered by default.

Binary file modified public/images/pokemon/436.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,685 changes: 1,019 additions & 2,666 deletions public/images/pokemon/back/436.json

Large diffs are not rendered by default.

Binary file modified public/images/pokemon/back/436.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,685 changes: 1,019 additions & 2,666 deletions public/images/pokemon/back/shiny/436.json

Large diffs are not rendered by default.

Binary file modified public/images/pokemon/back/shiny/436.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,685 changes: 1,019 additions & 2,666 deletions public/images/pokemon/shiny/436.json

Large diffs are not rendered by default.

Binary file modified public/images/pokemon/shiny/436.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions src/phases/move-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,7 @@ export class MovePhase extends BattlePhase {
protected resolveCounterAttackTarget() {
if (this.targets.length === 1 && this.targets[0] === BattlerIndex.ATTACKER) {
if (this.pokemon.turnData.attacksReceived.length) {
const attacker = this.pokemon.scene.getPokemonById(this.pokemon.turnData.attacksReceived[0].sourceId);

if (attacker?.isActive(true)) {
this.targets[0] = attacker.getBattlerIndex();
}
this.targets[0] = this.pokemon.turnData.attacksReceived[0].sourceBattlerIndex;

// account for metal burst and comeuppance hitting remaining targets in double battles
// counterattack will redirect to remaining ally if original attacker faints
Expand Down
80 changes: 80 additions & 0 deletions src/test/moves/metal_burst.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { BattlerIndex } from "#app/battle";
import { MoveResult } from "#app/field/pokemon";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

describe("Moves - Metal Burst", () => {
let phaserGame: Phaser.Game;
let game: GameManager;

beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});

afterEach(() => {
game.phaseInterceptor.restoreOg();
});

beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([ Moves.METAL_BURST, Moves.FISSURE, Moves.PRECIPICE_BLADES ])
.ability(Abilities.PURE_POWER)
.startingLevel(10)
.battleType("double")
.disableCrits()
.enemySpecies(Species.PICHU)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.TACKLE);
});

it("should redirect target if intended target faints", async () => {
await game.classicMode.startBattle([ Species.FEEBAS, Species.FEEBAS ]);

const [ , enemy2 ] = game.scene.getEnemyField();

game.move.select(Moves.METAL_BURST);
game.move.select(Moves.FISSURE, 1, BattlerIndex.ENEMY);

await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2);

await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]);

await game.phaseInterceptor.to("MoveEndPhase");
await game.move.forceHit();
await game.phaseInterceptor.to("MoveEndPhase");
await game.phaseInterceptor.to("MoveEndPhase");

expect(enemy2.isFullHp()).toBe(false);
});

it("should not crash if both opponents faint before the move is used", async () => {
await game.classicMode.startBattle([ Species.FEEBAS, Species.ARCEUS ]);

const [ enemy1, enemy2 ] = game.scene.getEnemyField();

game.move.select(Moves.METAL_BURST);
game.move.select(Moves.PRECIPICE_BLADES, 1);

await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2);

await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]);

await game.phaseInterceptor.to("MoveEndPhase");
await game.move.forceHit();
await game.phaseInterceptor.to("MoveEndPhase");
await game.phaseInterceptor.to("BerryPhase");

expect(enemy1.isFainted()).toBe(true);
expect(enemy2.isFainted()).toBe(true);
expect(game.scene.getPlayerField()[0].getLastXMoves(1)[0].result).toBe(MoveResult.FAIL);
});
});
57 changes: 34 additions & 23 deletions src/test/moves/scale_shot.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move";
import { DamagePhase } from "#app/phases/damage-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
Expand All @@ -8,7 +10,7 @@ import { Species } from "#enums/species";
import { Stat } from "#enums/stat";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, it, expect, vi } from "vitest";

describe("Moves - Scale Shot", () => {
let phaserGame: Phaser.Game;
Expand All @@ -30,45 +32,54 @@ describe("Moves - Scale Shot", () => {
.moveset([ Moves.SCALE_SHOT ])
.battleType("single")
.disableCrits()
.starterSpecies(Species.MINCCINO)
.ability(Abilities.NO_GUARD)
.passiveAbility(Abilities.SKILL_LINK)
.enemyAbility(Abilities.SHEER_FORCE)
.enemyPassiveAbility(Abilities.STALL)
.enemyMoveset(Moves.SKILL_SWAP)
.enemyLevel(5);
.enemyMoveset(Moves.SPLASH)
.enemyLevel(3);
});

it("applies stat changes after last hit", async () => {
await game.classicMode.startBattle([ Species.FORRETRESS ]);
game.override.enemySpecies(Species.FORRETRESS);

await game.classicMode.startBattle([ Species.MINCCINO ]);
const minccino = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SCALE_SHOT);

await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);

await game.phaseInterceptor.to(MoveEffectPhase);
await game.phaseInterceptor.to(DamagePhase);

//check that stats haven't changed after one or two hits have occurred
await game.phaseInterceptor.to(MoveEffectPhase);
expect (minccino?.getStatStage(Stat.DEF)).toBe(0);
expect (minccino?.getStatStage(Stat.SPD)).toBe(0);
expect(minccino.getStatStage(Stat.DEF)).toBe(0);
expect(minccino.getStatStage(Stat.SPD)).toBe(0);

//check that stats changed on last hit
await game.phaseInterceptor.to(MoveEndPhase);
expect (minccino.getStatStage(Stat.DEF)).toBe(-1);
expect (minccino.getStatStage(Stat.SPD)).toBe(1);
expect(minccino.getStatStage(Stat.DEF)).toBe(-1);
expect(minccino.getStatStage(Stat.SPD)).toBe(1);
});

it("unaffected by sheer force", async () => {
await game.classicMode.startBattle([ Species.WOBBUFFET ]);
const moveToCheck = allMoves[Moves.SCALE_SHOT];
const basePower = moveToCheck.power;

game.override.enemySpecies(Species.WOBBUFFET);

vi.spyOn(moveToCheck, "calculateBattlePower");

await game.classicMode.startBattle([ Species.MINCCINO ]);
const minccino = game.scene.getPlayerPokemon()!;
const wobbuffet = game.scene.getEnemyPokemon()!;
wobbuffet.setStat(Stat.HP, 100, true);
wobbuffet.hp = 100;

game.move.select(Moves.SCALE_SHOT);
await game.phaseInterceptor.to(TurnEndPhase);
const hpafter1 = wobbuffet.hp;

//effect not nullified by sheer force
expect (minccino.getStatStage(Stat.DEF)).toBe(-1);
expect (minccino.getStatStage(Stat.SPD)).toBe(1);
game.move.select(Moves.SCALE_SHOT);
await game.phaseInterceptor.to(MoveEndPhase);
const hpafter2 = wobbuffet.hp;
//check damage not boosted- make damage before sheer force a little lower than theoretical boosted sheer force damage
expect (100 - hpafter1).toBe(hpafter1 - hpafter2);
expect(minccino.getStatStage(Stat.DEF)).toBe(-1);
expect(minccino.getStatStage(Stat.SPD)).toBe(1);

//power not boosted by sheer force
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower);
});
});
8 changes: 4 additions & 4 deletions src/test/utils/helpers/moveHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { GameManagerHelper } from "./gameManagerHelper";
*/
export class MoveHelper extends GameManagerHelper {
/**
* Intercepts `MoveEffectPhase` and mocks the hitCheck's
* return value to `true` {@linkcode MoveEffectPhase.hitCheck}.
* Intercepts {@linkcode MoveEffectPhase} and mocks the
* {@linkcode MoveEffectPhase.hitCheck | hitCheck}'s return value to `true`.
* Used to force a move to hit.
*/
async forceHit(): Promise<void> {
Expand All @@ -23,8 +23,8 @@ export class MoveHelper extends GameManagerHelper {
}

/**
* Intercepts `MoveEffectPhase` and mocks the hitCheck's
* return value to `false` {@linkcode MoveEffectPhase.hitCheck}.
* Intercepts {@linkcode MoveEffectPhase} and mocks the
* {@linkcode MoveEffectPhase.hitCheck | hitCheck}'s return value to `false`.
* Used to force a move to miss.
* @param firstTargetOnly Whether the move should force miss on the first target only, in the case of multi-target moves.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/ui/modifier-select-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.getUi().clearText();
this.eraseCursor();

// Reset cursor positions
this.cursor = 0;
this.rowCursor = 0;

/* Multiplies the fade time duration by the speed parameter so that it is always constant, and avoids "flashbangs" at game speed x5 */
this.scene.hideShopOverlay(750 * this.scene.gameSpeed);
this.scene.hideLuckText(250);
Expand Down
2 changes: 2 additions & 0 deletions src/ui/starter-select-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { StarterContainer } from "#app/ui/starter-container";
import { DropDownColumn, FilterBar } from "#app/ui/filter-bar";
import { ScrollBar } from "#app/ui/scroll-bar";
import { SelectChallengePhase } from "#app/phases/select-challenge-phase";
import { EncounterPhase } from "#app/phases/encounter-phase";
import { TitlePhase } from "#app/phases/title-phase";
import { Abilities } from "#enums/abilities";
import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters";
Expand Down Expand Up @@ -3468,6 +3469,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.scene.clearPhaseQueue();
if (this.scene.gameMode.isChallenge) {
this.scene.pushPhase(new SelectChallengePhase(this.scene));
this.scene.pushPhase(new EncounterPhase(this.scene, false));
} else {
this.scene.pushPhase(new TitlePhase(this.scene));
}
Expand Down

0 comments on commit 7da5a73

Please sign in to comment.