2024-06-11 09:19:07 +08:00
|
|
|
import { BattleSceneEventType, CandyUpgradeNotificationChangedEvent } from "../events/battle-scene";
|
2024-05-13 20:02:44 -03:00
|
|
|
import { pokemonPrevolutions } from "#app/data/pokemon-evolutions";
|
|
|
|
import { Variant, getVariantTint } from "#app/data/variant";
|
|
|
|
import { argbFromRgba } from "@material/material-color-utilities";
|
|
|
|
import i18next from "i18next";
|
|
|
|
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
2024-05-05 16:30:00 +02:00
|
|
|
import BattleScene, { starterColors } from "../battle-scene";
|
2023-12-05 17:12:39 -05:00
|
|
|
import { allAbilities } from "../data/ability";
|
2024-05-13 20:02:44 -03:00
|
|
|
import { speciesEggMoves } from "../data/egg-moves";
|
2023-10-24 23:04:23 -04:00
|
|
|
import { GrowthRate, getGrowthRateColor } from "../data/exp";
|
2024-05-13 20:02:44 -03:00
|
|
|
import { Gender, getGenderColor, getGenderSymbol } from "../data/gender";
|
|
|
|
import { allMoves } from "../data/move";
|
2024-01-05 22:24:05 -05:00
|
|
|
import { Nature, getNatureName } from "../data/nature";
|
2024-01-12 20:16:29 -05:00
|
|
|
import { pokemonFormChanges } from "../data/pokemon-forms";
|
2024-02-21 01:03:34 -05:00
|
|
|
import { LevelMoves, pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "../data/pokemon-level-moves";
|
2024-05-13 20:02:44 -03:00
|
|
|
import PokemonSpecies, { allSpecies, getPokemonSpecies, getPokemonSpeciesForm, getStarterValueFriendshipCap, speciesStarters, starterPassiveAbilities } from "../data/pokemon-species";
|
2024-02-20 22:53:33 -05:00
|
|
|
import { Type } from "../data/type";
|
2024-06-08 15:07:23 +10:00
|
|
|
import { GameModes } from "../game-mode";
|
|
|
|
import { SelectChallengePhase, TitlePhase } from "../phases";
|
2024-06-17 06:49:29 +02:00
|
|
|
import { AbilityAttr, DexAttr, DexAttrProps, DexEntry, StarterFormMoveData, StarterMoveset, StarterAttributes, StarterPreferences, StarterPrefs } from "../system/game-data";
|
2024-05-13 20:02:44 -03:00
|
|
|
import { Tutorial, handleTutorial } from "../tutorial";
|
|
|
|
import * as Utils from "../utils";
|
2024-04-13 18:59:58 -04:00
|
|
|
import { OptionSelectItem } from "./abstact-option-select-ui-handler";
|
2024-05-13 20:02:44 -03:00
|
|
|
import MessageUiHandler from "./message-ui-handler";
|
|
|
|
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
|
|
|
|
import { StatsContainer } from "./stats-container";
|
|
|
|
import { TextStyle, addBBCodeTextObject, addTextObject } from "./text";
|
|
|
|
import { Mode } from "./ui";
|
|
|
|
import { addWindow } from "./ui-theme";
|
2024-06-22 02:19:56 +02:00
|
|
|
import { Egg } from "#app/data/egg";
|
|
|
|
import * as Overrides from "../overrides";
|
2024-06-08 21:35:11 -04:00
|
|
|
import {SettingKeyboard} from "#app/system/settings/settings-keyboard";
|
2024-06-13 18:44:23 -04:00
|
|
|
import {Passive as PassiveAttr} from "#enums/passive";
|
2024-06-08 15:07:23 +10:00
|
|
|
import * as Challenge from "../data/challenge";
|
2024-06-06 03:28:12 +02:00
|
|
|
import MoveInfoOverlay from "./move-info-overlay";
|
2024-06-09 10:45:21 -06:00
|
|
|
import { getEggTierForSpecies } from "#app/data/egg.js";
|
2024-06-13 18:44:23 -04:00
|
|
|
import { Device } from "#enums/devices";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import {Button} from "#enums/buttons";
|
2024-06-22 02:19:56 +02:00
|
|
|
import { EggSourceType } from "#app/enums/egg-source-types.js";
|
2023-04-09 19:15:21 -04:00
|
|
|
|
2023-04-17 22:44:41 -04:00
|
|
|
export type StarterSelectCallback = (starters: Starter[]) => void;
|
|
|
|
|
|
|
|
export interface Starter {
|
|
|
|
species: PokemonSpecies;
|
2023-11-12 23:47:04 -05:00
|
|
|
dexAttr: bigint;
|
2024-04-18 22:52:26 -04:00
|
|
|
abilityIndex: integer,
|
2024-04-13 18:59:58 -04:00
|
|
|
passive: boolean;
|
2024-01-05 22:24:05 -05:00
|
|
|
nature: Nature;
|
2024-03-15 21:59:34 -04:00
|
|
|
moveset?: StarterMoveset;
|
2023-10-25 14:15:44 -04:00
|
|
|
pokerus: boolean;
|
2023-04-17 22:44:41 -04:00
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-05-19 21:40:58 -04:00
|
|
|
interface LanguageSetting {
|
|
|
|
starterInfoTextSize: string,
|
|
|
|
instructionTextSize: string,
|
2024-05-19 23:11:07 -04:00
|
|
|
starterInfoXPos?: integer,
|
|
|
|
starterInfoYOffset?: integer
|
2024-05-19 21:40:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const languageSettings: { [key: string]: LanguageSetting } = {
|
|
|
|
"en":{
|
2024-05-23 17:03:10 +02:00
|
|
|
starterInfoTextSize: "56px",
|
2024-06-08 21:35:11 -04:00
|
|
|
instructionTextSize: "38px",
|
2024-05-19 21:40:58 -04:00
|
|
|
},
|
|
|
|
"de":{
|
2024-05-23 17:03:10 +02:00
|
|
|
starterInfoTextSize: "56px",
|
|
|
|
instructionTextSize: "35px",
|
2024-05-19 21:40:58 -04:00
|
|
|
},
|
|
|
|
"es":{
|
2024-05-23 17:03:10 +02:00
|
|
|
starterInfoTextSize: "56px",
|
|
|
|
instructionTextSize: "35px",
|
2024-05-19 21:40:58 -04:00
|
|
|
},
|
2024-06-01 20:53:13 -03:00
|
|
|
"fr":{
|
|
|
|
starterInfoTextSize: "54px",
|
|
|
|
instructionTextSize: "42px",
|
|
|
|
},
|
2024-05-19 21:40:58 -04:00
|
|
|
"it":{
|
2024-05-23 17:03:10 +02:00
|
|
|
starterInfoTextSize: "56px",
|
|
|
|
instructionTextSize: "38px",
|
2024-05-19 21:40:58 -04:00
|
|
|
},
|
2024-06-01 20:53:13 -03:00
|
|
|
"pt_BR":{
|
|
|
|
starterInfoTextSize: "47px",
|
|
|
|
instructionTextSize: "38px",
|
|
|
|
starterInfoXPos: 33,
|
2024-05-19 21:40:58 -04:00
|
|
|
},
|
2024-05-21 00:25:55 -04:00
|
|
|
"zh":{
|
2024-05-23 17:03:10 +02:00
|
|
|
starterInfoTextSize: "40px",
|
|
|
|
instructionTextSize: "42px",
|
2024-05-19 23:11:07 -04:00
|
|
|
starterInfoYOffset: 2
|
2024-05-19 21:40:58 -04:00
|
|
|
},
|
2024-05-21 00:25:55 -04:00
|
|
|
"pt":{
|
2024-05-28 11:00:27 -03:00
|
|
|
starterInfoTextSize: "48px",
|
|
|
|
instructionTextSize: "42px",
|
|
|
|
starterInfoXPos: 33,
|
2024-05-19 21:40:58 -04:00
|
|
|
},
|
Add Korean Locale (#737)
* Add korean locale without translation
* Translate ability,move,pokemon to Korean
* Translate miscellaneous to Korean
* Add Accuracy in the fight ui to Korean
* Apply nature,growth rate lang files to Korean
* Add missed file import to Korean config.ts
* Add font and its license for Korean then Apply it
pokemon-dppt from FontStruction and its license
* Translate any other lang file to Korean
* Cleanup Korean locale files
Indentation for pokemon and starter-select-ui-handler
Make config shoft
* Update Korean translation for the latest commits
ToggleSize dependency e4d3f73d,
+ Align togglesize locale text
Frisk description 6d73500a
Starter select UI 34a4f869, 74ee3329
Add ability triggers locale file 1c56efc8
Zippy Zap description 4e279224
* Implement locale font loading
Revert multiple font usage from style fe7fe845
Dynamic font loading on language changed
* Translate new localization parts to Korean
Return to title become save and quit
menu-ui-handler.ts ac2e7812
Generation text added
starter-select-ui-handler.ts afcffab9
Missing translations for learning move
battles.ts:countdownPoof, learnMoveAnd 44c0d29c
Weather & evolution texts translated
config.ts, weather.ts, menu.ts b8dff030
Added modifier type file for item translate
config.ts, modifier-type.ts b5ae8330, b82b8c31
Egg gatcha machine is now Korean
config.ts, egg.ts 975d1ed5
Add splash message literals to locales
config.ts, splash-messages.ts 8dce9fa2
Trainers are also localized
config.ts, trainers.ts b06190c4, 7f003d46, 364b19df
Double battle trainers appeared
battle.ts:trainerAppearedDouble f1e97f3b
* Small patches to Korean translations
Include generation consistency (learnMovePrompt, eggHatching),
wrong space (learnMoveReplaceQuestion),
missing word (learnMoveNotLearned),
match to modifier-type.ts (ivScannerUseQuestion),
and match to english and else (bossAppeared)
* Apply edits to Korean translation
Re-order config.ts 3f571a36
Fix splash message attribute to fixed config 429e6635
* Corrections and new text for Korean translations
Trainer misstypo correction 0cd305d7
trainer.ts
BerryType localization 25014208
config.ts, berry.ts
IV scanner updated 96af567c
config.ts, battle-message-ui-handler.ts
Melt stat and type into info 3cc9c93
config.ts, modifier-type.ts pokemon-stat.ts -> pokemon-info.ts
* Update Korean locale up to date
Larry and Lance are now unique 93dee06e
Trainer names errors about 'poké' 49adedbc, 13f2cafe
Wrong text edit for maylene
trainers.ts
Egg voucher translation 7216990d
config.ts, voucher.ts
Cleanup starter select ui handler ca1ae4b5, b95a59c0
starter-select-ui-handler.ts
Correct text overflow
tutorial.ts
* Modify loadFont to fit in nonExplicitSupportedLngs
'ko-KR' or 'ko' is loaded browser by browser, in any case font will be loaded.
* Update Korean translations
* Apply updated text
Berry pouch 8b4aa872
modifier-type.ts
Acrobatics 0d614526
move.ts
failedToLoadSaveData 32fadf8c
menu.ts
HoneyGather caeb22c2
ability.ts
* Apply added Text
Plates and Memories f914b8fe
modifier-type.ts
trainerSendOut, moneyWon, partyFull 79af1152
battle.ts
gym_leader_double, champion_double, Double Names aaa95ebe
elite_four_female, champion_female ac2f7755
trainers.ts
* Apply new locale category implement
Biomes de1c2b2b
config.ts, biome.ts
Trainer dialogue ac2f7755, d23d8356
config.ts, dialogue.ts
Statistics 6d2b8ef2
config.ts, game-stats-ui-handler
Info Container fb26b6d5
config.ts, pokemon-info-container.ts
* Recover coding style
include 2-space-indentation
* Add Korean Font
No more license text file
* Add missing config to Korean
* Fix ESLint failure on Korean
* Fix ESLint failure on Korean 2
* Update to Main Localization Changes
---------
Co-authored-by: Benjamin Odom <bennybroseph@gmail.com>
2024-05-30 08:05:14 +09:00
|
|
|
"ko":{
|
|
|
|
starterInfoTextSize: "52px",
|
|
|
|
instructionTextSize: "38px",
|
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
};
|
2024-05-19 21:40:58 -04:00
|
|
|
|
2024-06-22 02:19:56 +02:00
|
|
|
const starterCandyCosts: { passive: integer, costReduction: [integer, integer], egg: integer }[] = [
|
|
|
|
{ passive: 50, costReduction: [30, 75], egg: 35 }, // 1
|
|
|
|
{ passive: 45, costReduction: [25, 60], egg: 35 }, // 2
|
|
|
|
{ passive: 40, costReduction: [20, 50], egg: 35 }, // 3
|
|
|
|
{ passive: 30, costReduction: [15, 40], egg: 30 }, // 4
|
|
|
|
{ passive: 25, costReduction: [12, 35], egg: 25 }, // 5
|
|
|
|
{ passive: 20, costReduction: [10, 30], egg: 20 }, // 6
|
|
|
|
{ passive: 15, costReduction: [8, 20], egg: 15 }, // 7
|
|
|
|
{ passive: 10, costReduction: [5, 15], egg: 10 }, // 8
|
|
|
|
{ passive: 10, costReduction: [3, 10], egg: 10 }, // 9
|
|
|
|
{ passive: 10, costReduction: [3, 10], egg: 10 }, // 10
|
2024-05-23 17:03:10 +02:00
|
|
|
];
|
2024-05-19 21:40:58 -04:00
|
|
|
|
2024-04-13 18:59:58 -04:00
|
|
|
function getPassiveCandyCount(baseValue: integer): integer {
|
2024-05-19 21:40:58 -04:00
|
|
|
return starterCandyCosts[baseValue - 1].passive;
|
2024-04-13 18:59:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function getValueReductionCandyCounts(baseValue: integer): [integer, integer] {
|
2024-05-19 21:40:58 -04:00
|
|
|
return starterCandyCosts[baseValue - 1].costReduction;
|
2024-04-13 18:59:58 -04:00
|
|
|
}
|
|
|
|
|
2024-06-22 02:19:56 +02:00
|
|
|
function getSameSpeciesEggCandyCounts(baseValue: integer): integer {
|
|
|
|
return starterCandyCosts[baseValue - 1].egg;
|
|
|
|
}
|
|
|
|
|
2024-05-28 14:49:15 -03:00
|
|
|
/**
|
|
|
|
* Calculates the icon position for a Pokemon of a given UI index
|
|
|
|
* @param index UI index to calculate the icon position of
|
|
|
|
* @returns An interface with an x and y property
|
|
|
|
*/
|
|
|
|
function calcIconPosition(index: number): {x: number, y: number} {
|
|
|
|
const x = (index % 9) * 18;
|
|
|
|
const y = Math.floor(index / 9) * 18;
|
|
|
|
|
|
|
|
return {x: x, y: y};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the {@linkcode Phaser.GameObjects.Sprite} position for a Pokemon of a given UI index
|
|
|
|
* @param index UI index to calculate the icon position of
|
|
|
|
* @returns An interface with an x and y property
|
|
|
|
*/
|
|
|
|
function calcSpritePosition(index: number): {x: number, y: number} {
|
|
|
|
const position = calcIconPosition(index);
|
|
|
|
|
|
|
|
return {x: position.x - 2, y: position.y + 2};
|
|
|
|
}
|
|
|
|
|
2024-05-15 17:57:48 +02:00
|
|
|
const gens = [
|
2024-05-23 17:03:10 +02:00
|
|
|
i18next.t("starterSelectUiHandler:gen1"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen2"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen3"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen4"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen5"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen6"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen7"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen8"),
|
|
|
|
i18next.t("starterSelectUiHandler:gen9")
|
2024-05-15 17:57:48 +02:00
|
|
|
];
|
2023-11-13 22:29:03 -05:00
|
|
|
|
2023-04-12 19:09:15 -04:00
|
|
|
export default class StarterSelectUiHandler extends MessageUiHandler {
|
2023-12-19 23:51:48 -05:00
|
|
|
private starterSelectContainer: Phaser.GameObjects.Container;
|
2024-03-25 13:40:54 -04:00
|
|
|
private shinyOverlay: Phaser.GameObjects.Image;
|
2023-12-19 23:51:48 -05:00
|
|
|
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;
|
2024-04-11 11:39:08 -04:00
|
|
|
private type1Icon: Phaser.GameObjects.Sprite;
|
|
|
|
private type2Icon: Phaser.GameObjects.Sprite;
|
2024-04-26 17:32:28 -04:00
|
|
|
private pokemonLuckLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonLuckText: Phaser.GameObjects.Text;
|
2023-12-19 23:51:48 -05:00
|
|
|
private pokemonGenderText: Phaser.GameObjects.Text;
|
2024-02-18 22:21:57 -05:00
|
|
|
private pokemonUncaughtText: Phaser.GameObjects.Text;
|
2023-12-19 23:51:48 -05:00
|
|
|
private pokemonAbilityLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonAbilityText: Phaser.GameObjects.Text;
|
2024-04-13 18:59:58 -04:00
|
|
|
private pokemonPassiveLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonPassiveText: Phaser.GameObjects.Text;
|
2024-01-05 22:24:05 -05:00
|
|
|
private pokemonNatureLabelText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonNatureText: BBCodeText;
|
2024-02-21 15:47:44 -05:00
|
|
|
private pokemonMovesContainer: Phaser.GameObjects.Container;
|
2024-02-20 22:53:33 -05:00
|
|
|
private pokemonMoveContainers: Phaser.GameObjects.Container[];
|
|
|
|
private pokemonMoveBgs: Phaser.GameObjects.NineSlice[];
|
|
|
|
private pokemonMoveLabels: Phaser.GameObjects.Text[];
|
2024-02-21 15:47:44 -05:00
|
|
|
private pokemonAdditionalMoveCountLabel: Phaser.GameObjects.Text;
|
|
|
|
private pokemonEggMovesContainer: Phaser.GameObjects.Container;
|
|
|
|
private pokemonEggMoveContainers: Phaser.GameObjects.Container[];
|
|
|
|
private pokemonEggMoveBgs: Phaser.GameObjects.NineSlice[];
|
|
|
|
private pokemonEggMoveLabels: Phaser.GameObjects.Text[];
|
2024-04-13 18:59:58 -04:00
|
|
|
private pokemonCandyIcon: Phaser.GameObjects.Sprite;
|
2024-05-05 09:35:14 -05:00
|
|
|
private pokemonCandyDarknessOverlay: Phaser.GameObjects.Sprite;
|
2024-04-13 18:59:58 -04:00
|
|
|
private pokemonCandyOverlayIcon: Phaser.GameObjects.Sprite;
|
|
|
|
private pokemonCandyCountText: Phaser.GameObjects.Text;
|
|
|
|
private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container;
|
|
|
|
private pokemonCaughtCountText: Phaser.GameObjects.Text;
|
2024-06-09 10:45:21 -06:00
|
|
|
private pokemonHatchedIcon : Phaser.GameObjects.Sprite;
|
2024-04-13 18:59:58 -04:00
|
|
|
private pokemonHatchedCountText: Phaser.GameObjects.Text;
|
2023-12-19 23:51:48 -05:00
|
|
|
private genOptionsText: Phaser.GameObjects.Text;
|
2024-06-10 12:41:01 -04:00
|
|
|
|
2024-06-08 21:35:11 -04:00
|
|
|
private instructionsContainer: Phaser.GameObjects.Container;
|
2024-06-10 12:41:01 -04:00
|
|
|
private shinyIconElement: Phaser.GameObjects.Sprite;
|
|
|
|
private formIconElement: Phaser.GameObjects.Sprite;
|
|
|
|
private abilityIconElement: Phaser.GameObjects.Sprite;
|
|
|
|
private genderIconElement: Phaser.GameObjects.Sprite;
|
|
|
|
private natureIconElement: Phaser.GameObjects.Sprite;
|
|
|
|
private variantIconElement: Phaser.GameObjects.Sprite;
|
|
|
|
private shinyLabel: Phaser.GameObjects.Text;
|
|
|
|
private formLabel: Phaser.GameObjects.Text;
|
|
|
|
private genderLabel: Phaser.GameObjects.Text;
|
|
|
|
private abilityLabel: Phaser.GameObjects.Text;
|
|
|
|
private natureLabel: Phaser.GameObjects.Text;
|
|
|
|
private variantLabel: Phaser.GameObjects.Text;
|
|
|
|
|
2024-02-14 10:44:55 -05:00
|
|
|
private starterSelectMessageBox: Phaser.GameObjects.NineSlice;
|
2023-12-19 23:51:48 -05:00
|
|
|
private starterSelectMessageBoxContainer: Phaser.GameObjects.Container;
|
|
|
|
private statsContainer: StatsContainer;
|
2024-05-03 23:02:55 -05:00
|
|
|
private pokemonFormText: Phaser.GameObjects.Text;
|
2024-06-06 03:28:12 +02:00
|
|
|
private moveInfoOverlay : MoveInfoOverlay;
|
2023-12-19 23:51:48 -05:00
|
|
|
|
|
|
|
private genMode: boolean;
|
|
|
|
private statsMode: boolean;
|
|
|
|
private dexAttrCursor: bigint = 0n;
|
2024-04-18 22:52:26 -04:00
|
|
|
private abilityCursor: integer = -1;
|
2024-04-02 14:32:51 -04:00
|
|
|
private natureCursor: integer = -1;
|
2023-12-19 23:51:48 -05:00
|
|
|
private genCursor: integer = 0;
|
|
|
|
private genScrollCursor: integer = 0;
|
2024-02-21 01:03:34 -05:00
|
|
|
private starterMoveset: StarterMoveset;
|
2023-12-19 23:51:48 -05:00
|
|
|
|
|
|
|
private genSpecies: PokemonSpecies[][] = [];
|
|
|
|
private lastSpecies: PokemonSpecies;
|
|
|
|
private speciesLoaded: Map<Species, boolean> = new Map<Species, boolean>();
|
2024-06-08 00:33:45 +02:00
|
|
|
public starterGens: integer[] = [];
|
|
|
|
public starterCursors: integer[] = [];
|
2023-12-19 23:51:48 -05:00
|
|
|
private pokerusGens: integer[] = [];
|
|
|
|
private pokerusCursors: integer[] = [];
|
|
|
|
private starterAttr: bigint[] = [];
|
2024-04-18 22:52:26 -04:00
|
|
|
private starterAbilityIndexes: integer[] = [];
|
2024-01-05 22:24:05 -05:00
|
|
|
private starterNatures: Nature[] = [];
|
2024-02-21 01:03:34 -05:00
|
|
|
private starterMovesets: StarterMoveset[] = [];
|
2023-12-19 23:51:48 -05:00
|
|
|
private speciesStarterDexEntry: DexEntry;
|
2024-02-21 01:03:34 -05:00
|
|
|
private speciesStarterMoves: Moves[];
|
2023-12-19 23:51:48 -05:00
|
|
|
private canCycleShiny: boolean;
|
|
|
|
private canCycleForm: boolean;
|
|
|
|
private canCycleGender: boolean;
|
|
|
|
private canCycleAbility: boolean;
|
2024-01-05 22:24:05 -05:00
|
|
|
private canCycleNature: boolean;
|
2024-04-18 22:52:26 -04:00
|
|
|
private canCycleVariant: boolean;
|
2023-12-19 23:51:48 -05:00
|
|
|
private value: integer = 0;
|
2024-06-07 00:12:19 +09:00
|
|
|
private canAddParty: boolean;
|
2023-12-19 23:51:48 -05:00
|
|
|
|
|
|
|
private assetLoadCancelled: Utils.BooleanHolder;
|
2024-06-08 00:33:45 +02:00
|
|
|
public cursorObj: Phaser.GameObjects.Image;
|
2023-12-19 23:51:48 -05:00
|
|
|
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[];
|
2024-04-18 22:52:26 -04:00
|
|
|
private shinyIcons: Phaser.GameObjects.Image[][];
|
2024-04-13 23:20:54 -04:00
|
|
|
private hiddenAbilityIcons: Phaser.GameObjects.Image[];
|
2024-05-07 00:44:41 -04:00
|
|
|
private classicWinIcons: Phaser.GameObjects.Image[];
|
2024-05-28 14:49:15 -03:00
|
|
|
private candyUpgradeIcon: Phaser.GameObjects.Image[];
|
|
|
|
private candyUpgradeOverlayIcon: Phaser.GameObjects.Image[];
|
2023-12-19 23:51:48 -05:00
|
|
|
|
|
|
|
private iconAnimHandler: PokemonIconAnimHandler;
|
|
|
|
|
2024-06-08 21:35:11 -04:00
|
|
|
//variables to keep track of the dynamically rendered list of instruction prompts for starter select
|
|
|
|
private instructionRowX = 0;
|
|
|
|
private instructionRowY = 0;
|
|
|
|
private instructionRowTextOffset = 12;
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
private starterSelectCallback: StarterSelectCallback;
|
|
|
|
|
2024-06-17 06:49:29 +02:00
|
|
|
private starterPreferences: StarterPreferences;
|
|
|
|
|
2024-04-17 14:49:18 -04:00
|
|
|
protected blockInput: boolean = false;
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
constructor(scene: BattleScene) {
|
|
|
|
super(scene, Mode.STARTER_SELECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
const ui = this.getUi();
|
2024-06-04 22:11:02 +02:00
|
|
|
const currentLanguage = i18next.resolvedLanguage;
|
2024-05-21 00:25:55 -04:00
|
|
|
const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang));
|
|
|
|
const textSettings = languageSettings[langSettingKey];
|
2023-12-19 23:51:48 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const starterSelectBg = this.scene.add.image(0, 0, "starter_select_bg");
|
2023-12-19 23:51:48 -05:00
|
|
|
starterSelectBg.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(starterSelectBg);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.shinyOverlay = this.scene.add.image(6, 6, "summary_overlay_shiny");
|
2024-03-25 13:40:54 -04:00
|
|
|
this.shinyOverlay.setOrigin(0, 0);
|
|
|
|
this.shinyOverlay.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.shinyOverlay);
|
|
|
|
|
2024-03-31 21:14:35 -04:00
|
|
|
const starterContainerWindow = addWindow(this.scene, 141, 1, 178, 178);
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-01-01 10:14:49 -05:00
|
|
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 1, 34, 58));
|
|
|
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 59, 34, 91));
|
2023-12-20 22:22:15 -05:00
|
|
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 145, 34, 34, true));
|
2024-03-31 21:14:35 -04:00
|
|
|
this.starterSelectContainer.add(starterContainerWindow);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!this.scene.uiTheme) {
|
2024-03-31 21:14:35 -04:00
|
|
|
starterContainerWindow.setVisible(false);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-20 22:22:15 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.iconAnimHandler = new PokemonIconAnimHandler();
|
|
|
|
this.iconAnimHandler.setup(this.scene);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonNumberText = addTextObject(this.scene, 17, 1, "0000", TextStyle.SUMMARY);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonNumberText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNumberText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonNameText = addTextObject(this.scene, 6, 112, "", TextStyle.SUMMARY);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonNameText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNameText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonGrowthRateLabelText = addTextObject(this.scene, 8, 106, i18next.t("starterSelectUiHandler:growthRate"), TextStyle.SUMMARY_ALT, { fontSize: "36px" });
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonGrowthRateLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonGrowthRateLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonGrowthRateLabelText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonGrowthRateText = addTextObject(this.scene, 34, 106, "", TextStyle.SUMMARY_PINK, { fontSize: "36px" });
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonGrowthRateText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonGrowthRateText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonGenderText = addTextObject(this.scene, 96, 112, "", TextStyle.SUMMARY_ALT);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonGenderText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonGenderText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonUncaughtText = addTextObject(this.scene, 6, 127, i18next.t("starterSelectUiHandler:uncaught"), TextStyle.SUMMARY_ALT, { fontSize: "56px" });
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonUncaughtText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonUncaughtText);
|
|
|
|
|
2024-05-24 01:45:04 +02:00
|
|
|
|
2024-05-19 21:40:58 -04:00
|
|
|
// The position should be set per language
|
2024-05-23 17:03:10 +02:00
|
|
|
const starterInfoXPos = textSettings?.starterInfoXPos || 31;
|
|
|
|
const starterInfoYOffset = textSettings?.starterInfoYOffset || 0;
|
2024-05-15 12:13:35 -03:00
|
|
|
|
|
|
|
// The font size should be set per language
|
2024-05-23 17:03:10 +02:00
|
|
|
const starterInfoTextSize = textSettings?.starterInfoTextSize || 56;
|
2024-05-15 12:13:35 -03:00
|
|
|
|
2024-05-19 23:11:07 -04:00
|
|
|
this.pokemonAbilityLabelText = addTextObject(this.scene, 6, 127 + starterInfoYOffset, i18next.t("starterSelectUiHandler:ability"), TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize });
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonAbilityLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonAbilityLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonAbilityLabelText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonAbilityText = addTextObject(this.scene, starterInfoXPos, 127 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize });
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonAbilityText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonAbilityText);
|
|
|
|
|
2024-05-19 23:11:07 -04:00
|
|
|
this.pokemonPassiveLabelText = addTextObject(this.scene, 6, 136 + starterInfoYOffset, i18next.t("starterSelectUiHandler:passive"), TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize });
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonPassiveLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonPassiveLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonPassiveLabelText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonPassiveText = addTextObject(this.scene, starterInfoXPos, 136 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize });
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonPassiveText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonPassiveText);
|
|
|
|
|
2024-05-19 23:11:07 -04:00
|
|
|
this.pokemonNatureLabelText = addTextObject(this.scene, 6, 145 + starterInfoYOffset, i18next.t("starterSelectUiHandler:nature"), TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize });
|
2024-01-05 22:24:05 -05:00
|
|
|
this.pokemonNatureLabelText.setOrigin(0, 0);
|
|
|
|
this.pokemonNatureLabelText.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNatureLabelText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonNatureText = addBBCodeTextObject(this.scene, starterInfoXPos, 145 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize });
|
2024-01-05 22:24:05 -05:00
|
|
|
this.pokemonNatureText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonNatureText);
|
|
|
|
|
2024-02-20 22:53:33 -05:00
|
|
|
this.pokemonMoveContainers = [];
|
|
|
|
this.pokemonMoveBgs = [];
|
|
|
|
this.pokemonMoveLabels = [];
|
|
|
|
|
2024-02-21 15:47:44 -05:00
|
|
|
this.pokemonEggMoveContainers = [];
|
|
|
|
this.pokemonEggMoveBgs = [];
|
|
|
|
this.pokemonEggMoveLabels = [];
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.genOptionsText = addTextObject(this.scene, 124, 7, "", TextStyle.WINDOW, { fontSize: 72, lineSpacing: 39, align: "center" });
|
2023-12-19 23:51:48 -05:00
|
|
|
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) => {
|
2024-03-31 21:14:35 -04:00
|
|
|
const container = this.scene.add.container(151, 9);
|
2024-05-23 17:03:10 +02:00
|
|
|
if (i) {
|
2023-12-19 23:51:48 -05:00
|
|
|
container.setVisible(false);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterSelectContainer.add(container);
|
|
|
|
return container;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.pokerusCursorObjs = new Array(3).fill(null).map(() => {
|
2024-05-23 17:03:10 +02:00
|
|
|
const cursorObj = this.scene.add.image(0, 0, "select_cursor_pokerus");
|
2023-12-19 23:51:48 -05:00
|
|
|
cursorObj.setVisible(false);
|
|
|
|
cursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(cursorObj);
|
|
|
|
return cursorObj;
|
|
|
|
});
|
|
|
|
|
2024-01-01 10:14:49 -05:00
|
|
|
this.starterCursorObjs = new Array(6).fill(null).map(() => {
|
2024-05-23 17:03:10 +02:00
|
|
|
const cursorObj = this.scene.add.image(0, 0, "select_cursor_highlight");
|
2023-12-19 23:51:48 -05:00
|
|
|
cursorObj.setVisible(false);
|
|
|
|
cursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(cursorObj);
|
|
|
|
return cursorObj;
|
|
|
|
});
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.cursorObj = this.scene.add.image(0, 0, "select_cursor");
|
2023-12-19 23:51:48 -05:00
|
|
|
this.cursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.cursorObj);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.genCursorHighlightObj = this.scene.add.image(111, 5, "select_gen_cursor_highlight");
|
2023-12-19 23:51:48 -05:00
|
|
|
this.genCursorHighlightObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.genCursorHighlightObj);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.genCursorObj = this.scene.add.image(111, 5, "select_gen_cursor");
|
2023-12-19 23:51:48 -05:00
|
|
|
this.genCursorObj.setVisible(false);
|
|
|
|
this.genCursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.genCursorObj);
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.valueLimitLabel = addTextObject(this.scene, 124, 150, "0/10", TextStyle.TOOLTIP_CONTENT);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.valueLimitLabel.setOrigin(0.5, 0);
|
|
|
|
this.starterSelectContainer.add(this.valueLimitLabel);
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-06-19 15:40:08 -04:00
|
|
|
const startLabel = addTextObject(this.scene, 124, 162, i18next.t("common:start"), TextStyle.TOOLTIP_CONTENT);
|
2023-12-19 23:51:48 -05:00
|
|
|
startLabel.setOrigin(0.5, 0);
|
|
|
|
this.starterSelectContainer.add(startLabel);
|
2023-12-07 00:52:20 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.startCursorObj = this.scene.add.nineslice(111, 160, "select_cursor", null, 26, 15, 6, 6, 6, 6);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.startCursorObj.setVisible(false);
|
|
|
|
this.startCursorObj.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.startCursorObj);
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
const starterSpecies: Species[] = [];
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
for (let g = 0; g < this.starterSelectGenIconContainers.length; g++) {
|
|
|
|
let s = 0;
|
|
|
|
this.genSpecies.push([]);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
for (const species of allSpecies) {
|
|
|
|
if (!speciesStarters.hasOwnProperty(species.speciesId) || species.generation !== g + 1 || !species.isObtainable()) {
|
2023-12-19 23:51:48 -05:00
|
|
|
continue;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
starterSpecies.push(species.speciesId);
|
|
|
|
this.speciesLoaded.set(species.speciesId, false);
|
|
|
|
this.genSpecies[g].push(species);
|
2024-04-18 22:52:26 -04:00
|
|
|
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species, false, true);
|
2023-12-19 23:51:48 -05:00
|
|
|
const defaultProps = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
2024-05-28 14:49:15 -03:00
|
|
|
const position = calcIconPosition(s);
|
|
|
|
const icon = this.scene.add.sprite(position.x - 2, position.y + 2, species.getIconAtlasKey(defaultProps.formIndex, defaultProps.shiny, defaultProps.variant));
|
2023-12-19 23:51:48 -05:00
|
|
|
icon.setScale(0.5);
|
|
|
|
icon.setOrigin(0, 0);
|
2024-04-18 22:52:26 -04:00
|
|
|
icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant));
|
2024-05-13 14:23:34 -04:00
|
|
|
this.checkIconId(icon, species, defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant);
|
2024-02-18 22:21:57 -05:00
|
|
|
icon.setTint(0);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterSelectGenIconContainers[g].add(icon);
|
|
|
|
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.NONE);
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-01-01 10:14:49 -05:00
|
|
|
this.starterIcons = new Array(6).fill(null).map((_, i) => {
|
2024-05-23 17:03:10 +02:00
|
|
|
const icon = this.scene.add.sprite(113, 63 + 13 * i, "pokemon_icons_0");
|
2023-12-19 23:51:48 -05:00
|
|
|
icon.setScale(0.5);
|
|
|
|
icon.setOrigin(0, 0);
|
2024-05-23 17:03:10 +02:00
|
|
|
icon.setFrame("unknown");
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterSelectContainer.add(icon);
|
|
|
|
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.PASSIVE);
|
|
|
|
return icon;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.starterValueLabels = new Array(81).fill(null).map((_, i) => {
|
2024-05-28 14:49:15 -03:00
|
|
|
const position = calcIconPosition(i);
|
|
|
|
const ret = addTextObject(this.scene, position.x + 152, position.y + 11, "0", TextStyle.WINDOW, { fontSize: "32px" });
|
2023-12-19 23:51:48 -05:00
|
|
|
ret.setShadowOffset(2, 2);
|
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
2024-04-18 22:52:26 -04:00
|
|
|
const getShinyStar = (i: integer, v: integer): Phaser.GameObjects.Image => {
|
2024-05-28 14:49:15 -03:00
|
|
|
const position = calcIconPosition(i);
|
2024-05-28 14:50:40 -05:00
|
|
|
const ret = this.scene.add.image((position.x - v * 3) + 163, position.y + 11, "shiny_star_small");
|
2023-12-19 23:51:48 -05:00
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setScale(0.5);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
2024-05-23 17:03:10 +02:00
|
|
|
};
|
2024-04-18 22:52:26 -04:00
|
|
|
|
|
|
|
this.shinyIcons = new Array(81).fill(null).map((_, i) => {
|
|
|
|
return new Array(3).fill(null).map((_, v) => getShinyStar(i, v));
|
2023-12-19 23:51:48 -05:00
|
|
|
});
|
|
|
|
|
2024-04-13 23:20:54 -04:00
|
|
|
this.hiddenAbilityIcons = new Array(81).fill(null).map((_, i) => {
|
2024-05-28 14:49:15 -03:00
|
|
|
const position = calcIconPosition(i);
|
|
|
|
const ret = this.scene.add.image(position.x + 163, position.y + 16, "ha_capsule");
|
2024-04-13 23:20:54 -04:00
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setScale(0.5);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
2024-05-07 00:44:41 -04:00
|
|
|
this.classicWinIcons = new Array(81).fill(null).map((_, i) => {
|
2024-05-28 14:49:15 -03:00
|
|
|
const position = calcIconPosition(i);
|
|
|
|
const ret = this.scene.add.image(position.x + 153, position.y + 21, "champion_ribbon");
|
2024-05-07 00:44:41 -04:00
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setScale(0.5);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
2024-05-28 14:49:15 -03:00
|
|
|
this.candyUpgradeIcon = new Array(81).fill(null).map((_, i) => {
|
|
|
|
const position = calcIconPosition(i);
|
|
|
|
const ret = this.scene.add.image(position.x + 163, position.y + 21, "candy");
|
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setScale(0.25);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.candyUpgradeOverlayIcon = new Array(81).fill(null).map((_, i) => {
|
|
|
|
const position = calcIconPosition(i);
|
|
|
|
const ret = this.scene.add.image(position.x + 163, position.y + 21, "candy_overlay");
|
|
|
|
ret.setOrigin(0, 0);
|
|
|
|
ret.setScale(0.25);
|
|
|
|
ret.setVisible(false);
|
|
|
|
this.starterSelectContainer.add(ret);
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonSprite = this.scene.add.sprite(53, 63, "pkmn__sub");
|
2024-04-18 22:52:26 -04:00
|
|
|
this.pokemonSprite.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true });
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterSelectContainer.add(this.pokemonSprite);
|
|
|
|
|
2024-06-19 15:40:08 -04:00
|
|
|
this.type1Icon = this.scene.add.sprite(8, 98, `types${Utils.verifyLang(i18next.resolvedLanguage) ? `_${i18next.resolvedLanguage}` : ""}`);
|
|
|
|
this.type1Icon.setScale(0.5);
|
2024-04-13 19:28:32 -04:00
|
|
|
this.type1Icon.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.type1Icon);
|
|
|
|
|
2024-06-19 15:40:08 -04:00
|
|
|
this.type2Icon = this.scene.add.sprite(26, 98, `types${Utils.verifyLang(i18next.resolvedLanguage) ? `_${i18next.resolvedLanguage}` : ""}`);
|
|
|
|
this.type2Icon.setScale(0.5);
|
2024-04-13 19:28:32 -04:00
|
|
|
this.type2Icon.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.type2Icon);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonLuckLabelText = addTextObject(this.scene, 8, 89, "Luck:", TextStyle.WINDOW_ALT, { fontSize: "56px" });
|
2024-04-26 17:32:28 -04:00
|
|
|
this.pokemonLuckLabelText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonLuckLabelText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonLuckText = addTextObject(this.scene, 8 + this.pokemonLuckLabelText.displayWidth + 2, 89, "0", TextStyle.WINDOW, { fontSize: "56px" });
|
2024-04-26 17:32:28 -04:00
|
|
|
this.pokemonLuckText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonLuckText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonCandyIcon = this.scene.add.sprite(4.5, 18, "candy");
|
2024-04-13 19:28:32 -04:00
|
|
|
this.pokemonCandyIcon.setScale(0.5);
|
|
|
|
this.pokemonCandyIcon.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonCandyIcon);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonFormText = addTextObject(this.scene, 6, 42, "Form", TextStyle.WINDOW_ALT, { fontSize: "42px" });
|
2024-05-03 23:02:55 -05:00
|
|
|
this.pokemonFormText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonFormText);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonCandyOverlayIcon = this.scene.add.sprite(4.5, 18, "candy_overlay");
|
2024-04-13 19:28:32 -04:00
|
|
|
this.pokemonCandyOverlayIcon.setScale(0.5);
|
|
|
|
this.pokemonCandyOverlayIcon.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonCandyOverlayIcon);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonCandyDarknessOverlay = this.scene.add.sprite(4.5, 18, "candy");
|
2024-05-05 09:35:14 -05:00
|
|
|
this.pokemonCandyDarknessOverlay.setScale(0.5);
|
|
|
|
this.pokemonCandyDarknessOverlay.setOrigin(0, 0);
|
|
|
|
this.pokemonCandyDarknessOverlay.setTint(0x000000);
|
2024-05-08 12:01:05 -05:00
|
|
|
this.pokemonCandyDarknessOverlay.setAlpha(0.50);
|
2024-05-05 09:35:14 -05:00
|
|
|
this.pokemonCandyDarknessOverlay.setInteractive(new Phaser.Geom.Rectangle(0, 0, 16, 16), Phaser.Geom.Rectangle.Contains);
|
|
|
|
this.starterSelectContainer.add(this.pokemonCandyDarknessOverlay);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonCandyCountText = addTextObject(this.scene, 14, 18, "x0", TextStyle.WINDOW_ALT, { fontSize: "56px" });
|
2024-04-13 19:28:32 -04:00
|
|
|
this.pokemonCandyCountText.setOrigin(0, 0);
|
|
|
|
this.starterSelectContainer.add(this.pokemonCandyCountText);
|
|
|
|
|
|
|
|
this.pokemonCaughtHatchedContainer = this.scene.add.container(2, 25);
|
|
|
|
this.pokemonCaughtHatchedContainer.setScale(0.5);
|
|
|
|
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const pokemonCaughtIcon = this.scene.add.sprite(1, 0, "items", "pb");
|
2024-04-13 19:28:32 -04:00
|
|
|
pokemonCaughtIcon.setOrigin(0, 0);
|
|
|
|
pokemonCaughtIcon.setScale(0.75);
|
|
|
|
this.pokemonCaughtHatchedContainer.add(pokemonCaughtIcon);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonCaughtCountText = addTextObject(this.scene, 24, 4, "0", TextStyle.SUMMARY_ALT);
|
2024-04-13 19:28:32 -04:00
|
|
|
this.pokemonCaughtCountText.setOrigin(0, 0);
|
|
|
|
this.pokemonCaughtHatchedContainer.add(this.pokemonCaughtCountText);
|
|
|
|
|
2024-06-09 10:45:21 -06:00
|
|
|
this.pokemonHatchedIcon = this.scene.add.sprite(1, 14, "egg_icons");
|
|
|
|
this.pokemonHatchedIcon.setOrigin(0.15, 0.2);
|
|
|
|
this.pokemonHatchedIcon.setScale(0.8);
|
|
|
|
this.pokemonCaughtHatchedContainer.add(this.pokemonHatchedIcon);
|
2024-04-13 19:28:32 -04:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonHatchedCountText = addTextObject(this.scene, 24, 19, "0", TextStyle.SUMMARY_ALT);
|
2024-04-13 19:28:32 -04:00
|
|
|
this.pokemonHatchedCountText.setOrigin(0, 0);
|
|
|
|
this.pokemonCaughtHatchedContainer.add(this.pokemonHatchedCountText);
|
|
|
|
|
2024-02-21 15:47:44 -05:00
|
|
|
this.pokemonMovesContainer = this.scene.add.container(102, 16);
|
|
|
|
this.pokemonMovesContainer.setScale(0.5);
|
|
|
|
|
2024-02-20 22:53:33 -05:00
|
|
|
for (let m = 0; m < 4; m++) {
|
2024-02-21 15:47:44 -05:00
|
|
|
const moveContainer = this.scene.add.container(0, 14 * m);
|
2024-02-20 22:53:33 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const moveBg = this.scene.add.nineslice(0, 0, "type_bgs", "unknown", 92, 14, 2, 2, 2, 2);
|
2024-02-20 22:53:33 -05:00
|
|
|
moveBg.setOrigin(1, 0);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const moveLabel = addTextObject(this.scene, -moveBg.width / 2, 0, "-", TextStyle.PARTY);
|
2024-02-20 22:53:33 -05:00
|
|
|
moveLabel.setOrigin(0.5, 0);
|
|
|
|
|
|
|
|
this.pokemonMoveBgs.push(moveBg);
|
|
|
|
this.pokemonMoveLabels.push(moveLabel);
|
|
|
|
|
|
|
|
moveContainer.add(moveBg);
|
|
|
|
moveContainer.add(moveLabel);
|
|
|
|
|
|
|
|
this.pokemonMoveContainers.push(moveContainer);
|
2024-03-08 13:14:08 -05:00
|
|
|
this.pokemonMovesContainer.add(moveContainer);
|
2024-02-21 15:47:44 -05:00
|
|
|
}
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonAdditionalMoveCountLabel = addTextObject(this.scene, -this.pokemonMoveBgs[0].width / 2, 56, "(+0)", TextStyle.PARTY);
|
2024-02-21 15:47:44 -05:00
|
|
|
this.pokemonAdditionalMoveCountLabel.setOrigin(0.5, 0);
|
|
|
|
|
|
|
|
this.pokemonMovesContainer.add(this.pokemonAdditionalMoveCountLabel);
|
|
|
|
|
|
|
|
this.starterSelectContainer.add(this.pokemonMovesContainer);
|
|
|
|
|
2024-02-25 12:45:41 -05:00
|
|
|
this.pokemonEggMovesContainer = this.scene.add.container(102, 85);
|
|
|
|
this.pokemonEggMovesContainer.setScale(0.375);
|
2024-02-21 15:47:44 -05:00
|
|
|
|
2024-05-06 18:02:45 +02:00
|
|
|
const eggMovesLabel = addTextObject(this.scene, -46, 0, i18next.t("starterSelectUiHandler:eggMoves"), TextStyle.WINDOW_ALT);
|
2024-02-21 15:47:44 -05:00
|
|
|
eggMovesLabel.setOrigin(0.5, 0);
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-02-21 15:47:44 -05:00
|
|
|
this.pokemonEggMovesContainer.add(eggMovesLabel);
|
2024-02-20 22:53:33 -05:00
|
|
|
|
2024-02-21 15:47:44 -05:00
|
|
|
for (let m = 0; m < 4; m++) {
|
|
|
|
const eggMoveContainer = this.scene.add.container(0, 16 + 14 * m);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const eggMoveBg = this.scene.add.nineslice(0, 0, "type_bgs", "unknown", 92, 14, 2, 2, 2, 2);
|
2024-02-21 15:47:44 -05:00
|
|
|
eggMoveBg.setOrigin(1, 0);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const eggMoveLabel = addTextObject(this.scene, -eggMoveBg.width / 2, 0, "???", TextStyle.PARTY);
|
2024-02-21 15:47:44 -05:00
|
|
|
eggMoveLabel.setOrigin(0.5, 0);
|
|
|
|
|
|
|
|
this.pokemonEggMoveBgs.push(eggMoveBg);
|
|
|
|
this.pokemonEggMoveLabels.push(eggMoveLabel);
|
|
|
|
|
|
|
|
eggMoveContainer.add(eggMoveBg);
|
|
|
|
eggMoveContainer.add(eggMoveLabel);
|
|
|
|
|
|
|
|
this.pokemonEggMoveContainers.push(eggMoveContainer);
|
|
|
|
|
|
|
|
this.pokemonEggMovesContainer.add(eggMoveContainer);
|
2024-02-20 22:53:33 -05:00
|
|
|
}
|
|
|
|
|
2024-02-21 15:47:44 -05:00
|
|
|
this.starterSelectContainer.add(this.pokemonEggMovesContainer);
|
|
|
|
|
2024-05-13 18:06:26 +02:00
|
|
|
// The font size should be set per language
|
2024-06-10 12:41:01 -04:00
|
|
|
const instructionTextSize = textSettings.instructionTextSize;
|
|
|
|
|
2024-06-08 21:35:11 -04:00
|
|
|
this.instructionsContainer = this.scene.add.container(4, 156);
|
|
|
|
this.instructionsContainer.setVisible(true);
|
|
|
|
this.starterSelectContainer.add(this.instructionsContainer);
|
2023-12-19 23:51:48 -05:00
|
|
|
|
2024-06-10 12:41:01 -04:00
|
|
|
// instruction rows that will be pushed into the container dynamically based on need
|
|
|
|
this.shinyIconElement = this.scene.add.sprite(this.instructionRowX, this.instructionRowY, "keyboard", "R.png");
|
|
|
|
this.shinyIconElement.setScale(0.675);
|
|
|
|
this.shinyIconElement.setOrigin(0.0, 0.0);
|
|
|
|
this.shinyLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleShiny"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
|
|
|
|
|
|
|
this.formIconElement = this.scene.add.sprite(this.instructionRowX, this.instructionRowY, "keyboard", "F.png");
|
|
|
|
this.formIconElement.setScale(0.675);
|
|
|
|
this.formIconElement.setOrigin(0.0, 0.0);
|
|
|
|
this.formLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleForm"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
|
|
|
|
|
|
|
this.genderIconElement = this.scene.add.sprite(this.instructionRowX, this.instructionRowY, "keyboard", "G.png");
|
|
|
|
this.genderIconElement.setScale(0.675);
|
|
|
|
this.genderIconElement.setOrigin(0.0, 0.0);
|
|
|
|
this.genderLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleGender"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
|
|
|
|
|
|
|
this.abilityIconElement = this.scene.add.sprite(this.instructionRowX, this.instructionRowY, "keyboard", "E.png");
|
|
|
|
this.abilityIconElement.setScale(0.675);
|
|
|
|
this.abilityIconElement.setOrigin(0.0, 0.0);
|
|
|
|
this.abilityLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleAbility"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
|
|
|
|
|
|
|
this.natureIconElement = this.scene.add.sprite(this.instructionRowX, this.instructionRowY, "keyboard", "N.png");
|
|
|
|
this.natureIconElement.setScale(0.675);
|
|
|
|
this.natureIconElement.setOrigin(0.0, 0.0);
|
|
|
|
this.natureLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleNature"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
|
|
|
|
|
|
|
this.variantIconElement = this.scene.add.sprite(this.instructionRowX, this.instructionRowY, "keyboard", "V.png");
|
|
|
|
this.variantIconElement.setScale(0.675);
|
|
|
|
this.variantIconElement.setOrigin(0.0, 0.0);
|
|
|
|
this.variantLabel = addTextObject(this.scene, this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleVariant"), TextStyle.PARTY, { fontSize: instructionTextSize });
|
|
|
|
|
2024-06-10 16:19:06 -04:00
|
|
|
this.hideInstructions();
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
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 10:44:55 -05:00
|
|
|
this.starterSelectMessageBox = addWindow(this.scene, 1, -1, 318, 28);
|
|
|
|
this.starterSelectMessageBox.setOrigin(0, 1);
|
|
|
|
this.starterSelectMessageBoxContainer.add(this.starterSelectMessageBox);
|
2023-12-19 23:51:48 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.message = addTextObject(this.scene, 8, 8, "", TextStyle.WINDOW, { maxLines: 2 });
|
2024-02-14 10:44:55 -05:00
|
|
|
this.message.setOrigin(0, 0);
|
2023-12-19 23:51:48 -05: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 00:40:03 -05:00
|
|
|
randomSpeciesId = Utils.randSeedItem(starterSpecies);
|
2023-12-19 23:51:48 -05:00
|
|
|
species = getPokemonSpecies(randomSpeciesId);
|
|
|
|
pokerusCursor = this.genSpecies[species.generation - 1].indexOf(species);
|
|
|
|
};
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
let dupe = false;
|
2023-10-24 23:04:23 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
do {
|
2024-03-30 20:14:09 -04:00
|
|
|
dupe = false;
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
generateSpecies();
|
2023-10-24 23:04:23 -04:00
|
|
|
|
2023-12-19 23:51:48 -05: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 01:32:26 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokerusGens.push(species.generation - 1);
|
|
|
|
this.pokerusCursors.push(pokerusCursor);
|
2024-03-31 21:14:35 -04:00
|
|
|
this.pokerusCursorObjs[c].setPosition(150 + 18 * (pokerusCursor % 9), 10 + 18 * Math.floor(pokerusCursor / 9));
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
|
|
|
}, 0, date.getTime().toString());
|
2023-12-01 17:23:26 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.statsContainer = new StatsContainer(this.scene, 6, 16);
|
2023-12-01 17:23:26 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.scene.add.existing(this.statsContainer);
|
2023-10-25 14:15:44 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.statsContainer.setVisible(false);
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterSelectContainer.add(this.statsContainer);
|
2023-10-25 14:15:44 -04:00
|
|
|
|
2024-06-07 22:45:49 +02:00
|
|
|
// add the info overlay last to be the top most ui element and prevent the IVs from overlaying this
|
|
|
|
const overlayScale = 1;
|
|
|
|
this.moveInfoOverlay = new MoveInfoOverlay(this.scene, {
|
|
|
|
scale: overlayScale,
|
|
|
|
top: true,
|
|
|
|
x: 1,
|
|
|
|
y: this.scene.game.canvas.height / 6 - MoveInfoOverlay.getHeight(overlayScale) - 29,
|
|
|
|
});
|
|
|
|
this.starterSelectContainer.add(this.moveInfoOverlay);
|
|
|
|
|
2024-05-28 14:49:15 -03:00
|
|
|
this.scene.eventTarget.addEventListener(BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED, (e) => this.onCandyUpgradeDisplayChanged(e));
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.updateInstructions();
|
|
|
|
}
|
2023-10-25 14:15:44 -04:00
|
|
|
|
2023-12-30 18:41:25 -05:00
|
|
|
show(args: any[]): boolean {
|
2024-06-17 06:49:29 +02:00
|
|
|
if (!this.starterPreferences) {
|
|
|
|
// starterPreferences haven't been loaded yet
|
|
|
|
this.starterPreferences = StarterPrefs.load();
|
|
|
|
}
|
2024-06-07 22:45:49 +02:00
|
|
|
this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers
|
2024-06-08 15:07:23 +10:00
|
|
|
if (args.length >= 1 && args[0] instanceof Function) {
|
2023-12-19 23:51:48 -05:00
|
|
|
super.show(args);
|
2024-05-28 14:05:00 -04:00
|
|
|
this.starterSelectCallback = args[0] as StarterSelectCallback;
|
2023-11-13 22:29:03 -05:00
|
|
|
|
2024-05-28 14:49:15 -03:00
|
|
|
this.starterSelectContainer.setVisible(true);
|
|
|
|
|
2024-06-15 21:53:04 -04:00
|
|
|
this.setCursor(0);
|
2024-05-28 14:49:15 -03:00
|
|
|
this.setGenMode(false);
|
|
|
|
this.setCursor(0);
|
|
|
|
this.setGenMode(true);
|
|
|
|
this.setCursor(0);
|
|
|
|
this.tryUpdateValue(0);
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
for (let g = 0; g < this.genSpecies.length; g++) {
|
|
|
|
this.genSpecies[g].forEach((species, s) => {
|
|
|
|
const icon = this.starterSelectGenIconContainers[g].getAt(s) as Phaser.GameObjects.Sprite;
|
2024-05-28 14:49:15 -03:00
|
|
|
const dexEntry = this.scene.gameData.dexData[species.speciesId];
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (dexEntry.caughtAttr) {
|
2023-12-19 23:51:48 -05:00
|
|
|
icon.clearTint();
|
2024-05-23 17:03:10 +02:00
|
|
|
} else if (dexEntry.seenAttr) {
|
2024-02-18 22:21:57 -05:00
|
|
|
icon.setTint(0x808080);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-05-28 14:49:15 -03:00
|
|
|
|
|
|
|
this.setUpgradeAnimation(icon, species);
|
2023-12-19 23:51:48 -05:00
|
|
|
});
|
|
|
|
}
|
2023-11-13 22:29:03 -05:00
|
|
|
|
2024-02-14 10:44:55 -05:00
|
|
|
handleTutorial(this.scene, Tutorial.Starter_Select);
|
2024-02-13 18:42:11 -05:00
|
|
|
|
2023-12-30 18:41:25 -05:00
|
|
|
return true;
|
2023-04-09 19:15:21 -04:00
|
|
|
}
|
2023-12-30 18:41:25 -05:00
|
|
|
|
|
|
|
return false;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2023-04-24 22:32:12 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
showText(text: string, delay?: integer, callback?: Function, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer) {
|
|
|
|
super.showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (text?.indexOf("\n") === -1) {
|
2024-02-14 10:44:55 -05:00
|
|
|
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-19 23:51:48 -05:00
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-05-28 14:49:15 -03:00
|
|
|
/**
|
|
|
|
* Determines if 'Icon' based upgrade notifications should be shown
|
|
|
|
* @returns true if upgrade notifications are enabled and set to display an 'Icon'
|
|
|
|
*/
|
|
|
|
isUpgradeIconEnabled(): boolean {
|
|
|
|
return this.scene.candyUpgradeNotification !== 0 && this.scene.candyUpgradeDisplay === 0;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Determines if 'Animation' based upgrade notifications should be shown
|
|
|
|
* @returns true if upgrade notifications are enabled and set to display an 'Animation'
|
|
|
|
*/
|
|
|
|
isUpgradeAnimationEnabled(): boolean {
|
|
|
|
return this.scene.candyUpgradeNotification !== 0 && this.scene.candyUpgradeDisplay === 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if a passive upgrade is available for the given species ID
|
|
|
|
* @param speciesId The ID of the species to check the passive of
|
|
|
|
* @returns true if the user has enough candies and a passive has not been unlocked already
|
|
|
|
*/
|
|
|
|
isPassiveAvailable(speciesId: number): boolean {
|
|
|
|
// Get this species ID's starter data
|
|
|
|
const starterData = this.scene.gameData.starterData[speciesId];
|
|
|
|
|
|
|
|
return starterData.candyCount >= getPassiveCandyCount(speciesStarters[speciesId])
|
|
|
|
&& !(starterData.passiveAttr & PassiveAttr.UNLOCKED);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if a value reduction upgrade is available for the given species ID
|
|
|
|
* @param speciesId The ID of the species to check the value reduction of
|
|
|
|
* @returns true if the user has enough candies and all value reductions have not been unlocked already
|
|
|
|
*/
|
|
|
|
isValueReductionAvailable(speciesId: number): boolean {
|
|
|
|
// Get this species ID's starter data
|
|
|
|
const starterData = this.scene.gameData.starterData[speciesId];
|
|
|
|
|
|
|
|
return starterData.candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[starterData.valueReduction]
|
|
|
|
&& starterData.valueReduction < 2;
|
|
|
|
}
|
|
|
|
|
2024-06-22 02:19:56 +02:00
|
|
|
/**
|
|
|
|
* Determines if an same species egg can be baught for the given species ID
|
|
|
|
* @param speciesId The ID of the species to check the value reduction of
|
|
|
|
* @returns true if the user has enough candies
|
|
|
|
*/
|
|
|
|
isSameSpeciesEggAvailable(speciesId: number): boolean {
|
|
|
|
// Get this species ID's starter data
|
|
|
|
const starterData = this.scene.gameData.starterData[speciesId];
|
|
|
|
|
|
|
|
return starterData.candyCount >= getSameSpeciesEggCandyCounts(speciesStarters[speciesId]);
|
|
|
|
}
|
|
|
|
|
2024-05-28 14:49:15 -03:00
|
|
|
/**
|
|
|
|
* Sets a bounce animation if enabled and the Pokemon has an upgrade
|
|
|
|
* @param icon {@linkcode Phaser.GameObjects.GameObject} to animate
|
|
|
|
* @param species {@linkcode PokemonSpecies} of the icon used to check for upgrades
|
|
|
|
* @param startPaused Should this animation be paused after it is added?
|
|
|
|
*/
|
|
|
|
setUpgradeAnimation(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, startPaused: boolean = false): void {
|
|
|
|
this.scene.tweens.killTweensOf(icon);
|
|
|
|
// Skip animations if they are disabled
|
|
|
|
if (this.scene.candyUpgradeDisplay === 0 || species.speciesId !== species.getRootSpeciesId(false)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const position = calcSpritePosition(this.genSpecies[species.generation - 1].indexOf(species));
|
|
|
|
icon.y = position.y;
|
|
|
|
|
|
|
|
const tweenChain: Phaser.Types.Tweens.TweenChainBuilderConfig = {
|
|
|
|
targets: icon,
|
|
|
|
loop: -1,
|
|
|
|
// Make the initial bounce a little randomly delayed
|
|
|
|
delay: Utils.randIntRange(0, 50) * 5,
|
|
|
|
loopDelay: 1000,
|
|
|
|
tweens: [
|
|
|
|
{
|
|
|
|
targets: icon,
|
|
|
|
y: position.y - 5,
|
|
|
|
duration: Utils.fixedInt(125),
|
|
|
|
ease: "Cubic.easeOut",
|
|
|
|
yoyo: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
targets: icon,
|
|
|
|
y: position.y - 3,
|
|
|
|
duration: Utils.fixedInt(150),
|
|
|
|
ease: "Cubic.easeOut",
|
|
|
|
yoyo: true
|
|
|
|
}
|
|
|
|
],};
|
|
|
|
|
|
|
|
const passiveAvailable = this.isPassiveAvailable(species.speciesId);
|
|
|
|
// 'Only Passives' mode
|
|
|
|
if (this.scene.candyUpgradeNotification === 1) {
|
|
|
|
if (passiveAvailable) {
|
|
|
|
this.scene.tweens.chain(tweenChain).paused = startPaused;
|
|
|
|
}
|
|
|
|
// 'On' mode
|
|
|
|
} else if (this.scene.candyUpgradeNotification === 2) {
|
|
|
|
if (passiveAvailable || this.isValueReductionAvailable(species.speciesId)) {
|
|
|
|
this.scene.tweens.chain(tweenChain).paused = startPaused;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the visibility of a Candy Upgrade Icon given an index
|
|
|
|
* @param index The UI index of the icon within this generation container
|
|
|
|
*/
|
|
|
|
setUpgradeIcon(index: number): void {
|
|
|
|
const species = this.genSpecies[this.getGenCursorWithScroll()][index];
|
|
|
|
const slotVisible = !!species?.speciesId;
|
|
|
|
|
|
|
|
if (!species // No Pokemon exists at that UI index
|
|
|
|
|| this.scene.candyUpgradeNotification === 0 // Notification setting is 'Off'
|
2024-05-28 14:22:59 -05:00
|
|
|
|| species.speciesId !== species.getRootSpeciesId(false)) { // Pokemon is not the base evolution and can't use candy
|
2024-05-28 14:49:15 -03:00
|
|
|
// Set all icons as hidden and exit early
|
|
|
|
this.candyUpgradeIcon[index].setVisible(false);
|
|
|
|
this.candyUpgradeOverlayIcon[index].setVisible(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const passiveAvailable = this.isPassiveAvailable(species.speciesId);
|
|
|
|
// 'Only Passive Unlocks' mode
|
|
|
|
if (this.scene.candyUpgradeNotification === 1) {
|
|
|
|
this.candyUpgradeIcon[index].setVisible(slotVisible && passiveAvailable);
|
|
|
|
this.candyUpgradeOverlayIcon[index].setVisible(slotVisible && this.candyUpgradeIcon[index].visible);
|
|
|
|
|
|
|
|
// 'On' mode
|
|
|
|
} else if (this.scene.candyUpgradeNotification === 2) {
|
|
|
|
this.candyUpgradeIcon[index].setVisible(
|
|
|
|
slotVisible && ( passiveAvailable || this.isValueReductionAvailable(species.speciesId)));
|
|
|
|
this.candyUpgradeOverlayIcon[index].setVisible(slotVisible && this.candyUpgradeIcon[index].visible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes an {@linkcode CandyUpgradeNotificationChangedEvent} sent when the corresponding setting changes
|
|
|
|
* @param event {@linkcode Event} sent by the callback
|
|
|
|
*/
|
|
|
|
onCandyUpgradeDisplayChanged(event: Event): void {
|
|
|
|
const candyUpgradeDisplayEvent = event as CandyUpgradeNotificationChangedEvent;
|
|
|
|
if (!candyUpgradeDisplayEvent) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loop through all visible candy icons when set to 'Icon' mode
|
|
|
|
if (this.scene.candyUpgradeDisplay === 0) {
|
|
|
|
this.genSpecies[this.getGenCursorWithScroll()].forEach((_species, s) => {
|
|
|
|
this.setUpgradeIcon(s);
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loop through all animations when set to 'Animation' mode
|
|
|
|
for (let g = 0; g < this.genSpecies.length; g++) {
|
|
|
|
this.genSpecies[g].forEach((species, s) => {
|
|
|
|
const icon = this.starterSelectGenIconContainers[g].getAt(s) as Phaser.GameObjects.Sprite;
|
|
|
|
|
|
|
|
this.setUpgradeAnimation(icon, species);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
processInput(button: Button): boolean {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.blockInput) {
|
2024-04-17 14:49:18 -04:00
|
|
|
return false;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-17 14:49:18 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
const ui = this.getUi();
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
let success = false;
|
|
|
|
let error = false;
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-01-01 13:41:46 -05:00
|
|
|
if (button === Button.SUBMIT) {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.tryStart(true)) {
|
2024-01-01 13:41:46 -05:00
|
|
|
success = true;
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
2024-01-02 17:31:44 -05:00
|
|
|
error = true;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-03-15 15:13:32 -04:00
|
|
|
} 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 {
|
2024-04-17 14:49:18 -04:00
|
|
|
this.blockInput = true;
|
2024-03-15 15:13:32 -04:00
|
|
|
this.scene.clearPhaseQueue();
|
2024-06-08 15:07:23 +10:00
|
|
|
if (this.scene.gameMode.isChallenge) {
|
|
|
|
this.scene.pushPhase(new SelectChallengePhase(this.scene));
|
|
|
|
} else {
|
|
|
|
this.scene.pushPhase(new TitlePhase(this.scene));
|
|
|
|
}
|
2024-03-15 15:13:32 -04:00
|
|
|
this.scene.getCurrentPhase().end();
|
|
|
|
success = true;
|
|
|
|
}
|
2024-01-01 13:41:46 -05:00
|
|
|
} else if (this.startCursorObj.visible) {
|
2023-12-19 23:51:48 -05:00
|
|
|
switch (button) {
|
2024-05-23 17:03:10 +02:00
|
|
|
case Button.ACTION:
|
|
|
|
if (this.tryStart(true)) {
|
2024-04-04 16:19:45 -04:00
|
|
|
success = true;
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.UP:
|
|
|
|
this.startCursorObj.setVisible(false);
|
|
|
|
this.setGenMode(true);
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
case Button.LEFT:
|
|
|
|
this.startCursorObj.setVisible(false);
|
|
|
|
this.setGenMode(false);
|
|
|
|
this.setCursor(this.cursor + 8);
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
case Button.RIGHT:
|
|
|
|
this.startCursorObj.setVisible(false);
|
|
|
|
this.setGenMode(false);
|
|
|
|
success = true;
|
|
|
|
break;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
|
|
|
} else if (this.genMode) {
|
|
|
|
switch (button) {
|
2024-05-23 17:03:10 +02:00
|
|
|
case Button.UP:
|
|
|
|
if (this.genCursor) {
|
|
|
|
success = this.setCursor(this.genCursor - 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.DOWN:
|
|
|
|
if (this.genCursor < 2) {
|
|
|
|
success = this.setCursor(this.genCursor + 1);
|
|
|
|
} else {
|
|
|
|
this.startCursorObj.setVisible(true);
|
|
|
|
this.setGenMode(true);
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.LEFT:
|
|
|
|
success = this.setGenMode(false);
|
|
|
|
this.setCursor(this.cursor + 8);
|
|
|
|
break;
|
|
|
|
case Button.RIGHT:
|
|
|
|
success = this.setGenMode(false);
|
|
|
|
break;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (button === Button.ACTION) {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!this.speciesStarterDexEntry?.caughtAttr) {
|
2023-12-19 23:51:48 -05:00
|
|
|
error = true;
|
2024-05-23 17:03:10 +02:00
|
|
|
} else if (this.starterCursors.length < 6) {
|
2024-02-21 01:03:34 -05:00
|
|
|
const options = [
|
|
|
|
{
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("starterSelectUiHandler:addToParty"),
|
2024-02-21 01:03:34 -05:00
|
|
|
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;
|
2024-01-11 12:26:32 -05:00
|
|
|
}
|
|
|
|
}
|
2024-02-21 01:03:34 -05:00
|
|
|
const species = this.genSpecies[this.getGenCursorWithScroll()][this.cursor];
|
2024-06-08 15:07:23 +10:00
|
|
|
|
|
|
|
const isValidForChallenge = new Utils.BooleanHolder(true);
|
2024-06-18 23:27:06 +10:00
|
|
|
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor), this.starterGens.length);
|
2024-06-08 15:07:23 +10:00
|
|
|
|
|
|
|
if (!isDupe && isValidForChallenge.value && this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId))) {
|
2024-02-21 01:03:34 -05: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);
|
2024-04-18 22:52:26 -04:00
|
|
|
this.starterIcons[this.starterCursors.length].setTexture(species.getIconAtlasKey(props.formIndex, props.shiny, props.variant));
|
|
|
|
this.starterIcons[this.starterCursors.length].setFrame(species.getIconId(props.female, props.formIndex, props.shiny, props.variant));
|
2024-05-13 14:23:34 -04:00
|
|
|
this.checkIconId(this.starterIcons[this.starterCursors.length], species, props.female, props.formIndex, props.shiny, props.variant);
|
2024-02-21 01:03:34 -05:00
|
|
|
this.starterGens.push(this.getGenCursorWithScroll());
|
|
|
|
this.starterCursors.push(this.cursor);
|
|
|
|
this.starterAttr.push(this.dexAttrCursor);
|
2024-04-19 08:40:49 -04:00
|
|
|
this.starterAbilityIndexes.push(this.abilityCursor);
|
2024-02-21 01:03:34 -05:00
|
|
|
this.starterNatures.push(this.natureCursor as unknown as Nature);
|
|
|
|
this.starterMovesets.push(this.starterMoveset.slice(0) as StarterMoveset);
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.speciesLoaded.get(species.speciesId)) {
|
2024-04-04 08:38:10 -04:00
|
|
|
getPokemonSpeciesForm(species.speciesId, props.formIndex).cry(this.scene);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (this.starterCursors.length === 6 || this.value === this.getValueLimit()) {
|
2024-02-21 01:03:34 -05:00
|
|
|
this.tryStart();
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-02-21 01:03:34 -05:00
|
|
|
this.updateInstructions();
|
2024-06-07 00:12:19 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the user can't select a pokemon anymore,
|
|
|
|
* go to start button.
|
|
|
|
*/
|
|
|
|
if (!this.canAddParty) {
|
|
|
|
this.startCursorObj.setVisible(true);
|
|
|
|
this.setGenMode(true);
|
|
|
|
}
|
|
|
|
|
2024-02-21 01:03:34 -05:00
|
|
|
ui.playSelect();
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
2024-02-21 01:03:34 -05:00
|
|
|
ui.playError();
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
2024-02-20 22:53:33 -05:00
|
|
|
},
|
2024-02-21 01:03:34 -05:00
|
|
|
overrideSound: true
|
|
|
|
},
|
|
|
|
{
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("starterSelectUiHandler:toggleIVs"),
|
2024-02-21 01:03:34 -05:00
|
|
|
handler: () => {
|
|
|
|
this.toggleStatsMode();
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
2024-02-21 01:03:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
if (this.speciesStarterMoves.length > 1) {
|
|
|
|
const showSwapOptions = (moveset: StarterMoveset) => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT).then(() => {
|
2024-05-06 18:02:45 +02:00
|
|
|
ui.showText(i18next.t("starterSelectUiHandler:selectMoveSwapOut"), null, () => {
|
2024-06-06 03:28:12 +02:00
|
|
|
this.moveInfoOverlay.show(allMoves[moveset[0]]);
|
|
|
|
|
2024-02-21 01:03:34 -05:00
|
|
|
ui.setModeWithoutClear(Mode.OPTION_SELECT, {
|
2024-04-08 08:25:58 -04:00
|
|
|
options: moveset.map((m: Moves, i: number) => {
|
2024-04-13 18:59:58 -04:00
|
|
|
const option: OptionSelectItem = {
|
2024-02-21 01:03:34 -05:00
|
|
|
label: allMoves[m].name,
|
|
|
|
handler: () => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT).then(() => {
|
2024-05-06 18:02:45 +02:00
|
|
|
ui.showText(`${i18next.t("starterSelectUiHandler:selectMoveSwapWith")} ${allMoves[m].name}.`, null, () => {
|
2024-06-06 03:28:12 +02:00
|
|
|
const possibleMoves = this.speciesStarterMoves.filter((sm: Moves) => sm !== m);
|
|
|
|
this.moveInfoOverlay.show(allMoves[possibleMoves[0]]);
|
|
|
|
|
2024-02-21 01:03:34 -05:00
|
|
|
ui.setModeWithoutClear(Mode.OPTION_SELECT, {
|
2024-06-06 03:28:12 +02:00
|
|
|
options: possibleMoves.map(sm => {
|
2024-04-07 21:58:11 -04:00
|
|
|
// make an option for each available starter move
|
2024-04-13 18:59:58 -04:00
|
|
|
const option = {
|
2024-02-21 01:03:34 -05:00
|
|
|
label: allMoves[sm].name,
|
|
|
|
handler: () => {
|
2024-05-23 17:03:10 +02:00
|
|
|
this.switchMoveHandler(i, sm, m);
|
2024-02-21 01:03:34 -05:00
|
|
|
showSwapOptions(this.starterMoveset);
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
2024-06-06 03:28:12 +02:00
|
|
|
},
|
|
|
|
onHover: () => {
|
|
|
|
this.moveInfoOverlay.show(allMoves[sm]);
|
|
|
|
},
|
2024-02-21 01:03:34 -05:00
|
|
|
};
|
2024-04-13 18:59:58 -04:00
|
|
|
return option;
|
2024-02-21 01:03:34 -05:00
|
|
|
}).concat({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("menu:cancel"),
|
2024-04-13 18:59:58 -04:00
|
|
|
handler: () => {
|
|
|
|
showSwapOptions(this.starterMoveset);
|
|
|
|
return true;
|
2024-06-06 03:28:12 +02:00
|
|
|
},
|
|
|
|
onHover: () => {
|
|
|
|
this.moveInfoOverlay.clear();
|
|
|
|
},
|
2024-02-21 01:03:34 -05:00
|
|
|
}),
|
2024-06-06 03:28:12 +02:00
|
|
|
supportHover: true,
|
2024-02-21 15:47:44 -05:00
|
|
|
maxOptions: 8,
|
2024-02-21 01:03:34 -05:00
|
|
|
yOffset: 19
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
2024-06-06 03:28:12 +02:00
|
|
|
},
|
|
|
|
onHover: () => {
|
|
|
|
this.moveInfoOverlay.show(allMoves[m]);
|
|
|
|
},
|
2024-04-13 18:59:58 -04:00
|
|
|
};
|
|
|
|
return option;
|
2024-02-21 01:03:34 -05:00
|
|
|
}).concat({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("menu:cancel"),
|
2024-02-21 01:03:34 -05:00
|
|
|
handler: () => {
|
2024-06-06 03:28:12 +02:00
|
|
|
this.moveInfoOverlay.clear();
|
2024-02-21 01:03:34 -05:00
|
|
|
this.clearText();
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
2024-06-06 03:28:12 +02:00
|
|
|
},
|
|
|
|
onHover: () => {
|
|
|
|
this.moveInfoOverlay.clear();
|
|
|
|
},
|
2024-02-21 01:03:34 -05:00
|
|
|
}),
|
2024-06-06 03:28:12 +02:00
|
|
|
supportHover: true,
|
2024-02-21 15:47:44 -05:00
|
|
|
maxOptions: 8,
|
2024-02-21 01:03:34 -05:00
|
|
|
yOffset: 19
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("starterSelectUiHandler:manageMoves"),
|
2024-02-21 01:03:34 -05:00
|
|
|
handler: () => {
|
|
|
|
showSwapOptions(this.starterMoveset);
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2024-04-13 19:21:59 -04:00
|
|
|
}
|
|
|
|
const starterData = this.scene.gameData.starterData[this.lastSpecies.speciesId];
|
2024-06-17 06:49:29 +02:00
|
|
|
let starterAttributes = this.starterPreferences[this.lastSpecies.speciesId];
|
|
|
|
if (this.canCycleNature) {
|
|
|
|
// if we could cycle natures, enable the improved nature menu
|
|
|
|
const showNatureOptions = () => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT).then(() => {
|
|
|
|
ui.showText(i18next.t("starterSelectUiHandler:selectNature"), null, () => {
|
|
|
|
const natures = this.scene.gameData.getNaturesForAttr(this.speciesStarterDexEntry.natureAttr);
|
|
|
|
ui.setModeWithoutClear(Mode.OPTION_SELECT, {
|
|
|
|
options: natures.map((n: Nature, i: number) => {
|
|
|
|
const option: OptionSelectItem = {
|
|
|
|
label: getNatureName(n, true, true, true, this.scene.uiTheme),
|
|
|
|
handler: () => {
|
|
|
|
// update default nature in starter save data
|
|
|
|
if (!starterAttributes) {
|
|
|
|
starterAttributes=
|
|
|
|
this.starterPreferences[this.lastSpecies.speciesId] = {};
|
|
|
|
}
|
|
|
|
starterAttributes.nature = n as unknown as integer;
|
|
|
|
this.clearText();
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
|
|
|
// set nature for starter
|
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, n, undefined);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return option;
|
|
|
|
}).concat({
|
|
|
|
label: i18next.t("menu:cancel"),
|
|
|
|
handler: () => {
|
|
|
|
this.clearText();
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
maxOptions: 8,
|
|
|
|
yOffset: 19
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
options.push({
|
|
|
|
label: i18next.t("starterSelectUiHandler:manageNature"),
|
|
|
|
handler: () => {
|
|
|
|
showNatureOptions();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-04-13 19:21:59 -04:00
|
|
|
const candyCount = starterData.candyCount;
|
|
|
|
const passiveAttr = starterData.passiveAttr;
|
|
|
|
if (passiveAttr & PassiveAttr.UNLOCKED) {
|
|
|
|
if (!(passiveAttr & PassiveAttr.ENABLED)) {
|
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("starterSelectUiHandler:enablePassive"),
|
2024-04-13 19:21:59 -04:00
|
|
|
handler: () => {
|
|
|
|
starterData.passiveAttr |= PassiveAttr.ENABLED;
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined);
|
2024-04-13 19:21:59 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("starterSelectUiHandler:disablePassive"),
|
2024-04-13 19:21:59 -04:00
|
|
|
handler: () => {
|
|
|
|
starterData.passiveAttr ^= PassiveAttr.ENABLED;
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined);
|
2024-04-13 19:21:59 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const showUseCandies = () => {
|
|
|
|
const options = [];
|
|
|
|
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
|
|
|
|
const passiveCost = getPassiveCandyCount(speciesStarters[this.lastSpecies.speciesId]);
|
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: `x${passiveCost} ${i18next.t("starterSelectUiHandler:unlockPassive")} (${allAbilities[starterPassiveAbilities[this.lastSpecies.speciesId]].name})`,
|
2024-04-13 19:21:59 -04:00
|
|
|
handler: () => {
|
2024-06-22 02:19:56 +02:00
|
|
|
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= passiveCost) {
|
2024-04-13 19:21:59 -04:00
|
|
|
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
|
2024-06-22 02:19:56 +02:00
|
|
|
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
|
|
|
|
starterData.candyCount -= passiveCost;
|
|
|
|
}
|
2024-04-13 19:21:59 -04:00
|
|
|
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
|
|
|
|
this.scene.gameData.saveSystem().then(success => {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!success) {
|
2024-04-13 19:21:59 -04:00
|
|
|
return this.scene.reset(true);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-13 19:21:59 -04:00
|
|
|
});
|
2024-04-13 18:59:58 -04:00
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined);
|
2024-05-28 14:49:15 -03:00
|
|
|
|
|
|
|
// Update the candy upgrade display
|
|
|
|
if (this.isUpgradeIconEnabled() ) {
|
|
|
|
this.setUpgradeIcon(this.cursor);
|
|
|
|
}
|
|
|
|
if (this.isUpgradeAnimationEnabled()) {
|
|
|
|
const genSpecies = this.genSpecies[this.lastSpecies.generation - 1];
|
|
|
|
this.setUpgradeAnimation(this.starterSelectGenIconContainers[this.lastSpecies.generation - 1].getAt(genSpecies.indexOf(this.lastSpecies)), this.lastSpecies, true);
|
|
|
|
}
|
|
|
|
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
|
|
|
}
|
2024-04-13 19:21:59 -04:00
|
|
|
return false;
|
|
|
|
},
|
2024-05-23 17:03:10 +02:00
|
|
|
item: "candy",
|
2024-04-13 19:21:59 -04:00
|
|
|
itemArgs: starterColors[this.lastSpecies.speciesId]
|
|
|
|
});
|
2024-04-13 18:59:58 -04:00
|
|
|
}
|
2024-04-13 19:21:59 -04:00
|
|
|
const valueReduction = starterData.valueReduction;
|
|
|
|
if (valueReduction < 2) {
|
|
|
|
const reductionCost = getValueReductionCandyCounts(speciesStarters[this.lastSpecies.speciesId])[valueReduction];
|
2024-04-13 18:59:58 -04:00
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: `x${reductionCost} ${i18next.t("starterSelectUiHandler:reduceCost")}`,
|
2024-04-13 18:59:58 -04:00
|
|
|
handler: () => {
|
2024-06-22 02:19:56 +02:00
|
|
|
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= reductionCost) {
|
2024-04-13 19:21:59 -04:00
|
|
|
starterData.valueReduction++;
|
2024-06-22 02:19:56 +02:00
|
|
|
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
|
|
|
|
starterData.candyCount -= reductionCost;
|
|
|
|
}
|
2024-04-13 19:21:59 -04:00
|
|
|
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
|
|
|
|
this.scene.gameData.saveSystem().then(success => {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!success) {
|
2024-04-13 19:21:59 -04:00
|
|
|
return this.scene.reset(true);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-13 19:21:59 -04:00
|
|
|
});
|
|
|
|
this.updateStarterValueLabel(this.cursor);
|
|
|
|
this.tryUpdateValue(0);
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-05-23 17:03:10 +02:00
|
|
|
this.scene.playSound("buy");
|
2024-05-28 14:49:15 -03:00
|
|
|
|
|
|
|
// If the notification setting is set to 'On', update the candy upgrade display
|
|
|
|
if (this.scene.candyUpgradeNotification === 2) {
|
|
|
|
if (this.isUpgradeIconEnabled() ) {
|
|
|
|
this.setUpgradeIcon(this.cursor);
|
|
|
|
}
|
|
|
|
if (this.isUpgradeAnimationEnabled()) {
|
|
|
|
const genSpecies = this.genSpecies[this.lastSpecies.generation - 1];
|
|
|
|
this.setUpgradeAnimation(this.starterSelectGenIconContainers[this.lastSpecies.generation - 1].getAt(genSpecies.indexOf(this.lastSpecies)), this.lastSpecies, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-13 19:21:59 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2024-05-23 17:03:10 +02:00
|
|
|
item: "candy",
|
2024-04-13 19:21:59 -04:00
|
|
|
itemArgs: starterColors[this.lastSpecies.speciesId]
|
2024-04-13 18:59:58 -04:00
|
|
|
});
|
2024-04-13 19:21:59 -04:00
|
|
|
}
|
2024-06-22 02:19:56 +02:00
|
|
|
|
|
|
|
// Same species egg menu option. Only visible if passive is bought
|
|
|
|
if (passiveAttr & PassiveAttr.UNLOCKED) {
|
|
|
|
const sameSpeciesEggCost = getSameSpeciesEggCandyCounts(speciesStarters[this.lastSpecies.speciesId]);
|
|
|
|
options.push({
|
|
|
|
label: `x${sameSpeciesEggCost} ${i18next.t("starterSelectUiHandler:sameSpeciesEgg")}`,
|
|
|
|
handler: () => {
|
|
|
|
if (this.scene.gameData.eggs.length < 99 && (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost)) {
|
|
|
|
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
|
|
|
|
starterData.candyCount -= sameSpeciesEggCost;
|
|
|
|
}
|
|
|
|
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
|
|
|
|
this.scene.gameData.saveSystem().then(success => {
|
|
|
|
if (!success) {
|
|
|
|
return this.scene.reset(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const egg = new Egg({scene: this.scene, species: this.lastSpecies.speciesId, sourceType: EggSourceType.SAME_SPECIES_EGG});
|
|
|
|
egg.addEggToGameData(this.scene);
|
|
|
|
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
|
|
|
this.scene.playSound("buy");
|
|
|
|
|
|
|
|
// If the notification setting is set to 'On', update the candy upgrade display
|
|
|
|
// if (this.scene.candyUpgradeNotification === 2) {
|
|
|
|
// if (this.isUpgradeIconEnabled() ) {
|
|
|
|
// this.setUpgradeIcon(this.cursor);
|
|
|
|
// }
|
|
|
|
// if (this.isUpgradeAnimationEnabled()) {
|
|
|
|
// const genSpecies = this.genSpecies[this.lastSpecies.generation - 1];
|
|
|
|
// this.setUpgradeAnimation(this.starterSelectGenIconContainers[this.lastSpecies.generation - 1].getAt(genSpecies.indexOf(this.lastSpecies)), this.lastSpecies, true);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
item: "candy",
|
|
|
|
itemArgs: starterColors[this.lastSpecies.speciesId]
|
|
|
|
});
|
|
|
|
}
|
2024-04-13 18:59:58 -04:00
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("menu:cancel"),
|
2024-04-13 18:59:58 -04:00
|
|
|
handler: () => {
|
2024-04-13 19:21:59 -04:00
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2024-02-21 01:03:34 -05:00
|
|
|
});
|
2024-04-13 19:21:59 -04:00
|
|
|
ui.setModeWithoutClear(Mode.OPTION_SELECT, {
|
|
|
|
options: options,
|
|
|
|
yOffset: 47
|
|
|
|
});
|
|
|
|
};
|
2024-04-13 19:36:43 -04:00
|
|
|
if (!pokemonPrevolutions.hasOwnProperty(this.lastSpecies.speciesId)) {
|
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("starterSelectUiHandler:useCandies"),
|
2024-04-13 19:36:43 -04:00
|
|
|
handler: () => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT).then(() => showUseCandies());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-02-21 01:03:34 -05:00
|
|
|
options.push({
|
2024-05-06 18:02:45 +02:00
|
|
|
label: i18next.t("menu:cancel"),
|
2024-02-21 01:03:34 -05:00
|
|
|
handler: () => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-04-13 18:59:58 -04:00
|
|
|
return true;
|
2024-02-21 01:03:34 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
ui.setModeWithoutClear(Mode.OPTION_SELECT, {
|
|
|
|
options: options,
|
2024-02-06 23:11:00 -05:00
|
|
|
yOffset: 47
|
2023-12-19 23:51:48 -05:00
|
|
|
});
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
} 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);
|
2024-06-17 06:49:29 +02:00
|
|
|
// prepare persistent starter data to store changes
|
|
|
|
let starterAttributes = this.starterPreferences[this.lastSpecies.speciesId];
|
|
|
|
if (!starterAttributes) {
|
|
|
|
starterAttributes =
|
|
|
|
this.starterPreferences[this.lastSpecies.speciesId] = {};
|
|
|
|
}
|
2023-12-01 17:23:26 -05:00
|
|
|
switch (button) {
|
2024-05-23 17:03:10 +02:00
|
|
|
case Button.CYCLE_SHINY:
|
|
|
|
if (this.canCycleShiny) {
|
2024-06-17 06:49:29 +02:00
|
|
|
starterAttributes.variant = !props.shiny ? props.variant : -1; // update shiny setting
|
2024-05-23 17:03:10 +02:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, !props.shiny, undefined, undefined, props.shiny ? 0 : undefined, undefined, undefined);
|
|
|
|
if (this.dexAttrCursor & DexAttr.SHINY) {
|
|
|
|
this.scene.playSound("sparkle");
|
|
|
|
} else {
|
2023-12-19 23:51:48 -05:00
|
|
|
success = true;
|
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.CYCLE_FORM:
|
|
|
|
if (this.canCycleForm) {
|
|
|
|
const formCount = this.lastSpecies.forms.length;
|
|
|
|
let newFormIndex = props.formIndex;
|
|
|
|
do {
|
|
|
|
newFormIndex = (newFormIndex + 1) % formCount;
|
2024-05-25 22:31:42 -05:00
|
|
|
if (this.lastSpecies.forms[newFormIndex].isStarterSelectable && this.speciesStarterDexEntry.caughtAttr & this.scene.gameData.getFormAttr(newFormIndex)) {
|
2024-05-23 17:03:10 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (newFormIndex !== props.formIndex);
|
2024-06-17 06:49:29 +02:00
|
|
|
starterAttributes.form = newFormIndex; // store the selected form
|
2024-05-23 17:03:10 +02:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, newFormIndex, undefined, undefined, undefined, undefined);
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.CYCLE_GENDER:
|
|
|
|
if (this.canCycleGender) {
|
2024-06-17 06:49:29 +02:00
|
|
|
starterAttributes.female = !props.female;
|
2024-05-23 17:03:10 +02:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, !props.female, undefined, undefined, undefined);
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.CYCLE_ABILITY:
|
|
|
|
if (this.canCycleAbility) {
|
|
|
|
const abilityCount = this.lastSpecies.getAbilityCount();
|
|
|
|
const abilityAttr = this.scene.gameData.starterData[this.lastSpecies.speciesId].abilityAttr;
|
|
|
|
let newAbilityIndex = this.abilityCursor;
|
|
|
|
do {
|
|
|
|
newAbilityIndex = (newAbilityIndex + 1) % abilityCount;
|
|
|
|
if (!newAbilityIndex) {
|
|
|
|
if (abilityAttr & AbilityAttr.ABILITY_1) {
|
|
|
|
break;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
} else if (newAbilityIndex === 1) {
|
|
|
|
if (abilityAttr & (this.lastSpecies.ability2 ? AbilityAttr.ABILITY_2 : AbilityAttr.ABILITY_HIDDEN)) {
|
|
|
|
break;
|
2024-04-18 22:52:26 -04:00
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
|
|
|
if (abilityAttr & AbilityAttr.ABILITY_HIDDEN) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (newAbilityIndex !== this.abilityCursor);
|
2024-06-17 06:49:29 +02:00
|
|
|
starterAttributes.ability = newAbilityIndex; // store the selected ability
|
2024-05-23 17:03:10 +02:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, 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];
|
2024-06-17 06:49:29 +02:00
|
|
|
// store cycled nature as default
|
|
|
|
starterAttributes.nature = newNature as unknown as integer;
|
2024-05-23 17:03:10 +02:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, newNature, undefined);
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
2024-05-29 19:29:59 -05:00
|
|
|
case Button.V:
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.canCycleVariant) {
|
|
|
|
let newVariant = props.variant;
|
|
|
|
do {
|
|
|
|
newVariant = (newVariant + 1) % 3;
|
|
|
|
if (!newVariant) {
|
|
|
|
if (this.speciesStarterDexEntry.caughtAttr & DexAttr.DEFAULT_VARIANT) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (newVariant === 1) {
|
|
|
|
if (this.speciesStarterDexEntry.caughtAttr & DexAttr.VARIANT_2) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this.speciesStarterDexEntry.caughtAttr & DexAttr.VARIANT_3) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (newVariant !== props.variant);
|
2024-06-17 06:49:29 +02:00
|
|
|
starterAttributes.variant = newVariant; // store the selected variant
|
2024-05-23 17:03:10 +02:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, newVariant, undefined, undefined);
|
2024-06-14 11:01:11 -04:00
|
|
|
|
|
|
|
// Cycle tint based on current sprite tint
|
|
|
|
const tint = getVariantTint(newVariant);
|
|
|
|
this.variantLabel.setTint(tint);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.UP:
|
|
|
|
if (row) {
|
|
|
|
success = this.setCursor(this.cursor - 9);
|
2024-05-31 00:27:53 +02:00
|
|
|
} else {
|
|
|
|
// when strictly opposite starter based on rows length
|
|
|
|
// does not exits, set cursor on the second to last row
|
|
|
|
if (this.cursor + (rows - 1) * 9 > genStarters - 1) {
|
|
|
|
success = this.setCursor(this.cursor + (rows - 2) * 9);
|
|
|
|
} else {
|
|
|
|
success = this.setCursor(this.cursor + (rows - 1) * 9);
|
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.DOWN:
|
|
|
|
if (row < rows - 2 || (row < rows - 1 && this.cursor % 9 <= (genStarters - 1) % 9)) {
|
|
|
|
success = this.setCursor(this.cursor + 9);
|
2024-05-31 00:27:53 +02:00
|
|
|
} else {
|
|
|
|
// if there is no starter below while being on the second to
|
|
|
|
// last row, adjust cursor position with one line less
|
|
|
|
if (row === rows - 2 && this.cursor + 9 > genStarters - 1) {
|
|
|
|
success = this.setCursor(this.cursor - (rows - 2) * 9);
|
|
|
|
} else {
|
|
|
|
success = this.setCursor(this.cursor - (rows - 1) * 9);
|
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.LEFT:
|
|
|
|
if (this.cursor % 9) {
|
|
|
|
success = this.setCursor(this.cursor - 1);
|
|
|
|
} else {
|
|
|
|
if (row >= Math.min(5, rows - 1)) {
|
|
|
|
this.startCursorObj.setVisible(true);
|
2023-12-01 17:23:26 -05:00
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
success = this.setGenMode(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Button.RIGHT:
|
|
|
|
if (this.cursor % 9 < (row < rows - 1 ? 8 : (genStarters - 1) % 9)) {
|
|
|
|
success = this.setCursor(this.cursor + 1);
|
|
|
|
} else {
|
|
|
|
if (row >= Math.min(5, rows - 1)) {
|
|
|
|
this.startCursorObj.setVisible(true);
|
2024-04-04 16:19:45 -04:00
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
success = this.setGenMode(true);
|
|
|
|
}
|
|
|
|
break;
|
2023-04-12 19:09:15 -04:00
|
|
|
}
|
2023-04-09 19:15:21 -04:00
|
|
|
}
|
2023-04-17 22:44:41 -04:00
|
|
|
}
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (success) {
|
2023-12-19 23:51:48 -05:00
|
|
|
ui.playSelect();
|
2024-05-23 17:03:10 +02:00
|
|
|
} else if (error) {
|
2023-12-19 23:51:48 -05:00
|
|
|
ui.playError();
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
return success || error;
|
|
|
|
}
|
2024-04-08 08:25:58 -04:00
|
|
|
|
2024-04-09 11:52:34 -04:00
|
|
|
switchMoveHandler(i: number, newMove: Moves, move: Moves) {
|
2024-04-08 08:25:58 -04:00
|
|
|
const speciesId = this.lastSpecies.speciesId;
|
|
|
|
const existingMoveIndex = this.starterMoveset.indexOf(newMove);
|
|
|
|
this.starterMoveset[i] = newMove;
|
2024-05-23 17:03:10 +02:00
|
|
|
if (existingMoveIndex > -1) {
|
2024-04-08 08:25:58 -04:00
|
|
|
this.starterMoveset[existingMoveIndex] = move;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-08 08:25:58 -04:00
|
|
|
const props: DexAttrProps = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.dexAttrCursor);
|
|
|
|
// species has different forms
|
|
|
|
if (pokemonFormLevelMoves.hasOwnProperty(speciesId)) {
|
2024-04-09 11:52:34 -04:00
|
|
|
// starterMoveData doesn't have base form moves or is using the single form format
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!this.scene.gameData.starterData[speciesId].moveset || Array.isArray(this.scene.gameData.starterData[speciesId].moveset)) {
|
2024-04-13 18:59:58 -04:00
|
|
|
this.scene.gameData.starterData[speciesId].moveset = { [props.formIndex]: this.starterMoveset.slice(0) as StarterMoveset };
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-05-09 15:39:45 +10:00
|
|
|
const starterMoveData = this.scene.gameData.starterData[speciesId].moveset;
|
2024-04-09 11:52:34 -04:00
|
|
|
|
2024-04-08 08:25:58 -04:00
|
|
|
// starterMoveData doesn't have active form moves
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!starterMoveData.hasOwnProperty(props.formIndex)) {
|
2024-04-13 18:59:58 -04:00
|
|
|
this.scene.gameData.starterData[speciesId].moveset[props.formIndex] = this.starterMoveset.slice(0) as StarterMoveset;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-09 11:52:34 -04:00
|
|
|
|
2024-04-08 08:25:58 -04:00
|
|
|
// does the species' starter move data have its form's starter moves and has it been updated
|
2024-04-09 11:52:34 -04:00
|
|
|
if (starterMoveData.hasOwnProperty(props.formIndex)) {
|
2024-04-08 08:25:58 -04:00
|
|
|
// active form move hasn't been updated
|
2024-05-23 17:03:10 +02:00
|
|
|
if (starterMoveData[props.formIndex][existingMoveIndex] !== newMove) {
|
2024-04-13 18:59:58 -04:00
|
|
|
this.scene.gameData.starterData[speciesId].moveset[props.formIndex] = this.starterMoveset.slice(0) as StarterMoveset;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-09 11:52:34 -04:00
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
2024-04-13 18:59:58 -04:00
|
|
|
this.scene.gameData.starterData[speciesId].moveset = this.starterMoveset.slice(0) as StarterMoveset;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined, false);
|
2024-04-08 08:25:58 -04:00
|
|
|
}
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-06-10 12:41:01 -04:00
|
|
|
updateButtonIcon(iconSetting, gamepadType, iconElement, controlLabel): void {
|
2024-06-08 21:35:11 -04:00
|
|
|
let iconPath;
|
|
|
|
// touch controls cannot be rebound as is, and are just emulating a keyboard event.
|
|
|
|
// Additionally, since keyboard controls can be rebound (and will be displayed when they are), we need to have special handling for the touch controls
|
|
|
|
if (gamepadType === "touch") {
|
|
|
|
gamepadType = "keyboard";
|
|
|
|
switch (iconSetting) {
|
|
|
|
case SettingKeyboard.Button_Cycle_Shiny:
|
|
|
|
iconPath = "R.png";
|
|
|
|
break;
|
|
|
|
case SettingKeyboard.Button_Cycle_Form:
|
|
|
|
iconPath = "F.png";
|
|
|
|
break;
|
|
|
|
case SettingKeyboard.Button_Cycle_Gender:
|
|
|
|
iconPath = "G.png";
|
|
|
|
break;
|
|
|
|
case SettingKeyboard.Button_Cycle_Ability:
|
|
|
|
iconPath = "E.png";
|
|
|
|
break;
|
|
|
|
case SettingKeyboard.Button_Cycle_Nature:
|
|
|
|
iconPath = "N.png";
|
|
|
|
break;
|
|
|
|
case SettingKeyboard.Button_Cycle_Variant:
|
|
|
|
iconPath = "V.png";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
iconPath = this.scene.inputController?.getIconForLatestInputRecorded(iconSetting);
|
|
|
|
}
|
2024-06-10 12:41:01 -04:00
|
|
|
iconElement.setTexture(gamepadType, iconPath);
|
|
|
|
iconElement.setPosition(this.instructionRowX, this.instructionRowY);
|
|
|
|
controlLabel.setPosition(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY);
|
2024-06-10 16:19:06 -04:00
|
|
|
iconElement.setVisible(true);
|
|
|
|
controlLabel.setVisible(true);
|
2024-06-08 21:35:11 -04:00
|
|
|
this.instructionsContainer.add([iconElement, controlLabel]);
|
|
|
|
this.instructionRowY += 8;
|
|
|
|
if (this.instructionRowY >= 24) {
|
|
|
|
this.instructionRowY = 0;
|
|
|
|
this.instructionRowX += 50;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
updateInstructions(): void {
|
2024-06-08 21:35:11 -04:00
|
|
|
this.instructionRowX = 0;
|
|
|
|
this.instructionRowY = 0;
|
2024-06-10 16:19:06 -04:00
|
|
|
this.hideInstructions();
|
2024-06-08 21:35:11 -04:00
|
|
|
this.instructionsContainer.removeAll();
|
|
|
|
let gamepadType;
|
|
|
|
if (this.scene.inputMethod === "gamepad") {
|
|
|
|
gamepadType = this.scene.inputController.getConfig(this.scene.inputController.selectedDevice[Device.GAMEPAD]).padType;
|
|
|
|
} else {
|
|
|
|
gamepadType = this.scene.inputMethod;
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
if (this.speciesStarterDexEntry?.caughtAttr) {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.canCycleShiny) {
|
2024-06-10 12:41:01 -04:00
|
|
|
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Shiny, gamepadType, this.shinyIconElement, this.shinyLabel);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (this.canCycleForm) {
|
2024-06-10 12:41:01 -04:00
|
|
|
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Form, gamepadType, this.formIconElement, this.formLabel);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (this.canCycleGender) {
|
2024-06-10 12:41:01 -04:00
|
|
|
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Gender, gamepadType, this.genderIconElement, this.genderLabel);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (this.canCycleAbility) {
|
2024-06-10 12:41:01 -04:00
|
|
|
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Ability, gamepadType, this.abilityIconElement, this.abilityLabel);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (this.canCycleNature) {
|
2024-06-10 12:41:01 -04:00
|
|
|
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Nature, gamepadType, this.natureIconElement, this.natureLabel);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (this.canCycleVariant) {
|
2024-06-10 12:41:01 -04:00
|
|
|
this.updateButtonIcon(SettingKeyboard.Button_Cycle_Variant, gamepadType, this.variantIconElement, this.variantLabel);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-04-06 23:50:26 -04:00
|
|
|
getValueLimit(): integer {
|
2024-06-08 15:07:23 +10:00
|
|
|
const valueLimit = new Utils.IntegerHolder(0);
|
|
|
|
switch (this.scene.gameMode.modeId) {
|
2024-05-23 17:03:10 +02:00
|
|
|
case GameModes.ENDLESS:
|
|
|
|
case GameModes.SPLICED_ENDLESS:
|
2024-06-08 15:07:23 +10:00
|
|
|
valueLimit.value = 15;
|
2024-06-08 15:31:31 +10:00
|
|
|
break;
|
2024-05-23 17:03:10 +02:00
|
|
|
default:
|
2024-06-08 15:07:23 +10:00
|
|
|
valueLimit.value = 10;
|
2024-04-06 23:50:26 -04:00
|
|
|
}
|
2024-06-08 15:07:23 +10:00
|
|
|
|
|
|
|
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_POINTS, valueLimit);
|
|
|
|
|
|
|
|
return valueLimit.value;
|
2024-04-06 23:50:26 -04:00
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
setCursor(cursor: integer): boolean {
|
|
|
|
let changed = false;
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
if (this.genMode) {
|
|
|
|
changed = this.genCursor !== cursor;
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
let genCursorWithScroll = this.getGenCursorWithScroll();
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
if (!cursor && this.genScrollCursor) {
|
|
|
|
this.genScrollCursor--;
|
|
|
|
cursor++;
|
|
|
|
this.updateGenOptions();
|
2024-01-01 10:14:49 -05:00
|
|
|
} else if (cursor === 2 && this.genScrollCursor < gens.length - 3) {
|
2023-12-19 23:51:48 -05:00
|
|
|
this.genScrollCursor++;
|
|
|
|
cursor--;
|
|
|
|
this.updateGenOptions();
|
2023-11-13 22:29:03 -05:00
|
|
|
}
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (genCursorWithScroll !== undefined) {
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterSelectGenIconContainers[genCursorWithScroll].setVisible(false);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
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);
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
for (let s = 0; s < this.starterCursorObjs.length; s++) {
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterCursorObjs[s].setVisible(this.starterGens[s] === genCursorWithScroll);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
for (let s = 0; s < this.pokerusCursorObjs.length; s++) {
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokerusCursorObjs[s].setVisible(this.pokerusGens[s] === genCursorWithScroll);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
|
|
|
|
const genLimit = this.genSpecies[genCursorWithScroll].length;
|
|
|
|
for (let s = 0; s < 81; s++) {
|
2024-02-12 16:38:46 -05:00
|
|
|
const speciesId = s < genLimit ? this.genSpecies[genCursorWithScroll][s].speciesId : 0 as Species;
|
2024-04-09 16:58:56 -04:00
|
|
|
const slotVisible = !!speciesId;
|
2024-05-23 17:03:10 +02:00
|
|
|
if (slotVisible) {
|
2024-04-13 18:59:58 -04:00
|
|
|
this.updateStarterValueLabel(s);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterValueLabels[s].setVisible(slotVisible);
|
2024-04-18 22:52:26 -04:00
|
|
|
const speciesVariants = speciesId && this.scene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY
|
|
|
|
? [ DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3 ].filter(v => !!(this.scene.gameData.dexData[speciesId].caughtAttr & v))
|
|
|
|
: [];
|
|
|
|
for (let v = 0; v < 3; v++) {
|
|
|
|
const hasVariant = speciesVariants.length > v;
|
|
|
|
this.shinyIcons[s][v].setVisible(slotVisible && hasVariant);
|
2024-05-23 17:03:10 +02:00
|
|
|
if (hasVariant) {
|
2024-04-18 22:52:26 -04:00
|
|
|
this.shinyIcons[s][v].setTint(getVariantTint(speciesVariants[v] === DexAttr.DEFAULT_VARIANT ? 0 : speciesVariants[v] === DexAttr.VARIANT_2 ? 1 : 2));
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-18 22:52:26 -04:00
|
|
|
}
|
|
|
|
this.hiddenAbilityIcons[s].setVisible(slotVisible && !!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[speciesId].abilityAttr & 4));
|
2024-05-07 00:44:41 -04:00
|
|
|
this.classicWinIcons[s].setVisible(slotVisible && this.scene.gameData.starterData[speciesId].classicWinCount > 0);
|
2024-05-28 14:49:15 -03:00
|
|
|
|
|
|
|
// 'Candy Icon' mode
|
2024-05-28 14:22:59 -05:00
|
|
|
if (this.scene.candyUpgradeDisplay === 0) {
|
2024-05-28 14:49:15 -03:00
|
|
|
|
|
|
|
if (!starterColors[speciesId]) {
|
|
|
|
// Default to white if no colors are found
|
|
|
|
starterColors[speciesId] = [ "ffffff", "ffffff" ];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the candy colors
|
|
|
|
this.candyUpgradeIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][0])));
|
|
|
|
this.candyUpgradeOverlayIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][1])));
|
|
|
|
|
|
|
|
this.setUpgradeIcon(s);
|
|
|
|
} else if (this.scene.candyUpgradeDisplay === 1) {
|
|
|
|
this.candyUpgradeIcon[s].setVisible(false);
|
|
|
|
this.candyUpgradeOverlayIcon[s].setVisible(false);
|
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
} else {
|
|
|
|
changed = super.setCursor(cursor);
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-03-31 21:14:35 -04:00
|
|
|
this.cursorObj.setPosition(150 + 18 * (cursor % 9), 10 + 18 * Math.floor(cursor / 9));
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-06-14 11:01:11 -04:00
|
|
|
const species = this.genSpecies[this.getGenCursorWithScroll()][cursor];
|
|
|
|
|
|
|
|
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species, false, true);
|
|
|
|
const defaultProps = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
|
|
|
const variant = defaultProps.variant;
|
|
|
|
const tint = getVariantTint(variant);
|
2023-04-17 22:44:41 -04:00
|
|
|
|
2024-06-14 11:01:11 -04:00
|
|
|
this.variantLabel.setTint(tint);
|
|
|
|
this.setSpecies(species);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.updateInstructions();
|
2023-04-17 22:44:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
getGenCursorWithScroll(): integer {
|
|
|
|
return this.genCursor !== undefined
|
|
|
|
? this.genCursor + this.genScrollCursor
|
|
|
|
: undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateGenOptions(): void {
|
2024-05-23 17:03:10 +02:00
|
|
|
let text = "";
|
2024-01-01 10:14:49 -05:00
|
|
|
for (let g = this.genScrollCursor; g <= this.genScrollCursor + 2; g++) {
|
2024-05-23 17:03:10 +02:00
|
|
|
let optionText = "";
|
|
|
|
if (g === this.genScrollCursor && this.genScrollCursor) {
|
|
|
|
optionText = "↑";
|
|
|
|
} else if (g === this.genScrollCursor + 2 && this.genScrollCursor < gens.length - 3) {
|
|
|
|
optionText = "↓";
|
|
|
|
} else {
|
|
|
|
optionText = i18next.t(`starterSelectUiHandler:gen${g + 1}`);
|
|
|
|
}
|
|
|
|
text += `${text ? "\n" : ""}${optionText}`;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
|
|
|
this.genOptionsText.setText(text);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-11-12 23:47:04 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
setGenMode(genMode: boolean): boolean {
|
|
|
|
this.genCursorObj.setVisible(genMode && !this.startCursorObj.visible);
|
|
|
|
this.cursorObj.setVisible(!genMode && !this.startCursorObj.visible);
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
if (genMode !== this.genMode) {
|
|
|
|
this.genMode = genMode;
|
2023-04-17 22:44:41 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.setCursor(genMode ? this.genCursor : this.cursor);
|
2024-05-23 17:03:10 +02:00
|
|
|
if (genMode) {
|
2023-12-19 23:51:48 -05:00
|
|
|
this.setSpecies(null);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-04-17 22:44:41 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
return true;
|
|
|
|
}
|
2023-04-18 01:32:26 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
return false;
|
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
setSpecies(species: PokemonSpecies) {
|
|
|
|
this.speciesStarterDexEntry = species ? this.scene.gameData.dexData[species.speciesId] : null;
|
2024-04-18 22:52:26 -04:00
|
|
|
this.dexAttrCursor = species ? this.scene.gameData.getSpeciesDefaultDexAttr(species, false, true) : 0n;
|
|
|
|
this.abilityCursor = species ? this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species) : 0;
|
2024-01-05 22:24:05 -05:00
|
|
|
this.natureCursor = species ? this.scene.gameData.getSpeciesDefaultNature(species) : 0;
|
2023-04-17 22:44:41 -04:00
|
|
|
|
2024-06-17 06:49:29 +02:00
|
|
|
const starterAttributes : StarterAttributes = species ? {...this.starterPreferences[species.speciesId]} : null;
|
|
|
|
// validate starterAttributes
|
|
|
|
if (starterAttributes) {
|
|
|
|
// this may cause changes so we created a copy of the attributes before
|
|
|
|
if (!isNaN(starterAttributes.variant)) {
|
|
|
|
if (![
|
|
|
|
this.speciesStarterDexEntry.caughtAttr & DexAttr.NON_SHINY,
|
|
|
|
this.speciesStarterDexEntry.caughtAttr & DexAttr.DEFAULT_VARIANT,
|
|
|
|
this.speciesStarterDexEntry.caughtAttr & DexAttr.VARIANT_2,
|
|
|
|
this.speciesStarterDexEntry.caughtAttr & DexAttr.VARIANT_3
|
|
|
|
][starterAttributes.variant+1]) { // add 1 as -1 = non-shiny
|
|
|
|
// requested variant wasn't unlocked, purging setting
|
|
|
|
delete starterAttributes.variant;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof starterAttributes.female !== "boolean" || !(starterAttributes.female ?
|
|
|
|
this.speciesStarterDexEntry.caughtAttr & DexAttr.FEMALE :
|
|
|
|
this.speciesStarterDexEntry.caughtAttr & DexAttr.MALE
|
|
|
|
)) {
|
|
|
|
// requested gender wasn't unlocked, purging setting
|
|
|
|
delete starterAttributes.female;
|
|
|
|
}
|
|
|
|
|
|
|
|
const abilityAttr = this.scene.gameData.starterData[species.speciesId].abilityAttr;
|
|
|
|
if (![
|
|
|
|
abilityAttr & AbilityAttr.ABILITY_1,
|
|
|
|
species.ability2 ? (abilityAttr & AbilityAttr.ABILITY_2) : abilityAttr & AbilityAttr.ABILITY_HIDDEN,
|
|
|
|
species.ability2 && abilityAttr & AbilityAttr.ABILITY_HIDDEN
|
|
|
|
][starterAttributes.ability]) {
|
|
|
|
// requested ability wasn't unlocked, purging setting
|
|
|
|
delete starterAttributes.ability;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(species.forms[starterAttributes.form]?.isStarterSelectable && this.speciesStarterDexEntry.caughtAttr & this.scene.gameData.getFormAttr(starterAttributes.form))) {
|
|
|
|
// requested form wasn't unlocked/isn't a starter form, purging setting
|
|
|
|
delete starterAttributes.form;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.scene.gameData.getNaturesForAttr(this.speciesStarterDexEntry.natureAttr).indexOf(starterAttributes.nature as unknown as Nature) < 0) {
|
|
|
|
// requested nature wasn't unlocked, purging setting
|
|
|
|
delete starterAttributes.nature;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (starterAttributes?.nature) {
|
|
|
|
// load default nature from stater save data, if set
|
|
|
|
this.natureCursor = starterAttributes.nature;
|
|
|
|
}
|
|
|
|
if (!isNaN(starterAttributes?.ability)) {
|
|
|
|
// load default nature from stater save data, if set
|
|
|
|
this.abilityCursor = starterAttributes.ability;
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05: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-17 22:44:41 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
if (this.lastSpecies) {
|
2024-04-18 22:52:26 -04:00
|
|
|
const dexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(this.lastSpecies, false, true);
|
2023-12-19 23:51:48 -05:00
|
|
|
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);
|
2024-04-18 22:52:26 -04:00
|
|
|
lastSpeciesIcon.setTexture(this.lastSpecies.getIconAtlasKey(props.formIndex, props.shiny, props.variant), this.lastSpecies.getIconId(props.female, props.formIndex, props.shiny, props.variant));
|
2024-05-13 14:23:34 -04:00
|
|
|
this.checkIconId(lastSpeciesIcon, this.lastSpecies, props.female, props.formIndex, props.shiny, props.variant);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
2024-05-28 14:49:15 -03:00
|
|
|
|
|
|
|
// Resume the animation for the previously selected species
|
|
|
|
const speciesIndex = this.genSpecies[this.lastSpecies.generation - 1].indexOf(this.lastSpecies);
|
|
|
|
const icon = this.starterSelectGenIconContainers[this.lastSpecies.generation - 1].getAt(speciesIndex) as Phaser.GameObjects.Sprite;
|
|
|
|
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.resume());
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2023-04-18 01:32:26 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.lastSpecies = species;
|
2023-04-26 12:50:21 -04:00
|
|
|
|
2024-02-18 22:21:57 -05:00
|
|
|
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr)) {
|
2024-02-12 16:38:46 -05:00
|
|
|
this.pokemonNumberText.setText(Utils.padInt(species.speciesId, 4));
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonNameText.setText(species.name);
|
2024-01-05 22:24:05 -05:00
|
|
|
|
2024-02-18 22:21:57 -05:00
|
|
|
if (this.speciesStarterDexEntry?.caughtAttr) {
|
2024-04-13 18:59:58 -04:00
|
|
|
const colorScheme = starterColors[species.speciesId];
|
|
|
|
|
2024-04-26 17:32:28 -04:00
|
|
|
const luck = this.scene.gameData.getDexAttrLuck(this.speciesStarterDexEntry.caughtAttr);
|
|
|
|
this.pokemonLuckText.setVisible(!!luck);
|
|
|
|
this.pokemonLuckText.setText(luck.toString());
|
|
|
|
this.pokemonLuckText.setTint(getVariantTint(Math.min(luck - 1, 2) as Variant));
|
|
|
|
this.pokemonLuckLabelText.setVisible(this.pokemonLuckText.visible);
|
|
|
|
|
2024-05-12 04:04:09 +02:00
|
|
|
//Growth translate
|
|
|
|
let growthReadable = Utils.toReadableString(GrowthRate[species.growthRate]);
|
2024-05-23 17:03:10 +02:00
|
|
|
const growthAux = growthReadable.replace(" ", "_");
|
2024-05-24 02:19:20 +02:00
|
|
|
if (i18next.exists("growth:" + growthAux)) {
|
2024-05-23 17:03:10 +02:00
|
|
|
growthReadable = i18next.t("growth:"+ growthAux as any);
|
2024-05-12 04:04:09 +02:00
|
|
|
}
|
|
|
|
this.pokemonGrowthRateText.setText(growthReadable);
|
2024-05-13 18:06:26 +02:00
|
|
|
|
2024-02-18 22:21:57 -05:00
|
|
|
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);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonPassiveLabelText.setVisible(true);
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonNatureLabelText.setVisible(true);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry.caughtCount}`);
|
2024-06-09 10:45:21 -06:00
|
|
|
if (species.speciesId === Species.MANAPHY || species.speciesId === Species.PHIONE) {
|
|
|
|
this.pokemonHatchedIcon.setFrame("manaphy");
|
|
|
|
} else {
|
|
|
|
this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species));
|
|
|
|
}
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonHatchedCountText.setText(`${this.speciesStarterDexEntry.hatchedCount}`);
|
|
|
|
this.pokemonCaughtHatchedContainer.setVisible(true);
|
2024-04-14 00:14:23 -04:00
|
|
|
if (pokemonPrevolutions.hasOwnProperty(species.speciesId)) {
|
|
|
|
this.pokemonCaughtHatchedContainer.setY(16);
|
2024-06-09 10:45:21 -06:00
|
|
|
[
|
|
|
|
this.pokemonCandyIcon,
|
|
|
|
this.pokemonCandyOverlayIcon,
|
|
|
|
this.pokemonCandyDarknessOverlay,
|
|
|
|
this.pokemonCandyCountText,
|
|
|
|
this.pokemonHatchedIcon,
|
|
|
|
this.pokemonHatchedCountText
|
|
|
|
].map(c => c.setVisible(false));
|
2024-06-17 21:41:29 -06:00
|
|
|
this.pokemonFormText.setY(25);
|
2024-06-09 10:45:21 -06:00
|
|
|
} else if (species.speciesId === Species.ETERNATUS) {
|
|
|
|
this.pokemonHatchedIcon.setVisible(false);
|
|
|
|
this.pokemonHatchedCountText.setVisible(false);
|
2024-04-14 00:14:23 -04:00
|
|
|
} else {
|
|
|
|
this.pokemonCaughtHatchedContainer.setY(25);
|
|
|
|
this.pokemonCandyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0])));
|
|
|
|
this.pokemonCandyIcon.setVisible(true);
|
|
|
|
this.pokemonCandyOverlayIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[1])));
|
|
|
|
this.pokemonCandyOverlayIcon.setVisible(true);
|
2024-05-05 09:35:14 -05:00
|
|
|
this.pokemonCandyDarknessOverlay.setVisible(true);
|
2024-04-14 00:14:23 -04:00
|
|
|
this.pokemonCandyCountText.setText(`x${this.scene.gameData.starterData[species.speciesId].candyCount}`);
|
|
|
|
this.pokemonCandyCountText.setVisible(true);
|
2024-05-03 23:02:55 -05:00
|
|
|
this.pokemonFormText.setVisible(true);
|
2024-06-17 21:41:29 -06:00
|
|
|
this.pokemonFormText.setY(42);
|
2024-06-09 10:45:21 -06:00
|
|
|
this.pokemonHatchedIcon.setVisible(true);
|
|
|
|
this.pokemonHatchedCountText.setVisible(true);
|
2024-05-05 09:35:14 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
let currentFriendship = this.scene.gameData.starterData[this.lastSpecies.speciesId].friendship;
|
|
|
|
if (!currentFriendship || currentFriendship === undefined) {
|
2024-05-05 09:35:14 -05:00
|
|
|
currentFriendship = 0;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-05-05 09:35:14 -05:00
|
|
|
|
|
|
|
const friendshipCap = getStarterValueFriendshipCap(speciesStarters[this.lastSpecies.speciesId]);
|
|
|
|
const candyCropY = 16 - (16 * (currentFriendship / friendshipCap));
|
|
|
|
|
|
|
|
if (this.pokemonCandyDarknessOverlay.visible) {
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonCandyDarknessOverlay.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, `${currentFriendship}/${friendshipCap}`, true));
|
|
|
|
this.pokemonCandyDarknessOverlay.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip());
|
2024-05-05 09:35:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
this.pokemonCandyDarknessOverlay.setCrop(0,0,16, candyCropY);
|
2024-04-14 00:14:23 -04:00
|
|
|
}
|
2024-05-28 14:49:15 -03:00
|
|
|
|
|
|
|
|
|
|
|
// Pause the animation when the species is selected
|
|
|
|
const speciesIndex = this.genSpecies[species.generation - 1].indexOf(species);
|
|
|
|
const icon = this.starterSelectGenIconContainers[species.generation - 1].getAt(speciesIndex) as Phaser.GameObjects.Sprite;
|
|
|
|
|
|
|
|
if (this.isUpgradeAnimationEnabled()) {
|
|
|
|
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.pause());
|
|
|
|
// Reset the position of the icon
|
|
|
|
const position = calcSpritePosition(speciesIndex);
|
|
|
|
icon.x = position.x;
|
|
|
|
icon.y = position.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initiates the small up and down idle animation
|
|
|
|
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.PASSIVE);
|
2024-02-18 22:21:57 -05: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;
|
|
|
|
});
|
|
|
|
|
2024-04-11 19:10:56 -04:00
|
|
|
let props: DexAttrProps;
|
|
|
|
|
2024-02-18 22:21:57 -05:00
|
|
|
if (starterIndex > -1) {
|
2024-04-11 19:10:56 -04:00
|
|
|
props = this.scene.gameData.getSpeciesDexAttrProps(species, this.starterAttr[starterIndex]);
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.variant, this.starterAbilityIndexes[starterIndex], this.starterNatures[starterIndex]);
|
2024-02-18 22:21:57 -05:00
|
|
|
} else {
|
2024-04-18 22:52:26 -04:00
|
|
|
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species, false, true);
|
2024-06-17 06:49:29 +02:00
|
|
|
const defaultAbilityIndex = starterAttributes?.ability ?? this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species);
|
|
|
|
// load default nature from stater save data, if set
|
|
|
|
const defaultNature = starterAttributes?.nature || this.scene.gameData.getSpeciesDefaultNature(species);
|
2024-04-11 19:10:56 -04:00
|
|
|
props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
2024-06-17 06:49:29 +02:00
|
|
|
if (!isNaN(starterAttributes?.variant)) {
|
|
|
|
if (props.shiny = (starterAttributes.variant >= 0)) {
|
|
|
|
props.variant = starterAttributes.variant as Variant;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
props.formIndex = starterAttributes?.form ?? props.formIndex;
|
|
|
|
props.female = starterAttributes?.female ?? props.female;
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.variant, defaultAbilityIndex, defaultNature);
|
2024-02-18 22:21:57 -05:00
|
|
|
}
|
2024-04-11 19:10:56 -04:00
|
|
|
|
|
|
|
const speciesForm = getPokemonSpeciesForm(species.speciesId, props.formIndex);
|
|
|
|
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
|
|
|
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonSprite.clearTint();
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.pokerusCursors.find((cursor: integer, i: integer) => cursor === this.cursor && this.pokerusGens[i] === this.getGenCursorWithScroll())) {
|
2024-04-01 22:50:00 -04:00
|
|
|
handleTutorial(this.scene, Tutorial.Pokerus);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-01-05 22:24:05 -05:00
|
|
|
} else {
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonGrowthRateText.setText("");
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonGrowthRateLabelText.setVisible(false);
|
2024-04-11 11:39:08 -04:00
|
|
|
this.type1Icon.setVisible(false);
|
|
|
|
this.type2Icon.setVisible(false);
|
2024-04-26 17:32:28 -04:00
|
|
|
this.pokemonLuckLabelText.setVisible(false);
|
|
|
|
this.pokemonLuckText.setVisible(false);
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonUncaughtText.setVisible(true);
|
|
|
|
this.pokemonAbilityLabelText.setVisible(false);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonPassiveLabelText.setVisible(false);
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonNatureLabelText.setVisible(false);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonCaughtHatchedContainer.setVisible(false);
|
|
|
|
this.pokemonCandyIcon.setVisible(false);
|
|
|
|
this.pokemonCandyOverlayIcon.setVisible(false);
|
2024-05-05 09:35:14 -05:00
|
|
|
this.pokemonCandyDarknessOverlay.setVisible(false);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonCandyCountText.setVisible(false);
|
2024-05-03 23:02:55 -05:00
|
|
|
this.pokemonFormText.setVisible(false);
|
2024-02-18 22:21:57 -05:00
|
|
|
|
2024-04-18 22:52:26 -04:00
|
|
|
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species, true, true);
|
|
|
|
const defaultAbilityIndex = this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species);
|
2024-01-05 22:24:05 -05:00
|
|
|
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
|
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(species, props.shiny, props.formIndex, props.female, props.variant, defaultAbilityIndex, defaultNature, true);
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonSprite.setTint(0x808080);
|
2024-01-05 22:24:05 -05:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
} else {
|
2024-02-12 16:38:46 -05:00
|
|
|
this.pokemonNumberText.setText(Utils.padInt(0, 4));
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonNameText.setText(species ? "???" : "");
|
|
|
|
this.pokemonGrowthRateText.setText("");
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonGrowthRateLabelText.setVisible(false);
|
2024-04-11 11:39:08 -04:00
|
|
|
this.type1Icon.setVisible(false);
|
|
|
|
this.type2Icon.setVisible(false);
|
2024-04-26 17:32:28 -04:00
|
|
|
this.pokemonLuckLabelText.setVisible(false);
|
|
|
|
this.pokemonLuckText.setVisible(false);
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonUncaughtText.setVisible(!!species);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonAbilityLabelText.setVisible(false);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonPassiveLabelText.setVisible(false);
|
2024-01-05 22:24:05 -05:00
|
|
|
this.pokemonNatureLabelText.setVisible(false);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonCaughtHatchedContainer.setVisible(false);
|
|
|
|
this.pokemonCandyIcon.setVisible(false);
|
|
|
|
this.pokemonCandyOverlayIcon.setVisible(false);
|
2024-05-05 09:35:14 -05:00
|
|
|
this.pokemonCandyDarknessOverlay.setVisible(false);
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonCandyCountText.setVisible(false);
|
2024-05-03 23:02:55 -05:00
|
|
|
this.pokemonFormText.setVisible(false);
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-04-18 22:52:26 -04:00
|
|
|
this.setSpeciesDetails(species, false, 0, false, 0, 0, 0);
|
2024-02-18 22:21:57 -05:00
|
|
|
this.pokemonSprite.clearTint();
|
2023-04-12 19:09:15 -04:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2023-04-12 19:09:15 -04:00
|
|
|
|
2024-04-18 22:52:26 -04:00
|
|
|
setSpeciesDetails(species: PokemonSpecies, shiny: boolean, formIndex: integer, female: boolean, variant: Variant, abilityIndex: integer, natureIndex: integer, forSeen: boolean = false): void {
|
2023-12-19 23:51:48 -05:00
|
|
|
const oldProps = species ? this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor) : null;
|
2024-04-18 22:52:26 -04:00
|
|
|
const oldAbilityIndex = this.abilityCursor > -1 ? this.abilityCursor : this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species);
|
2024-04-02 14:32:51 -04:00
|
|
|
const oldNatureIndex = this.natureCursor > -1 ? this.natureCursor : this.scene.gameData.getSpeciesDefaultNature(species);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.dexAttrCursor = 0n;
|
2024-04-18 22:52:26 -04:00
|
|
|
this.abilityCursor = -1;
|
2024-04-02 14:32:51 -04:00
|
|
|
this.natureCursor = -1;
|
2023-12-19 23:51:48 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (species?.forms?.find(f => f.formKey === "female")) {
|
|
|
|
if (female !== undefined) {
|
2024-04-15 17:34:36 -04:00
|
|
|
formIndex = female ? 1 : 0;
|
2024-05-23 17:03:10 +02:00
|
|
|
} else if (formIndex !== undefined) {
|
2024-04-15 17:34:36 -04:00
|
|
|
female = formIndex === 1;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-15 17:34:36 -04:00
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
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;
|
2024-04-18 22:52:26 -04:00
|
|
|
this.dexAttrCursor |= (variant !== undefined ? !variant : !(variant = oldProps.variant)) ? DexAttr.DEFAULT_VARIANT : variant === 1 ? DexAttr.VARIANT_2 : DexAttr.VARIANT_3;
|
2023-12-19 23:51:48 -05:00
|
|
|
this.dexAttrCursor |= this.scene.gameData.getFormAttr(formIndex !== undefined ? formIndex : (formIndex = oldProps.formIndex));
|
2024-04-18 22:52:26 -04:00
|
|
|
this.abilityCursor = abilityIndex !== undefined ? abilityIndex : (abilityIndex = oldAbilityIndex);
|
2024-04-02 14:32:51 -04:00
|
|
|
this.natureCursor = natureIndex !== undefined ? natureIndex : (natureIndex = oldNatureIndex);
|
2023-12-01 17:23:26 -05:00
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonSprite.setVisible(false);
|
|
|
|
|
|
|
|
if (this.assetLoadCancelled) {
|
|
|
|
this.assetLoadCancelled.value = true;
|
|
|
|
this.assetLoadCancelled = null;
|
2023-12-01 17:23:26 -05:00
|
|
|
}
|
|
|
|
|
2024-02-21 01:03:34 -05:00
|
|
|
this.starterMoveset = null;
|
|
|
|
this.speciesStarterMoves = [];
|
2024-02-20 22:53:33 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
if (species) {
|
|
|
|
const dexEntry = this.scene.gameData.dexData[species.speciesId];
|
2024-04-18 22:52:26 -04:00
|
|
|
const abilityAttr = this.scene.gameData.starterData[species.speciesId].abilityAttr;
|
2023-12-19 23:51:48 -05:00
|
|
|
if (!dexEntry.caughtAttr) {
|
2024-04-18 22:52:26 -04:00
|
|
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.scene.gameData.getSpeciesDefaultDexAttr(species, forSeen, !forSeen));
|
|
|
|
const defaultAbilityIndex = this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species);
|
2024-01-05 22:24:05 -05:00
|
|
|
const defaultNature = this.scene.gameData.getSpeciesDefaultNature(species);
|
2024-05-23 17:03:10 +02:00
|
|
|
if (shiny === undefined || shiny !== props.shiny) {
|
2023-12-19 23:51:48 -05:00
|
|
|
shiny = props.shiny;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (formIndex === undefined || formIndex !== props.formIndex) {
|
2023-12-19 23:51:48 -05:00
|
|
|
formIndex = props.formIndex;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (female === undefined || female !== props.female) {
|
2023-12-19 23:51:48 -05:00
|
|
|
female = props.female;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (variant === undefined || variant !== props.variant) {
|
2024-04-18 22:52:26 -04:00
|
|
|
variant = props.variant;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (abilityIndex === undefined || abilityIndex !== defaultAbilityIndex) {
|
2024-04-18 22:52:26 -04:00
|
|
|
abilityIndex = defaultAbilityIndex;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
|
|
|
if (natureIndex === undefined || natureIndex !== defaultNature) {
|
2024-01-05 22:24:05 -05:00
|
|
|
natureIndex = defaultNature;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2023-12-01 17:23:26 -05:00
|
|
|
|
2024-03-25 13:40:54 -04:00
|
|
|
this.shinyOverlay.setVisible(shiny);
|
2024-03-31 21:14:35 -04:00
|
|
|
this.pokemonNumberText.setColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, false));
|
|
|
|
this.pokemonNumberText.setShadowColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true));
|
2024-03-25 13:40:54 -04:00
|
|
|
|
2024-02-18 22:21:57 -05:00
|
|
|
if (forSeen ? this.speciesStarterDexEntry?.seenAttr : this.speciesStarterDexEntry?.caughtAttr) {
|
2024-01-05 22:24:05 -05: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;
|
2024-04-19 08:40:49 -04:00
|
|
|
this.starterAbilityIndexes[starterIndex] = this.abilityCursor;
|
2024-01-05 22:24:05 -05:00
|
|
|
this.starterNatures[starterIndex] = this.natureCursor;
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
const assetLoadCancelled = new Utils.BooleanHolder(false);
|
|
|
|
this.assetLoadCancelled = assetLoadCancelled;
|
|
|
|
|
2024-04-18 22:52:26 -04:00
|
|
|
species.loadAssets(this.scene, female, formIndex, shiny, variant, true).then(() => {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (assetLoadCancelled.value) {
|
2023-12-19 23:51:48 -05:00
|
|
|
return;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
this.assetLoadCancelled = null;
|
|
|
|
this.speciesLoaded.set(species.speciesId, true);
|
2024-04-18 22:52:26 -04:00
|
|
|
this.pokemonSprite.play(species.getSpriteKey(female, formIndex, shiny, variant));
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonSprite.setPipelineData("shiny", shiny);
|
|
|
|
this.pokemonSprite.setPipelineData("variant", variant);
|
|
|
|
this.pokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female, formIndex, shiny, variant));
|
2023-12-19 23:51:48 -05:00
|
|
|
this.pokemonSprite.setVisible(!this.statsMode);
|
|
|
|
});
|
|
|
|
|
2024-06-18 23:27:06 +10:00
|
|
|
|
|
|
|
const isValidForChallenge = new Utils.BooleanHolder(true);
|
|
|
|
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor), this.starterGens.length);
|
|
|
|
const starterSprite = this.starterSelectGenIconContainers[this.getGenCursorWithScroll()].getAt(this.cursor) as Phaser.GameObjects.Sprite;
|
|
|
|
starterSprite.setTexture(species.getIconAtlasKey(formIndex, shiny, variant), species.getIconId(female, formIndex, shiny, variant));
|
|
|
|
starterSprite.setAlpha(isValidForChallenge.value ? 1 : 0.375);
|
2024-05-13 14:23:34 -04:00
|
|
|
this.checkIconId((this.starterSelectGenIconContainers[this.getGenCursorWithScroll()].getAt(this.cursor) as Phaser.GameObjects.Sprite), species, female, formIndex, shiny, variant);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.canCycleShiny = !!(dexEntry.caughtAttr & DexAttr.NON_SHINY && dexEntry.caughtAttr & DexAttr.SHINY);
|
|
|
|
this.canCycleGender = !!(dexEntry.caughtAttr & DexAttr.MALE && dexEntry.caughtAttr & DexAttr.FEMALE);
|
2024-04-19 11:01:22 -04:00
|
|
|
this.canCycleAbility = [ abilityAttr & AbilityAttr.ABILITY_1, (abilityAttr & AbilityAttr.ABILITY_2) && species.ability2, abilityAttr & AbilityAttr.ABILITY_HIDDEN ].filter(a => a).length > 1;
|
2024-05-25 12:53:46 -05:00
|
|
|
this.canCycleForm = species.forms.filter(f => f.isStarterSelectable || !pokemonFormChanges[species.speciesId]?.find(fc => fc.formKey))
|
2024-04-18 22:52:26 -04:00
|
|
|
.map((_, f) => dexEntry.caughtAttr & this.scene.gameData.getFormAttr(f)).filter(f => f).length > 1;
|
2024-01-05 22:24:05 -05:00
|
|
|
this.canCycleNature = this.scene.gameData.getNaturesForAttr(dexEntry.natureAttr).length > 1;
|
2024-04-18 22:52:26 -04:00
|
|
|
this.canCycleVariant = shiny && [ dexEntry.caughtAttr & DexAttr.DEFAULT_VARIANT, dexEntry.caughtAttr & DexAttr.VARIANT_2, dexEntry.caughtAttr & DexAttr.VARIANT_3].filter(v => v).length > 1;
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2023-12-01 17:23:26 -05:00
|
|
|
|
2023-12-19 23:51:48 -05: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));
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
|
|
|
this.pokemonGenderText.setText("");
|
|
|
|
}
|
2023-12-01 17:23:26 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
if (dexEntry.caughtAttr) {
|
|
|
|
const ability = this.lastSpecies.getAbility(abilityIndex);
|
|
|
|
this.pokemonAbilityText.setText(allAbilities[ability].name);
|
2023-12-01 17:23:26 -05:00
|
|
|
|
2024-04-23 12:37:26 -04:00
|
|
|
const isHidden = abilityIndex === (this.lastSpecies.ability2 ? 2 : 1);
|
2024-03-31 21:14:35 -04:00
|
|
|
this.pokemonAbilityText.setColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD));
|
|
|
|
this.pokemonAbilityText.setShadowColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD, true));
|
2024-01-05 22:24:05 -05:00
|
|
|
|
2024-04-13 18:59:58 -04:00
|
|
|
const passiveAttr = this.scene.gameData.starterData[species.speciesId].passiveAttr;
|
2024-05-13 12:50:56 -05:00
|
|
|
this.pokemonPassiveText.setText(passiveAttr & PassiveAttr.UNLOCKED ? passiveAttr & PassiveAttr.ENABLED ? allAbilities[starterPassiveAbilities[this.lastSpecies.speciesId]].name : i18next.t("starterSelectUiHandler:disabled") : i18next.t("starterSelectUiHandler:locked"));
|
2024-04-13 18:59:58 -04:00
|
|
|
this.pokemonPassiveText.setColor(this.getTextColor(passiveAttr === (PassiveAttr.UNLOCKED | PassiveAttr.ENABLED) ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GRAY));
|
|
|
|
this.pokemonPassiveText.setShadowColor(this.getTextColor(passiveAttr === (PassiveAttr.UNLOCKED | PassiveAttr.ENABLED) ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GRAY, true));
|
|
|
|
|
2024-04-04 20:33:08 -04:00
|
|
|
this.pokemonNatureText.setText(getNatureName(natureIndex as unknown as Nature, true, true, false, this.scene.uiTheme));
|
2024-02-20 22:53:33 -05:00
|
|
|
|
2024-02-21 01:03:34 -05:00
|
|
|
let levelMoves: LevelMoves;
|
2024-05-23 17:03:10 +02:00
|
|
|
if (pokemonFormLevelMoves.hasOwnProperty(species.speciesId) && pokemonFormLevelMoves[species.speciesId].hasOwnProperty(formIndex)) {
|
2024-02-21 01:03:34 -05:00
|
|
|
levelMoves = pokemonFormLevelMoves[species.speciesId][formIndex];
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
2024-02-21 01:03:34 -05:00
|
|
|
levelMoves = pokemonSpeciesLevelMoves[species.speciesId];
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-02-21 01:03:34 -05:00
|
|
|
this.speciesStarterMoves.push(...levelMoves.filter(lm => lm[0] <= 5).map(lm => lm[1]));
|
2024-02-25 12:45:41 -05:00
|
|
|
if (speciesEggMoves.hasOwnProperty(species.speciesId)) {
|
|
|
|
for (let em = 0; em < 4; em++) {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.scene.gameData.starterData[species.speciesId].eggMoves & Math.pow(2, em)) {
|
2024-02-25 12:45:41 -05:00
|
|
|
this.speciesStarterMoves.push(speciesEggMoves[species.speciesId][em]);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-02-25 12:45:41 -05:00
|
|
|
}
|
|
|
|
}
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2024-04-13 18:59:58 -04:00
|
|
|
const speciesMoveData = this.scene.gameData.starterData[species.speciesId].moveset;
|
2024-05-23 17:03:10 +02:00
|
|
|
const moveData: StarterMoveset = speciesMoveData
|
2024-02-21 01:03:34 -05:00
|
|
|
? Array.isArray(speciesMoveData)
|
|
|
|
? speciesMoveData as StarterMoveset
|
|
|
|
: (speciesMoveData as StarterFormMoveData)[formIndex]
|
|
|
|
: null;
|
2024-04-13 18:59:58 -04:00
|
|
|
const availableStarterMoves = this.speciesStarterMoves.concat(speciesEggMoves.hasOwnProperty(species.speciesId) ? speciesEggMoves[species.speciesId].filter((_, em: integer) => this.scene.gameData.starterData[species.speciesId].eggMoves & Math.pow(2, em)) : []);
|
2024-03-01 18:18:07 -05:00
|
|
|
this.starterMoveset = (moveData || (this.speciesStarterMoves.slice(0, 4) as StarterMoveset)).filter(m => availableStarterMoves.find(sm => sm === m)) as StarterMoveset;
|
|
|
|
// Consolidate move data if it contains an incompatible move
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.starterMoveset.length < 4 && this.starterMoveset.length < availableStarterMoves.length) {
|
2024-03-01 18:18:07 -05:00
|
|
|
this.starterMoveset.push(...availableStarterMoves.filter(sm => this.starterMoveset.indexOf(sm) === -1).slice(0, 4 - this.starterMoveset.length));
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-05-24 01:45:04 +02:00
|
|
|
|
2024-05-12 13:56:37 -05:00
|
|
|
// Remove duplicate moves
|
|
|
|
this.starterMoveset = this.starterMoveset.filter(
|
|
|
|
(move, i) => {
|
|
|
|
return this.starterMoveset.indexOf(move) === i;
|
2024-05-24 01:45:04 +02:00
|
|
|
}) as StarterMoveset;
|
2024-04-11 19:10:56 -04:00
|
|
|
|
|
|
|
const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex);
|
2024-05-13 18:06:26 +02:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
const formText = species?.forms[formIndex]?.formKey.split("-");
|
|
|
|
for (let i = 0; i < formText?.length; i++) {
|
2024-05-03 23:02:55 -05:00
|
|
|
formText[i] = formText[i].charAt(0).toUpperCase() + formText[i].substring(1);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-05-03 23:02:55 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonFormText.setText(formText?.join(" "));
|
2024-05-03 23:02:55 -05:00
|
|
|
|
2024-04-11 19:10:56 -04:00
|
|
|
this.setTypeIcons(speciesForm.type1, speciesForm.type2);
|
2024-01-05 22:24:05 -05:00
|
|
|
} else {
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonAbilityText.setText("");
|
|
|
|
this.pokemonPassiveText.setText("");
|
|
|
|
this.pokemonNatureText.setText("");
|
2024-04-11 19:10:56 -04:00
|
|
|
this.setTypeIcons(null, null);
|
2024-01-05 22:24:05 -05:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
} else {
|
2024-03-25 13:40:54 -04:00
|
|
|
this.shinyOverlay.setVisible(false);
|
2024-03-31 21:14:35 -04:00
|
|
|
this.pokemonNumberText.setColor(this.getTextColor(TextStyle.SUMMARY));
|
|
|
|
this.pokemonNumberText.setShadowColor(this.getTextColor(TextStyle.SUMMARY, true));
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonGenderText.setText("");
|
|
|
|
this.pokemonAbilityText.setText("");
|
|
|
|
this.pokemonPassiveText.setText("");
|
|
|
|
this.pokemonNatureText.setText("");
|
2024-04-11 19:10:56 -04:00
|
|
|
this.setTypeIcons(null, null);
|
2023-04-12 19:09:15 -04:00
|
|
|
}
|
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!this.starterMoveset) {
|
2024-02-21 01:03:34 -05:00
|
|
|
this.starterMoveset = this.speciesStarterMoves.slice(0, 4) as StarterMoveset;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-02-21 01:03:34 -05:00
|
|
|
|
2024-02-20 22:53:33 -05:00
|
|
|
for (let m = 0; m < 4; m++) {
|
2024-02-21 01:03:34 -05:00
|
|
|
const move = m < this.starterMoveset.length ? allMoves[this.starterMoveset[m]] : null;
|
2024-02-20 22:53:33 -05:00
|
|
|
this.pokemonMoveBgs[m].setFrame(Type[move ? move.type : Type.UNKNOWN].toString().toLowerCase());
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonMoveLabels[m].setText(move ? move.name : "-");
|
2024-02-20 22:53:33 -05:00
|
|
|
this.pokemonMoveContainers[m].setVisible(!!move);
|
|
|
|
}
|
|
|
|
|
2024-02-25 12:45:41 -05:00
|
|
|
const hasEggMoves = species && speciesEggMoves.hasOwnProperty(species.speciesId);
|
|
|
|
|
|
|
|
for (let em = 0; em < 4; em++) {
|
|
|
|
const eggMove = hasEggMoves ? allMoves[speciesEggMoves[species.speciesId][em]] : null;
|
2024-04-13 18:59:58 -04:00
|
|
|
const eggMoveUnlocked = eggMove && this.scene.gameData.starterData[species.speciesId].eggMoves & Math.pow(2, em);
|
2024-02-25 12:45:41 -05:00
|
|
|
this.pokemonEggMoveBgs[em].setFrame(Type[eggMove ? eggMove.type : Type.UNKNOWN].toString().toLowerCase());
|
2024-05-23 17:03:10 +02:00
|
|
|
this.pokemonEggMoveLabels[em].setText(eggMove && eggMoveUnlocked ? eggMove.name : "???");
|
2024-02-25 12:45:41 -05:00
|
|
|
}
|
|
|
|
|
2024-04-11 11:39:08 -04:00
|
|
|
this.pokemonEggMovesContainer.setVisible(this.speciesStarterDexEntry?.caughtAttr && hasEggMoves);
|
2024-02-25 12:45:41 -05:00
|
|
|
|
2024-02-21 15:47:44 -05:00
|
|
|
this.pokemonAdditionalMoveCountLabel.setText(`(+${Math.max(this.speciesStarterMoves.length - 4, 0)})`);
|
|
|
|
this.pokemonAdditionalMoveCountLabel.setVisible(this.speciesStarterMoves.length > 4);
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.updateInstructions();
|
|
|
|
}
|
|
|
|
|
2024-04-11 19:10:56 -04:00
|
|
|
setTypeIcons(type1: Type, type2: Type): void {
|
|
|
|
if (type1 !== null) {
|
|
|
|
this.type1Icon.setVisible(true);
|
|
|
|
this.type1Icon.setFrame(Type[type1].toLowerCase());
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
2024-04-11 19:10:56 -04:00
|
|
|
this.type1Icon.setVisible(false);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-11 19:10:56 -04:00
|
|
|
if (type2 !== null) {
|
|
|
|
this.type2Icon.setVisible(true);
|
|
|
|
this.type2Icon.setFrame(Type[type2].toLowerCase());
|
2024-05-23 17:03:10 +02:00
|
|
|
} else {
|
2024-04-11 19:10:56 -04:00
|
|
|
this.type2Icon.setVisible(false);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-11 19:10:56 -04:00
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
popStarter(): void {
|
|
|
|
this.starterGens.pop();
|
|
|
|
this.starterCursors.pop();
|
|
|
|
this.starterAttr.pop();
|
2024-04-19 08:40:49 -04:00
|
|
|
this.starterAbilityIndexes.pop();
|
2024-01-05 22:24:05 -05:00
|
|
|
this.starterNatures.pop();
|
2024-02-21 01:03:34 -05:00
|
|
|
this.starterMovesets.pop();
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterCursorObjs[this.starterCursors.length].setVisible(false);
|
2024-05-23 17:03:10 +02:00
|
|
|
this.starterIcons[this.starterCursors.length].setTexture("pokemon_icons_0");
|
|
|
|
this.starterIcons[this.starterCursors.length].setFrame("unknown");
|
2023-12-19 23:51:48 -05:00
|
|
|
this.tryUpdateValue();
|
|
|
|
}
|
|
|
|
|
2024-04-13 18:59:58 -04:00
|
|
|
updateStarterValueLabel(cursor: integer): void {
|
2024-04-13 19:06:33 -04:00
|
|
|
const speciesId = this.genSpecies[this.getGenCursorWithScroll()][cursor].speciesId;
|
2024-04-13 18:59:58 -04:00
|
|
|
const baseStarterValue = speciesStarters[speciesId];
|
|
|
|
const starterValue = this.scene.gameData.getSpeciesStarterValue(speciesId);
|
|
|
|
let valueStr = starterValue.toString();
|
2024-05-23 17:03:10 +02:00
|
|
|
if (valueStr.startsWith("0.")) {
|
2024-04-13 18:59:58 -04:00
|
|
|
valueStr = valueStr.slice(1);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-13 18:59:58 -04:00
|
|
|
this.starterValueLabels[cursor].setText(valueStr);
|
|
|
|
let textStyle: TextStyle;
|
|
|
|
switch (baseStarterValue - starterValue) {
|
2024-05-23 17:03:10 +02:00
|
|
|
case 0:
|
|
|
|
textStyle = TextStyle.WINDOW;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 0.5:
|
|
|
|
textStyle = TextStyle.SUMMARY_BLUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
textStyle = TextStyle.SUMMARY_GOLD;
|
|
|
|
break;
|
2024-04-13 18:59:58 -04:00
|
|
|
}
|
|
|
|
this.starterValueLabels[cursor].setColor(this.getTextColor(textStyle));
|
|
|
|
this.starterValueLabels[cursor].setShadowColor(this.getTextColor(textStyle, true));
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
tryUpdateValue(add?: integer): boolean {
|
2024-02-12 16:38:46 -05: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-19 23:51:48 -05:00
|
|
|
const newValue = value + (add || 0);
|
2024-04-09 16:58:56 -04:00
|
|
|
const valueLimit = this.getValueLimit();
|
|
|
|
const overLimit = newValue > valueLimit;
|
2024-02-12 16:38:46 -05:00
|
|
|
let newValueStr = newValue.toString();
|
2024-05-23 17:03:10 +02:00
|
|
|
if (newValueStr.startsWith("0.")) {
|
2024-02-12 16:38:46 -05:00
|
|
|
newValueStr = newValueStr.slice(1);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-09 16:58:56 -04:00
|
|
|
this.valueLimitLabel.setText(`${newValueStr}/${valueLimit}`);
|
2024-03-31 21:14:35 -04:00
|
|
|
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));
|
2023-12-19 23:51:48 -05:00
|
|
|
if (overLimit) {
|
|
|
|
this.scene.time.delayedCall(Utils.fixedInt(500), () => this.tryUpdateValue());
|
|
|
|
return false;
|
2023-11-13 22:29:03 -05:00
|
|
|
}
|
2024-06-07 00:12:19 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* this loop is used to set the Sprite's alpha value and check if the user can select other pokemon more.
|
|
|
|
*/
|
|
|
|
this.canAddParty = false;
|
|
|
|
const remainValue = valueLimit - newValue;
|
2024-04-09 16:58:56 -04:00
|
|
|
for (let g = 0; g < this.genSpecies.length; g++) {
|
2024-05-23 17:03:10 +02:00
|
|
|
for (let s = 0; s < this.genSpecies[g].length; s++) {
|
2024-06-07 00:12:19 +09:00
|
|
|
/** Cost of pokemon species */
|
|
|
|
const speciesStarterValue = this.scene.gameData.getSpeciesStarterValue(this.genSpecies[g][s].speciesId);
|
|
|
|
/** Used to detect if this pokemon is registered in starter */
|
|
|
|
const speciesStarterDexEntry = this.scene.gameData.dexData[this.genSpecies[g][s].speciesId];
|
|
|
|
/** {@linkcode Phaser.GameObjects.Sprite} object of Pokémon for setting the alpha value */
|
|
|
|
const speciesSprite = this.starterSelectGenIconContainers[g].getAt(s) as Phaser.GameObjects.Sprite;
|
|
|
|
|
|
|
|
/**
|
2024-06-08 15:07:23 +10:00
|
|
|
* If remainValue greater than or equal pokemon species and the pokemon is legal for this challenge, the user can select.
|
2024-06-07 00:12:19 +09:00
|
|
|
* so that the alpha value of pokemon sprite set 1.
|
|
|
|
*
|
|
|
|
* If speciesStarterDexEntry?.caughtAttr is true, this species registered in stater.
|
|
|
|
* we change to can AddParty value to true since the user has enough cost to choose this pokemon and this pokemon registered too.
|
|
|
|
*/
|
2024-06-08 15:07:23 +10:00
|
|
|
const isValidForChallenge = new Utils.BooleanHolder(true);
|
2024-06-18 23:27:06 +10:00
|
|
|
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, this.genSpecies[g][s], isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(this.genSpecies[g][s], this.scene.gameData.getSpeciesDefaultDexAttr(this.genSpecies[g][s], false, true)), this.starterGens.length + (add ? 1 : 0));
|
2024-06-08 15:07:23 +10:00
|
|
|
|
|
|
|
const canBeChosen = remainValue >= speciesStarterValue && isValidForChallenge.value;
|
|
|
|
|
|
|
|
if (canBeChosen) {
|
2024-06-07 00:12:19 +09:00
|
|
|
speciesSprite.setAlpha(1);
|
|
|
|
if (speciesStarterDexEntry?.caughtAttr) {
|
|
|
|
this.canAddParty = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/**
|
2024-06-08 15:07:23 +10:00
|
|
|
* If it can't be chosen, the user can't select.
|
2024-06-07 00:12:19 +09:00
|
|
|
* so that the alpha value of pokemon sprite set 0.375.
|
|
|
|
*/
|
|
|
|
speciesSprite.setAlpha(0.375);
|
|
|
|
}
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2024-04-09 16:58:56 -04:00
|
|
|
}
|
2024-06-07 00:12:19 +09:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.value = newValue;
|
|
|
|
return true;
|
|
|
|
}
|
2023-11-13 22:29:03 -05:00
|
|
|
|
2024-01-01 11:17:20 -05:00
|
|
|
tryStart(manualTrigger: boolean = false): boolean {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!this.starterGens.length) {
|
2023-12-19 23:51:48 -05:00
|
|
|
return false;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-11-13 22:29:03 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
const ui = this.getUi();
|
|
|
|
|
|
|
|
const cancel = () => {
|
|
|
|
ui.setMode(Mode.STARTER_SELECT);
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!manualTrigger) {
|
2024-01-01 11:17:20 -05:00
|
|
|
this.popStarter();
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
this.clearText();
|
|
|
|
};
|
|
|
|
|
2024-05-06 18:02:45 +02:00
|
|
|
ui.showText(i18next.t("starterSelectUiHandler:confirmStartTeam"), null, () => {
|
2023-12-19 23:51:48 -05:00
|
|
|
ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
2024-06-08 15:07:23 +10:00
|
|
|
const startRun = () => {
|
2024-03-15 21:59:34 -04:00
|
|
|
this.scene.money = this.scene.gameMode.getStartingMoney();
|
2023-12-19 23:51:48 -05:00
|
|
|
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-04-18 22:52:26 -04:00
|
|
|
abilityIndex: thisObj.starterAbilityIndexes[i],
|
2024-04-13 18:59:58 -04:00
|
|
|
passive: !(thisObj.scene.gameData.starterData[starterSpecies.speciesId].passiveAttr ^ (PassiveAttr.ENABLED | PassiveAttr.UNLOCKED)),
|
2024-01-05 22:24:05 -05:00
|
|
|
nature: thisObj.starterNatures[i] as Nature,
|
2024-02-21 01:03:34 -05:00
|
|
|
moveset: thisObj.starterMovesets[i],
|
2023-12-19 23:51:48 -05:00
|
|
|
pokerus: !![ 0, 1, 2 ].filter(n => thisObj.pokerusGens[n] === starterSpecies.generation - 1 && thisObj.pokerusCursors[n] === thisObj.genSpecies[starterSpecies.generation - 1].indexOf(starterSpecies)).length
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
2024-06-08 15:07:23 +10:00
|
|
|
startRun();
|
2024-02-06 23:11:00 -05:00
|
|
|
}, cancel, null, null, 19);
|
2023-12-19 23:51:48 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleStatsMode(on?: boolean): void {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (on === undefined) {
|
2023-12-19 23:51:48 -05:00
|
|
|
on = !this.statsMode;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
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-12 19:09:15 -04:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2024-04-30 20:48:55 +02:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
showStats(): void {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (!this.speciesStarterDexEntry) {
|
2023-12-19 23:51:48 -05:00
|
|
|
return;
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-04-21 22:59:09 -04:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.statsContainer.setVisible(true);
|
2023-11-13 22:29:03 -05:00
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
this.statsContainer.updateIvs(this.speciesStarterDexEntry.ivs);
|
|
|
|
}
|
|
|
|
|
|
|
|
clearText() {
|
|
|
|
this.starterSelectMessageBoxContainer.setVisible(false);
|
|
|
|
super.clearText();
|
|
|
|
}
|
|
|
|
|
2024-06-10 12:41:01 -04:00
|
|
|
hideInstructions(): void {
|
|
|
|
this.shinyIconElement.setVisible(false);
|
|
|
|
this.shinyLabel.setVisible(false);
|
|
|
|
this.formIconElement.setVisible(false);
|
|
|
|
this.formLabel.setVisible(false);
|
|
|
|
this.genderIconElement.setVisible(false);
|
|
|
|
this.genderLabel.setVisible(false);
|
|
|
|
this.abilityIconElement.setVisible(false);
|
|
|
|
this.abilityLabel.setVisible(false);
|
|
|
|
this.natureIconElement.setVisible(false);
|
|
|
|
this.natureLabel.setVisible(false);
|
|
|
|
this.variantIconElement.setVisible(false);
|
|
|
|
this.variantLabel.setVisible(false);
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:51:48 -05:00
|
|
|
clear(): void {
|
|
|
|
super.clear();
|
2024-06-17 06:49:29 +02:00
|
|
|
|
|
|
|
StarterPrefs.save(this.starterPreferences);
|
2023-12-19 23:51:48 -05:00
|
|
|
this.cursor = -1;
|
2024-06-10 12:41:01 -04:00
|
|
|
this.hideInstructions();
|
2023-12-19 23:51:48 -05:00
|
|
|
this.starterSelectContainer.setVisible(false);
|
2024-04-17 14:49:18 -04:00
|
|
|
this.blockInput = false;
|
2023-12-19 23:51:48 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
while (this.starterCursors.length) {
|
2023-12-19 23:51:48 -05:00
|
|
|
this.popStarter();
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
|
2024-05-23 17:03:10 +02:00
|
|
|
if (this.statsMode) {
|
2023-12-19 23:51:48 -05:00
|
|
|
this.toggleStatsMode(false);
|
2024-05-23 17:03:10 +02:00
|
|
|
}
|
2023-12-19 23:51:48 -05:00
|
|
|
}
|
2024-05-13 14:23:34 -04:00
|
|
|
|
|
|
|
checkIconId(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, female, formIndex, shiny, variant) {
|
2024-05-23 17:03:10 +02:00
|
|
|
if (icon.frame.name !== species.getIconId(female, formIndex, shiny, variant)) {
|
2024-05-13 14:23:34 -04:00
|
|
|
console.log(`${species.name}'s variant icon does not exist. Replacing with default.`);
|
|
|
|
icon.setTexture(species.getIconAtlasKey(formIndex, false, variant));
|
|
|
|
icon.setFrame(species.getIconId(female, formIndex, false, variant));
|
|
|
|
}
|
|
|
|
}
|
2024-05-15 17:57:48 +02:00
|
|
|
}
|