Back to showing only caught battleforms; added dexForDevs option

This commit is contained in:
Wlowscha 2025-01-30 00:21:18 +01:00
parent dabc275bdf
commit bd61ac6c9f
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
3 changed files with 61 additions and 33 deletions

View File

@ -161,6 +161,7 @@ export default class BattleScene extends SceneBase {
public reroll: boolean = false; public reroll: boolean = false;
public shopCursorTarget: number = ShopCursorTarget.REWARDS; public shopCursorTarget: number = ShopCursorTarget.REWARDS;
public commandCursorMemory: boolean = false; public commandCursorMemory: boolean = false;
public dexForDevs: boolean = false;
public showMovesetFlyout: boolean = true; public showMovesetFlyout: boolean = true;
public showArenaFlyout: boolean = true; public showArenaFlyout: boolean = true;
public showTimeOfDayWidget: boolean = true; public showTimeOfDayWidget: boolean = true;

View File

@ -9,6 +9,7 @@ import { EaseType } from "#enums/ease-type";
import { MoneyFormat } from "#enums/money-format"; import { MoneyFormat } from "#enums/money-format";
import { PlayerGender } from "#enums/player-gender"; import { PlayerGender } from "#enums/player-gender";
import { ShopCursorTarget } from "#enums/shop-cursor-target"; import { ShopCursorTarget } from "#enums/shop-cursor-target";
import * as Utils from "../../utils";
const VOLUME_OPTIONS: SettingOption[] = new Array(11).fill(null).map((_, i) => i ? { const VOLUME_OPTIONS: SettingOption[] = new Array(11).fill(null).map((_, i) => i ? {
value: (i * 10).toString(), value: (i * 10).toString(),
@ -150,6 +151,7 @@ export const SettingKeys = {
Show_Stats_on_Level_Up: "SHOW_LEVEL_UP_STATS", Show_Stats_on_Level_Up: "SHOW_LEVEL_UP_STATS",
Shop_Cursor_Target: "SHOP_CURSOR_TARGET", Shop_Cursor_Target: "SHOP_CURSOR_TARGET",
Command_Cursor_Memory: "COMMAND_CURSOR_MEMORY", Command_Cursor_Memory: "COMMAND_CURSOR_MEMORY",
Dex_For_Devs: "DEX_FOR_DEVS",
Candy_Upgrade_Notification: "CANDY_UPGRADE_NOTIFICATION", Candy_Upgrade_Notification: "CANDY_UPGRADE_NOTIFICATION",
Candy_Upgrade_Display: "CANDY_UPGRADE_DISPLAY", Candy_Upgrade_Display: "CANDY_UPGRADE_DISPLAY",
Move_Info: "MOVE_INFO", Move_Info: "MOVE_INFO",
@ -691,6 +693,16 @@ export const Setting: Array<Setting> = [
} }
]; ];
if (Utils.isLocal) {
Setting.push({
key: SettingKeys.Dex_For_Devs,
label: i18next.t("settings:dexForDevs"),
options: OFF_ON,
default: 0,
type: SettingType.GENERAL
});
}
/** /**
* Return the index of a Setting * Return the index of a Setting
* @param key SettingKey * @param key SettingKey
@ -828,6 +840,9 @@ export function setSetting(setting: string, value: integer): boolean {
case SettingKeys.Command_Cursor_Memory: case SettingKeys.Command_Cursor_Memory:
globalScene.commandCursorMemory = Setting[index].options[value].value === "On"; globalScene.commandCursorMemory = Setting[index].options[value].value === "On";
break; break;
case SettingKeys.Dex_For_Devs:
globalScene.dexForDevs = Setting[index].options[value].value === "On";
break;
case SettingKeys.EXP_Gains_Speed: case SettingKeys.EXP_Gains_Speed:
globalScene.expGainsSpeed = value; globalScene.expGainsSpeed = value;
break; break;

View File

@ -745,6 +745,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
return biomes; return biomes;
} }
isCaught(otherSpeciesDexEntry?: DexEntry): bigint {
if (globalScene.dexForDevs) {
return 255n;
}
const dexEntry = otherSpeciesDexEntry ? otherSpeciesDexEntry : this.speciesStarterDexEntry;
return dexEntry?.caughtAttr ?? 0n;
}
/** /**
* Check whether a given form is caught for a given species. * Check whether a given form is caught for a given species.
* All forms that can be reached through a form change during battle are considered caught and show up in the dex as such. * All forms that can be reached through a form change during battle are considered caught and show up in the dex as such.
@ -754,14 +763,16 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
* @returns StarterAttributes for the species * @returns StarterAttributes for the species
*/ */
isFormCaught(otherSpecies?: PokemonSpecies, otherFormIndex?: integer | undefined): boolean { isFormCaught(otherSpecies?: PokemonSpecies, otherFormIndex?: integer | undefined): boolean {
if (globalScene.dexForDevs) {
return true;
}
const species = otherSpecies ? otherSpecies : this.species; const species = otherSpecies ? otherSpecies : this.species;
const formIndex = otherFormIndex !== undefined ? otherFormIndex : this.formIndex; const formIndex = otherFormIndex !== undefined ? otherFormIndex : this.formIndex;
const dexEntry = globalScene.gameData.dexData[species.speciesId]; const dexEntry = globalScene.gameData.dexData[species.speciesId];
const allFormChanges = pokemonFormChanges.hasOwnProperty(species.speciesId) ? pokemonFormChanges[species.speciesId] : [];
const formChangeAccess = allFormChanges.filter(f => (f.formKey === species.forms[formIndex].formKey)).length > 0;
const isFormCaught = dexEntry ? const isFormCaught = dexEntry ?
(dexEntry.caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n || formChangeAccess (dexEntry.caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n
: false; : false;
return isFormCaught; return isFormCaught;
} }
@ -777,14 +788,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
initStarterPrefs(): StarterAttributes { initStarterPrefs(): StarterAttributes {
const starterAttributes : StarterAttributes | null = this.species ? { ...this.savedStarterAttributes } : null; const starterAttributes : StarterAttributes | null = this.species ? { ...this.savedStarterAttributes } : null;
const dexEntry = globalScene.gameData.dexData[this.species.speciesId]; const dexEntry = globalScene.gameData.dexData[this.species.speciesId];
const caughtAttr = this.isCaught(dexEntry);
// 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 || !caughtAttr) {
return {}; return {};
} }
const caughtAttr = dexEntry.caughtAttr;
const hasShiny = caughtAttr & DexAttr.SHINY; const hasShiny = caughtAttr & DexAttr.SHINY;
const hasNonShiny = caughtAttr & DexAttr.NON_SHINY; const hasNonShiny = caughtAttr & DexAttr.NON_SHINY;
if (starterAttributes.shiny && !hasShiny) { if (starterAttributes.shiny && !hasShiny) {
@ -929,7 +939,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
let success = false; let success = false;
let error = false; let error = false;
const isCaught = this.speciesStarterDexEntry?.caughtAttr; const isCaught = this.isCaught();
const isFormCaught = this.isFormCaught(); const isFormCaught = this.isFormCaught();
if (this.blockInputOverlay) { if (this.blockInputOverlay) {
@ -1253,7 +1263,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
case MenuOptions.BIOMES: case MenuOptions.BIOMES:
if (!(this.speciesStarterDexEntry?.caughtAttr || this.speciesStarterDexEntry?.seenAttr)) { if (!(this.isCaught() || this.speciesStarterDexEntry?.seenAttr)) {
error = true; error = true;
} else { } else {
this.blockInput = true; this.blockInput = true;
@ -1389,8 +1399,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
}); });
this.evolutions.map(evo => { this.evolutions.map(evo => {
const evoSpecies = allSpecies.find(species => species.speciesId === evo.speciesId); const evoSpecies = allSpecies.find(species => species.speciesId === evo.speciesId);
const evoSpeciesStarterDexEntry = evoSpecies ? globalScene.gameData.dexData[evoSpecies.speciesId] : null; const evoSpeciesStarterDexEntry = evoSpecies ? globalScene.gameData.dexData[evoSpecies.speciesId] : undefined;
const isCaughtEvo = evoSpeciesStarterDexEntry?.caughtAttr ? true : false; const isCaughtEvo = this.isCaught(evoSpeciesStarterDexEntry) ? true : false;
// Attempts to find the formIndex of the evolved species // Attempts to find the formIndex of the evolved species
const newFormKey = evo.evoFormKey ? evo.evoFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : ""); const newFormKey = evo.evoFormKey ? evo.evoFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : "");
const matchingForm = evoSpecies?.forms.find(form => form.formKey === newFormKey); const matchingForm = evoSpecies?.forms.find(form => form.formKey === newFormKey);
@ -1562,15 +1572,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
do { do {
newVariant = (newVariant + 1) % 3; newVariant = (newVariant + 1) % 3;
if (newVariant === 0) { if (newVariant === 0) {
if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.DEFAULT_VARIANT) { // TODO: is this bang correct? if (this.isCaught() & DexAttr.DEFAULT_VARIANT) { // TODO: is this bang correct?
break; break;
} }
} else if (newVariant === 1) { } else if (newVariant === 1) {
if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.VARIANT_2) { // TODO: is this bang correct? if (this.isCaught() & DexAttr.VARIANT_2) { // TODO: is this bang correct?
break; break;
} }
} else { } else {
if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.VARIANT_3) { // TODO: is this bang correct? if (this.isCaught() & DexAttr.VARIANT_3) { // TODO: is this bang correct?
break; break;
} }
} }
@ -1591,7 +1601,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
let newFormIndex = this.formIndex; let newFormIndex = this.formIndex;
do { do {
newFormIndex = (newFormIndex + 1) % formCount; newFormIndex = (newFormIndex + 1) % formCount;
if (this.species.forms[newFormIndex].isStarterSelectable) { // TODO: are those bangs correct? if (this.species.forms[newFormIndex].isStarterSelectable || globalScene.dexForDevs) { // TODO: are those bangs correct?
break; break;
} }
} while (newFormIndex !== props.formIndex); } while (newFormIndex !== props.formIndex);
@ -1864,7 +1874,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const isFormCaught = this.isFormCaught(); const isFormCaught = this.isFormCaught();
if (this.speciesStarterDexEntry?.caughtAttr) { if (this.isCaught()) {
if (isFormCaught) { if (isFormCaught) {
if (!pokemonPrevolutions.hasOwnProperty(this.species.speciesId)) { if (!pokemonPrevolutions.hasOwnProperty(this.species.speciesId)) {
this.updateButtonIcon(SettingKeyboard.Button_Stats, gamepadType, this.candyUpgradeIconElement, this.candyUpgradeLabel); this.updateButtonIcon(SettingKeyboard.Button_Stats, gamepadType, this.candyUpgradeIconElement, this.candyUpgradeLabel);
@ -1918,7 +1928,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const isFormCaught = this.isFormCaught(); const isFormCaught = this.isFormCaught();
if ((this.speciesStarterDexEntry?.caughtAttr && isFormCaught) || (this.speciesStarterDexEntry?.seenAttr && cursor === 5)) { if ((this.isCaught() && isFormCaught) || (this.speciesStarterDexEntry?.seenAttr && cursor === 5)) {
ui.showText(this.menuDescriptions[cursor]); ui.showText(this.menuDescriptions[cursor]);
} else { } else {
ui.showText(""); ui.showText("");
@ -1947,7 +1957,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
if (this.statsMode) { if (this.statsMode) {
if (this.speciesStarterDexEntry?.caughtAttr) { if (this.isCaught()) {
this.statsContainer.setVisible(true); this.statsContainer.setVisible(true);
this.showStats(); this.showStats();
} else { } else {
@ -1957,7 +1967,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
} }
} }
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr)) { if (species && (this.speciesStarterDexEntry?.seenAttr || this.isCaught())) {
this.pokemonNumberText.setText(padInt(species.speciesId, 4)); this.pokemonNumberText.setText(padInt(species.speciesId, 4));
if (starterAttributes?.nickname) { if (starterAttributes?.nickname) {
const name = decodeURIComponent(escape(atob(starterAttributes.nickname))); const name = decodeURIComponent(escape(atob(starterAttributes.nickname)));
@ -1966,10 +1976,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonNameText.setText(species.name); this.pokemonNameText.setText(species.name);
} }
if (this.speciesStarterDexEntry?.caughtAttr) { if (this.isCaught()) {
const colorScheme = starterColors[species.speciesId]; const colorScheme = starterColors[species.speciesId];
const luck = globalScene.gameData.getDexAttrLuck(this.speciesStarterDexEntry.caughtAttr); const luck = globalScene.gameData.getDexAttrLuck(this.isCaught());
this.pokemonLuckText.setVisible(!!luck); this.pokemonLuckText.setVisible(!!luck);
this.pokemonLuckText.setText(luck.toString()); this.pokemonLuckText.setText(luck.toString());
this.pokemonLuckText.setTint(getVariantTint(Math.min(luck - 1, 2) as Variant)); this.pokemonLuckText.setTint(getVariantTint(Math.min(luck - 1, 2) as Variant));
@ -1987,13 +1997,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonGrowthRateText.setShadowColor(getGrowthRateColor(species.growthRate, true)); this.pokemonGrowthRateText.setShadowColor(getGrowthRateColor(species.growthRate, true));
this.pokemonGrowthRateLabelText.setVisible(true); this.pokemonGrowthRateLabelText.setVisible(true);
this.pokemonUncaughtText.setVisible(false); this.pokemonUncaughtText.setVisible(false);
this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry.caughtCount}`); this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry?.caughtCount}`);
if (species.speciesId === Species.MANAPHY || species.speciesId === Species.PHIONE) { if (species.speciesId === Species.MANAPHY || species.speciesId === Species.PHIONE) {
this.pokemonHatchedIcon.setFrame("manaphy"); this.pokemonHatchedIcon.setFrame("manaphy");
} else { } else {
this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species)); this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species));
} }
this.pokemonHatchedCountText.setText(`${this.speciesStarterDexEntry.hatchedCount}`); this.pokemonHatchedCountText.setText(`${this.speciesStarterDexEntry?.hatchedCount}`);
const defaultDexAttr = this.getCurrentDexProps(species.speciesId); const defaultDexAttr = this.getCurrentDexProps(species.speciesId);
const defaultProps = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); const defaultProps = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
@ -2166,9 +2176,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (species) { if (species) {
const dexEntry = globalScene.gameData.dexData[species.speciesId]; const dexEntry = globalScene.gameData.dexData[species.speciesId];
const caughtAttr = globalScene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0); const caughtAttr = this.isCaught(dexEntry);
if (!dexEntry.caughtAttr) { if (!caughtAttr) {
const props = this.starterAttributes; const props = this.starterAttributes;
if (shiny === undefined || shiny !== props.shiny) { if (shiny === undefined || shiny !== props.shiny) {
@ -2233,9 +2243,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const isFemaleCaught = !!(caughtAttr & DexAttr.FEMALE); const isFemaleCaught = !!(caughtAttr & DexAttr.FEMALE);
this.canCycleGender = isMaleCaught && isFemaleCaught; this.canCycleGender = isMaleCaught && isFemaleCaught;
this.canCycleForm = species.forms.filter(f => f.isStarterSelectable).filter(f => f).length > 1; // If the dev option for the dex is selected, all forms can be cycled through
this.canCycleForm = globalScene.dexForDevs ? species.forms.length > 1 :
species.forms.filter(f => f.isStarterSelectable).filter(f => f).length > 1;
if (dexEntry.caughtAttr && species.malePercent !== null) { if (caughtAttr && species.malePercent !== null) {
const gender = !female ? Gender.MALE : Gender.FEMALE; const gender = !female ? Gender.MALE : Gender.FEMALE;
this.pokemonGenderText.setText(getGenderSymbol(gender)); this.pokemonGenderText.setText(getGenderSymbol(gender));
this.pokemonGenderText.setColor(getGenderColor(gender)); this.pokemonGenderText.setColor(getGenderColor(gender));
@ -2244,20 +2256,20 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonGenderText.setText(""); this.pokemonGenderText.setText("");
} }
if (dexEntry.caughtAttr) { if (caughtAttr) {
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
const crier = (this.species.forms && this.species.forms.length > 0) ? this.species.forms[formIndex ?? this.formIndex] : this.species;
crier.cry();
});
if (isFormCaught) { if (isFormCaught) {
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
const crier = (this.species.forms && this.species.forms.length > 0) ? this.species.forms[formIndex ?? this.formIndex] : this.species;
crier.cry();
});
this.pokemonSprite.clearTint(); this.pokemonSprite.clearTint();
} else { } else {
this.pokemonSprite.setTint(0x000000); this.pokemonSprite.setTint(0x000000);
} }
} }
if (dexEntry.caughtAttr || forSeen) { if (caughtAttr || forSeen) {
const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex!); // TODO: is the bang correct? const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex!); // TODO: is the bang correct?
this.setTypeIcons(speciesForm.type1, speciesForm.type2); this.setTypeIcons(speciesForm.type1, speciesForm.type2);
this.pokemonFormText.setText(this.getFormString((speciesForm as PokemonForm).formKey, species)); this.pokemonFormText.setText(this.getFormString((speciesForm as PokemonForm).formKey, species));