mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23:24 +02:00
Merge cfb0857b44
into cffbafe4bd
This commit is contained in:
commit
457cf7656b
@ -1,8 +1,11 @@
|
|||||||
import { pokerogueApi } from "#api/pokerogue-api";
|
import { pokerogueApi } from "#api/pokerogue-api";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
|
import { bypassLogin } from "#app/global-vars/bypass-login";
|
||||||
import { Button } from "#enums/buttons";
|
import { Button } from "#enums/buttons";
|
||||||
import { TextStyle } from "#enums/text-style";
|
import { TextStyle } from "#enums/text-style";
|
||||||
import { UiMode } from "#enums/ui-mode";
|
import { UiMode } from "#enums/ui-mode";
|
||||||
|
import type { GameData } from "#system/game-data";
|
||||||
|
import type { SearchAccountResponse } from "#types/api/pokerogue-admin-api";
|
||||||
import type { InputFieldConfig } from "#ui/form-modal-ui-handler";
|
import type { InputFieldConfig } from "#ui/form-modal-ui-handler";
|
||||||
import { FormModalUiHandler } from "#ui/form-modal-ui-handler";
|
import { FormModalUiHandler } from "#ui/form-modal-ui-handler";
|
||||||
import type { ModalConfig } from "#ui/modal-ui-handler";
|
import type { ModalConfig } from "#ui/modal-ui-handler";
|
||||||
@ -17,6 +20,8 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
private adminResult: AdminSearchInfo;
|
private adminResult: AdminSearchInfo;
|
||||||
private config: ModalConfig;
|
private config: ModalConfig;
|
||||||
|
|
||||||
|
private tempGameData: GameData;
|
||||||
|
|
||||||
private readonly buttonGap = 10;
|
private readonly buttonGap = 10;
|
||||||
private readonly ERR_REQUIRED_FIELD = (field: string) => {
|
private readonly ERR_REQUIRED_FIELD = (field: string) => {
|
||||||
if (field === "username") {
|
if (field === "username") {
|
||||||
@ -48,13 +53,13 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
override getButtonLabels(): string[] {
|
override getButtonLabels(): string[] {
|
||||||
switch (this.adminMode) {
|
switch (this.adminMode) {
|
||||||
case AdminMode.LINK:
|
case AdminMode.LINK:
|
||||||
return ["Link Account", "Cancel"];
|
return ["Link Account", "Cancel", " ", " "];
|
||||||
case AdminMode.SEARCH:
|
case AdminMode.SEARCH:
|
||||||
return ["Find account", "Cancel"];
|
return ["Find account", "Cancel", " ", " "];
|
||||||
case AdminMode.ADMIN:
|
case AdminMode.ADMIN:
|
||||||
return ["Back to search", "Cancel"];
|
return ["Back to search", "Cancel", "Stats", "Pokedex"];
|
||||||
default:
|
default:
|
||||||
return ["Activate ADMIN", "Cancel"];
|
return ["Activate ADMIN", "Cancel", " ", " "];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,8 +278,8 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AdminMode.SEARCH:
|
case AdminMode.SEARCH:
|
||||||
if (!this.inputs[0].text) {
|
if (!this.inputs[0].text && !bypassLogin) {
|
||||||
// username missing from search panel
|
// username missing from search panel, skip check for local testing
|
||||||
return {
|
return {
|
||||||
error: true,
|
error: true,
|
||||||
errorMessage: this.ERR_REQUIRED_FIELD("username"),
|
errorMessage: this.ERR_REQUIRED_FIELD("username"),
|
||||||
@ -314,6 +319,18 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async adminSearch(adminSearchResult: AdminSearchInfo) {
|
private async adminSearch(adminSearchResult: AdminSearchInfo) {
|
||||||
|
// Mocking response, solely for local testing
|
||||||
|
if (bypassLogin) {
|
||||||
|
const fakeResponse: SearchAccountResponse = {
|
||||||
|
username: adminSearchResult.username,
|
||||||
|
discordId: "",
|
||||||
|
googleId: "",
|
||||||
|
lastLoggedIn: "",
|
||||||
|
registered: "",
|
||||||
|
};
|
||||||
|
this.tempGameData = globalScene.gameData;
|
||||||
|
return { adminSearchResult: fakeResponse, error: false };
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const [adminInfo, errorType] = await pokerogueApi.admin.searchAccount({
|
const [adminInfo, errorType] = await pokerogueApi.admin.searchAccount({
|
||||||
username: adminSearchResult.username,
|
username: adminSearchResult.username,
|
||||||
@ -397,6 +414,12 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
globalScene.ui.revertMode();
|
globalScene.ui.revertMode();
|
||||||
globalScene.ui.revertMode();
|
globalScene.ui.revertMode();
|
||||||
},
|
},
|
||||||
|
() => {
|
||||||
|
globalScene.ui.setOverlayMode(UiMode.GAME_STATS, this.tempGameData);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
globalScene.ui.setOverlayMode(UiMode.POKEDEX, this.tempGameData);
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
mode,
|
mode,
|
||||||
|
@ -239,6 +239,9 @@ export class GameStatsUiHandler extends UiHandler {
|
|||||||
/** Logged in username */
|
/** Logged in username */
|
||||||
private headerText: Phaser.GameObjects.Text;
|
private headerText: Phaser.GameObjects.Text;
|
||||||
|
|
||||||
|
/** The game data to display */
|
||||||
|
private gameData: GameData;
|
||||||
|
|
||||||
/** Whether the UI is single column mode */
|
/** Whether the UI is single column mode */
|
||||||
private get singleCol(): boolean {
|
private get singleCol(): boolean {
|
||||||
const resolvedLang = i18next.resolvedLanguage ?? "en";
|
const resolvedLang = i18next.resolvedLanguage ?? "en";
|
||||||
@ -396,7 +399,12 @@ export class GameStatsUiHandler extends UiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show(args: any[]): boolean {
|
show(args: any[]): boolean {
|
||||||
super.show(args);
|
super.show([]);
|
||||||
|
|
||||||
|
this.gameData = globalScene.gameData;
|
||||||
|
if (args.length > 0) {
|
||||||
|
this.gameData = args[0];
|
||||||
|
}
|
||||||
|
|
||||||
// show updated username on every render
|
// show updated username on every render
|
||||||
this.headerText.setText(this.getUsername());
|
this.headerText.setText(this.getUsername());
|
||||||
@ -436,7 +444,7 @@ export class GameStatsUiHandler extends UiHandler {
|
|||||||
const statKeys = Object.keys(displayStats).slice(this.cursor * columns, this.cursor * columns + perPage);
|
const statKeys = Object.keys(displayStats).slice(this.cursor * columns, this.cursor * columns + perPage);
|
||||||
statKeys.forEach((key, s) => {
|
statKeys.forEach((key, s) => {
|
||||||
const stat = displayStats[key] as DisplayStat;
|
const stat = displayStats[key] as DisplayStat;
|
||||||
const value = stat.sourceFunc?.(globalScene.gameData) ?? "-";
|
const value = stat.sourceFunc?.(this.gameData) ?? "-";
|
||||||
const valAsInt = Number.parseInt(value);
|
const valAsInt = Number.parseInt(value);
|
||||||
this.statLabels[s].setText(
|
this.statLabels[s].setText(
|
||||||
!stat.hidden || Number.isNaN(value) || valAsInt ? i18next.t(`gameStatsUiHandler:${stat.label_key}`) : "???",
|
!stat.hidden || Number.isNaN(value) || valAsInt ? i18next.t(`gameStatsUiHandler:${stat.label_key}`) : "???",
|
||||||
@ -512,6 +520,7 @@ export class GameStatsUiHandler extends UiHandler {
|
|||||||
clear() {
|
clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
this.gameStatsContainer.setVisible(false).setActive(false);
|
this.gameStatsContainer.setVisible(false).setActive(false);
|
||||||
|
// TODO: do we need to clear this.gameData here?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ export class MenuUiHandler extends MessageUiHandler {
|
|||||||
keepOpen: true,
|
keepOpen: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (!bypassLogin && loggedInUser?.hasAdminRole) {
|
if (bypassLogin || loggedInUser?.hasAdminRole) {
|
||||||
communityOptions.push({
|
communityOptions.push({
|
||||||
label: "Admin",
|
label: "Admin",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
@ -31,6 +31,7 @@ import { UiMode } from "#enums/ui-mode";
|
|||||||
import { UiTheme } from "#enums/ui-theme";
|
import { UiTheme } from "#enums/ui-theme";
|
||||||
import type { Variant } from "#sprites/variant";
|
import type { Variant } from "#sprites/variant";
|
||||||
import { getVariantIcon, getVariantTint } from "#sprites/variant";
|
import { getVariantIcon, getVariantTint } from "#sprites/variant";
|
||||||
|
import type { GameData } from "#system/game-data";
|
||||||
import { SettingKeyboard } from "#system/settings-keyboard";
|
import { SettingKeyboard } from "#system/settings-keyboard";
|
||||||
import type { DexEntry } from "#types/dex-data";
|
import type { DexEntry } from "#types/dex-data";
|
||||||
import type { DexAttrProps, StarterAttributes } from "#types/save-data";
|
import type { DexAttrProps, StarterAttributes } from "#types/save-data";
|
||||||
@ -236,6 +237,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
private showFormTrayLabel: Phaser.GameObjects.Text;
|
private showFormTrayLabel: Phaser.GameObjects.Text;
|
||||||
private canShowFormTray: boolean;
|
private canShowFormTray: boolean;
|
||||||
private filteredIndices: SpeciesId[];
|
private filteredIndices: SpeciesId[];
|
||||||
|
private gameData: GameData;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(UiMode.POKEDEX);
|
super(UiMode.POKEDEX);
|
||||||
@ -641,10 +643,15 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
this.pokerusSpecies = getPokerusStarters();
|
this.pokerusSpecies = getPokerusStarters();
|
||||||
|
|
||||||
|
this.gameData = globalScene.gameData;
|
||||||
|
|
||||||
// When calling with "refresh", we do not reset the cursor and filters
|
// When calling with "refresh", we do not reset the cursor and filters
|
||||||
if (args.length > 0 && args[0] === "refresh") {
|
if (args.length > 0) {
|
||||||
|
if (args[0] === "refresh") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
this.gameData = args[0];
|
||||||
|
}
|
||||||
|
|
||||||
super.show(args);
|
super.show(args);
|
||||||
|
|
||||||
@ -685,8 +692,8 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
*/
|
*/
|
||||||
initStarterPrefs(species: PokemonSpecies): StarterAttributes {
|
initStarterPrefs(species: PokemonSpecies): StarterAttributes {
|
||||||
const starterAttributes = this.starterPreferences[species.speciesId];
|
const starterAttributes = this.starterPreferences[species.speciesId];
|
||||||
const dexEntry = globalScene.gameData.dexData[species.speciesId];
|
const dexEntry = this.gameData.dexData[species.speciesId];
|
||||||
const starterData = globalScene.gameData.starterData[species.speciesId];
|
const starterData = this.gameData.starterData[species.speciesId];
|
||||||
|
|
||||||
// no preferences or Pokemon wasn't caught, return empty attribute
|
// no preferences or Pokemon wasn't caught, return empty attribute
|
||||||
if (!starterAttributes || !dexEntry.caughtAttr) {
|
if (!starterAttributes || !dexEntry.caughtAttr) {
|
||||||
@ -753,15 +760,14 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
const selectedForm = starterAttributes.form;
|
const selectedForm = starterAttributes.form;
|
||||||
if (
|
if (
|
||||||
selectedForm !== undefined
|
selectedForm !== undefined
|
||||||
&& (!species.forms[selectedForm]?.isStarterSelectable
|
&& (!species.forms[selectedForm]?.isStarterSelectable || !(caughtAttr & this.gameData.getFormAttr(selectedForm)))
|
||||||
|| !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm)))
|
|
||||||
) {
|
) {
|
||||||
// requested form wasn't unlocked/isn't a starter form, purging setting
|
// requested form wasn't unlocked/isn't a starter form, purging setting
|
||||||
starterAttributes.form = undefined;
|
starterAttributes.form = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starterAttributes.nature !== undefined) {
|
if (starterAttributes.nature !== undefined) {
|
||||||
const unlockedNatures = globalScene.gameData.getNaturesForAttr(dexEntry.natureAttr);
|
const unlockedNatures = this.gameData.getNaturesForAttr(dexEntry.natureAttr);
|
||||||
if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) {
|
if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) {
|
||||||
// requested nature wasn't unlocked, purging setting
|
// requested nature wasn't unlocked, purging setting
|
||||||
starterAttributes.nature = undefined;
|
starterAttributes.nature = undefined;
|
||||||
@ -812,7 +818,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!seenFilter) {
|
if (!seenFilter) {
|
||||||
const starterDexEntry = globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)];
|
const starterDexEntry = this.gameData.dexData[this.getStarterSpeciesId(species.speciesId)];
|
||||||
return !!starterDexEntry?.caughtAttr;
|
return !!starterDexEntry?.caughtAttr;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -851,7 +857,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
*/
|
*/
|
||||||
isPassiveAvailable(speciesId: number): boolean {
|
isPassiveAvailable(speciesId: number): boolean {
|
||||||
// Get this species ID's starter data
|
// Get this species ID's starter data
|
||||||
const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)];
|
const starterData = this.gameData.starterData[this.getStarterSpeciesId(speciesId)];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])
|
starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])
|
||||||
@ -866,7 +872,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
*/
|
*/
|
||||||
isValueReductionAvailable(speciesId: number): boolean {
|
isValueReductionAvailable(speciesId: number): boolean {
|
||||||
// Get this species ID's starter data
|
// Get this species ID's starter data
|
||||||
const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)];
|
const starterData = this.gameData.starterData[this.getStarterSpeciesId(speciesId)];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
starterData.candyCount
|
starterData.candyCount
|
||||||
@ -883,7 +889,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
*/
|
*/
|
||||||
isSameSpeciesEggAvailable(speciesId: number): boolean {
|
isSameSpeciesEggAvailable(speciesId: number): boolean {
|
||||||
// Get this species ID's starter data
|
// Get this species ID's starter data
|
||||||
const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)];
|
const starterData = this.gameData.starterData[this.getStarterSpeciesId(speciesId)];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
starterData.candyCount >= getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])
|
starterData.candyCount >= getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])
|
||||||
@ -1372,21 +1378,21 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
const starterId = this.getStarterSpeciesId(species.speciesId);
|
const starterId = this.getStarterSpeciesId(species.speciesId);
|
||||||
|
|
||||||
const currentDexAttr = this.getCurrentDexProps(species.speciesId);
|
const currentDexAttr = this.getCurrentDexProps(species.speciesId);
|
||||||
const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(species, currentDexAttr));
|
const props = this.getSanitizedProps(this.gameData.getSpeciesDexAttrProps(species, currentDexAttr));
|
||||||
|
|
||||||
const data: ContainerData = {
|
const data: ContainerData = {
|
||||||
species,
|
species,
|
||||||
cost: globalScene.gameData.getSpeciesStarterValue(starterId),
|
cost: this.gameData.getSpeciesStarterValue(starterId),
|
||||||
props,
|
props,
|
||||||
};
|
};
|
||||||
|
|
||||||
// First, ensure you have the caught attributes for the species else default to bigint 0
|
// First, ensure you have the caught attributes for the species else default to bigint 0
|
||||||
// TODO: This might be removed depending on how accessible we want the pokedex function to be
|
// TODO: This might be removed depending on how accessible we want the pokedex function to be
|
||||||
const caughtAttr =
|
const caughtAttr =
|
||||||
(globalScene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0))
|
(this.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0))
|
||||||
& (globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)]?.caughtAttr || BigInt(0))
|
& (this.gameData.dexData[this.getStarterSpeciesId(species.speciesId)]?.caughtAttr || BigInt(0))
|
||||||
& species.getFullUnlocksData();
|
& species.getFullUnlocksData();
|
||||||
const starterData = globalScene.gameData.starterData[starterId];
|
const starterData = this.gameData.starterData[starterId];
|
||||||
const isStarterProgressable = speciesEggMoves.hasOwnProperty(starterId);
|
const isStarterProgressable = speciesEggMoves.hasOwnProperty(starterId);
|
||||||
|
|
||||||
// Name filter
|
// Name filter
|
||||||
@ -1635,7 +1641,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Seen Filter
|
// Seen Filter
|
||||||
const dexEntry = globalScene.gameData.dexData[species.speciesId];
|
const dexEntry = this.gameData.dexData[species.speciesId];
|
||||||
const isItSeen = this.isSeen(species, dexEntry, true) || !!dexEntry.caughtAttr;
|
const isItSeen = this.isSeen(species, dexEntry, true) || !!dexEntry.caughtAttr;
|
||||||
const fitsSeen = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
const fitsSeen = this.filterBar.getVals(DropDownColumn.MISC).some(misc => {
|
||||||
if (misc.val === "SEEN_SPECIES" && misc.state === DropDownState.ON) {
|
if (misc.val === "SEEN_SPECIES" && misc.state === DropDownState.ON) {
|
||||||
@ -1725,33 +1731,31 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
case SortCriteria.COST:
|
case SortCriteria.COST:
|
||||||
return (a.cost - b.cost) * -sort.dir;
|
return (a.cost - b.cost) * -sort.dir;
|
||||||
case SortCriteria.CANDY: {
|
case SortCriteria.CANDY: {
|
||||||
const candyCountA =
|
const candyCountA = this.gameData.starterData[this.getStarterSpeciesId(a.species.speciesId)].candyCount;
|
||||||
globalScene.gameData.starterData[this.getStarterSpeciesId(a.species.speciesId)].candyCount;
|
const candyCountB = this.gameData.starterData[this.getStarterSpeciesId(b.species.speciesId)].candyCount;
|
||||||
const candyCountB =
|
|
||||||
globalScene.gameData.starterData[this.getStarterSpeciesId(b.species.speciesId)].candyCount;
|
|
||||||
return (candyCountA - candyCountB) * -sort.dir;
|
return (candyCountA - candyCountB) * -sort.dir;
|
||||||
}
|
}
|
||||||
case SortCriteria.IV: {
|
case SortCriteria.IV: {
|
||||||
const avgIVsA =
|
const avgIVsA =
|
||||||
globalScene.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0)
|
this.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0)
|
||||||
/ globalScene.gameData.dexData[a.species.speciesId].ivs.length;
|
/ this.gameData.dexData[a.species.speciesId].ivs.length;
|
||||||
const avgIVsB =
|
const avgIVsB =
|
||||||
globalScene.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0)
|
this.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0)
|
||||||
/ globalScene.gameData.dexData[b.species.speciesId].ivs.length;
|
/ this.gameData.dexData[b.species.speciesId].ivs.length;
|
||||||
return (avgIVsA - avgIVsB) * -sort.dir;
|
return (avgIVsA - avgIVsB) * -sort.dir;
|
||||||
}
|
}
|
||||||
case SortCriteria.NAME:
|
case SortCriteria.NAME:
|
||||||
return a.species.name.localeCompare(b.species.name) * -sort.dir;
|
return a.species.name.localeCompare(b.species.name) * -sort.dir;
|
||||||
case SortCriteria.CAUGHT:
|
case SortCriteria.CAUGHT:
|
||||||
return (
|
return (
|
||||||
(globalScene.gameData.dexData[a.species.speciesId].caughtCount
|
(this.gameData.dexData[a.species.speciesId].caughtCount
|
||||||
- globalScene.gameData.dexData[b.species.speciesId].caughtCount)
|
- this.gameData.dexData[b.species.speciesId].caughtCount)
|
||||||
* -sort.dir
|
* -sort.dir
|
||||||
);
|
);
|
||||||
case SortCriteria.HATCHED:
|
case SortCriteria.HATCHED:
|
||||||
return (
|
return (
|
||||||
(globalScene.gameData.dexData[this.getStarterSpeciesId(a.species.speciesId)].hatchedCount
|
(this.gameData.dexData[this.getStarterSpeciesId(a.species.speciesId)].hatchedCount
|
||||||
- globalScene.gameData.dexData[this.getStarterSpeciesId(b.species.speciesId)].hatchedCount)
|
- this.gameData.dexData[this.getStarterSpeciesId(b.species.speciesId)].hatchedCount)
|
||||||
* -sort.dir
|
* -sort.dir
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
@ -1795,10 +1799,10 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
container.checkIconId(props.female, props.formIndex, props.shiny, props.variant);
|
container.checkIconId(props.female, props.formIndex, props.shiny, props.variant);
|
||||||
|
|
||||||
const speciesId = data.species.speciesId;
|
const speciesId = data.species.speciesId;
|
||||||
const dexEntry = globalScene.gameData.dexData[speciesId];
|
const dexEntry = this.gameData.dexData[speciesId];
|
||||||
const caughtAttr =
|
const caughtAttr =
|
||||||
dexEntry.caughtAttr
|
dexEntry.caughtAttr
|
||||||
& globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr
|
& this.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr
|
||||||
& data.species.getFullUnlocksData();
|
& data.species.getFullUnlocksData();
|
||||||
|
|
||||||
if (caughtAttr & data.species.getFullUnlocksData() || globalScene.dexForDevs) {
|
if (caughtAttr & data.species.getFullUnlocksData() || globalScene.dexForDevs) {
|
||||||
@ -1857,13 +1861,13 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.starterPassiveBgs.setVisible(
|
container.starterPassiveBgs.setVisible(
|
||||||
!!globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].passiveAttr,
|
!!this.gameData.starterData[this.getStarterSpeciesId(speciesId)].passiveAttr,
|
||||||
);
|
);
|
||||||
container.hiddenAbilityIcon.setVisible(
|
container.hiddenAbilityIcon.setVisible(
|
||||||
!!caughtAttr && !!(globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].abilityAttr & 4),
|
!!caughtAttr && !!(this.gameData.starterData[this.getStarterSpeciesId(speciesId)].abilityAttr & 4),
|
||||||
);
|
);
|
||||||
container.classicWinIcon.setVisible(
|
container.classicWinIcon.setVisible(
|
||||||
globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].classicWinCount > 0,
|
this.gameData.starterData[this.getStarterSpeciesId(speciesId)].classicWinCount > 0,
|
||||||
);
|
);
|
||||||
container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false);
|
container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false);
|
||||||
|
|
||||||
@ -1989,15 +1993,15 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
this.formTrayContainer.setX((goLeft ? boxPos.x - 18 * (this.trayColumns - spaceRight) : boxPos.x) - 3);
|
this.formTrayContainer.setX((goLeft ? boxPos.x - 18 * (this.trayColumns - spaceRight) : boxPos.x) - 3);
|
||||||
this.formTrayContainer.setY(goUp ? boxPos.y - this.trayBg.height : boxPos.y + 17);
|
this.formTrayContainer.setY(goUp ? boxPos.y - this.trayBg.height : boxPos.y + 17);
|
||||||
|
|
||||||
const dexEntry = globalScene.gameData.dexData[species.speciesId];
|
const dexEntry = this.gameData.dexData[species.speciesId];
|
||||||
const dexAttr = this.getCurrentDexProps(species.speciesId);
|
const dexAttr = this.getCurrentDexProps(species.speciesId);
|
||||||
const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr));
|
const props = this.getSanitizedProps(this.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr));
|
||||||
|
|
||||||
this.trayContainers = [];
|
this.trayContainers = [];
|
||||||
const isFormSeen = this.isSeen(species, dexEntry);
|
const isFormSeen = this.isSeen(species, dexEntry);
|
||||||
this.trayForms.map((f, index) => {
|
this.trayForms.map((f, index) => {
|
||||||
const isFormCaught = dexEntry
|
const isFormCaught = dexEntry
|
||||||
? (dexEntry.caughtAttr & species.getFullUnlocksData() & globalScene.gameData.getFormAttr(f.formIndex ?? 0)) > 0n
|
? (dexEntry.caughtAttr & species.getFullUnlocksData() & this.gameData.getFormAttr(f.formIndex ?? 0)) > 0n
|
||||||
: false;
|
: false;
|
||||||
const formContainer = new PokedexMonContainer(species, {
|
const formContainer = new PokedexMonContainer(species, {
|
||||||
formIndex: f.formIndex,
|
formIndex: f.formIndex,
|
||||||
@ -2066,7 +2070,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFriendship(speciesId: number) {
|
getFriendship(speciesId: number) {
|
||||||
let currentFriendship = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].friendship;
|
let currentFriendship = this.gameData.starterData[this.getStarterSpeciesId(speciesId)].friendship;
|
||||||
if (!currentFriendship || currentFriendship === undefined) {
|
if (!currentFriendship || currentFriendship === undefined) {
|
||||||
currentFriendship = 0;
|
currentFriendship = 0;
|
||||||
}
|
}
|
||||||
@ -2094,7 +2098,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
if (container) {
|
if (container) {
|
||||||
const lastSpeciesIcon = container.icon;
|
const lastSpeciesIcon = container.icon;
|
||||||
const dexAttr = this.getCurrentDexProps(container.species.speciesId);
|
const dexAttr = this.getCurrentDexProps(container.species.speciesId);
|
||||||
const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(container.species, dexAttr));
|
const props = this.getSanitizedProps(this.gameData.getSpeciesDexAttrProps(container.species, dexAttr));
|
||||||
this.checkIconId(lastSpeciesIcon, container.species, props.female, props.formIndex, props.shiny, props.variant);
|
this.checkIconId(lastSpeciesIcon, container.species, props.female, props.formIndex, props.shiny, props.variant);
|
||||||
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
||||||
// Resume the animation for the previously selected species
|
// Resume the animation for the previously selected species
|
||||||
@ -2103,7 +2107,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSpecies(species: PokemonSpecies | null) {
|
setSpecies(species: PokemonSpecies | null) {
|
||||||
this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null;
|
this.speciesStarterDexEntry = species ? this.gameData.dexData[species.speciesId] : null;
|
||||||
|
|
||||||
if (!species && globalScene.ui.getTooltip().visible) {
|
if (!species && globalScene.ui.getTooltip().visible) {
|
||||||
globalScene.ui.hideTooltip();
|
globalScene.ui.hideTooltip();
|
||||||
@ -2182,15 +2186,15 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (species) {
|
if (species) {
|
||||||
const dexEntry = globalScene.gameData.dexData[species.speciesId];
|
const dexEntry = this.gameData.dexData[species.speciesId];
|
||||||
const caughtAttr =
|
const caughtAttr =
|
||||||
dexEntry.caughtAttr
|
dexEntry.caughtAttr
|
||||||
& globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)].caughtAttr
|
& this.gameData.dexData[this.getStarterSpeciesId(species.speciesId)].caughtAttr
|
||||||
& species.getFullUnlocksData();
|
& species.getFullUnlocksData();
|
||||||
|
|
||||||
if (caughtAttr) {
|
if (caughtAttr) {
|
||||||
const props = this.getSanitizedProps(
|
const props = this.getSanitizedProps(
|
||||||
globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)),
|
this.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (shiny === undefined) {
|
if (shiny === undefined) {
|
||||||
@ -2207,7 +2211,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFormCaught = dexEntry ? (caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n : false;
|
const isFormCaught = dexEntry ? (caughtAttr & this.gameData.getFormAttr(formIndex ?? 0)) > 0n : false;
|
||||||
const isFormSeen = this.isSeen(species, dexEntry);
|
const isFormSeen = this.isSeen(species, dexEntry);
|
||||||
|
|
||||||
const assetLoadCancelled = new BooleanHolder(false);
|
const assetLoadCancelled = new BooleanHolder(false);
|
||||||
@ -2291,7 +2295,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
updateStarterValueLabel(starter: PokedexMonContainer): void {
|
updateStarterValueLabel(starter: PokedexMonContainer): void {
|
||||||
const speciesId = starter.species.speciesId;
|
const speciesId = starter.species.speciesId;
|
||||||
const baseStarterValue = speciesStarterCosts[speciesId];
|
const baseStarterValue = speciesStarterCosts[speciesId];
|
||||||
const starterValue = globalScene.gameData.getSpeciesStarterValue(this.getStarterSpeciesId(speciesId));
|
const starterValue = this.gameData.getSpeciesStarterValue(this.getStarterSpeciesId(speciesId));
|
||||||
starter.cost = starterValue;
|
starter.cost = starterValue;
|
||||||
let valueStr = starterValue.toString();
|
let valueStr = starterValue.toString();
|
||||||
if (valueStr.startsWith("0.")) {
|
if (valueStr.startsWith("0.")) {
|
||||||
@ -2356,8 +2360,8 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
let props = 0n;
|
let props = 0n;
|
||||||
const species = allSpecies.find(sp => sp.speciesId === speciesId);
|
const species = allSpecies.find(sp => sp.speciesId === speciesId);
|
||||||
const caughtAttr =
|
const caughtAttr =
|
||||||
globalScene.gameData.dexData[speciesId].caughtAttr
|
this.gameData.dexData[speciesId].caughtAttr
|
||||||
& globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr
|
& this.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr
|
||||||
& (species?.getFullUnlocksData() ?? 0n);
|
& (species?.getFullUnlocksData() ?? 0n);
|
||||||
|
|
||||||
/* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props
|
/* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props
|
||||||
@ -2401,7 +2405,7 @@ export class PokedexUiHandler extends MessageUiHandler {
|
|||||||
props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.form)) * DexAttr.DEFAULT_FORM;
|
props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.form)) * DexAttr.DEFAULT_FORM;
|
||||||
} else {
|
} else {
|
||||||
// Get the first unlocked form
|
// Get the first unlocked form
|
||||||
props += globalScene.gameData.getFormAttr(globalScene.gameData.getFormIndex(caughtAttr));
|
props += this.gameData.getFormAttr(this.gameData.getFormIndex(caughtAttr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return props;
|
return props;
|
||||||
|
Loading…
Reference in New Issue
Block a user