2023-04-11 05:24:55 +01:00
|
|
|
import BattleScene, { Button } from "../battle-scene";
|
2024-02-12 21:38:46 +00:00
|
|
|
import PokemonSpecies, { allSpecies, getPokemonSpecies, speciesStarters } from "../data/pokemon-species";
|
2024-01-13 17:24:24 +00:00
|
|
|
import { Species } from "../data/enums/species";
|
2024-01-06 03:24:05 +00:00
|
|
|
import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text";
|
2023-04-10 00:15:21 +01:00
|
|
|
import { Mode } from "./ui";
|
2023-04-13 00:09:15 +01:00
|
|
|
import MessageUiHandler from "./message-ui-handler";
|
2023-04-20 20:46:05 +01:00
|
|
|
import { Gender, getGenderColor, getGenderSymbol } from "../data/gender";
|
2023-12-05 22:12:39 +00:00
|
|
|
import { allAbilities } from "../data/ability";
|
2024-02-07 04:11:00 +00:00
|
|
|
import { GameMode, gameModeNames } from "../game-mode";
|
2023-06-01 00:54:57 +01:00
|
|
|
import { Unlockables } from "../system/unlockables";
|
2023-10-25 04:04:23 +01:00
|
|
|
import { GrowthRate, getGrowthRateColor } from "../data/exp";
|
2023-11-13 04:47:04 +00:00
|
|
|
import { DexAttr, DexEntry } from "../system/game-data";
|
2023-11-14 03:29:03 +00:00
|
|
|
import * as Utils from "../utils";
|
2024-02-17 05:40:03 +00:00
|
|
|
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "../sprite/pokemon-icon-anim-handler";
|
2023-12-16 04:42:31 +00:00
|
|
|
import { StatsContainer } from "./stats-container";
|
2023-12-21 03:22:15 +00:00
|
|
|
import { addWindow } from "./window";
|
2024-01-06 03:24:05 +00:00
|
|
|
import { Nature, getNatureName } from "../data/nature";
|
|
|
|
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
2024-01-13 01:16:29 +00:00
|
|
|
import { pokemonFormChanges } from "../data/pokemon-forms";
|
2024-02-13 23:42:11 +00:00
|
|
|
import { Tutorial, handleTutorial } from "../tutorial";
|
2023-04-10 00:15:21 +01:00
|
|
|
|
2023-04-18 03:44:41 +01:00
|
|
|
export type StarterSelectCallback = (starters: Starter[]) => void;
|
|
|
|
|
|
|
|
export interface Starter {
|
|
|
|
species: PokemonSpecies;
|
2023-11-13 04:47:04 +00:00
|
|
|
dexAttr: bigint;
|
2024-01-06 03:24:05 +00:00
|
|
|
nature: Nature;
|
2023-10-25 19:15:44 +01:00
|
|
|
pokerus: boolean;
|
2023-04-18 03:44:41 +01:00
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-21 06:24:24 +00:00
|
|
|
const gens = [ 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX' ];
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2023-04-13 00:09:15 +01:00
|
|
|
export default class StarterSelectUiHandler extends MessageUiHandler {
|
2023-12-20 04:51:48 +00:00
|
|
|
private starterSelectContainer: Phaser.GameObjects.Container;
|
|
|
|
private starterSelectGenIconContainers: Phaser.GameObjects.Container[];
|
|
|
|
private pokemonNumberText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonSprite: Phaser.GameObjects.Sprite;
|
|
|
|
private pokemonNameText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonGrowthRateLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonGrowthRateText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonGenderText: Phaser.GameObjects.Text;
|
2024-02-19 03:21:57 +00:00
|
|
|
private pokemonUncaughtText: Phaser.GameObjects.Text;
|
2023-12-20 04:51:48 +00:00
|
|
|
private pokemonAbilityLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonAbilityText: Phaser.GameObjects.Text;
|
2024-01-06 03:24:05 +00:00
|
|
|
private pokemonNatureLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonNatureText: BBCodeText;
|
2024-02-12 21:38:46 +00:00
|
|
|
private pokemonCaughtCountLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonCaughtCountText: Phaser.GameObjects.Text;
|
2023-12-20 04:51:48 +00:00
|
|
|
private genOptionsText: Phaser.GameObjects.Text;
|
|
|
|
private instructionsText: Phaser.GameObjects.Text;
|
2024-02-14 15:44:55 +00:00
|
|
|
private starterSelectMessageBox: Phaser.GameObjects.NineSlice;
|
2023-12-20 04:51:48 +00:00
|
|
|
private starterSelectMessageBoxContainer: Phaser.GameObjects.Container;
|
|
|
|
private statsContainer: StatsContainer;
|
|
|
|
|
|
|
|
private genMode: boolean;
|
|
|
|
private statsMode: boolean;
|
|
|
|
private dexAttrCursor: bigint = 0n;
|
2024-01-06 03:24:05 +00:00
|
|
|
private natureCursor: integer = 0;
|
2023-12-20 04:51:48 +00:00
|
|
|
private genCursor: integer = 0;
|
|
|
|
private genScrollCursor: integer = 0;
|
|
|
|
|
|
|
|
private genSpecies: PokemonSpecies[][] = [];
|
|
|
|
private lastSpecies: PokemonSpecies;
|
|
|
|
private speciesLoaded: Map<Species, boolean> = new Map<Species, boolean>();
|
|
|
|
private starterGens: integer[] = [];
|
|
|
|
private starterCursors: integer[] = [];
|
|
|
|
private pokerusGens: integer[] = [];
|
|
|
|
private pokerusCursors: integer[] = [];
|
|
|
|
private starterAttr: bigint[] = [];
|
2024-01-06 03:24:05 +00:00
|
|
|
private starterNatures: Nature[] = [];
|
2023-12-20 04:51:48 +00:00
|
|
|
private speciesStarterDexEntry: DexEntry;
|
|
|
|
private canCycleShiny: boolean;
|
|
|
|
private canCycleForm: boolean;
|
|
|
|
private canCycleGender: boolean;
|
|
|
|
private canCycleAbility: boolean;
|
2024-01-06 03:24:05 +00:00
|
|
|
private canCycleNature: boolean;
|
2023-12-20 04:51:48 +00:00
|
|
|
private value: integer = 0;
|
|
|
|
|
|
|
|
private assetLoadCancelled: Utils.BooleanHolder;
|
|
|
|
private cursorObj: Phaser.GameObjects.Image;
|
|
|
|
private starterCursorObjs: Phaser.GameObjects.Image[];
|
|
|
|
private pokerusCursorObjs: Phaser.GameObjects.Image[];
|
|
|
|
private starterIcons: Phaser.GameObjects.Sprite[];
|
|
|
|
private genCursorObj: Phaser.GameObjects.Image;
|
|
|
|
private genCursorHighlightObj: Phaser.GameObjects.Image;
|
|
|
|
private valueLimitLabel: Phaser.GameObjects.Text;
|
|
|
|
private startCursorObj: Phaser.GameObjects.NineSlice;
|
|
|
|
private starterValueLabels: Phaser.GameObjects.Text[];
|
|
|
|
private shinyIcons: Phaser.GameObjects.Image[];
|
|
|
|
|
|
|
|
private iconAnimHandler: PokemonIconAnimHandler;
|
|
|
|
|
|
|
|
private starterSelectCallback: StarterSelectCallback;
|
|
|
|
|
|
|
|
constructor(scene: BattleScene) {
|
|
|
|
super(scene, Mode.STARTER_SELECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
const ui = this.getUi();
|
|
|
|
|
|
|
|
this.starterSelectContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6);
|
|
|
|
this.starterSelectContainer.setVisible(false);
|
|
|
|
ui.add(this.starterSelectContainer);
|
|
|
|
|
|
|
|
const bgColor = this.scene.add.rectangle(0, 0, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0x006860);
|
|
|
|
bgColor.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(bgColor);
|
|
|
|
|
|
|
|
const starterSelectBg = this.scene.add.image(1, 1, 'starter_select_bg');
|
|
|
|
starterSelectBg.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(starterSelectBg);
|
|
|
|
|
2024-01-01 15:14:49 +00:00
|
|
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 1, 34, 58));
|
|
|
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 59, 34, 91));
|
2023-12-21 03:22:15 +00:00
|
|
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 145, 34, 34, true));
|
|
|
|
this.starterSelectContainer.add(addWindow(this.scene, 141, 1, 178, 178));
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.iconAnimHandler = new PokemonIconAnimHandler();
|
|
|
|
this.iconAnimHandler.setup(this.scene);
|
|
|
|
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonNumberText = addTextObject(this.scene, 17, 1, '0000', TextStyle.SUMMARY);
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonNumberText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNumberText);
|
|
|
|
|
|
|
|
this.pokemonNameText = addTextObject(this.scene, 6, 112, '', TextStyle.SUMMARY);
|
|
|
|
this.pokemonNameText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNameText);
|
|
|
|
|
|
|
|
this.pokemonGrowthRateLabelText = addTextObject(this.scene, 8, 103, 'Growth Rate:', TextStyle.SUMMARY, { fontSize: '48px' });
|
|
|
|
this.pokemonGrowthRateLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonGrowthRateLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonGrowthRateLabelText);
|
|
|
|
|
2024-01-05 16:29:34 +00:00
|
|
|
this.pokemonGrowthRateText = addTextObject(this.scene, 44, 103, '', TextStyle.SUMMARY_PINK, { fontSize: '48px' });
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonGrowthRateText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonGrowthRateText);
|
|
|
|
|
|
|
|
this.pokemonGenderText = addTextObject(this.scene, 96, 112, '', TextStyle.SUMMARY);
|
|
|
|
this.pokemonGenderText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonGenderText);
|
|
|
|
|
2024-02-19 03:21:57 +00:00
|
|
|
this.pokemonUncaughtText = addTextObject(this.scene, 6, 126, 'Uncaught', TextStyle.SUMMARY, { fontSize: '56px' });
|
|
|
|
this.pokemonUncaughtText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonUncaughtText);
|
|
|
|
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonAbilityLabelText = addTextObject(this.scene, 6, 126, 'Ability:', TextStyle.SUMMARY, { fontSize: '56px' });
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonAbilityLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonAbilityLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonAbilityLabelText);
|
|
|
|
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonAbilityText = addTextObject(this.scene, 30, 126, '', TextStyle.SUMMARY, { fontSize: '56px' });
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonAbilityText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonAbilityText);
|
|
|
|
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonNatureLabelText = addTextObject(this.scene, 6, 135, 'Nature:', TextStyle.SUMMARY, { fontSize: '56px' });
|
2024-01-06 03:24:05 +00:00
|
|
|
this.pokemonNatureLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonNatureLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNatureLabelText);
|
|
|
|
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonNatureText = addBBCodeTextObject(this.scene, 30, 135, '', TextStyle.SUMMARY, { fontSize: '56px' });
|
2024-01-06 03:24:05 +00:00
|
|
|
this.pokemonNatureText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNatureText);
|
|
|
|
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonCaughtCountLabelText = addTextObject(this.scene, 6, 144, 'Caught/Hatched:', TextStyle.SUMMARY, { fontSize: '56px' });
|
|
|
|
this.pokemonCaughtCountLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonCaughtCountLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonCaughtCountLabelText);
|
|
|
|
|
|
|
|
this.pokemonCaughtCountText = addTextObject(this.scene, 58, 144, '0/0 (0)', TextStyle.SUMMARY, { fontSize: '56px' });
|
|
|
|
this.pokemonCaughtCountText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonCaughtCountText);
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.genOptionsText = addTextObject(this.scene, 124, 7, '', TextStyle.WINDOW, { fontSize: 72, lineSpacing: 39, align: 'center' });
|
|
|
|
this.genOptionsText.setShadowOffset(4.5, 4.5);
|
|
|
|
this.genOptionsText.setOrigin(0.5, 0);
|
|
|
|
this.starterSelectContainer.add(this.genOptionsText);
|
|
|
|
|
|
|
|
this.updateGenOptions();
|
|
|
|
|
|
|
|
this.starterSelectGenIconContainers = new Array(gens.length).fill(null).map((_, i) => {
|
|
|
|
const container = this.scene.add.container(149, 9);
|
|
|
|
if (i)
|
|
|
|
container.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(container);
|
|
|
|
return container;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.pokerusCursorObjs = new Array(3).fill(null).map(() => {
|
|
|
|
const cursorObj = this.scene.add.image(0, 0, 'starter_select_cursor_pokerus');
|
|
|
|
cursorObj.setVisible(false);
|
|
|
|
cursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(cursorObj);
|
|
|
|
return cursorObj;
|
|
|
|
});
|
|
|
|
|
2024-01-01 15:14:49 +00:00
|
|
|
this.starterCursorObjs = new Array(6).fill(null).map(() => {
|
2023-12-20 04:51:48 +00:00
|
|
|
const cursorObj = this.scene.add.image(0, 0, 'starter_select_cursor_highlight');
|
|
|
|
cursorObj.setVisible(false);
|
|
|
|
cursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(cursorObj);
|
|
|
|
return cursorObj;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.cursorObj = this.scene.add.image(0, 0, 'starter_select_cursor');
|
|
|
|
this.cursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.cursorObj);
|
|
|
|
|
|
|
|
this.genCursorHighlightObj = this.scene.add.image(111, 5, 'starter_select_gen_cursor_highlight');
|
|
|
|
this.genCursorHighlightObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.genCursorHighlightObj);
|
|
|
|
|
|
|
|
this.genCursorObj = this.scene.add.image(111, 5, 'starter_select_gen_cursor');
|
|
|
|
this.genCursorObj.setVisible(false);
|
|
|
|
this.genCursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.genCursorObj);
|
|
|
|
|
|
|
|
this.valueLimitLabel = addTextObject(this.scene, 124, 150, '0/10', TextStyle.TOOLTIP_CONTENT);
|
|
|
|
this.valueLimitLabel.setOrigin(0.5, 0);
|
|
|
|
this.starterSelectContainer.add(this.valueLimitLabel);
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
const startLabel = addTextObject(this.scene, 124, 162, 'Start', TextStyle.TOOLTIP_CONTENT);
|
|
|
|
startLabel.setOrigin(0.5, 0);
|
|
|
|
this.starterSelectContainer.add(startLabel);
|
2023-12-07 05:52:20 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.startCursorObj = this.scene.add.nineslice(111, 160, 'starter_select_cursor', null, 26, 15, 1, 1, 1, 1);
|
|
|
|
this.startCursorObj.setVisible(false);
|
|
|
|
this.startCursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.startCursorObj);
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
const starterSpecies: Species[] = [];
|
|
|
|
|
|
|
|
for (let g = 0; g < this.starterSelectGenIconContainers.length; g++) {
|
|
|
|
let s = 0;
|
|
|
|
this.genSpecies.push([]);
|
|
|
|
|
|
|
|
for (let species of allSpecies) {
|
2024-02-12 21:38:46 +00:00
|
|
|
if (!speciesStarters.hasOwnProperty(species.speciesId) || species.generation !== g + 1 || !species.isObtainable())
|
2023-12-20 04:51:48 +00:00
|
|
|
continue;
|
|
|
|
starterSpecies.push(species.speciesId);
|
|
|
|
this.speciesLoaded.set(species.speciesId, false);
|
|
|
|
this.genSpecies[g].push(species);
|
|
|
|
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
|
|
|
|
const defaultProps = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
|
|
|
const x = (s % 9) * 18;
|
|
|
|
const y = Math.floor(s / 9) * 18;
|
|
|
|
const icon = this.scene.add.sprite(x - 2, y + 2, species.getIconAtlasKey(defaultProps.formIndex));
|
|
|
|
icon.setScale(0.5);
|
|
|
|
icon.setOrigin(0, 0);
|
|
|
|
icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny));
|
2024-02-19 03:21:57 +00:00
|
|
|
icon.setTint(0);
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterSelectGenIconContainers[g].add(icon);
|
|
|
|
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.NONE);
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2024-01-01 15:14:49 +00:00
|
|
|
this.starterIcons = new Array(6).fill(null).map((_, i) => {
|
|
|
|
const icon = this.scene.add.sprite(113, 63 + 13 * i, 'pokemon_icons_0');
|
2023-12-20 04:51:48 +00:00
|
|
|
icon.setScale(0.5);
|
|
|
|
icon.setOrigin(0, 0);
|
|
|
|
icon.setFrame('unknown');
|
|
|
|
this.starterSelectContainer.add(icon);
|
|
|
|
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.PASSIVE);
|
|
|
|
return icon;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.starterValueLabels = new Array(81).fill(null).map((_, i) => {
|
|
|
|
const x = (i % 9) * 18;
|
|
|
|
const y = Math.floor(i / 9) * 18;
|
|
|
|
const ret = addTextObject(this.scene, x + 150, y + 11, '0', TextStyle.WINDOW, { fontSize: '32px' });
|
|
|
|
ret.setShadowOffset(2, 2);
|
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.shinyIcons = new Array(81).fill(null).map((_, i) => {
|
|
|
|
const x = (i % 9) * 18;
|
|
|
|
const y = Math.floor(i / 9) * 18;
|
|
|
|
const ret = this.scene.add.image(x + 161, y + 11, 'shiny_star');
|
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setScale(0.5);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`);
|
|
|
|
this.starterSelectContainer.add(this.pokemonSprite);
|
|
|
|
|
2024-02-12 21:38:46 +00:00
|
|
|
this.instructionsText = addTextObject(this.scene, 4, 156, '', TextStyle.PARTY, { fontSize: '42px' });
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterSelectContainer.add(this.instructionsText);
|
|
|
|
|
|
|
|
this.starterSelectMessageBoxContainer = this.scene.add.container(0, this.scene.game.canvas.height / 6);
|
|
|
|
this.starterSelectMessageBoxContainer.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.starterSelectMessageBoxContainer);
|
|
|
|
|
2024-02-14 15:44:55 +00:00
|
|
|
this.starterSelectMessageBox = addWindow(this.scene, 1, -1, 318, 28);
|
|
|
|
this.starterSelectMessageBox.setOrigin(0, 1);
|
|
|
|
this.starterSelectMessageBoxContainer.add(this.starterSelectMessageBox);
|
2023-12-20 04:51:48 +00:00
|
|
|
|
2024-02-14 15:44:55 +00:00
|
|
|
this.message = addTextObject(this.scene, 8, 8, '', TextStyle.WINDOW, { maxLines: 2 });
|
|
|
|
this.message.setOrigin(0, 0);
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterSelectMessageBoxContainer.add(this.message);
|
|
|
|
|
|
|
|
const date = new Date();
|
|
|
|
date.setUTCHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
this.scene.executeWithSeedOffset(() => {
|
|
|
|
for (let c = 0; c < 3; c++) {
|
|
|
|
let randomSpeciesId: Species;
|
|
|
|
let species: PokemonSpecies;
|
|
|
|
let pokerusCursor: integer;
|
|
|
|
|
|
|
|
const generateSpecies = () => {
|
2024-02-17 05:40:03 +00:00
|
|
|
randomSpeciesId = Utils.randSeedItem(starterSpecies);
|
2023-12-20 04:51:48 +00:00
|
|
|
species = getPokemonSpecies(randomSpeciesId);
|
|
|
|
pokerusCursor = this.genSpecies[species.generation - 1].indexOf(species);
|
|
|
|
};
|
|
|
|
|
|
|
|
let dupe = false;
|
2023-10-25 04:04:23 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
do {
|
|
|
|
generateSpecies();
|
2023-10-25 04:04:23 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
for (let pc = 0; pc < c; pc++) {
|
|
|
|
if (this.pokerusGens[pc] === species.generation -1 && this.pokerusCursors[pc] === pokerusCursor) {
|
|
|
|
dupe = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (dupe);
|
2023-04-18 06:32:26 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokerusGens.push(species.generation - 1);
|
|
|
|
this.pokerusCursors.push(pokerusCursor);
|
|
|
|
this.pokerusCursorObjs[c].setPosition(148 + 18 * (pokerusCursor % 9), 10 + 18 * Math.floor(pokerusCursor / 9));
|
|
|
|
}
|
|
|
|
}, 0, date.getTime().toString());
|
2023-12-01 22:23:26 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.statsContainer = new StatsContainer(this.scene, 6, 16);
|
2023-12-01 22:23:26 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.scene.add.existing(this.statsContainer);
|
2023-10-25 19:15:44 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.statsContainer.setVisible(false);
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterSelectContainer.add(this.statsContainer);
|
2023-10-25 19:15:44 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.updateInstructions();
|
|
|
|
}
|
2023-10-25 19:15:44 +01:00
|
|
|
|
2023-12-30 23:41:25 +00:00
|
|
|
show(args: any[]): boolean {
|
2023-12-20 04:51:48 +00:00
|
|
|
if (args.length >= 1 && args[0] instanceof Function) {
|
|
|
|
super.show(args);
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
for (let g = 0; g < this.genSpecies.length; g++) {
|
|
|
|
this.genSpecies[g].forEach((species, s) => {
|
|
|
|
const dexEntry = this.scene.gameData.dexData[species.speciesId];
|
|
|
|
const icon = this.starterSelectGenIconContainers[g].getAt(s) as Phaser.GameObjects.Sprite;
|
|
|
|
if (dexEntry.caughtAttr)
|
|
|
|
icon.clearTint();
|
2024-02-19 03:21:57 +00:00
|
|
|
else if (dexEntry.seenAttr)
|
|
|
|
icon.setTint(0x808080);
|
2023-12-20 04:51:48 +00:00
|
|
|
});
|
|
|
|
}
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterSelectCallback = args[0] as StarterSelectCallback;
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterSelectContainer.setVisible(true);
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.setGenMode(false);
|
|
|
|
this.setCursor(0);
|
|
|
|
this.setGenMode(true);
|
|
|
|
this.setCursor(0);
|
2023-12-30 23:41:25 +00:00
|
|
|
|
2024-02-14 15:44:55 +00:00
|
|
|
handleTutorial(this.scene, Tutorial.Starter_Select);
|
2024-02-13 23:42:11 +00:00
|
|
|
|
2023-12-30 23:41:25 +00:00
|
|
|
return true;
|
2023-04-10 00:15:21 +01:00
|
|
|
}
|
2023-12-30 23:41:25 +00:00
|
|
|
|
|
|
|
return false;
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2023-04-25 03:32:12 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
showText(text: string, delay?: integer, callback?: Function, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer) {
|
|
|
|
super.showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2024-02-14 15:44:55 +00:00
|
|
|
if (text?.indexOf('\n') === -1) {
|
|
|
|
this.starterSelectMessageBox.setSize(318, 28);
|
|
|
|
this.message.setY(-22);
|
|
|
|
} else {
|
|
|
|
this.starterSelectMessageBox.setSize(318, 42);
|
|
|
|
this.message.setY(-37);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.starterSelectMessageBoxContainer.setVisible(!!text?.length);
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
processInput(button: Button): boolean {
|
|
|
|
const ui = this.getUi();
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
let success = false;
|
|
|
|
let error = false;
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2024-01-01 18:41:46 +00:00
|
|
|
if (button === Button.SUBMIT) {
|
|
|
|
if (this.tryStart(true))
|
|
|
|
success = true;
|
2024-01-02 22:31:44 +00:00
|
|
|
else
|
|
|
|
error = true;
|
2024-01-01 18:41:46 +00:00
|
|
|
} else if (this.startCursorObj.visible) {
|
2023-12-20 04:51:48 +00:00
|
|
|
switch (button) {
|
|
|
|
case Button.ACTION:
|
2024-01-01 16:17:20 +00:00
|
|
|
if (this.tryStart(true))
|
2023-12-20 04:51:48 +00:00
|
|
|
success = true;
|
|
|
|
else
|
|
|
|
error = true;
|
|
|
|
break;
|
|
|
|
case Button.UP:
|
|
|
|
this.startCursorObj.setVisible(false);
|
|
|
|
this.setGenMode(true);
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
case Button.RIGHT:
|
|
|
|
this.startCursorObj.setVisible(false);
|
|
|
|
this.setGenMode(false);
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (this.genMode) {
|
|
|
|
switch (button) {
|
|
|
|
case Button.UP:
|
|
|
|
if (this.genCursor)
|
|
|
|
success = this.setCursor(this.genCursor - 1);
|
|
|
|
break;
|
|
|
|
case Button.DOWN:
|
2024-01-01 15:14:49 +00:00
|
|
|
if (this.genCursor < 2)
|
2023-12-20 04:51:48 +00:00
|
|
|
success = this.setCursor(this.genCursor + 1);
|
|
|
|
else {
|
|
|
|
this.startCursorObj.setVisible(true);
|
|
|
|
this.setGenMode(true);
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.RIGHT:
|
|
|
|
success = this.setGenMode(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (button === Button.ACTION) {
|
|
|
|
if (!this.speciesStarterDexEntry?.caughtAttr)
|
|
|
|
error = true;
|
2024-01-01 15:14:49 +00:00
|
|
|
else if (this.starterCursors.length < 6) {
|
2024-01-11 17:26:32 +00:00
|
|
|
ui.setModeWithoutClear(Mode.OPTION_SELECT, {
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
label: 'Add to Party',
|
|
|
|
handler: () => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
|
|
|
let isDupe = false;
|
|
|
|
for (let s = 0; s < this.starterCursors.length; s++) {
|
|
|
|
if (this.starterGens[s] === this.getGenCursorWithScroll() && this.starterCursors[s] === this.cursor) {
|
|
|
|
isDupe = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const species = this.genSpecies[this.getGenCursorWithScroll()][this.cursor];
|
2024-02-12 21:38:46 +00:00
|
|
|
if (!isDupe && this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId))) {
|
2024-01-11 17:26:32 +00:00
|
|
|
const cursorObj = this.starterCursorObjs[this.starterCursors.length];
|
|
|
|
cursorObj.setVisible(true);
|
|
|
|
cursorObj.setPosition(this.cursorObj.x, this.cursorObj.y);
|
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor);
|
|
|
|
this.starterIcons[this.starterCursors.length].setTexture(species.getIconAtlasKey(props.formIndex));
|
|
|
|
this.starterIcons[this.starterCursors.length].setFrame(species.getIconId(props.female, props.formIndex, props.shiny));
|
|
|
|
this.starterGens.push(this.getGenCursorWithScroll());
|
|
|
|
this.starterCursors.push(this.cursor);
|
|
|
|
this.starterAttr.push(this.dexAttrCursor);
|
|
|
|
this.starterNatures.push(this.natureCursor as unknown as Nature);
|
|
|
|
if (this.speciesLoaded.get(species.speciesId))
|
|
|
|
species.cry(this.scene);
|
|
|
|
if (this.starterCursors.length === 6 || this.value === 10)
|
|
|
|
this.tryStart();
|
|
|
|
this.updateInstructions();
|
|
|
|
ui.playSelect();
|
|
|
|
} else
|
|
|
|
ui.playError();
|
|
|
|
},
|
|
|
|
overrideSound: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Toggle IVs',
|
|
|
|
handler: () => {
|
|
|
|
this.toggleStatsMode();
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2024-02-07 04:11:00 +00:00
|
|
|
],
|
|
|
|
yOffset: 47
|
2023-12-20 04:51:48 +00:00
|
|
|
});
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
} else if (button === Button.CANCEL) {
|
|
|
|
if (this.statsMode) {
|
|
|
|
this.toggleStatsMode(false);
|
|
|
|
success = true;
|
|
|
|
} else if (this.starterCursors.length) {
|
|
|
|
this.popStarter();
|
|
|
|
success = true;
|
|
|
|
this.updateInstructions();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const genStarters = this.starterSelectGenIconContainers[this.getGenCursorWithScroll()].getAll().length;
|
|
|
|
const rows = Math.ceil(genStarters / 9);
|
|
|
|
const row = Math.floor(this.cursor / 9);
|
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.dexAttrCursor);
|
2023-12-01 22:23:26 +00:00
|
|
|
switch (button) {
|
2023-12-20 04:51:48 +00:00
|
|
|
case Button.CYCLE_SHINY:
|
|
|
|
if (this.canCycleShiny) {
|
2024-01-06 03:24:05 +00:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, !props.shiny, undefined, undefined, undefined, undefined);
|
2023-12-20 04:51:48 +00:00
|
|
|
if (this.dexAttrCursor & DexAttr.SHINY)
|
|
|
|
this.scene.playSound('sparkle');
|
|
|
|
else
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.CYCLE_FORM:
|
|
|
|
if (this.canCycleForm) {
|
|
|
|
const formCount = this.lastSpecies.forms.length;
|
|
|
|
let newFormIndex = props.formIndex;
|
|
|
|
do {
|
|
|
|
newFormIndex = (newFormIndex + 1) % formCount;
|
|
|
|
if (this.speciesStarterDexEntry.caughtAttr & this.scene.gameData.getFormAttr(newFormIndex))
|
|
|
|
break;
|
|
|
|
} while (newFormIndex !== props.formIndex);
|
2024-01-06 03:24:05 +00:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, newFormIndex, undefined, undefined, undefined);
|
2023-12-01 22:23:26 +00:00
|
|
|
success = true;
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2023-12-01 22:23:26 +00:00
|
|
|
break;
|
2023-12-20 04:51:48 +00:00
|
|
|
case Button.CYCLE_GENDER:
|
|
|
|
if (this.canCycleGender) {
|
2024-01-06 03:24:05 +00:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, !props.female, undefined, undefined);
|
2023-12-20 04:51:48 +00:00
|
|
|
success = true;
|
|
|
|
}
|
2023-12-01 22:23:26 +00:00
|
|
|
break;
|
2023-12-20 04:51:48 +00:00
|
|
|
case Button.CYCLE_ABILITY:
|
|
|
|
if (this.canCycleAbility) {
|
|
|
|
const abilityCount = this.lastSpecies.getAbilityCount();
|
|
|
|
let newAbilityIndex = props.abilityIndex;
|
|
|
|
do {
|
|
|
|
newAbilityIndex = (newAbilityIndex + 1) % abilityCount;
|
|
|
|
if (!newAbilityIndex) {
|
|
|
|
if (this.speciesStarterDexEntry.caughtAttr & DexAttr.ABILITY_1)
|
|
|
|
break;
|
|
|
|
} else if (newAbilityIndex === 1) {
|
|
|
|
if (this.speciesStarterDexEntry.caughtAttr & (this.lastSpecies.ability2 ? DexAttr.ABILITY_2 : DexAttr.ABILITY_HIDDEN))
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
if (this.speciesStarterDexEntry.caughtAttr & DexAttr.ABILITY_HIDDEN)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (newAbilityIndex !== props.abilityIndex);
|
2024-01-06 03:24:05 +00:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, newAbilityIndex, undefined);
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.CYCLE_NATURE:
|
|
|
|
if (this.canCycleNature) {
|
|
|
|
const natures = this.scene.gameData.getNaturesForAttr(this.speciesStarterDexEntry.natureAttr);
|
|
|
|
const natureIndex = natures.indexOf(this.natureCursor);
|
|
|
|
const newNature = natures[natureIndex < natures.length - 1 ? natureIndex + 1 : 0];
|
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, newNature);
|
2023-12-20 04:51:48 +00:00
|
|
|
success = true;
|
|
|
|
}
|
2023-12-01 22:23:26 +00:00
|
|
|
break;
|
2023-04-13 00:09:15 +01:00
|
|
|
case Button.UP:
|
2023-12-20 04:51:48 +00:00
|
|
|
if (row)
|
|
|
|
success = this.setCursor(this.cursor - 9);
|
2023-04-13 00:09:15 +01:00
|
|
|
break;
|
|
|
|
case Button.DOWN:
|
2023-12-20 04:51:48 +00:00
|
|
|
if (row < rows - 2 || (row < rows - 1 && this.cursor % 9 <= (genStarters - 1) % 9))
|
|
|
|
success = this.setCursor(this.cursor + 9);
|
|
|
|
break;
|
|
|
|
case Button.LEFT:
|
|
|
|
if (this.cursor % 9)
|
|
|
|
success = this.setCursor(this.cursor - 1);
|
2023-12-01 22:23:26 +00:00
|
|
|
else {
|
2023-12-20 04:51:48 +00:00
|
|
|
if (row >= Math.min(5, rows - 1))
|
|
|
|
this.startCursorObj.setVisible(true);
|
|
|
|
success = this.setGenMode(true);
|
2023-12-01 22:23:26 +00:00
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
break;
|
|
|
|
case Button.RIGHT:
|
2023-12-20 04:51:48 +00:00
|
|
|
if (this.cursor % 9 < (row < rows - 1 ? 8 : (genStarters - 1) % 9))
|
|
|
|
success = this.setCursor(this.cursor + 1);
|
2023-04-13 00:09:15 +01:00
|
|
|
break;
|
|
|
|
}
|
2023-04-10 00:15:21 +01:00
|
|
|
}
|
2023-04-18 03:44:41 +01:00
|
|
|
}
|
2023-04-10 00:15:21 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (success)
|
|
|
|
ui.playSelect();
|
|
|
|
else if (error)
|
|
|
|
ui.playError();
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
return success || error;
|
|
|
|
}
|
2023-04-10 00:15:21 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
updateInstructions(): void {
|
2024-01-06 03:24:05 +00:00
|
|
|
let instructionLines = [ ];
|
2023-12-20 04:51:48 +00:00
|
|
|
let cycleInstructionLines = [];
|
|
|
|
if (this.speciesStarterDexEntry?.caughtAttr) {
|
|
|
|
if (this.canCycleShiny)
|
|
|
|
cycleInstructionLines.push('R: Cycle Shiny');
|
|
|
|
if (this.canCycleForm)
|
|
|
|
cycleInstructionLines.push('F: Cycle Form');
|
|
|
|
if (this.canCycleGender)
|
|
|
|
cycleInstructionLines.push('G: Cycle Gender');
|
|
|
|
if (this.canCycleAbility)
|
|
|
|
cycleInstructionLines.push('E: Cycle Ability');
|
2024-01-06 03:24:05 +00:00
|
|
|
if (this.canCycleNature)
|
|
|
|
cycleInstructionLines.push('N: Cycle Nature');
|
2023-04-10 00:15:21 +01:00
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (cycleInstructionLines.length > 2) {
|
|
|
|
cycleInstructionLines[0] += ' | ' + cycleInstructionLines.splice(1, 1);
|
|
|
|
if (cycleInstructionLines.length > 2)
|
|
|
|
cycleInstructionLines[1] += ' | ' + cycleInstructionLines.splice(2, 1);
|
2023-12-08 21:29:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
for (let cil of cycleInstructionLines)
|
|
|
|
instructionLines.push(cil);
|
2023-12-08 21:29:03 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.instructionsText.setText(instructionLines.join('\n'));
|
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
setCursor(cursor: integer): boolean {
|
|
|
|
let changed = false;
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (this.genMode) {
|
|
|
|
changed = this.genCursor !== cursor;
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
let genCursorWithScroll = this.getGenCursorWithScroll();
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (!cursor && this.genScrollCursor) {
|
|
|
|
this.genScrollCursor--;
|
|
|
|
cursor++;
|
|
|
|
this.updateGenOptions();
|
2024-01-01 15:14:49 +00:00
|
|
|
} else if (cursor === 2 && this.genScrollCursor < gens.length - 3) {
|
2023-12-20 04:51:48 +00:00
|
|
|
this.genScrollCursor++;
|
|
|
|
cursor--;
|
|
|
|
this.updateGenOptions();
|
2023-11-14 03:29:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (genCursorWithScroll !== undefined)
|
|
|
|
this.starterSelectGenIconContainers[genCursorWithScroll].setVisible(false);
|
|
|
|
this.cursor = 0;
|
|
|
|
this.genCursor = cursor;
|
|
|
|
genCursorWithScroll = this.getGenCursorWithScroll();
|
|
|
|
this.genCursorObj.setY(5 + 17 * this.genCursor);
|
|
|
|
this.genCursorHighlightObj.setY(this.genCursorObj.y);
|
|
|
|
this.starterSelectGenIconContainers[genCursorWithScroll].setVisible(true);
|
|
|
|
|
|
|
|
for (let s = 0; s < this.starterCursorObjs.length; s++)
|
|
|
|
this.starterCursorObjs[s].setVisible(this.starterGens[s] === genCursorWithScroll);
|
|
|
|
for (let s = 0; s < this.pokerusCursorObjs.length; s++)
|
|
|
|
this.pokerusCursorObjs[s].setVisible(this.pokerusGens[s] === genCursorWithScroll);
|
|
|
|
|
|
|
|
const genLimit = this.genSpecies[genCursorWithScroll].length;
|
|
|
|
for (let s = 0; s < 81; s++) {
|
2024-02-12 21:38:46 +00:00
|
|
|
const speciesId = s < genLimit ? this.genSpecies[genCursorWithScroll][s].speciesId : 0 as Species;
|
|
|
|
const slotVisible = speciesId && !!(this.scene.gameData.dexData[speciesId].caughtAttr);
|
|
|
|
if (slotVisible) {
|
|
|
|
const baseStarterValue = speciesStarters[speciesId];
|
|
|
|
const starterValue = slotVisible ? this.scene.gameData.getSpeciesStarterValue(speciesId) : 0;
|
|
|
|
let valueStr = starterValue.toString();
|
|
|
|
if (valueStr.startsWith('0.'))
|
|
|
|
valueStr = valueStr.slice(1);
|
|
|
|
this.starterValueLabels[s].setText(valueStr);
|
|
|
|
let textStyle: TextStyle;
|
|
|
|
switch (baseStarterValue - starterValue) {
|
|
|
|
case 0:
|
|
|
|
textStyle = TextStyle.WINDOW;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 0.5:
|
|
|
|
textStyle = TextStyle.SUMMARY_BLUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
textStyle = TextStyle.SUMMARY_GOLD;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
this.starterValueLabels[s].setColor(getTextColor(textStyle));
|
|
|
|
this.starterValueLabels[s].setShadowColor(getTextColor(textStyle, true));
|
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterValueLabels[s].setVisible(slotVisible);
|
2024-02-12 21:38:46 +00:00
|
|
|
this.shinyIcons[s].setVisible(slotVisible && !!(this.scene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY));
|
2023-04-13 00:09:15 +01:00
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
} else {
|
|
|
|
changed = super.setCursor(cursor);
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.cursorObj.setPosition(148 + 18 * (cursor % 9), 10 + 18 * Math.floor(cursor / 9));
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.setSpecies(this.genSpecies[this.getGenCursorWithScroll()][cursor]);
|
2023-04-18 03:44:41 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.updateInstructions();
|
2023-04-18 03:44:41 +01:00
|
|
|
}
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
getGenCursorWithScroll(): integer {
|
|
|
|
return this.genCursor !== undefined
|
|
|
|
? this.genCursor + this.genScrollCursor
|
|
|
|
: undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateGenOptions(): void {
|
|
|
|
let text = '';
|
2024-01-01 15:14:49 +00:00
|
|
|
for (let g = this.genScrollCursor; g <= this.genScrollCursor + 2; g++) {
|
2023-12-20 04:51:48 +00:00
|
|
|
let optionText = gens[g];
|
|
|
|
if (g === this.genScrollCursor && this.genScrollCursor)
|
|
|
|
optionText = '↑';
|
2024-01-01 15:14:49 +00:00
|
|
|
else if (g === this.genScrollCursor + 2 && this.genScrollCursor < gens.length - 3)
|
2023-12-20 04:51:48 +00:00
|
|
|
optionText = '↓'
|
|
|
|
text += `${text ? '\n' : ''}${optionText}`;
|
|
|
|
}
|
|
|
|
this.genOptionsText.setText(text);
|
|
|
|
}
|
2023-11-13 04:47:04 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
setGenMode(genMode: boolean): boolean {
|
|
|
|
this.genCursorObj.setVisible(genMode && !this.startCursorObj.visible);
|
|
|
|
this.cursorObj.setVisible(!genMode && !this.startCursorObj.visible);
|
|
|
|
|
|
|
|
if (genMode !== this.genMode) {
|
|
|
|
this.genMode = genMode;
|
2023-04-18 03:44:41 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.setCursor(genMode ? this.genCursor : this.cursor);
|
|
|
|
if (genMode)
|
|
|
|
this.setSpecies(null);
|
2023-04-18 03:44:41 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
2023-04-18 06:32:26 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
setSpecies(species: PokemonSpecies) {
|
|
|
|
this.speciesStarterDexEntry = species ? this.scene.gameData.dexData[species.speciesId] : null;
|
|
|
|
this.dexAttrCursor = species ? this.scene.gameData.getSpeciesDefaultDexAttr(species) : 0n;
|
2024-01-06 03:24:05 +00:00
|
|
|
this.natureCursor = species ? this.scene.gameData.getSpeciesDefaultNature(species) : 0;
|
2023-04-18 03:44:41 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (this.statsMode) {
|
|
|
|
if (this.speciesStarterDexEntry?.caughtAttr) {
|
|
|
|
this.statsContainer.setVisible(true);
|
|
|
|
this.showStats();
|
|
|
|
} else {
|
|
|
|
this.statsContainer.setVisible(false);
|
|
|
|
this.statsContainer.updateIvs(null);
|
|
|
|
}
|
|
|
|
}
|
2023-04-18 03:44:41 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (this.lastSpecies) {
|
|
|
|
const dexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(this.lastSpecies);
|
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr);
|
|
|
|
const lastSpeciesIcon = (this.starterSelectGenIconContainers[this.lastSpecies.generation - 1].getAt(this.genSpecies[this.lastSpecies.generation - 1].indexOf(this.lastSpecies)) as Phaser.GameObjects.Sprite);
|
|
|
|
lastSpeciesIcon.setFrame(this.lastSpecies.getIconId(props.female, props.formIndex, props.shiny));
|
|
|
|
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
|
|
|
}
|
2023-04-18 06:32:26 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.lastSpecies = species;
|
2023-04-26 17:50:21 +01:00
|
|
|
|
2024-02-19 03:21:57 +00:00
|
|
|
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr)) {
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4));
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonNameText.setText(species.name);
|
2024-01-06 03:24:05 +00:00
|
|
|
|
2024-02-19 03:21:57 +00:00
|
|
|
if (this.speciesStarterDexEntry?.caughtAttr) {
|
|
|
|
this.pokemonGrowthRateText.setText(Utils.toReadableString(GrowthRate[species.growthRate]));
|
|
|
|
this.pokemonGrowthRateText.setColor(getGrowthRateColor(species.growthRate));
|
|
|
|
this.pokemonGrowthRateText.setShadowColor(getGrowthRateColor(species.growthRate, true));
|
|
|
|
this.pokemonGrowthRateLabelText.setVisible(true);
|
|
|
|
this.pokemonUncaughtText.setVisible(false);
|
|
|
|
this.pokemonAbilityLabelText.setVisible(true);
|
|
|
|
this.pokemonNatureLabelText.setVisible(true);
|
|
|
|
this.pokemonCaughtCountLabelText.setVisible(true);
|
|
|
|
this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry.caughtCount}/${this.speciesStarterDexEntry.hatchedCount} (${this.speciesStarterDexEntry.caughtCount + this.speciesStarterDexEntry.hatchedCount})`);
|
|
|
|
this.pokemonCaughtCountText.setVisible(true);
|
|
|
|
this.iconAnimHandler.addOrUpdate(this.starterSelectGenIconContainers[species.generation - 1].getAt(this.genSpecies[species.generation - 1].indexOf(species)) as Phaser.GameObjects.Sprite, PokemonIconAnimMode.PASSIVE);
|
|
|
|
|
|
|
|
let starterIndex = -1;
|
|
|
|
|
|
|
|
this.starterGens.every((g, i) => {
|
|
|
|
const starterSpecies = this.genSpecies[g][this.starterCursors[i]];
|
|
|
|
if (starterSpecies.speciesId === species.speciesId) {
|
|
|
|
starterIndex = i;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (starterIndex > -1) {
|
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.starterAttr[starterIndex]);
|
|
|
|
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, this.starterNatures[starterIndex]);
|
|
|
|
} else {
|
|
|
|
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
|
|
|
|
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
|
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
|
|
|
|
|
|
|
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, defaultNature);
|
|
|
|
}
|
|
|
|
this.pokemonSprite.clearTint();
|
2024-01-06 03:24:05 +00:00
|
|
|
} else {
|
2024-02-19 03:21:57 +00:00
|
|
|
this.pokemonGrowthRateText.setText('');
|
|
|
|
this.pokemonGrowthRateLabelText.setVisible(false);
|
|
|
|
this.pokemonUncaughtText.setVisible(true);
|
|
|
|
this.pokemonAbilityLabelText.setVisible(false);
|
|
|
|
this.pokemonNatureLabelText.setVisible(false);
|
|
|
|
this.pokemonCaughtCountLabelText.setVisible(false);
|
|
|
|
this.pokemonCaughtCountText.setVisible(false);
|
|
|
|
|
|
|
|
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species, true);
|
2024-01-06 03:24:05 +00:00
|
|
|
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
|
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
|
|
|
|
2024-02-19 03:21:57 +00:00
|
|
|
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.abilityIndex, defaultNature, true);
|
|
|
|
this.pokemonSprite.setTint(0x808080);
|
2024-01-06 03:24:05 +00:00
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
} else {
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonNumberText.setText(Utils.padInt(0, 4));
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonNameText.setText(species ? '???' : '');
|
|
|
|
this.pokemonGrowthRateText.setText('');
|
|
|
|
this.pokemonGrowthRateLabelText.setVisible(false);
|
2024-02-19 03:21:57 +00:00
|
|
|
this.pokemonUncaughtText.setVisible(!!species);
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonAbilityLabelText.setVisible(false);
|
2024-01-06 03:24:05 +00:00
|
|
|
this.pokemonNatureLabelText.setVisible(false);
|
2024-02-12 21:38:46 +00:00
|
|
|
this.pokemonCaughtCountLabelText.setVisible(false);
|
|
|
|
this.pokemonCaughtCountText.setVisible(false);
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2024-01-06 03:24:05 +00:00
|
|
|
this.setSpeciesDetails(species, false, 0, false, 0, 0);
|
2024-02-19 03:21:57 +00:00
|
|
|
this.pokemonSprite.clearTint();
|
2023-04-13 00:09:15 +01:00
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2023-04-13 00:09:15 +01:00
|
|
|
|
2024-02-19 03:21:57 +00:00
|
|
|
setSpeciesDetails(species: PokemonSpecies, shiny: boolean, formIndex: integer, female: boolean, abilityIndex: integer, natureIndex: integer, forSeen: boolean = false): void {
|
2023-12-20 04:51:48 +00:00
|
|
|
const oldProps = species ? this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor) : null;
|
|
|
|
this.dexAttrCursor = 0n;
|
|
|
|
|
|
|
|
if (species) {
|
|
|
|
this.dexAttrCursor |= (shiny !== undefined ? !shiny : !(shiny = oldProps.shiny)) ? DexAttr.NON_SHINY : DexAttr.SHINY;
|
|
|
|
this.dexAttrCursor |= (female !== undefined ? !female : !(female = oldProps.female)) ? DexAttr.MALE : DexAttr.FEMALE;
|
|
|
|
this.dexAttrCursor |= (abilityIndex !== undefined ? !abilityIndex : !(abilityIndex = oldProps.abilityIndex)) ? DexAttr.ABILITY_1 : species.ability2 && abilityIndex === 1 ? DexAttr.ABILITY_2 : DexAttr.ABILITY_HIDDEN;
|
|
|
|
this.dexAttrCursor |= this.scene.gameData.getFormAttr(formIndex !== undefined ? formIndex : (formIndex = oldProps.formIndex));
|
2024-01-06 03:24:05 +00:00
|
|
|
if (natureIndex === undefined)
|
|
|
|
natureIndex = this.scene.gameData.getSpeciesDefaultNature(species);
|
2023-12-01 22:23:26 +00:00
|
|
|
}
|
|
|
|
|
2024-01-06 03:24:05 +00:00
|
|
|
this.natureCursor = natureIndex;
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonSprite.setVisible(false);
|
|
|
|
|
|
|
|
if (this.assetLoadCancelled) {
|
|
|
|
this.assetLoadCancelled.value = true;
|
|
|
|
this.assetLoadCancelled = null;
|
2023-12-01 22:23:26 +00:00
|
|
|
}
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (species) {
|
|
|
|
const dexEntry = this.scene.gameData.dexData[species.speciesId];
|
|
|
|
if (!dexEntry.caughtAttr) {
|
2024-02-19 03:21:57 +00:00
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.scene.gameData.getSpeciesDefaultDexAttr(species, forSeen));
|
2024-01-06 03:24:05 +00:00
|
|
|
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
|
2023-12-20 04:51:48 +00:00
|
|
|
if (shiny === undefined || shiny !== props.shiny)
|
|
|
|
shiny = props.shiny;
|
|
|
|
if (formIndex === undefined || formIndex !== props.formIndex)
|
|
|
|
formIndex = props.formIndex;
|
|
|
|
if (female === undefined || female !== props.female)
|
|
|
|
female = props.female;
|
|
|
|
if (abilityIndex === undefined || abilityIndex !== props.abilityIndex)
|
|
|
|
abilityIndex = props.abilityIndex;
|
2024-01-06 03:24:05 +00:00
|
|
|
if (natureIndex === undefined || natureIndex !== defaultNature)
|
|
|
|
natureIndex = defaultNature;
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2023-12-01 22:23:26 +00:00
|
|
|
|
2024-02-19 03:21:57 +00:00
|
|
|
if (forSeen ? this.speciesStarterDexEntry?.seenAttr : this.speciesStarterDexEntry?.caughtAttr) {
|
2024-01-06 03:24:05 +00:00
|
|
|
let starterIndex = -1;
|
|
|
|
|
|
|
|
this.starterGens.every((g, i) => {
|
|
|
|
const starterSpecies = this.genSpecies[g][this.starterCursors[i]];
|
|
|
|
if (starterSpecies.speciesId === species.speciesId) {
|
|
|
|
starterIndex = i;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (starterIndex > -1) {
|
|
|
|
this.starterAttr[starterIndex] = this.dexAttrCursor;
|
|
|
|
this.starterNatures[starterIndex] = this.natureCursor;
|
|
|
|
}
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
const assetLoadCancelled = new Utils.BooleanHolder(false);
|
|
|
|
this.assetLoadCancelled = assetLoadCancelled;
|
|
|
|
|
|
|
|
species.loadAssets(this.scene, female, formIndex, shiny, true).then(() => {
|
|
|
|
if (assetLoadCancelled.value)
|
|
|
|
return;
|
|
|
|
this.assetLoadCancelled = null;
|
|
|
|
this.speciesLoaded.set(species.speciesId, true);
|
|
|
|
this.pokemonSprite.play(species.getSpriteKey(female, formIndex, shiny));
|
|
|
|
this.pokemonSprite.setVisible(!this.statsMode);
|
|
|
|
});
|
|
|
|
|
|
|
|
(this.starterSelectGenIconContainers[this.getGenCursorWithScroll()].getAt(this.cursor) as Phaser.GameObjects.Sprite).setFrame(species.getIconId(female, formIndex, shiny));
|
|
|
|
|
|
|
|
this.canCycleShiny = !!(dexEntry.caughtAttr & DexAttr.NON_SHINY && dexEntry.caughtAttr & DexAttr.SHINY);
|
|
|
|
this.canCycleGender = !!(dexEntry.caughtAttr & DexAttr.MALE && dexEntry.caughtAttr & DexAttr.FEMALE);
|
|
|
|
this.canCycleAbility = [ dexEntry.caughtAttr & DexAttr.ABILITY_1, dexEntry.caughtAttr & DexAttr.ABILITY_2, dexEntry.caughtAttr & DexAttr.ABILITY_HIDDEN ].filter(a => a).length > 1;
|
2024-01-13 05:41:07 +00:00
|
|
|
this.canCycleForm = species.forms.filter(f => !f.formKey || !pokemonFormChanges[species.speciesId]?.find(fc => fc.formKey))
|
2023-12-20 04:51:48 +00:00
|
|
|
.map((_, f) => dexEntry.caughtAttr & this.scene.gameData.getFormAttr(f)).filter(a => a).length > 1;
|
2024-01-06 03:24:05 +00:00
|
|
|
this.canCycleNature = this.scene.gameData.getNaturesForAttr(dexEntry.natureAttr).length > 1;
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2023-12-01 22:23:26 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (dexEntry.caughtAttr && species.malePercent !== null) {
|
|
|
|
const gender = !female ? Gender.MALE : Gender.FEMALE;
|
|
|
|
this.pokemonGenderText.setText(getGenderSymbol(gender));
|
|
|
|
this.pokemonGenderText.setColor(getGenderColor(gender));
|
|
|
|
this.pokemonGenderText.setShadowColor(getGenderColor(gender, true));
|
|
|
|
} else
|
|
|
|
this.pokemonGenderText.setText('');
|
2023-12-01 22:23:26 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
if (dexEntry.caughtAttr) {
|
|
|
|
const ability = this.lastSpecies.getAbility(abilityIndex);
|
|
|
|
this.pokemonAbilityText.setText(allAbilities[ability].name);
|
2023-12-01 22:23:26 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
const isHidden = ability === this.lastSpecies.abilityHidden;
|
|
|
|
this.pokemonAbilityText.setColor(getTextColor(!isHidden ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD));
|
|
|
|
this.pokemonAbilityText.setShadowColor(getTextColor(!isHidden ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true));
|
2024-01-06 03:24:05 +00:00
|
|
|
|
|
|
|
this.pokemonNatureText.setText(getNatureName(natureIndex as unknown as Nature, true, true));
|
|
|
|
} else {
|
2023-12-20 04:51:48 +00:00
|
|
|
this.pokemonAbilityText.setText('');
|
2024-01-06 03:24:05 +00:00
|
|
|
this.pokemonNatureText.setText('');
|
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
} else {
|
|
|
|
this.pokemonGenderText.setText('');
|
|
|
|
this.pokemonAbilityText.setText('');
|
2024-01-06 03:24:05 +00:00
|
|
|
this.pokemonNatureText.setText('');
|
2023-04-13 00:09:15 +01:00
|
|
|
}
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.updateInstructions();
|
|
|
|
}
|
|
|
|
|
|
|
|
popStarter(): void {
|
|
|
|
this.starterGens.pop();
|
|
|
|
this.starterCursors.pop();
|
|
|
|
this.starterAttr.pop();
|
2024-01-06 03:24:05 +00:00
|
|
|
this.starterNatures.pop();
|
2023-12-20 04:51:48 +00:00
|
|
|
this.starterCursorObjs[this.starterCursors.length].setVisible(false);
|
|
|
|
this.starterIcons[this.starterCursors.length].setTexture('pokemon_icons_0');
|
|
|
|
this.starterIcons[this.starterCursors.length].setFrame('unknown');
|
|
|
|
this.tryUpdateValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
tryUpdateValue(add?: integer): boolean {
|
2024-02-12 21:38:46 +00:00
|
|
|
const value = this.starterGens.reduce((total: integer, gen: integer, i: integer) => total += this.scene.gameData.getSpeciesStarterValue(this.genSpecies[gen][this.starterCursors[i]].speciesId), 0);
|
2023-12-20 04:51:48 +00:00
|
|
|
const newValue = value + (add || 0);
|
|
|
|
const overLimit = newValue > 10;
|
2024-02-12 21:38:46 +00:00
|
|
|
let newValueStr = newValue.toString();
|
|
|
|
if (newValueStr.startsWith('0.'))
|
|
|
|
newValueStr = newValueStr.slice(1);
|
|
|
|
this.valueLimitLabel.setText(`${newValueStr}/10`);
|
2024-01-05 16:29:34 +00:00
|
|
|
this.valueLimitLabel.setColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK));
|
|
|
|
this.valueLimitLabel.setShadowColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK, true));
|
2023-12-20 04:51:48 +00:00
|
|
|
if (overLimit) {
|
|
|
|
this.scene.time.delayedCall(Utils.fixedInt(500), () => this.tryUpdateValue());
|
|
|
|
return false;
|
2023-11-14 03:29:03 +00:00
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
this.value = newValue;
|
|
|
|
return true;
|
|
|
|
}
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2024-01-01 16:17:20 +00:00
|
|
|
tryStart(manualTrigger: boolean = false): boolean {
|
2023-12-20 04:51:48 +00:00
|
|
|
if (!this.starterGens.length)
|
|
|
|
return false;
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
const ui = this.getUi();
|
|
|
|
|
|
|
|
const cancel = () => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-01-01 16:17:20 +00:00
|
|
|
if (!manualTrigger)
|
|
|
|
this.popStarter();
|
2023-12-20 04:51:48 +00:00
|
|
|
this.clearText();
|
|
|
|
};
|
|
|
|
|
|
|
|
ui.showText('Begin with these Pokémon?', null, () => {
|
|
|
|
ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
|
|
|
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(this.starterGens.length).fill(0).map(function (_, i) {
|
|
|
|
const starterSpecies = thisObj.genSpecies[thisObj.starterGens[i]][thisObj.starterCursors[i]];
|
|
|
|
return {
|
|
|
|
species: starterSpecies,
|
|
|
|
dexAttr: thisObj.starterAttr[i],
|
2024-01-06 03:24:05 +00:00
|
|
|
nature: thisObj.starterNatures[i] as Nature,
|
2023-12-20 04:51:48 +00:00
|
|
|
pokerus: !![ 0, 1, 2 ].filter(n => thisObj.pokerusGens[n] === starterSpecies.generation - 1 && thisObj.pokerusCursors[n] === thisObj.genSpecies[starterSpecies.generation - 1].indexOf(starterSpecies)).length
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-02-07 04:11:00 +00:00
|
|
|
const options = [
|
|
|
|
{
|
|
|
|
label: gameModeNames[GameMode.CLASSIC],
|
|
|
|
handler: () => startRun(GameMode.CLASSIC)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: gameModeNames[GameMode.ENDLESS],
|
|
|
|
handler: () => startRun(GameMode.ENDLESS)
|
|
|
|
}
|
|
|
|
];
|
|
|
|
if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) {
|
|
|
|
options.push({
|
|
|
|
label: gameModeNames[GameMode.SPLICED_ENDLESS],
|
|
|
|
handler: () => startRun(GameMode.SPLICED_ENDLESS)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
options.push({
|
|
|
|
label: 'Cancel',
|
|
|
|
handler: () => cancel()
|
|
|
|
});
|
|
|
|
ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, yOffset: 19 }));
|
2023-12-20 04:51:48 +00:00
|
|
|
} else
|
|
|
|
startRun(GameMode.CLASSIC);
|
2024-02-07 04:11:00 +00:00
|
|
|
}, cancel, null, null, 19);
|
2023-12-20 04:51:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleStatsMode(on?: boolean): void {
|
|
|
|
if (on === undefined)
|
|
|
|
on = !this.statsMode;
|
|
|
|
if (on) {
|
|
|
|
this.showStats();
|
|
|
|
this.statsMode = true;
|
|
|
|
this.pokemonSprite.setVisible(false);
|
|
|
|
} else {
|
|
|
|
this.statsMode = false;
|
|
|
|
this.statsContainer.setVisible(false);
|
|
|
|
this.pokemonSprite.setVisible(!!this.speciesStarterDexEntry?.caughtAttr);
|
|
|
|
this.statsContainer.updateIvs(null);
|
2023-04-13 00:09:15 +01:00
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
2023-04-10 00:15:21 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
showStats(): void {
|
|
|
|
if (!this.speciesStarterDexEntry)
|
|
|
|
return;
|
2023-04-22 03:59:09 +01:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.statsContainer.setVisible(true);
|
2023-11-14 03:29:03 +00:00
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
this.statsContainer.updateIvs(this.speciesStarterDexEntry.ivs);
|
|
|
|
}
|
|
|
|
|
|
|
|
clearText() {
|
|
|
|
this.starterSelectMessageBoxContainer.setVisible(false);
|
|
|
|
super.clearText();
|
|
|
|
}
|
|
|
|
|
|
|
|
clear(): void {
|
|
|
|
super.clear();
|
|
|
|
this.cursor = -1;
|
|
|
|
this.starterSelectContainer.setVisible(false);
|
|
|
|
|
|
|
|
while (this.starterCursors.length)
|
|
|
|
this.popStarter();
|
|
|
|
|
|
|
|
if (this.statsMode)
|
|
|
|
this.toggleStatsMode(false);
|
|
|
|
}
|
|
|
|
}
|