Apply suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
RedstonewolfX 2024-09-19 12:54:44 -04:00 committed by GitHub
parent e625891230
commit e6458f9ac4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 17 deletions

View File

@ -2432,7 +2432,7 @@ export function getPartyLuckValue(party: Pokemon[]): integer {
}
const luck = Phaser.Math.Clamp(party.map(p => p.isAllowedInBattle() ? (p.scene.gameMode.isDaily ? 0 : p.getLuck()) : 0)
.reduce((total: integer, value: integer) => total += value, 0), 0, 14);
return luck || 0;
return luck ?? 0;
}
export function getLuckString(luckValue: integer): string {

View File

@ -4,7 +4,6 @@ import GameManager from "./utils/gameManager";
import { Moves } from "#app/enums/moves";
import { getPartyLuckValue } from "#app/modifier/modifier-type";
import { Biome } from "#app/enums/biome";
import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { Mode } from "#app/ui/ui";
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
import { Species } from "#app/enums/species";
@ -42,9 +41,6 @@ describe("Daily Mode", () => {
});
});
//*
// Need to figure out how to properly start a battle
// Need to fix eviolite - test keeps insisting it is not in loot table, even though Mini Black Hole (which is using the exact same condition) is
describe("Shop modifications", async () => {
let phaserGame: Phaser.Game;
let game: GameManager;
@ -80,7 +76,7 @@ describe("Shop modifications", async () => {
game.move.select(Moves.KOWTOW_CLEAVE);
await game.phaseInterceptor.to("DamagePhase");
await game.doKillOpponents();
await game.phaseInterceptor.to(BattleEndPhase);
await game.phaseInterceptor.to("BattleEndPhase");
game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => {
expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler);
game.modifiers
@ -129,14 +125,11 @@ describe("Luck modifications", async() => {
afterEach(() => {
game.phaseInterceptor.restoreOg();
//vi.resetAllMocks();
//vi.clearAllMocks();
});
it("should apply luck in Classic Mode", async () => {
await game.classicMode.runToSummon([Species.PIKACHU]);
const party = game.scene.getParty();
expect(party[0]).toBeDefined();
vi.spyOn(party[0], "getLuck").mockReturnValue(3);
expect(party[0].getLuck()).toBeGreaterThan(0);
expect(getPartyLuckValue(party)).toBeGreaterThan(0);
@ -145,7 +138,6 @@ describe("Luck modifications", async() => {
it("should not apply luck in Daily Run", async () => {
await game.dailyMode.runToSummon();
const party = game.scene.getParty();
expect(party[0]).toBeDefined();
vi.spyOn(party[0], "getLuck").mockReturnValue(3);
expect(party[0].getLuck()).toBeGreaterThan(0);
expect(getPartyLuckValue(party)).toBe(0);

View File

@ -3,12 +3,10 @@ import { GameManagerHelper } from "./gameManagerHelper";
import { itemPoolChecks, ModifierTypeKeys } from "#app/modifier/modifier-type";
export class ModifierHelper extends GameManagerHelper {
// TODO
/**
* Adds a Modifier to the list of modifiers to check for.
*
* Note that all modifiers are updated during the start of SelectModifierPhase.
* Note that all modifiers are updated during the start of `SelectModifierPhase`.
* @param modifier The Modifier to add.
*/
addCheck(modifier: ModifierTypeKeys) {
@ -42,8 +40,8 @@ export class ModifierHelper extends GameManagerHelper {
*
* Note that if a `SelectModifierPhase` has not been run yet, these values will be `undefined`, and the check will fail.
* @param modifier The modifier to check.
* @param expectToBePreset Whether the Modifier should be in the Modifier Pool. Set to false to expect it to be absent instead.
* @returns this
* @param expectToBePreset Whether the Modifier should be in the Modifier Pool. Set to `false` to expect it to be absent instead.
* @returns `this`
*/
testCheck(modifier: ModifierTypeKeys, expectToBePreset: boolean): this {
if (expectToBePreset) {

View File

@ -304,8 +304,8 @@ export class OverridesHelper extends GameManagerHelper {
/**
* Gives the player access to an Unlockable.
* @param unlockable The Unlockable to enable.
* @returns this
* @param unlockable The Unlockable(s) to enable.
* @returns `this`
*/
enableUnlockable(unlockable: Unlockables[]) {
vi.spyOn(Overrides, "ITEM_UNLOCK_OVERRIDE", "get").mockReturnValue(unlockable);