Manual merge for game-data.ts
This commit is contained in:
parent
cbf8ea8f2f
commit
4fc51e2636
|
@ -41,7 +41,6 @@ import { Moves } from "#enums/moves";
|
||||||
import { PlayerGender } from "#enums/player-gender";
|
import { PlayerGender } from "#enums/player-gender";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import { applyChallenges, ChallengeType } from "#app/data/challenge.js";
|
import { applyChallenges, ChallengeType } from "#app/data/challenge.js";
|
||||||
import { Abilities } from "#app/enums/abilities.js";
|
|
||||||
|
|
||||||
export const defaultStarterSpecies: Species[] = [
|
export const defaultStarterSpecies: Species[] = [
|
||||||
Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE,
|
Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE,
|
||||||
|
@ -297,7 +296,6 @@ export class GameData {
|
||||||
public starterData: StarterData;
|
public starterData: StarterData;
|
||||||
|
|
||||||
public gameStats: GameStats;
|
public gameStats: GameStats;
|
||||||
|
|
||||||
public runHistory: RunHistoryData;
|
public runHistory: RunHistoryData;
|
||||||
|
|
||||||
public unlocks: Unlocks;
|
public unlocks: Unlocks;
|
||||||
|
@ -319,6 +317,7 @@ export class GameData {
|
||||||
this.secretId = Utils.randInt(65536);
|
this.secretId = Utils.randInt(65536);
|
||||||
this.starterData = {};
|
this.starterData = {};
|
||||||
this.gameStats = new GameStats();
|
this.gameStats = new GameStats();
|
||||||
|
this.runHistory = {};
|
||||||
this.unlocks = {
|
this.unlocks = {
|
||||||
[Unlockables.ENDLESS_MODE]: false,
|
[Unlockables.ENDLESS_MODE]: false,
|
||||||
[Unlockables.MINI_BLACK_HOLE]: false,
|
[Unlockables.MINI_BLACK_HOLE]: false,
|
||||||
|
@ -326,7 +325,6 @@ export class GameData {
|
||||||
};
|
};
|
||||||
this.achvUnlocks = {};
|
this.achvUnlocks = {};
|
||||||
this.voucherUnlocks = {};
|
this.voucherUnlocks = {};
|
||||||
this.runHistory = {};
|
|
||||||
this.voucherCounts = {
|
this.voucherCounts = {
|
||||||
[VoucherType.REGULAR]: 0,
|
[VoucherType.REGULAR]: 0,
|
||||||
[VoucherType.PLUS]: 0,
|
[VoucherType.PLUS]: 0,
|
||||||
|
@ -365,7 +363,7 @@ export class GameData {
|
||||||
this.scene.ui.savingIcon.show();
|
this.scene.ui.savingIcon.show();
|
||||||
const data = this.getSystemSaveData();
|
const data = this.getSystemSaveData();
|
||||||
|
|
||||||
const maxIntAttrValue = Math.pow(2, 31);
|
const maxIntAttrValue = 0x80000000;
|
||||||
const systemData = JSON.stringify(data, (k: any, v: any) => typeof v === "bigint" ? v <= maxIntAttrValue ? Number(v) : v.toString() : v);
|
const systemData = JSON.stringify(data, (k: any, v: any) => typeof v === "bigint" ? v <= maxIntAttrValue ? Number(v) : v.toString() : v);
|
||||||
|
|
||||||
localStorage.setItem(`data_${loggedInUser.username}`, encrypt(systemData, bypassLogin));
|
localStorage.setItem(`data_${loggedInUser.username}`, encrypt(systemData, bypassLogin));
|
||||||
|
@ -454,7 +452,6 @@ export class GameData {
|
||||||
if (versions[0] !== versions[1]) {
|
if (versions[0] !== versions[1]) {
|
||||||
const [ versionNumbers, oldVersionNumbers ] = versions.map(ver => ver.split('.').map(v => parseInt(v)));
|
const [ versionNumbers, oldVersionNumbers ] = versions.map(ver => ver.split('.').map(v => parseInt(v)));
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (!localStorage.hasOwnProperty(`runHistoryData_${loggedInUser.username}`)) {
|
if (!localStorage.hasOwnProperty(`runHistoryData_${loggedInUser.username}`)) {
|
||||||
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, encrypt("", true));
|
localStorage.setItem(`runHistoryData_${loggedInUser.username}`, encrypt("", true));
|
||||||
}
|
}
|
||||||
|
@ -949,14 +946,6 @@ export class GameData {
|
||||||
const handleSessionData = async (sessionDataStr: string) => {
|
const handleSessionData = async (sessionDataStr: string) => {
|
||||||
try {
|
try {
|
||||||
const sessionData = this.parseSessionData(sessionDataStr);
|
const sessionData = this.parseSessionData(sessionDataStr);
|
||||||
for (let i = 0; i <= 5; i++) {
|
|
||||||
const speciesToCheck = getPokemonSpecies(sessionData.party[i]?.species);
|
|
||||||
if (sessionData.party[i]?.abilityIndex === 1) {
|
|
||||||
if (speciesToCheck.ability1 === speciesToCheck.ability2 && speciesToCheck.abilityHidden !== Abilities.NONE && speciesToCheck.abilityHidden !== speciesToCheck.ability1) {
|
|
||||||
sessionData.party[i].abilityIndex = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resolve(sessionData);
|
resolve(sessionData);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
@ -1269,7 +1258,7 @@ export class GameData {
|
||||||
}
|
}
|
||||||
const sessionData = useCachedSession ? this.parseSessionData(decrypt(localStorage.getItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ""}_${loggedInUser.username}`), bypassLogin)) : this.getSessionSaveData(scene);
|
const sessionData = useCachedSession ? this.parseSessionData(decrypt(localStorage.getItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ""}_${loggedInUser.username}`), bypassLogin)) : this.getSessionSaveData(scene);
|
||||||
|
|
||||||
const maxIntAttrValue = Math.pow(2, 31);
|
const maxIntAttrValue = 0x80000000;
|
||||||
const systemData = useCachedSystem ? this.parseSystemData(decrypt(localStorage.getItem(`data_${loggedInUser.username}`), bypassLogin)) : this.getSystemSaveData();
|
const systemData = useCachedSystem ? this.parseSystemData(decrypt(localStorage.getItem(`data_${loggedInUser.username}`), bypassLogin)) : this.getSystemSaveData();
|
||||||
|
|
||||||
const request = {
|
const request = {
|
||||||
|
@ -1474,7 +1463,7 @@ export class GameData {
|
||||||
const entry = data[defaultStarterSpecies[ds]] as DexEntry;
|
const entry = data[defaultStarterSpecies[ds]] as DexEntry;
|
||||||
entry.seenAttr = defaultStarterAttr;
|
entry.seenAttr = defaultStarterAttr;
|
||||||
entry.caughtAttr = defaultStarterAttr;
|
entry.caughtAttr = defaultStarterAttr;
|
||||||
entry.natureAttr = Math.pow(2, defaultStarterNatures[ds] + 1);
|
entry.natureAttr = 1 << (defaultStarterNatures[ds] + 1);
|
||||||
for (const i in entry.ivs) {
|
for (const i in entry.ivs) {
|
||||||
entry.ivs[i] = 10;
|
entry.ivs[i] = 10;
|
||||||
}
|
}
|
||||||
|
@ -1541,10 +1530,10 @@ export class GameData {
|
||||||
dexEntry.caughtAttr |= dexAttr;
|
dexEntry.caughtAttr |= dexAttr;
|
||||||
if (speciesStarters.hasOwnProperty(species.speciesId)) {
|
if (speciesStarters.hasOwnProperty(species.speciesId)) {
|
||||||
this.starterData[species.speciesId].abilityAttr |= pokemon.abilityIndex !== 1 || pokemon.species.ability2
|
this.starterData[species.speciesId].abilityAttr |= pokemon.abilityIndex !== 1 || pokemon.species.ability2
|
||||||
? Math.pow(2, pokemon.abilityIndex)
|
? 1 << pokemon.abilityIndex
|
||||||
: AbilityAttr.ABILITY_HIDDEN;
|
: AbilityAttr.ABILITY_HIDDEN;
|
||||||
}
|
}
|
||||||
dexEntry.natureAttr |= Math.pow(2, pokemon.nature + 1);
|
dexEntry.natureAttr |= 1 << (pokemon.nature + 1);
|
||||||
|
|
||||||
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(species.speciesId);
|
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(species.speciesId);
|
||||||
const newCatch = !caughtAttr;
|
const newCatch = !caughtAttr;
|
||||||
|
@ -1580,7 +1569,7 @@ export class GameData {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPrevolution && (!pokemon.scene.gameMode.isDaily || hasNewAttr || fromEgg)) {
|
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));
|
this.addStarterCandy(species, (1 * (pokemon.isShiny() ? 5 * (1 << (pokemon.variant ?? 0)) : 1)) * (fromEgg || pokemon.isBoss() ? 2 : 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,7 +1640,7 @@ export class GameData {
|
||||||
this.starterData[speciesId].eggMoves = 0;
|
this.starterData[speciesId].eggMoves = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = Math.pow(2, eggMoveIndex);
|
const value = 1 << eggMoveIndex;
|
||||||
|
|
||||||
if (this.starterData[speciesId].eggMoves & value) {
|
if (this.starterData[speciesId].eggMoves & value) {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
|
@ -1743,7 +1732,7 @@ export class GameData {
|
||||||
getSpeciesDefaultNature(species: PokemonSpecies): Nature {
|
getSpeciesDefaultNature(species: PokemonSpecies): Nature {
|
||||||
const dexEntry = this.dexData[species.speciesId];
|
const dexEntry = this.dexData[species.speciesId];
|
||||||
for (let n = 0; n < 25; n++) {
|
for (let n = 0; n < 25; n++) {
|
||||||
if (dexEntry.natureAttr & Math.pow(2, n + 1)) {
|
if (dexEntry.natureAttr & (1 << (n + 1))) {
|
||||||
return n as Nature;
|
return n as Nature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1751,7 +1740,7 @@ export class GameData {
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpeciesDefaultNatureAttr(species: PokemonSpecies): integer {
|
getSpeciesDefaultNatureAttr(species: PokemonSpecies): integer {
|
||||||
return Math.pow(2, this.getSpeciesDefaultNature(species));
|
return 1 << (this.getSpeciesDefaultNature(species));
|
||||||
}
|
}
|
||||||
|
|
||||||
getDexAttrLuck(dexAttr: bigint): integer {
|
getDexAttrLuck(dexAttr: bigint): integer {
|
||||||
|
@ -1761,7 +1750,7 @@ export class GameData {
|
||||||
getNaturesForAttr(natureAttr: integer): Nature[] {
|
getNaturesForAttr(natureAttr: integer): Nature[] {
|
||||||
const ret: Nature[] = [];
|
const ret: Nature[] = [];
|
||||||
for (let n = 0; n < 25; n++) {
|
for (let n = 0; n < 25; n++) {
|
||||||
if (natureAttr & Math.pow(2, n + 1)) {
|
if (natureAttr & (1 << (n + 1))) {
|
||||||
ret.push(n);
|
ret.push(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1803,7 +1792,7 @@ export class GameData {
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormAttr(formIndex: integer): bigint {
|
getFormAttr(formIndex: integer): bigint {
|
||||||
return BigInt(Math.pow(2, 7 + formIndex));
|
return BigInt(1 << (7 + formIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
consolidateDexData(dexData: DexData): void {
|
consolidateDexData(dexData: DexData): void {
|
||||||
|
@ -1813,7 +1802,7 @@ export class GameData {
|
||||||
entry.hatchedCount = 0;
|
entry.hatchedCount = 0;
|
||||||
}
|
}
|
||||||
if (!entry.hasOwnProperty("natureAttr") || (entry.caughtAttr && !entry.natureAttr)) {
|
if (!entry.hasOwnProperty("natureAttr") || (entry.caughtAttr && !entry.natureAttr)) {
|
||||||
entry.natureAttr = this.defaultDexData[k].natureAttr || Math.pow(2, Utils.randInt(25, 1));
|
entry.natureAttr = this.defaultDexData[k].natureAttr || (1 << Utils.randInt(25, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue