From e747fa2ecda09443ab242ecdf7bb3c3e92d8e343 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sat, 6 Apr 2024 23:50:26 -0400 Subject: [PATCH] Increase endless mode limit to 15 --- src/phases.ts | 50 +++++++++++++++++++++++++---- src/ui/starter-select-ui-handler.ts | 50 ++++++++++++----------------- 2 files changed, 63 insertions(+), 37 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 9ea5ce9ef..a39b77660 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -129,6 +129,7 @@ export class LoginPhase extends Phase { export class TitlePhase extends Phase { private loaded: boolean; private lastSessionData: SessionSaveData; + private gameMode: GameModes; constructor(scene: BattleScene) { super(scene); @@ -169,9 +170,40 @@ export class TitlePhase extends Phase { options.push({ label: 'New Game', handler: () => { - this.scene.ui.setMode(Mode.MESSAGE); - this.scene.ui.clearText(); - this.end(); + const setModeAndEnd = (gameMode: GameModes) => { + this.gameMode = gameMode; + this.scene.ui.setMode(Mode.MESSAGE); + this.scene.ui.clearText(); + this.end(); + }; + if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) { + const options = [ + { + label: gameModes[GameModes.CLASSIC].getName(), + handler: () => setModeAndEnd(GameModes.CLASSIC) + }, + { + label: gameModes[GameModes.ENDLESS].getName(), + handler: () => setModeAndEnd(GameModes.ENDLESS) + } + ]; + if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) { + options.push({ + label: gameModes[GameModes.SPLICED_ENDLESS].getName(), + handler: () => setModeAndEnd(GameModes.SPLICED_ENDLESS) + }); + } + options.push({ + label: 'Cancel', + handler: () => { + this.scene.clearPhaseQueue(); + this.scene.pushPhase(new TitlePhase(this.scene)); + super.end(); + } + }); + this.scene.ui.showText('Select a game mode.', null, () => this.scene.ui.setOverlayMode(Mode.OPTION_SELECT, { options: options })); + } else + this.end(); } }, { @@ -271,7 +303,7 @@ export class TitlePhase extends Phase { end(): void { if (!this.loaded && !this.scene.gameMode.isDaily) { this.scene.arena.preloadBgm(); - this.scene.pushPhase(new SelectStarterPhase(this.scene)); + this.scene.pushPhase(new SelectStarterPhase(this.scene, this.gameMode)); this.scene.newArena(this.scene.gameMode.getStartingBiome(this.scene)); } else this.scene.playBgm(); @@ -339,8 +371,12 @@ export class SelectGenderPhase extends Phase { } export class SelectStarterPhase extends Phase { - constructor(scene: BattleScene) { + private gameMode: GameModes; + + constructor(scene: BattleScene, gameMode: GameModes) { super(scene); + + this.gameMode = gameMode; } start() { @@ -394,7 +430,7 @@ export class SelectStarterPhase extends Phase { this.end(); }); }); - }); + }, this.gameMode); } } @@ -2322,7 +2358,7 @@ export class MoveEffectPhase extends PokemonPhase { return true; if (this.scene.arena.weather?.weatherType === WeatherType.FOG) - moveAccuracy.value = Math.floor(moveAccuracy.value * 0.6); + moveAccuracy.value = Math.floor(moveAccuracy.value * 0.8); if (!this.move.getMove().getAttrs(OneHitKOAttr).length && this.scene.arena.getTag(ArenaTagType.GRAVITY)) moveAccuracy.value = Math.floor(moveAccuracy.value * 1.67); diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index bdf10fede..9e9ed36ff 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -6,7 +6,7 @@ import { Mode } from "./ui"; import MessageUiHandler from "./message-ui-handler"; import { Gender, getGenderColor, getGenderSymbol } from "../data/gender"; import { allAbilities } from "../data/ability"; -import { GameModes, gameModes } from "../game-mode"; +import { GameMode, GameModes, gameModes } from "../game-mode"; import { Unlockables } from "../system/unlockables"; import { GrowthRate, getGrowthRateColor } from "../data/exp"; import { DexAttr, DexEntry, StarterFormMoveData, StarterMoveset } from "../system/game-data"; @@ -111,6 +111,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private iconAnimHandler: PokemonIconAnimHandler; private starterSelectCallback: StarterSelectCallback; + private gameMode: GameModes; constructor(scene: BattleScene) { super(scene, Mode.STARTER_SELECT); @@ -450,7 +451,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } show(args: any[]): boolean { - if (args.length >= 1 && args[0] instanceof Function) { + if (args.length >= 2 && args[0] instanceof Function && typeof args[1] === 'number') { super.show(args); for (let g = 0; g < this.genSpecies.length; g++) { @@ -468,10 +469,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterSelectContainer.setVisible(true); + this.gameMode = args[1]; + this.setGenMode(false); this.setCursor(0); this.setGenMode(true); this.setCursor(0); + this.tryUpdateValue(0); handleTutorial(this.scene, Tutorial.Starter_Select); @@ -600,7 +604,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterMovesets.push(this.starterMoveset.slice(0) as StarterMoveset); if (this.speciesLoaded.get(species.speciesId)) getPokemonSpeciesForm(species.speciesId, props.formIndex).cry(this.scene); - if (this.starterCursors.length === 6 || this.value === 10) + if (this.starterCursors.length === 6 || this.value === this.getValueLimit()) this.tryStart(); this.updateInstructions(); ui.playSelect(); @@ -826,6 +830,16 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.instructionsText.setText(instructionLines.join('\n')); } + getValueLimit(): integer { + switch (this.gameMode) { + case GameModes.ENDLESS: + case GameModes.SPLICED_ENDLESS: + return 15; + default: + return 10; + } + } + setCursor(cursor: integer): boolean { let changed = false; @@ -1216,11 +1230,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { tryUpdateValue(add?: integer): boolean { const value = this.starterGens.reduce((total: integer, gen: integer, i: integer) => total += this.scene.gameData.getSpeciesStarterValue(this.genSpecies[gen][this.starterCursors[i]].speciesId), 0); const newValue = value + (add || 0); - const overLimit = newValue > 10; + const overLimit = newValue > this.getValueLimit(); let newValueStr = newValue.toString(); if (newValueStr.startsWith('0.')) newValueStr = newValueStr.slice(1); - this.valueLimitLabel.setText(`${newValueStr}/10`); + this.valueLimitLabel.setText(`${newValueStr}/${this.getValueLimit()}`); this.valueLimitLabel.setColor(this.getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK)); this.valueLimitLabel.setShadowColor(this.getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK, true)); if (overLimit) { @@ -1264,31 +1278,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { }; })); }; - if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) { - ui.setMode(Mode.STARTER_SELECT); - const options = [ - { - label: gameModes[GameModes.CLASSIC].getName(), - handler: () => startRun(GameModes.CLASSIC) - }, - { - label: gameModes[GameModes.ENDLESS].getName(), - handler: () => startRun(GameModes.ENDLESS) - } - ]; - if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) { - options.push({ - label: gameModes[GameModes.SPLICED_ENDLESS].getName(), - handler: () => startRun(GameModes.SPLICED_ENDLESS) - }); - } - options.push({ - label: 'Cancel', - handler: () => cancel() - }); - ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, yOffset: 19 })); - } else - startRun(GameModes.CLASSIC); + startRun(this.gameMode); }, cancel, null, null, 19); });