From daaf2ef532c3a161d52ce2156244a442306759b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinto?= Date: Mon, 6 May 2024 18:32:51 +0200 Subject: [PATCH] Feature: Displaying all starters based on environment parameters. --- .env.development | 5 ++++- src/data/enums/species.ts | 12 +++++++++++- src/system/game-data.ts | 24 +++++++++++++----------- src/vite-env.d.ts | 13 +++++++++++++ vite.env.d.ts | 12 ------------ 5 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 src/vite-env.d.ts delete mode 100644 vite.env.d.ts diff --git a/.env.development b/.env.development index effc4f15860..94c5e1ee7ce 100644 --- a/.env.development +++ b/.env.development @@ -2,4 +2,7 @@ VITE_ENVIRONMENT="local" VITE_API_BASE_URL="http://localhost:8001" VITE_BYPASS_LOGIN=true -VITE_BYPASS_TUTORIAL=false \ No newline at end of file +VITE_BYPASS_TUTORIAL=false + +# Debug +VITE_ACTIVATE_ALL_POKEMON_STARTERS=false \ No newline at end of file diff --git a/src/data/enums/species.ts b/src/data/enums/species.ts index 0197a09ff85..4537b15ca47 100644 --- a/src/data/enums/species.ts +++ b/src/data/enums/species.ts @@ -1093,4 +1093,14 @@ export const defaultStarterSpecies: Species[] = [ Species.ROWLET, Species.LITTEN, Species.POPPLIO, Species.GROOKEY, Species.SCORBUNNY, Species.SOBBLE, Species.SPRIGATITO, Species.FUECOCO, Species.QUAXLY -]; \ No newline at end of file +]; + +if(Boolean(import.meta.env.VITE_ACTIVATE_ALL_POKEMON_STARTERS)){ + console.log('je suis passé') + defaultStarterSpecies.length = 0; + for (const value in Species) { + if (isNaN(Number(value))) { + defaultStarterSpecies.push(Species[value as keyof typeof Species]); + } + } +} diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 6410c52a2b8..505822258cc 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -166,7 +166,7 @@ export interface StarterMoveData { } export interface StarterDataEntry { - moveset: StarterMoveset | StarterFormMoveData; + moveset: StarterMoveset | StarterFormMoveData; eggMoves: integer; candyCount: integer; friendship: integer; @@ -204,7 +204,7 @@ export class GameData { public secretId: integer; public gender: PlayerGender; - + public dexData: DexData; private defaultDexData: DexData; @@ -315,7 +315,7 @@ export class GameData { console.debug(systemData); /*const versions = [ this.scene.game.config.gameVersion, data.gameVersion || '0.0.0' ]; - + if (versions[0] !== versions[1]) { const [ versionNumbers, oldVersionNumbers ] = versions.map(ver => ver.split('.').map(v => parseInt(v))); }*/ @@ -372,7 +372,7 @@ export class GameData { for (let a of Object.keys(systemData.achvUnlocks)) { if (achvs.hasOwnProperty(a)) this.achvUnlocks[a] = systemData.achvUnlocks[a]; - } + } } if (systemData.voucherUnlocks) { @@ -856,7 +856,7 @@ export class GameData { let saveFile: any = document.getElementById('saveFile'); if (saveFile) saveFile.remove(); - + saveFile = document.createElement('input'); saveFile.id = 'saveFile'; saveFile.type = 'file'; @@ -1034,7 +1034,7 @@ export class GameData { : AbilityAttr.ABILITY_HIDDEN; } dexEntry.natureAttr |= Math.pow(2, pokemon.nature + 1); - + const hasPrevolution = pokemonPrevolutions.hasOwnProperty(species.speciesId); const newCatch = !caughtAttr; const hasNewAttr = (caughtAttr & dexAttr) !== dexAttr; @@ -1063,7 +1063,7 @@ export class GameData { if (!hasPrevolution && (!pokemon.scene.gameMode.isDaily || hasNewAttr || fromEgg)) this.addStarterCandy(species, (1 * (pokemon.isShiny() ? 5 * Math.pow(2, pokemon.variant || 0) : 1)) * (fromEgg || pokemon.isBoss() ? 2 : 1)); } - + const checkPrevolution = () => { if (hasPrevolution) { const prevolutionSpecies = pokemonPrevolutions[species.speciesId]; @@ -1235,7 +1235,7 @@ export class GameData { getFormAttr(formIndex: integer): bigint { return BigInt(Math.pow(2, 7 + formIndex)); } - + consolidateDexData(dexData: DexData): void { for (let k of Object.keys(dexData)) { const entry = dexData[k] as DexEntry; @@ -1308,7 +1308,9 @@ export class GameData { } fixStarterData(systemData: SystemSaveData): void { - for (let starterId of defaultStarterSpecies) - systemData.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1; - } + if(!Boolean(import.meta.env.VITE_ACTIVATE_ALL_POKEMON_STARTERS)){ + for (let starterId of defaultStarterSpecies) + systemData.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1; + } + } } \ No newline at end of file diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 00000000000..4a982c4c1dc --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1,13 @@ +/// + +interface ImportMetaEnv { + readonly VITE_ENVIRONMENT: string + readonly VITE_API_BASE_URL: string + readonly VITE_BYPASS_LOGIN: boolean + readonly VITE_BYPASS_TUTORIAL: boolean + readonly VITE_ACTIVATE_ALL_POKEMON_STARTERS: boolean +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} \ No newline at end of file diff --git a/vite.env.d.ts b/vite.env.d.ts deleted file mode 100644 index 801785b6384..00000000000 --- a/vite.env.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -interface ImportMetaEnv { - readonly VITE_ENVIRONMENT: string; - readonly VITE_API_BASE_URL: string; - readonly VITE_BYPASS_LOGIN: boolean; - readonly VITE_BYPASS_TUTORIAL: boolean; -} - -interface ImportMeta { - readonly env: ImportMetaEnv; -} \ No newline at end of file