mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-30 02:36:11 +00:00
bac6c22973
* eslint config + packages
* updated eslint config
* fix the issue eslint adding ;;;; at interfaces
* first round with eslint --fix .
* removed config for unused export
* Revert "first round with eslint --fix ."
This reverts commit 77a88e0895
.
* removed config for camelCase
* for real this time, first round of eslint --fix .
* halfway to manual eslint fix
* eslint done
* added "how to setup" the hook to eslint --fix each new file before commit (if wanted)
* removed eslintrc config file duplicat
* fix human error + ignore build folder + merge overrides
* added curly brace style + eslint
* applied double quote linter rule
* added lefthook
* test precommit
* test precommit
* test precommit
* test precommit
* test precommit
* test precommit
* test precommit
* github action to run eslint
* added node_modules to ignore eslint
* different action for typescript
* no need for different glob (default src)
* node 20
* node 20
* removed no longer needed install file
* remove hooks part from README
* eslint fixes
---------
Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt>
89 lines
3.3 KiB
TypeScript
89 lines
3.3 KiB
TypeScript
import BattleScene from "./battle-scene";
|
|
import AwaitableUiHandler from "./ui/awaitable-ui-handler";
|
|
import { Mode } from "./ui/ui";
|
|
import i18next from "./plugins/i18n";
|
|
|
|
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);
|
|
});
|
|
},
|
|
};
|
|
|
|
export function handleTutorial(scene: BattleScene, tutorial: Tutorial): Promise<boolean> {
|
|
return new Promise<boolean>(resolve => {
|
|
if (!scene.enableTutorials) {
|
|
return resolve(false);
|
|
}
|
|
|
|
if (scene.gameData.getTutorialFlags()[tutorial]) {
|
|
return resolve(false);
|
|
}
|
|
|
|
const handler = scene.ui.getHandler();
|
|
if (handler instanceof AwaitableUiHandler) {
|
|
handler.tutorialActive = true;
|
|
}
|
|
tutorialHandlers[tutorial](scene).then(() => {
|
|
scene.gameData.saveTutorialFlag(tutorial, true);
|
|
if (handler instanceof AwaitableUiHandler) {
|
|
handler.tutorialActive = false;
|
|
}
|
|
resolve(true);
|
|
});
|
|
});
|
|
}
|