mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
06331ccdf6
* Disable Luck in Daily Runs If the Game Mode is Daily Run, the player's Luck is set to 0, and the Luck value is hidden. * Give free map in daily Adds a Map to the player's pool of starting items for Daily Runs. * Disable Eviolite in Daily Runs Disables Eviolite spawning in Daily Run mode. * Write shop test and add new overrides Adds new overrides that allow you to force content to be locked or unlocked These overrides were also added to the OverridesHelper to make them available to tests Adds a new check function for content unlocks, which returns `true` if it is overrode to be unlocked, `false` if it is overrode to be locked, and the unlock data mapped to a Boolean otherwise All existing checks (other than the ones that involve actually unlocking things) for unlockables have been changed to use this Added a pair of new exporting booleans, specifically for my test, that check if Eviolite or Mini Black Hole are in the loot table * Prevent shinies from altering runs Places variant rolls inside of an ExecuteWithSeedOffset block, using the current floor's RNG seed as the seed and the Pokémon's ID as the offset. --------- Co-authored-by: Leo Kim <47556641+KimJeongSun@users.noreply.github.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com>
152 lines
5.3 KiB
TypeScript
152 lines
5.3 KiB
TypeScript
import BattleScene from "./battle-scene";
|
|
import AwaitableUiHandler from "./ui/awaitable-ui-handler";
|
|
import UiHandler from "./ui/ui-handler";
|
|
import { Mode } from "./ui/ui";
|
|
import i18next from "i18next";
|
|
import Overrides from "#app/overrides";
|
|
|
|
export enum Tutorial {
|
|
Intro = "INTRO",
|
|
Access_Menu = "ACCESS_MENU",
|
|
Menu = "MENU",
|
|
Starter_Select = "STARTER_SELECT",
|
|
Pokerus = "POKERUS",
|
|
Stat_Change = "STAT_CHANGE",
|
|
Select_Item = "SELECT_ITEM",
|
|
Egg_Gacha = "EGG_GACHA"
|
|
}
|
|
|
|
const tutorialHandlers = {
|
|
[Tutorial.Intro]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
scene.ui.showText(i18next.t("tutorial:intro"), null, () => resolve(), null, true);
|
|
});
|
|
},
|
|
[Tutorial.Access_Menu]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
if (scene.enableTouchControls) {
|
|
return resolve();
|
|
}
|
|
scene.showFieldOverlay(1000).then(() => scene.ui.showText(i18next.t("tutorial:accessMenu"), null, () => scene.hideFieldOverlay(1000).then(() => resolve()), null, true));
|
|
});
|
|
},
|
|
[Tutorial.Menu]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
scene.gameData.saveTutorialFlag(Tutorial.Access_Menu, true);
|
|
scene.ui.showText(i18next.t("tutorial:menu"), null, () => scene.ui.showText("", null, () => resolve()), null, true);
|
|
});
|
|
},
|
|
[Tutorial.Starter_Select]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
scene.ui.showText(i18next.t("tutorial:starterSelect"), null, () => scene.ui.showText("", null, () => resolve()), null, true);
|
|
});
|
|
},
|
|
[Tutorial.Pokerus]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
scene.ui.showText(i18next.t("tutorial:pokerus"), null, () => scene.ui.showText("", null, () => resolve()), null, true);
|
|
});
|
|
},
|
|
[Tutorial.Stat_Change]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
scene.showFieldOverlay(1000).then(() => scene.ui.showText(i18next.t("tutorial:statChange"), null, () => scene.ui.showText("", null, () => scene.hideFieldOverlay(1000).then(() => resolve())), null, true));
|
|
});
|
|
},
|
|
[Tutorial.Select_Item]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
scene.ui.setModeWithoutClear(Mode.MESSAGE).then(() => {
|
|
scene.ui.showText(i18next.t("tutorial:selectItem"), null, () => scene.ui.showText("", null, () => scene.ui.setModeWithoutClear(Mode.MODIFIER_SELECT).then(() => resolve())), null, true);
|
|
});
|
|
});
|
|
},
|
|
[Tutorial.Egg_Gacha]: (scene: BattleScene) => {
|
|
return new Promise<void>(resolve => {
|
|
scene.ui.showText(i18next.t("tutorial:eggGacha"), null, () => scene.ui.showText("", null, () => resolve()), null, true);
|
|
});
|
|
},
|
|
};
|
|
|
|
/**
|
|
* Run through the specified tutorial if it hasn't been seen before and mark it as seen once done
|
|
* This will show a tutorial overlay if defined in the current {@linkcode AwaitableUiHandler}
|
|
* The main menu will also get disabled while the tutorial is running
|
|
* @param scene the current {@linkcode BattleScene}
|
|
* @param tutorial the {@linkcode Tutorial} to play
|
|
* @returns a promise with result `true` if the tutorial was run and finished, `false` otherwise
|
|
*/
|
|
export async function handleTutorial(scene: BattleScene, tutorial: Tutorial): Promise<boolean> {
|
|
if (!scene.enableTutorials && !Overrides.BYPASS_TUTORIAL_SKIP_OVERRIDE) {
|
|
return false;
|
|
}
|
|
|
|
if (scene.gameData.getTutorialFlags()[tutorial] && !Overrides.BYPASS_TUTORIAL_SKIP_OVERRIDE) {
|
|
return false;
|
|
}
|
|
|
|
const handler = scene.ui.getHandler();
|
|
const isMenuDisabled = scene.disableMenu;
|
|
|
|
// starting tutorial, disable menu
|
|
scene.disableMenu = true;
|
|
if (handler instanceof AwaitableUiHandler) {
|
|
handler.tutorialActive = true;
|
|
}
|
|
|
|
await showTutorialOverlay(scene, handler);
|
|
await tutorialHandlers[tutorial](scene);
|
|
await hideTutorialOverlay(scene, handler);
|
|
|
|
// tutorial finished and overlay gone, re-enable menu, save tutorial as seen
|
|
scene.disableMenu = isMenuDisabled;
|
|
scene.gameData.saveTutorialFlag(tutorial, true);
|
|
if (handler instanceof AwaitableUiHandler) {
|
|
handler.tutorialActive = false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Show the tutorial overlay if there is one
|
|
* @param scene the current BattleScene
|
|
* @param handler the current UiHandler
|
|
* @returns `true` once the overlay has finished appearing, or if there is no overlay
|
|
*/
|
|
async function showTutorialOverlay(scene: BattleScene, handler: UiHandler) {
|
|
if (handler instanceof AwaitableUiHandler && handler.tutorialOverlay) {
|
|
scene.tweens.add({
|
|
targets: handler.tutorialOverlay,
|
|
alpha: 0.5,
|
|
duration: 750,
|
|
ease: "Sine.easeOut",
|
|
onComplete: () => {
|
|
return true;
|
|
}
|
|
});
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Hide the tutorial overlay if there is one
|
|
* @param scene the current BattleScene
|
|
* @param handler the current UiHandler
|
|
* @returns `true` once the overlay has finished disappearing, or if there is no overlay
|
|
*/
|
|
async function hideTutorialOverlay(scene: BattleScene, handler: UiHandler) {
|
|
if (handler instanceof AwaitableUiHandler && handler.tutorialOverlay) {
|
|
scene.tweens.add({
|
|
targets: handler.tutorialOverlay,
|
|
alpha: 0,
|
|
duration: 500,
|
|
ease: "Sine.easeOut",
|
|
onComplete: () => {
|
|
return true;
|
|
}
|
|
});
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|