Merge branch 'beta' into mystery-encounters-translations

This commit is contained in:
Lugiad 2024-09-14 20:27:56 +02:00 committed by GitHub
commit 76f1a9eae2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 150 additions and 13 deletions

View File

@ -105,6 +105,7 @@ import HeldModifierConfig from "#app/interfaces/held-modifier-config";
import { ExpPhase } from "#app/phases/exp-phase";
import { ShowPartyExpBarPhase } from "#app/phases/show-party-exp-bar-phase";
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { ExpGainsSpeed } from "./enums/exp-gains-speed";
export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1";
@ -180,7 +181,7 @@ export default class BattleScene extends SceneBase {
public experimentalSprites: boolean = false;
public musicPreference: integer = 0;
public moveAnimations: boolean = true;
public expGainsSpeed: integer = 0;
public expGainsSpeed: ExpGainsSpeed = ExpGainsSpeed.DEFAULT;
public skipSeenDialogues: boolean = false;
/**
* Determines if the egg hatching animation should be skipped

View File

@ -0,0 +1,22 @@
/**
* Defines the speed of gaining experience.
*
* @remarks
* The `expGainSpeed` can have several modes:
* - `0` - Default: The normal speed.
* - `1` - Fast: Fast speed.
* - `2` - Faster: Faster speed.
* - `3` - Skip: Skip gaining exp animation.
*
* @default 0 - Uses the default normal speed.
*/
export enum ExpGainsSpeed {
/** The normal speed. */
DEFAULT,
/** Fast speed. */
FAST,
/** Faster speed. */
FASTER,
/** Skip gaining exp animation. */
SKIP
}

View File

@ -4410,7 +4410,10 @@ export class EnemyPokemon extends Pokemon {
const isCritical = move.hasAttr(CritOnlyAttr) || !!this.getTag(BattlerTagType.ALWAYS_CRIT);
return move.category !== MoveCategory.STATUS
&& moveTargets.some(p => p.getAttackDamage(this, move, !p.battleData.abilityRevealed, false, isCritical).damage >= p.hp);
&& moveTargets.some(p => {
const doesNotFail = move.applyConditions(this, p, move) || [Moves.SUCKER_PUNCH, Moves.UPPER_HAND, Moves.THUNDERCLAP].includes(move.id);
return doesNotFail && p.getAttackDamage(this, move, !p.battleData.abilityRevealed, false, isCritical).damage >= p.hp;
});
}, this);
if (koMoves.length > 0) {

View File

@ -364,8 +364,8 @@
"effect": "Le lanceur creuse au premier tour et frappe au second."
},
"toxic": {
"name": "Fil Toxique",
"effect": "Tisse un fil imprégné de venin. Empoisonne la cible et baisse sa Vitesse."
"name": "Toxik",
"effect": "Le lanceur empoisonne gravement la cible. Les dégâts dus au poison augmentent à chaque tour."
},
"confusion": {
"name": "Choc Mental",

View File

@ -11,6 +11,10 @@
"expGainsSpeed": "Vit. barre dExp",
"expPartyDisplay": "Afficher Exp équipe",
"skipSeenDialogues": "Passer dialogues connus",
"eggSkip": "Animation déclosion",
"never": "Jamais",
"always": "Toujours",
"ask": "Demander",
"battleStyle": "Style de combat",
"enableRetries": "Activer les réessais",
"hideIvs": "Masquer Scanner dIV",

View File

@ -1,4 +1,5 @@
import BattleScene from "#app/battle-scene";
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
import { ExpNotification } from "#app/enums/exp-notification";
import { ExpBoosterModifier } from "#app/modifier/modifier";
import * as Utils from "#app/utils";
@ -44,7 +45,7 @@ export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase {
} else {
this.end();
}
} else if (this.scene.expGainsSpeed < 3) {
} else if (this.scene.expGainsSpeed < ExpGainsSpeed.SKIP) {
this.scene.partyExpBar.showPokemonExp(pokemon, exp.value, false, newLevel).then(() => {
setTimeout(() => this.end(), 500 / Math.pow(2, this.scene.expGainsSpeed));
});

View File

@ -6,7 +6,7 @@ import { AiType, EnemyPokemon } from "#app/field/pokemon";
import { randSeedInt } from "#app/utils";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
const TIMEOUT = 20 * 1000;
const NUM_TRIALS = 300;
@ -36,22 +36,26 @@ describe("Enemy Commands - Move Selection", () => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
game = new GameManager(phaserGame);
game.override.ability(Abilities.BALL_FETCH);
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.ability(Abilities.BALL_FETCH)
.enemyAbility(Abilities.BALL_FETCH);
});
it(
"should never use Status moves if an attack can KO",
async () => {
game.override
.enemySpecies(Species.ETERNATUS)
.enemyMoveset([Moves.ETERNABEAM, Moves.SLUDGE_BOMB, Moves.DRAGON_DANCE, Moves.COSMIC_POWER])
.enemyAbility(Abilities.BALL_FETCH)
.ability(Abilities.BALL_FETCH)
.startingLevel(1)
.enemyLevel(100);
@ -72,4 +76,31 @@ describe("Enemy Commands - Move Selection", () => {
});
}, TIMEOUT
);
it(
"should not select Last Resort if it would fail, even if the move KOs otherwise",
async () => {
game.override
.enemySpecies(Species.KANGASKHAN)
.enemyMoveset([Moves.LAST_RESORT, Moves.GIGA_IMPACT, Moves.SPLASH, Moves.SWORDS_DANCE])
.startingLevel(1)
.enemyLevel(100);
await game.classicMode.startBattle([Species.MAGIKARP]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
enemyPokemon.aiType = AiType.SMART_RANDOM;
const moveChoices: MoveChoiceSet = {};
const enemyMoveset = enemyPokemon.getMoveset();
enemyMoveset.forEach(mv => moveChoices[mv!.moveId] = 0);
getEnemyMoveChoices(enemyPokemon, moveChoices);
enemyMoveset.forEach(mv => {
if (mv?.getMove().category === MoveCategory.STATUS || mv?.moveId === Moves.LAST_RESORT) {
expect(moveChoices[mv.moveId]).toBe(0);
}
});
}, TIMEOUT
);
});

View File

@ -0,0 +1,55 @@
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
import { Species } from "#app/enums/species";
import { ExpPhase } from "#app/phases/exp-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("../data/exp", ({}) => {
return {
getLevelRelExp: vi.fn(() => 1), //consistent levelRelExp
};
});
describe("UI - Battle Info", () => {
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.GUILLOTINE, Moves.SPLASH])
.battleType("single")
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH)
.enemySpecies(Species.CATERPIE);
});
it.each([ExpGainsSpeed.FAST, ExpGainsSpeed.FASTER, ExpGainsSpeed.SKIP])(
"should increase exp gains animation by 2^%i",
async (expGainsSpeed) => {
game.settings.expGainsSpeed(expGainsSpeed);
vi.spyOn(Math, "pow");
await game.classicMode.startBattle([Species.CHARIZARD]);
game.move.select(Moves.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to(ExpPhase, true);
expect(Math.pow).not.toHaveBeenCalledWith(2, expGainsSpeed);
}
);
});

View File

@ -54,6 +54,7 @@ import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
import { expect } from "vitest";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { isNullOrUndefined } from "#app/utils";
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
/**
* Class to manage the game state and transitions between phases.
@ -148,7 +149,7 @@ export default class GameManager {
this.scene.gameSpeed = 5;
this.scene.moveAnimations = false;
this.scene.showLevelUpStats = false;
this.scene.expGainsSpeed = 3;
this.scene.expGainsSpeed = ExpGainsSpeed.SKIP;
this.scene.expParty = ExpNotification.SKIP;
this.scene.hpBarSpeed = 3;
this.scene.enableTutorials = false;

View File

@ -1,6 +1,7 @@
import { PlayerGender } from "#app/enums/player-gender";
import { BattleStyle } from "#app/enums/battle-style";
import { GameManagerHelper } from "./gameManagerHelper";
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
/**
* Helper to handle settings for tests
@ -38,6 +39,15 @@ export class SettingsHelper extends GameManagerHelper {
this.log(`Gender set to: ${PlayerGender[gender]} (=${gender})` );
}
/**
* Change the exp gains speed
* @param speed the {@linkcode ExpGainsSpeed} to set
*/
expGainsSpeed(speed: ExpGainsSpeed) {
this.game.scene.expGainsSpeed = speed;
this.log(`Exp Gains Speed set to: ${ExpGainsSpeed[speed]} (=${speed})` );
}
private log(...params: any[]) {
console.log("Settings:", ...params);
}

View File

@ -60,6 +60,7 @@ export interface PromptHandler {
expireFn?: () => void;
awaitingActionInput?: boolean;
}
import { ExpPhase } from "#app/phases/exp-phase";
export default class PhaseInterceptor {
public scene;
@ -127,7 +128,8 @@ export default class PhaseInterceptor {
[MysteryEncounterRewardsPhase, this.startPhase],
[PostMysteryEncounterPhase, this.startPhase],
[ModifierRewardPhase, this.startPhase],
[PartyExpPhase, this.startPhase]
[PartyExpPhase, this.startPhase],
[ExpPhase, this.startPhase],
];
private endBySetMode = [

View File

@ -11,8 +11,11 @@ import { Stat } from "#enums/stat";
import BattleFlyout from "./battle-flyout";
import { WindowVariant, addWindow } from "./ui-theme";
import i18next from "i18next";
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
export default class BattleInfo extends Phaser.GameObjects.Container {
public static readonly EXP_GAINS_DURATION_BASE = 1650;
private baseY: number;
private player: boolean;
@ -702,7 +705,11 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
instant = true;
}
const durationMultiplier = Phaser.Tweens.Builders.GetEaseFunction("Sine.easeIn")(1 - (Math.max(this.lastLevel - 100, 0) / 150));
const duration = this.visible && !instant ? (((levelExp - this.lastLevelExp) / relLevelExp) * 1650) * durationMultiplier * levelDurationMultiplier : 0;
let duration = this.visible && !instant ? (((levelExp - this.lastLevelExp) / relLevelExp) * BattleInfo.EXP_GAINS_DURATION_BASE) * durationMultiplier * levelDurationMultiplier : 0;
const speed = (this.scene as BattleScene).expGainsSpeed;
if (speed && speed >= ExpGainsSpeed.DEFAULT) {
duration = speed >= ExpGainsSpeed.SKIP ? ExpGainsSpeed.DEFAULT : duration / Math.pow(2, speed);
}
if (ratio === 1) {
this.lastLevelExp = 0;
this.lastLevel++;