Add endless mode
Add endless mode; prevent stat booster items from being transferred or stolen
This commit is contained in:
1 parent
ac9814e665
commit
9faa489f19
16 files changed
+241
-112
No files matched your search
@@ -1,17 +1,9 @@
|
||||
import BattleScene, { Button } from "../battle-scene";
|
||||
import OptionSelectUiHandler from "./option-select-ui-handler";
|
||||
import { addTextObject, TextStyle } from "./text";
|
||||
import { Mode } from "./ui";
|
||||
import UiHandler from "./uiHandler";
|
||||
|
||||
export default class ConfirmUiHandler extends UiHandler {
|
||||
private yesHandler: Function;
|
||||
private noHander: Function;
|
||||
|
||||
private confirmContainer: Phaser.GameObjects.Container;
|
||||
private confirmBg: Phaser.GameObjects.Image;
|
||||
|
||||
private cursorObj: Phaser.GameObjects.Image;
|
||||
|
||||
export default class ConfirmUiHandler extends OptionSelectUiHandler {
|
||||
private switchCheck: boolean;
|
||||
private switchCheckCursor: integer;
|
||||
|
||||
@@ -19,94 +11,34 @@ export default class ConfirmUiHandler extends UiHandler {
|
||||
super(scene, Mode.CONFIRM);
|
||||
}
|
||||
|
||||
setup() {
|
||||
const ui = this.getUi();
|
||||
|
||||
this.confirmContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 49, -49);
|
||||
this.confirmContainer.setVisible(false);
|
||||
ui.add(this.confirmContainer);
|
||||
getWindowName(): string {
|
||||
return 'boolean_window';
|
||||
}
|
||||
|
||||
this.confirmBg = this.scene.add.image(0, 0, 'boolean_window');
|
||||
this.confirmBg.setOrigin(0, 1);
|
||||
this.confirmContainer.add(this.confirmBg);
|
||||
getWindowWidth(): integer {
|
||||
return 48;
|
||||
}
|
||||
|
||||
const confirmText = addTextObject(this.scene, 0, 0, 'Yes\nNo', TextStyle.WINDOW, { maxLines: 2 });
|
||||
confirmText.setPositionRelative(this.confirmBg, 16, 9);
|
||||
confirmText.setLineSpacing(12);
|
||||
this.confirmContainer.add(confirmText);
|
||||
|
||||
this.setCursor(0);
|
||||
getOptions(): string[] {
|
||||
return [ 'Yes', 'No' ];
|
||||
}
|
||||
|
||||
show(args: any[]) {
|
||||
if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) {
|
||||
super.show(args);
|
||||
|
||||
this.yesHandler = args[0] as Function;
|
||||
this.noHander = args[1] as Function;
|
||||
this.switchCheck = args.length >= 3 && args[2] as boolean;
|
||||
|
||||
this.confirmContainer.setVisible(true);
|
||||
this.setCursor(this.switchCheck ? this.switchCheckCursor : 0);
|
||||
}
|
||||
}
|
||||
|
||||
processInput(button: Button) {
|
||||
const ui = this.getUi();
|
||||
|
||||
let success = false;
|
||||
|
||||
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||
success = true;
|
||||
if (button === Button.CANCEL)
|
||||
this.setCursor(1);
|
||||
const handler = this.cursor ? this.noHander : this.yesHandler;
|
||||
handler();
|
||||
this.clear();
|
||||
} else {
|
||||
switch (button) {
|
||||
case Button.UP:
|
||||
if (this.cursor)
|
||||
success = this.setCursor(0);
|
||||
break;
|
||||
case Button.DOWN:
|
||||
if (!this.cursor)
|
||||
success = this.setCursor(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
ui.playSelect();
|
||||
}
|
||||
|
||||
setCursor(cursor: integer): boolean {
|
||||
const ret = super.setCursor(cursor);
|
||||
|
||||
if (ret && this.switchCheck)
|
||||
this.switchCheckCursor = this.cursor;
|
||||
|
||||
if (!this.cursorObj) {
|
||||
this.cursorObj = this.scene.add.image(0, 0, 'cursor');
|
||||
this.confirmContainer.add(this.cursorObj);
|
||||
}
|
||||
|
||||
this.cursorObj.setPositionRelative(this.confirmBg, 12, this.cursor ? 33 : 17);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
clear() {
|
||||
super.clear();
|
||||
this.yesHandler = null;
|
||||
this.noHander = null;
|
||||
this.confirmContainer.setVisible(false);
|
||||
this.eraseCursor();
|
||||
}
|
||||
|
||||
eraseCursor() {
|
||||
if (this.cursorObj)
|
||||
this.cursorObj.destroy();
|
||||
this.cursorObj = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import BattleScene from "../battle-scene";
|
||||
import OptionSelectUiHandler from "./option-select-ui-handler";
|
||||
import { Mode } from "./ui";
|
||||
|
||||
export default class GameModeSelectUiHandler extends OptionSelectUiHandler {
|
||||
|
||||
constructor(scene: BattleScene) {
|
||||
super(scene, Mode.GAME_MODE_SELECT);
|
||||
}
|
||||
|
||||
getWindowName(): string {
|
||||
return 'game_mode_select_window';
|
||||
}
|
||||
|
||||
getWindowWidth(): integer {
|
||||
return 64;
|
||||
}
|
||||
|
||||
getOptions(): string[] {
|
||||
return [ 'Classic', 'Endless', 'Cancel' ];
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
|
||||
this.getUi().clearText();
|
||||
|
||||
const partyHasHeldItem = !!this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier).length;
|
||||
const partyHasHeldItem = !!this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).getTransferrable(true)).length;
|
||||
|
||||
this.transferButtonContainer.setVisible(false);
|
||||
this.transferButtonContainer.setAlpha(0);
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
import BattleScene, { Button } from "../battle-scene";
|
||||
import { TextStyle, addTextObject } from "./text";
|
||||
import { Mode } from "./ui";
|
||||
import UiHandler from "./uiHandler";
|
||||
|
||||
export default abstract class OptionSelectUiHandler extends UiHandler {
|
||||
protected handlers: Function[];
|
||||
|
||||
protected optionSelectContainer: Phaser.GameObjects.Container;
|
||||
protected optionSelectBg: Phaser.GameObjects.Image;
|
||||
|
||||
private cursorObj: Phaser.GameObjects.Image;
|
||||
|
||||
constructor(scene: BattleScene, mode?: Mode) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
abstract getWindowName(): string;
|
||||
|
||||
abstract getWindowWidth(): integer;
|
||||
|
||||
abstract getOptions(): string[];
|
||||
|
||||
setup() {
|
||||
const ui = this.getUi();
|
||||
|
||||
this.optionSelectContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - (this.getWindowWidth() + 1), -(this.getWindowWidth() + 1));
|
||||
this.optionSelectContainer.setVisible(false);
|
||||
ui.add(this.optionSelectContainer);
|
||||
|
||||
this.optionSelectBg = this.scene.add.image(0, 0, this.getWindowName());
|
||||
this.optionSelectBg.setOrigin(0, 1);
|
||||
this.optionSelectContainer.add(this.optionSelectBg);
|
||||
|
||||
const options = this.getOptions();
|
||||
|
||||
const optionSelectText = addTextObject(this.scene, 0, 0, options.join('\n'), TextStyle.WINDOW, { maxLines: options.length });
|
||||
optionSelectText.setPositionRelative(this.optionSelectBg, 16, 9);
|
||||
optionSelectText.setLineSpacing(12);
|
||||
this.optionSelectContainer.add(optionSelectText);
|
||||
|
||||
this.setCursor(0);
|
||||
}
|
||||
|
||||
show(args: any[]) {
|
||||
const options = this.getOptions();
|
||||
|
||||
if (args.length >= options.length && args[0] instanceof Function && args[1] instanceof Function) {
|
||||
super.show(args);
|
||||
|
||||
this.handlers = args.slice(0, options.length) as Function[];
|
||||
|
||||
this.optionSelectContainer.setVisible(true);
|
||||
this.setCursor(0);
|
||||
}
|
||||
}
|
||||
|
||||
processInput(button: Button) {
|
||||
const ui = this.getUi();
|
||||
|
||||
let success = false;
|
||||
|
||||
const options = this.getOptions();
|
||||
|
||||
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||
success = true;
|
||||
if (button === Button.CANCEL)
|
||||
this.setCursor(options.length - 1);
|
||||
const handler = this.handlers[this.cursor];
|
||||
handler();
|
||||
this.clear();
|
||||
} else {
|
||||
switch (button) {
|
||||
case Button.UP:
|
||||
if (this.cursor)
|
||||
success = this.setCursor(this.cursor - 1);
|
||||
break;
|
||||
case Button.DOWN:
|
||||
if (this.cursor < options.length - 1)
|
||||
success = this.setCursor(this.cursor + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
ui.playSelect();
|
||||
}
|
||||
|
||||
setCursor(cursor: integer): boolean {
|
||||
const ret = super.setCursor(cursor);
|
||||
|
||||
if (!this.cursorObj) {
|
||||
this.cursorObj = this.scene.add.image(0, 0, 'cursor');
|
||||
this.optionSelectContainer.add(this.cursorObj);
|
||||
}
|
||||
|
||||
this.cursorObj.setPositionRelative(this.optionSelectBg, 12, 17 + this.cursor * 16);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
clear() {
|
||||
super.clear();
|
||||
for (let h = 0; h < this.handlers.length; h++)
|
||||
this.handlers[h] = null;
|
||||
this.optionSelectContainer.setVisible(false);
|
||||
this.eraseCursor();
|
||||
}
|
||||
|
||||
eraseCursor() {
|
||||
if (this.cursorObj)
|
||||
this.cursorObj.destroy();
|
||||
this.cursorObj = null;
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]);
|
||||
} else {
|
||||
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[];
|
||||
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[];
|
||||
filterResult = (this.selectFilter as PokemonModifierTransferSelectFilter)(pokemon, itemModifiers[this.transferOptionCursor]);
|
||||
}
|
||||
if (filterResult === null) {
|
||||
@@ -409,7 +409,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
const pokemon = this.scene.getParty()[this.cursor];
|
||||
|
||||
const itemModifiers = this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER
|
||||
? this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[]
|
||||
? this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[]
|
||||
: null;
|
||||
|
||||
if (this.partyUiMode !== PartyUiMode.MOVE_MODIFIER && (this.transferMode || this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER)) {
|
||||
|
||||
@@ -9,6 +9,8 @@ import { DexEntryDetails, StarterDexUnlockTree } from "../system/game-data";
|
||||
import { Gender, getGenderColor, getGenderSymbol } from "../data/gender";
|
||||
import { pokemonPrevolutions } from "../data/pokemon-evolutions";
|
||||
import { abilities } from "../data/ability";
|
||||
import { GameMode } from "../game-mode";
|
||||
import { Unlockables } from "../system/unlockables";
|
||||
|
||||
export type StarterSelectCallback = (starters: Starter[]) => void;
|
||||
|
||||
@@ -269,26 +271,37 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
if (this.speciesLoaded.get(species.speciesId))
|
||||
species.cry(this.scene);
|
||||
if (this.starterCursors.length === 3) {
|
||||
const cancel = () => {
|
||||
ui.setMode(Mode.STARTER_SELECT);
|
||||
this.popStarter();
|
||||
this.clearText();
|
||||
};
|
||||
ui.showText('Begin with these POKéMON?', null, () => {
|
||||
ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
||||
ui.setMode(Mode.STARTER_SELECT);
|
||||
const thisObj = this;
|
||||
const originalStarterSelectCallback = this.starterSelectCallback;
|
||||
this.starterSelectCallback = null;
|
||||
originalStarterSelectCallback(new Array(3).fill(0).map(function (_, i) {
|
||||
return {
|
||||
species: thisObj.genSpecies[thisObj.starterGens[i]][thisObj.starterCursors[i]],
|
||||
shiny: thisObj.starterDetails[i][0],
|
||||
formIndex: thisObj.starterDetails[i][1],
|
||||
female: thisObj.starterDetails[i][2],
|
||||
abilityIndex: thisObj.starterDetails[i][3]
|
||||
};
|
||||
}));
|
||||
}, () => {
|
||||
ui.setMode(Mode.STARTER_SELECT);
|
||||
this.popStarter();
|
||||
this.clearText();
|
||||
});
|
||||
const startRun = (gameMode: GameMode) => {
|
||||
this.scene.gameMode = gameMode;
|
||||
ui.setMode(Mode.STARTER_SELECT);
|
||||
const thisObj = this;
|
||||
const originalStarterSelectCallback = this.starterSelectCallback;
|
||||
this.starterSelectCallback = null;
|
||||
originalStarterSelectCallback(new Array(3).fill(0).map(function (_, i) {
|
||||
return {
|
||||
species: thisObj.genSpecies[thisObj.starterGens[i]][thisObj.starterCursors[i]],
|
||||
shiny: thisObj.starterDetails[i][0],
|
||||
formIndex: thisObj.starterDetails[i][1],
|
||||
female: thisObj.starterDetails[i][2],
|
||||
abilityIndex: thisObj.starterDetails[i][3]
|
||||
};
|
||||
}));
|
||||
};
|
||||
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
|
||||
ui.setMode(Mode.STARTER_SELECT);
|
||||
ui.showText('Select a game mode.', null, () => {
|
||||
ui.setModeWithoutClear(Mode.GAME_MODE_SELECT, () => startRun(GameMode.CLASSIC), () => startRun(GameMode.ENDLESS), cancel);
|
||||
});
|
||||
} else
|
||||
startRun(GameMode.CLASSIC);
|
||||
}, cancel);
|
||||
});
|
||||
}
|
||||
success = true;
|
||||
|
||||
+7
-3
@@ -13,6 +13,7 @@ import StarterSelectUiHandler from './starter-select-ui-handler';
|
||||
import EvolutionSceneHandler from './evolution-scene-handler';
|
||||
import BiomeSelectUiHandler from './biome-select-ui-handler';
|
||||
import TargetSelectUiHandler from './target-select-ui-handler';
|
||||
import GameModeSelectUiHandler from './game-mode-select-ui-handler';
|
||||
|
||||
export enum Mode {
|
||||
MESSAGE,
|
||||
@@ -26,7 +27,8 @@ export enum Mode {
|
||||
BIOME_SELECT,
|
||||
STARTER_SELECT,
|
||||
EVOLUTION_SCENE,
|
||||
CONFIRM
|
||||
CONFIRM,
|
||||
GAME_MODE_SELECT
|
||||
};
|
||||
|
||||
const transitionModes = [
|
||||
@@ -37,7 +39,8 @@ const transitionModes = [
|
||||
];
|
||||
|
||||
const noTransitionModes = [
|
||||
Mode.CONFIRM
|
||||
Mode.CONFIRM,
|
||||
Mode.GAME_MODE_SELECT
|
||||
];
|
||||
|
||||
export default class UI extends Phaser.GameObjects.Container {
|
||||
@@ -63,7 +66,8 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||
new BiomeSelectUiHandler(scene),
|
||||
new StarterSelectUiHandler(scene),
|
||||
new EvolutionSceneHandler(scene),
|
||||
new ConfirmUiHandler(scene)
|
||||
new ConfirmUiHandler(scene),
|
||||
new GameModeSelectUiHandler(scene)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user