mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 06:49:35 +02:00
Merge branch 'beta' into charge-move-overhaul
This commit is contained in:
commit
6743c450da
@ -1,5 +1,5 @@
|
|||||||
import tseslint from '@typescript-eslint/eslint-plugin';
|
import tseslint from '@typescript-eslint/eslint-plugin';
|
||||||
import stylisticTs from '@stylistic/eslint-plugin-ts'
|
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
||||||
import parser from '@typescript-eslint/parser';
|
import parser from '@typescript-eslint/parser';
|
||||||
import importX from 'eslint-plugin-import-x';
|
import importX from 'eslint-plugin-import-x';
|
||||||
|
|
||||||
@ -16,15 +16,15 @@ export default [
|
|||||||
'@typescript-eslint': tseslint
|
'@typescript-eslint': tseslint
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"eqeqeq": ["error", "always"], // Enforces the use of === and !== instead of == and !=
|
"eqeqeq": ["error", "always"], // Enforces the use of `===` and `!==` instead of `==` and `!=`
|
||||||
"indent": ["error", 2], // Enforces a 2-space indentation
|
"indent": ["error", 2, { "SwitchCase": 1 }], // Enforces a 2-space indentation, enforces indentation of `case ...:` statements
|
||||||
"quotes": ["error", "double"], // Enforces the use of double quotes for strings
|
"quotes": ["error", "double"], // Enforces the use of double quotes for strings
|
||||||
"no-var": "error", // Disallows the use of var, enforcing let or const instead
|
"no-var": "error", // Disallows the use of `var`, enforcing `let` or `const` instead
|
||||||
"prefer-const": "error", // Prefers the use of const for variables that are never reassigned
|
"prefer-const": "error", // Enforces the use of `const` for variables that are never reassigned
|
||||||
"no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this)
|
"no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this)
|
||||||
"@typescript-eslint/no-unused-vars": [ "error", {
|
"@typescript-eslint/no-unused-vars": [ "error", {
|
||||||
"args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used.
|
"args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used.
|
||||||
"ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the rest.
|
"ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the others.
|
||||||
}],
|
}],
|
||||||
"eol-last": ["error", "always"], // Enforces at least one newline at the end of files
|
"eol-last": ["error", "always"], // Enforces at least one newline at the end of files
|
||||||
"@stylistic/ts/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax
|
"@stylistic/ts/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax
|
||||||
@ -32,14 +32,14 @@ export default [
|
|||||||
"no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax
|
"no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax
|
||||||
"brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors
|
"brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors
|
||||||
"curly": ["error", "all"], // Enforces the use of curly braces for all control statements
|
"curly": ["error", "all"], // Enforces the use of curly braces for all control statements
|
||||||
"@stylistic/ts/brace-style": ["error", "1tbs"],
|
"@stylistic/ts/brace-style": ["error", "1tbs"], // Enforces the following brace style: https://eslint.style/rules/js/brace-style#_1tbs
|
||||||
"no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines
|
"no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines
|
||||||
"skipBlankLines": false, // Enforces the rule even on blank lines
|
"skipBlankLines": false, // Enforces the rule even on blank lines
|
||||||
"ignoreComments": false // Enforces the rule on lines containing comments
|
"ignoreComments": false // Enforces the rule on lines containing comments
|
||||||
}],
|
}],
|
||||||
"space-before-blocks": ["error", "always"], // Enforces a space before blocks
|
"space-before-blocks": ["error", "always"], // Enforces a space before blocks
|
||||||
"keyword-spacing": ["error", { "before": true, "after": true }], // Enforces spacing before and after keywords
|
"keyword-spacing": ["error", { "before": true, "after": true }], // Enforces spacing before and after keywords
|
||||||
"comma-spacing": ["error", { "before": false, "after": true }], // Enforces spacing after comma
|
"comma-spacing": ["error", { "before": false, "after": true }], // Enforces spacing after commas
|
||||||
"import-x/extensions": ["error", "never", { "json": "always" }], // Enforces no extension for imports unless json
|
"import-x/extensions": ["error", "never", { "json": "always" }], // Enforces no extension for imports unless json
|
||||||
"array-bracket-spacing": ["error", "always", { "objectsInArrays": false, "arraysInArrays": false }], // Enforces consistent spacing inside array brackets
|
"array-bracket-spacing": ["error", "always", { "objectsInArrays": false, "arraysInArrays": false }], // Enforces consistent spacing inside array brackets
|
||||||
"object-curly-spacing": ["error", "always", { "arraysInObjects": false, "objectsInObjects": false }], // Enforces consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers
|
"object-curly-spacing": ["error", "always", { "arraysInObjects": false, "objectsInObjects": false }], // Enforces consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "pokemon-rogue-battle",
|
"name": "pokemon-rogue-battle",
|
||||||
"version": "1.0.4",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pokemon-rogue-battle",
|
"name": "pokemon-rogue-battle",
|
||||||
"version": "1.0.4",
|
"version": "1.1.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@material/material-color-utilities": "^0.2.7",
|
"@material/material-color-utilities": "^0.2.7",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "pokemon-rogue-battle",
|
"name": "pokemon-rogue-battle",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.4",
|
"version": "1.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.4 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.4 KiB |
@ -3177,6 +3177,9 @@ export default class BattleScene extends SceneBase {
|
|||||||
let encounter: MysteryEncounter | null;
|
let encounter: MysteryEncounter | null;
|
||||||
if (!isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_OVERRIDE) && allMysteryEncounters.hasOwnProperty(Overrides.MYSTERY_ENCOUNTER_OVERRIDE)) {
|
if (!isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_OVERRIDE) && allMysteryEncounters.hasOwnProperty(Overrides.MYSTERY_ENCOUNTER_OVERRIDE)) {
|
||||||
encounter = allMysteryEncounters[Overrides.MYSTERY_ENCOUNTER_OVERRIDE];
|
encounter = allMysteryEncounters[Overrides.MYSTERY_ENCOUNTER_OVERRIDE];
|
||||||
|
if (canBypass) {
|
||||||
|
return encounter;
|
||||||
|
}
|
||||||
} else if (canBypass) {
|
} else if (canBypass) {
|
||||||
encounter = allMysteryEncounters[encounterType ?? -1];
|
encounter = allMysteryEncounters[encounterType ?? -1];
|
||||||
return encounter;
|
return encounter;
|
||||||
|
@ -4913,8 +4913,7 @@ export function initAbilities() {
|
|||||||
.attr(TypeImmunityAddBattlerTagAbAttr, Type.FIRE, BattlerTagType.FIRE_BOOST, 1)
|
.attr(TypeImmunityAddBattlerTagAbAttr, Type.FIRE, BattlerTagType.FIRE_BOOST, 1)
|
||||||
.ignorable(),
|
.ignorable(),
|
||||||
new Ability(Abilities.SHIELD_DUST, 3)
|
new Ability(Abilities.SHIELD_DUST, 3)
|
||||||
.attr(IgnoreMoveEffectsAbAttr)
|
.attr(IgnoreMoveEffectsAbAttr),
|
||||||
.edgeCase(), // Does not work with secret power (unimplemented)
|
|
||||||
new Ability(Abilities.OWN_TEMPO, 3)
|
new Ability(Abilities.OWN_TEMPO, 3)
|
||||||
.attr(BattlerTagImmunityAbAttr, BattlerTagType.CONFUSED)
|
.attr(BattlerTagImmunityAbAttr, BattlerTagType.CONFUSED)
|
||||||
.attr(IntimidateImmunityAbAttr)
|
.attr(IntimidateImmunityAbAttr)
|
||||||
@ -4958,8 +4957,7 @@ export function initAbilities() {
|
|||||||
.attr(TypeImmunityStatStageChangeAbAttr, Type.ELECTRIC, Stat.SPATK, 1)
|
.attr(TypeImmunityStatStageChangeAbAttr, Type.ELECTRIC, Stat.SPATK, 1)
|
||||||
.ignorable(),
|
.ignorable(),
|
||||||
new Ability(Abilities.SERENE_GRACE, 3)
|
new Ability(Abilities.SERENE_GRACE, 3)
|
||||||
.attr(MoveEffectChanceMultiplierAbAttr, 2)
|
.attr(MoveEffectChanceMultiplierAbAttr, 2),
|
||||||
.edgeCase(), // does not work with secret power (unimplemented)
|
|
||||||
new Ability(Abilities.SWIFT_SWIM, 3)
|
new Ability(Abilities.SWIFT_SWIM, 3)
|
||||||
.attr(StatMultiplierAbAttr, Stat.SPD, 2)
|
.attr(StatMultiplierAbAttr, Stat.SPD, 2)
|
||||||
.condition(getWeatherCondition(WeatherType.RAIN, WeatherType.HEAVY_RAIN)),
|
.condition(getWeatherCondition(WeatherType.RAIN, WeatherType.HEAVY_RAIN)),
|
||||||
|
@ -2925,8 +2925,6 @@ export class SecretPowerAttr extends MoveEffectAttr {
|
|||||||
this.effectChanceOverride = move.chance;
|
this.effectChanceOverride = move.chance;
|
||||||
const moveChance = this.getMoveChance(user, target, move, this.selfTarget);
|
const moveChance = this.getMoveChance(user, target, move, this.selfTarget);
|
||||||
if (moveChance < 0 || moveChance === 100 || user.randSeedInt(100) < moveChance) {
|
if (moveChance < 0 || moveChance === 100 || user.randSeedInt(100) < moveChance) {
|
||||||
// effectChanceOverride used in the application of the actual secondary effect
|
|
||||||
this.effectChanceOverride = 100;
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -2949,6 +2947,8 @@ export class SecretPowerAttr extends MoveEffectAttr {
|
|||||||
const biome = user.scene.arena.biomeType;
|
const biome = user.scene.arena.biomeType;
|
||||||
secondaryEffect = this.determineBiomeEffect(biome);
|
secondaryEffect = this.determineBiomeEffect(biome);
|
||||||
}
|
}
|
||||||
|
// effectChanceOverride used in the application of the actual secondary effect
|
||||||
|
secondaryEffect.effectChanceOverride = 100;
|
||||||
return secondaryEffect.apply(user, target, move, []);
|
return secondaryEffect.apply(user, target, move, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
import BattleScene from "#app/battle-scene";
|
|
||||||
import { Phase } from "#app/phase";
|
|
||||||
import { Mode } from "#app/ui/ui";
|
|
||||||
|
|
||||||
export class OutdatedPhase extends Phase {
|
|
||||||
constructor(scene: BattleScene) {
|
|
||||||
super(scene);
|
|
||||||
}
|
|
||||||
|
|
||||||
start(): void {
|
|
||||||
this.scene.ui.setMode(Mode.OUTDATED);
|
|
||||||
}
|
|
||||||
}
|
|
@ -43,10 +43,9 @@ import { Species } from "#enums/species";
|
|||||||
import { applyChallenges, ChallengeType } from "#app/data/challenge";
|
import { applyChallenges, ChallengeType } from "#app/data/challenge";
|
||||||
import { WeatherType } from "#enums/weather-type";
|
import { WeatherType } from "#enums/weather-type";
|
||||||
import { TerrainType } from "#app/data/terrain";
|
import { TerrainType } from "#app/data/terrain";
|
||||||
import { OutdatedPhase } from "#app/phases/outdated-phase";
|
|
||||||
import { ReloadSessionPhase } from "#app/phases/reload-session-phase";
|
import { ReloadSessionPhase } from "#app/phases/reload-session-phase";
|
||||||
import { RUN_HISTORY_LIMIT } from "#app/ui/run-history-ui-handler";
|
import { RUN_HISTORY_LIMIT } from "#app/ui/run-history-ui-handler";
|
||||||
import { applySessionDataPatches, applySettingsDataPatches, applySystemDataPatches } from "#app/system/version-converter";
|
import { applySessionVersionMigration, applySystemVersionMigration, applySettingsVersionMigration } from "./version_migration/version_converter";
|
||||||
import { MysteryEncounterSaveData } from "#app/data/mystery-encounters/mystery-encounter-save-data";
|
import { MysteryEncounterSaveData } from "#app/data/mystery-encounters/mystery-encounter-save-data";
|
||||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||||
import { PokerogueApiClearSessionData } from "#app/@types/pokerogue-api";
|
import { PokerogueApiClearSessionData } from "#app/@types/pokerogue-api";
|
||||||
@ -403,10 +402,7 @@ export class GameData {
|
|||||||
.then(error => {
|
.then(error => {
|
||||||
this.scene.ui.savingIcon.hide();
|
this.scene.ui.savingIcon.hide();
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.startsWith("client version out of date")) {
|
if (error.startsWith("session out of date")) {
|
||||||
this.scene.clearPhaseQueue();
|
|
||||||
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
|
|
||||||
} else if (error.startsWith("session out of date")) {
|
|
||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
||||||
}
|
}
|
||||||
@ -482,7 +478,7 @@ export class GameData {
|
|||||||
localStorage.setItem(lsItemKey, "");
|
localStorage.setItem(lsItemKey, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
applySystemDataPatches(systemData);
|
applySystemVersionMigration(systemData);
|
||||||
|
|
||||||
this.trainerId = systemData.trainerId;
|
this.trainerId = systemData.trainerId;
|
||||||
this.secretId = systemData.secretId;
|
this.secretId = systemData.secretId;
|
||||||
@ -857,7 +853,7 @@ export class GameData {
|
|||||||
|
|
||||||
const settings = JSON.parse(localStorage.getItem("settings")!); // TODO: is this bang correct?
|
const settings = JSON.parse(localStorage.getItem("settings")!); // TODO: is this bang correct?
|
||||||
|
|
||||||
applySettingsDataPatches(settings);
|
applySettingsVersionMigration(settings);
|
||||||
|
|
||||||
for (const setting of Object.keys(settings)) {
|
for (const setting of Object.keys(settings)) {
|
||||||
setSetting(this.scene, setting, settings[setting]);
|
setSetting(this.scene, setting, settings[setting]);
|
||||||
@ -1313,7 +1309,7 @@ export class GameData {
|
|||||||
return v;
|
return v;
|
||||||
}) as SessionSaveData;
|
}) as SessionSaveData;
|
||||||
|
|
||||||
applySessionDataPatches(sessionData);
|
applySessionVersionMigration(sessionData);
|
||||||
|
|
||||||
return sessionData;
|
return sessionData;
|
||||||
}
|
}
|
||||||
@ -1354,10 +1350,7 @@ export class GameData {
|
|||||||
this.scene.ui.savingIcon.hide();
|
this.scene.ui.savingIcon.hide();
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.startsWith("client version out of date")) {
|
if (error.startsWith("session out of date")) {
|
||||||
this.scene.clearPhaseQueue();
|
|
||||||
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
|
|
||||||
} else if (error.startsWith("session out of date")) {
|
|
||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
||||||
}
|
}
|
||||||
|
@ -1,157 +0,0 @@
|
|||||||
import { allSpecies } from "#app/data/pokemon-species";
|
|
||||||
import { AbilityAttr, defaultStarterSpecies, DexAttr, SessionSaveData, SystemSaveData } from "./game-data";
|
|
||||||
import { SettingKeys } from "./settings/settings";
|
|
||||||
|
|
||||||
const LATEST_VERSION = "1.0.5";
|
|
||||||
|
|
||||||
export function applySessionDataPatches(data: SessionSaveData) {
|
|
||||||
const curVersion = data.gameVersion;
|
|
||||||
|
|
||||||
// Always sanitize money as a safeguard
|
|
||||||
data.money = Math.floor(data.money);
|
|
||||||
|
|
||||||
if (curVersion !== LATEST_VERSION) {
|
|
||||||
switch (curVersion) {
|
|
||||||
case "1.0.0":
|
|
||||||
case "1.0.1":
|
|
||||||
case "1.0.2":
|
|
||||||
case "1.0.3":
|
|
||||||
case "1.0.4":
|
|
||||||
// --- PATCHES ---
|
|
||||||
|
|
||||||
// Fix Battle Items, Vitamins, and Lures
|
|
||||||
data.modifiers.forEach((m) => {
|
|
||||||
if (m.className === "PokemonBaseStatModifier") {
|
|
||||||
m.className = "BaseStatModifier";
|
|
||||||
} else if (m.className === "PokemonResetNegativeStatStageModifier") {
|
|
||||||
m.className = "ResetNegativeStatStageModifier";
|
|
||||||
} else if (m.className === "TempBattleStatBoosterModifier") {
|
|
||||||
// Dire Hit no longer a part of the TempBattleStatBoosterModifierTypeGenerator
|
|
||||||
if (m.typeId !== "DIRE_HIT") {
|
|
||||||
m.className = "TempStatStageBoosterModifier";
|
|
||||||
m.typeId = "TEMP_STAT_STAGE_BOOSTER";
|
|
||||||
|
|
||||||
// Migration from TempBattleStat to Stat
|
|
||||||
const newStat = m.typePregenArgs[0] + 1;
|
|
||||||
m.typePregenArgs[0] = newStat;
|
|
||||||
|
|
||||||
// From [ stat, battlesLeft ] to [ stat, maxBattles, battleCount ]
|
|
||||||
m.args = [ newStat, 5, m.args[1] ];
|
|
||||||
} else {
|
|
||||||
m.className = "TempCritBoosterModifier";
|
|
||||||
m.typePregenArgs = [];
|
|
||||||
|
|
||||||
// From [ stat, battlesLeft ] to [ maxBattles, battleCount ]
|
|
||||||
m.args = [ 5, m.args[1] ];
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (m.className === "DoubleBattleChanceBoosterModifier" && m.args.length === 1) {
|
|
||||||
let maxBattles: number;
|
|
||||||
switch (m.typeId) {
|
|
||||||
case "MAX_LURE":
|
|
||||||
maxBattles = 30;
|
|
||||||
break;
|
|
||||||
case "SUPER_LURE":
|
|
||||||
maxBattles = 15;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
maxBattles = 10;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// From [ battlesLeft ] to [ maxBattles, battleCount ]
|
|
||||||
m.args = [ maxBattles, m.args[0] ];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
data.enemyModifiers.forEach((m) => {
|
|
||||||
if (m.className === "PokemonBaseStatModifier") {
|
|
||||||
m.className = "BaseStatModifier";
|
|
||||||
} else if (m.className === "PokemonResetNegativeStatStageModifier") {
|
|
||||||
m.className = "ResetNegativeStatStageModifier";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
data.gameVersion = LATEST_VERSION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function applySystemDataPatches(data: SystemSaveData) {
|
|
||||||
const curVersion = data.gameVersion;
|
|
||||||
if (curVersion !== LATEST_VERSION) {
|
|
||||||
switch (curVersion) {
|
|
||||||
case "1.0.0":
|
|
||||||
case "1.0.1":
|
|
||||||
case "1.0.2":
|
|
||||||
case "1.0.3":
|
|
||||||
case "1.0.4":
|
|
||||||
// --- LEGACY PATCHES ---
|
|
||||||
if (data.starterData && data.dexData) {
|
|
||||||
// Migrate ability starter data if empty for caught species
|
|
||||||
Object.keys(data.starterData).forEach(sd => {
|
|
||||||
if (data.dexData[sd]?.caughtAttr && (data.starterData[sd] && !data.starterData[sd].abilityAttr)) {
|
|
||||||
data.starterData[sd].abilityAttr = 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix Legendary Stats
|
|
||||||
if (data.gameStats && (data.gameStats.legendaryPokemonCaught !== undefined && data.gameStats.subLegendaryPokemonCaught === undefined)) {
|
|
||||||
data.gameStats.subLegendaryPokemonSeen = 0;
|
|
||||||
data.gameStats.subLegendaryPokemonCaught = 0;
|
|
||||||
data.gameStats.subLegendaryPokemonHatched = 0;
|
|
||||||
allSpecies.filter(s => s.subLegendary).forEach(s => {
|
|
||||||
const dexEntry = data.dexData[s.speciesId];
|
|
||||||
data.gameStats.subLegendaryPokemonSeen += dexEntry.seenCount;
|
|
||||||
data.gameStats.legendaryPokemonSeen = Math.max(data.gameStats.legendaryPokemonSeen - dexEntry.seenCount, 0);
|
|
||||||
data.gameStats.subLegendaryPokemonCaught += dexEntry.caughtCount;
|
|
||||||
data.gameStats.legendaryPokemonCaught = Math.max(data.gameStats.legendaryPokemonCaught - dexEntry.caughtCount, 0);
|
|
||||||
data.gameStats.subLegendaryPokemonHatched += dexEntry.hatchedCount;
|
|
||||||
data.gameStats.legendaryPokemonHatched = Math.max(data.gameStats.legendaryPokemonHatched - dexEntry.hatchedCount, 0);
|
|
||||||
});
|
|
||||||
data.gameStats.subLegendaryPokemonSeen = Math.max(data.gameStats.subLegendaryPokemonSeen, data.gameStats.subLegendaryPokemonCaught);
|
|
||||||
data.gameStats.legendaryPokemonSeen = Math.max(data.gameStats.legendaryPokemonSeen, data.gameStats.legendaryPokemonCaught);
|
|
||||||
data.gameStats.mythicalPokemonSeen = Math.max(data.gameStats.mythicalPokemonSeen, data.gameStats.mythicalPokemonCaught);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- PATCHES ---
|
|
||||||
|
|
||||||
// Fix Starter Data
|
|
||||||
if (data.starterData && data.dexData) {
|
|
||||||
for (const starterId of defaultStarterSpecies) {
|
|
||||||
if (data.starterData[starterId]?.abilityAttr) {
|
|
||||||
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
|
|
||||||
}
|
|
||||||
if (data.dexData[starterId]?.caughtAttr) {
|
|
||||||
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data.gameVersion = LATEST_VERSION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function applySettingsDataPatches(settings: Object) {
|
|
||||||
const curVersion = settings.hasOwnProperty("gameVersion") ? settings["gameVersion"] : "1.0.0";
|
|
||||||
if (curVersion !== LATEST_VERSION) {
|
|
||||||
switch (curVersion) {
|
|
||||||
case "1.0.0":
|
|
||||||
case "1.0.1":
|
|
||||||
case "1.0.2":
|
|
||||||
case "1.0.3":
|
|
||||||
case "1.0.4":
|
|
||||||
// --- PATCHES ---
|
|
||||||
|
|
||||||
// Fix Reward Cursor Target
|
|
||||||
if (settings.hasOwnProperty("REROLL_TARGET") && !settings.hasOwnProperty(SettingKeys.Shop_Cursor_Target)) {
|
|
||||||
settings[SettingKeys.Shop_Cursor_Target] = settings["REROLL_TARGET"];
|
|
||||||
delete settings["REROLL_TARGET"];
|
|
||||||
localStorage.setItem("settings", JSON.stringify(settings));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Note that the current game version will be written at `saveSettings`
|
|
||||||
}
|
|
||||||
}
|
|
182
src/system/version_migration/version_converter.ts
Normal file
182
src/system/version_migration/version_converter.ts
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
import { SessionSaveData, SystemSaveData } from "../game-data";
|
||||||
|
import { version } from "../../../package.json";
|
||||||
|
|
||||||
|
// --- v1.0.4 (and below) PATCHES --- //
|
||||||
|
import * as v1_0_4 from "./versions/v1_0_4";
|
||||||
|
|
||||||
|
const LATEST_VERSION = version.split(".").map(value => parseInt(value));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts incoming {@linkcode SystemSaveData} that has a version below the
|
||||||
|
* current version number listed in `package.json`.
|
||||||
|
*
|
||||||
|
* Note that no transforms act on the {@linkcode data} if its version matches
|
||||||
|
* the current version or if there are no migrations made between its version up
|
||||||
|
* to the current version.
|
||||||
|
* @param data {@linkcode SystemSaveData}
|
||||||
|
* @see {@link SystemVersionConverter}
|
||||||
|
*/
|
||||||
|
export function applySystemVersionMigration(data: SystemSaveData) {
|
||||||
|
const curVersion = data.gameVersion.split(".").map(value => parseInt(value));
|
||||||
|
|
||||||
|
if (!curVersion.every((value, index) => value === LATEST_VERSION[index])) {
|
||||||
|
const converter = new SystemVersionConverter();
|
||||||
|
converter.applyStaticPreprocessors(data);
|
||||||
|
converter.applyMigration(data, curVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts incoming {@linkcode SessionSavaData} that has a version below the
|
||||||
|
* current version number listed in `package.json`.
|
||||||
|
*
|
||||||
|
* Note that no transforms act on the {@linkcode data} if its version matches
|
||||||
|
* the current version or if there are no migrations made between its version up
|
||||||
|
* to the current version.
|
||||||
|
* @param data {@linkcode SessionSaveData}
|
||||||
|
* @see {@link SessionVersionConverter}
|
||||||
|
*/
|
||||||
|
export function applySessionVersionMigration(data: SessionSaveData) {
|
||||||
|
const curVersion = data.gameVersion.split(".").map(value => parseInt(value));
|
||||||
|
|
||||||
|
if (!curVersion.every((value, index) => value === LATEST_VERSION[index])) {
|
||||||
|
const converter = new SessionVersionConverter();
|
||||||
|
converter.applyStaticPreprocessors(data);
|
||||||
|
converter.applyMigration(data, curVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts incoming settings data that has a version below the
|
||||||
|
* current version number listed in `package.json`.
|
||||||
|
*
|
||||||
|
* Note that no transforms act on the {@linkcode data} if its version matches
|
||||||
|
* the current version or if there are no migrations made between its version up
|
||||||
|
* to the current version.
|
||||||
|
* @param data Settings data object
|
||||||
|
* @see {@link SettingsVersionConverter}
|
||||||
|
*/
|
||||||
|
export function applySettingsVersionMigration(data: Object) {
|
||||||
|
const gameVersion: string = data.hasOwnProperty("gameVersion") ? data["gameVersion"] : "1.0.0";
|
||||||
|
const curVersion = gameVersion.split(".").map(value => parseInt(value));
|
||||||
|
|
||||||
|
if (!curVersion.every((value, index) => value === LATEST_VERSION[index])) {
|
||||||
|
const converter = new SettingsVersionConverter();
|
||||||
|
converter.applyStaticPreprocessors(data);
|
||||||
|
converter.applyMigration(data, curVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class encapsulating the logic for migrating data from a given version up to
|
||||||
|
* the current version listed in `package.json`.
|
||||||
|
*
|
||||||
|
* Note that, for any version converter, the corresponding `applyMigration`
|
||||||
|
* function would only need to be changed once when the first migration for a
|
||||||
|
* given version is introduced. Similarly, a version file (within the `versions`
|
||||||
|
* folder) would only need to be created for a version once with the appropriate
|
||||||
|
* array nomenclature.
|
||||||
|
*/
|
||||||
|
abstract class VersionConverter {
|
||||||
|
/**
|
||||||
|
* Iterates through an array of designated migration functions that are each
|
||||||
|
* called one by one to transform the data.
|
||||||
|
* @param data The data to be operated on
|
||||||
|
* @param migrationArr An array of functions that will transform the incoming data
|
||||||
|
*/
|
||||||
|
callMigrators(data: any, migrationArr: readonly any[]) {
|
||||||
|
for (const migrate of migrationArr) {
|
||||||
|
migrate(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies any version-agnostic data sanitation as defined within the function
|
||||||
|
* body.
|
||||||
|
* @param data The data to be operated on
|
||||||
|
*/
|
||||||
|
applyStaticPreprocessors(_data: any): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the current version the incoming data to determine the starting point
|
||||||
|
* of the migration which will cascade up to the latest version, calling the
|
||||||
|
* necessary migration functions in the process.
|
||||||
|
* @param data The data to be operated on
|
||||||
|
* @param curVersion [0] Current major version
|
||||||
|
* [1] Current minor version
|
||||||
|
* [2] Current patch version
|
||||||
|
*/
|
||||||
|
abstract applyMigration(data: any, curVersion: number[]): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class encapsulating the logic for migrating {@linkcode SessionSaveData} from
|
||||||
|
* a given version up to the current version listed in `package.json`.
|
||||||
|
* @extends VersionConverter
|
||||||
|
*/
|
||||||
|
class SessionVersionConverter extends VersionConverter {
|
||||||
|
override applyStaticPreprocessors(data: SessionSaveData): void {
|
||||||
|
// Always sanitize money as a safeguard
|
||||||
|
data.money = Math.floor(data.money);
|
||||||
|
}
|
||||||
|
|
||||||
|
override applyMigration(data: SessionSaveData, curVersion: number[]): void {
|
||||||
|
const [ curMajor, curMinor, curPatch ] = curVersion;
|
||||||
|
|
||||||
|
if (curMajor === 1) {
|
||||||
|
if (curMinor === 0) {
|
||||||
|
if (curPatch <= 4) {
|
||||||
|
console.log("Applying v1.0.4 session data migration!");
|
||||||
|
this.callMigrators(data, v1_0_4.sessionMigrators);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Session data successfully migrated to v${version}!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class encapsulating the logic for migrating {@linkcode SystemSaveData} from
|
||||||
|
* a given version up to the current version listed in `package.json`.
|
||||||
|
* @extends VersionConverter
|
||||||
|
*/
|
||||||
|
class SystemVersionConverter extends VersionConverter {
|
||||||
|
override applyMigration(data: SystemSaveData, curVersion: number[]): void {
|
||||||
|
const [ curMajor, curMinor, curPatch ] = curVersion;
|
||||||
|
|
||||||
|
if (curMajor === 1) {
|
||||||
|
if (curMinor === 0) {
|
||||||
|
if (curPatch <= 4) {
|
||||||
|
console.log("Applying v1.0.4 system data migraton!");
|
||||||
|
this.callMigrators(data, v1_0_4.systemMigrators);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`System data successfully migrated to v${version}!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class encapsulating the logic for migrating settings data from
|
||||||
|
* a given version up to the current version listed in `package.json`.
|
||||||
|
* @extends VersionConverter
|
||||||
|
*/
|
||||||
|
class SettingsVersionConverter extends VersionConverter {
|
||||||
|
override applyMigration(data: Object, curVersion: number[]): void {
|
||||||
|
const [ curMajor, curMinor, curPatch ] = curVersion;
|
||||||
|
|
||||||
|
if (curMajor === 1) {
|
||||||
|
if (curMinor === 0) {
|
||||||
|
if (curPatch <= 4) {
|
||||||
|
console.log("Applying v1.0.4 settings data migraton!");
|
||||||
|
this.callMigrators(data, v1_0_4.settingsMigrators);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`System data successfully migrated to v${version}!`);
|
||||||
|
}
|
||||||
|
}
|
135
src/system/version_migration/versions/v1_0_4.ts
Normal file
135
src/system/version_migration/versions/v1_0_4.ts
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
import { SettingKeys } from "../../settings/settings";
|
||||||
|
import { AbilityAttr, defaultStarterSpecies, DexAttr, SystemSaveData, SessionSaveData } from "../../game-data";
|
||||||
|
import { allSpecies } from "../../../data/pokemon-species";
|
||||||
|
|
||||||
|
export const systemMigrators = [
|
||||||
|
/**
|
||||||
|
* Migrate ability starter data if empty for caught species.
|
||||||
|
* @param data {@linkcode SystemSaveData}
|
||||||
|
*/
|
||||||
|
function migrateAbilityData(data: SystemSaveData) {
|
||||||
|
if (data.starterData && data.dexData) {
|
||||||
|
Object.keys(data.starterData).forEach(sd => {
|
||||||
|
if (data.dexData[sd]?.caughtAttr && (data.starterData[sd] && !data.starterData[sd].abilityAttr)) {
|
||||||
|
data.starterData[sd].abilityAttr = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate legendary Pokémon statistics if they are missing.
|
||||||
|
* @param data {@linkcode SystemSaveData}
|
||||||
|
*/
|
||||||
|
function fixLegendaryStats(data: SystemSaveData) {
|
||||||
|
if (data.gameStats && (data.gameStats.legendaryPokemonCaught !== undefined && data.gameStats.subLegendaryPokemonCaught === undefined)) {
|
||||||
|
data.gameStats.subLegendaryPokemonSeen = 0;
|
||||||
|
data.gameStats.subLegendaryPokemonCaught = 0;
|
||||||
|
data.gameStats.subLegendaryPokemonHatched = 0;
|
||||||
|
allSpecies.filter(s => s.subLegendary).forEach(s => {
|
||||||
|
const dexEntry = data.dexData[s.speciesId];
|
||||||
|
data.gameStats.subLegendaryPokemonSeen += dexEntry.seenCount;
|
||||||
|
data.gameStats.legendaryPokemonSeen = Math.max(data.gameStats.legendaryPokemonSeen - dexEntry.seenCount, 0);
|
||||||
|
data.gameStats.subLegendaryPokemonCaught += dexEntry.caughtCount;
|
||||||
|
data.gameStats.legendaryPokemonCaught = Math.max(data.gameStats.legendaryPokemonCaught - dexEntry.caughtCount, 0);
|
||||||
|
data.gameStats.subLegendaryPokemonHatched += dexEntry.hatchedCount;
|
||||||
|
data.gameStats.legendaryPokemonHatched = Math.max(data.gameStats.legendaryPokemonHatched - dexEntry.hatchedCount, 0);
|
||||||
|
});
|
||||||
|
data.gameStats.subLegendaryPokemonSeen = Math.max(data.gameStats.subLegendaryPokemonSeen, data.gameStats.subLegendaryPokemonCaught);
|
||||||
|
data.gameStats.legendaryPokemonSeen = Math.max(data.gameStats.legendaryPokemonSeen, data.gameStats.legendaryPokemonCaught);
|
||||||
|
data.gameStats.mythicalPokemonSeen = Math.max(data.gameStats.mythicalPokemonSeen, data.gameStats.mythicalPokemonCaught);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlock all starters' first ability and female gender option.
|
||||||
|
* @param data {@linkcode SystemSaveData}
|
||||||
|
*/
|
||||||
|
function fixStarterData(data: SystemSaveData) {
|
||||||
|
for (const starterId of defaultStarterSpecies) {
|
||||||
|
if (data.starterData[starterId]?.abilityAttr) {
|
||||||
|
data.starterData[starterId].abilityAttr |= AbilityAttr.ABILITY_1;
|
||||||
|
}
|
||||||
|
if (data.dexData[starterId]?.caughtAttr) {
|
||||||
|
data.dexData[starterId].caughtAttr |= DexAttr.FEMALE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const settingsMigrators = [
|
||||||
|
/**
|
||||||
|
* Migrate from "REROLL_TARGET" property to {@linkcode
|
||||||
|
* SettingKeys.Shop_Cursor_Target}.
|
||||||
|
* @param data the `settings` object
|
||||||
|
*/
|
||||||
|
function fixRerollTarget(data: Object) {
|
||||||
|
if (data.hasOwnProperty("REROLL_TARGET") && !data.hasOwnProperty(SettingKeys.Shop_Cursor_Target)) {
|
||||||
|
data[SettingKeys.Shop_Cursor_Target] = data["REROLL_TARGET"];
|
||||||
|
delete data["REROLL_TARGET"];
|
||||||
|
localStorage.setItem("settings", JSON.stringify(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const sessionMigrators = [
|
||||||
|
/**
|
||||||
|
* Converts old lapsing modifiers (battle items, lures, and Dire Hit) and
|
||||||
|
* other miscellaneous modifiers (vitamins, White Herb) to any new class
|
||||||
|
* names and/or change in reload arguments.
|
||||||
|
* @param data {@linkcode SessionSaveData}
|
||||||
|
*/
|
||||||
|
function migrateModifiers(data: SessionSaveData) {
|
||||||
|
data.modifiers.forEach((m) => {
|
||||||
|
if (m.className === "PokemonBaseStatModifier") {
|
||||||
|
m.className = "BaseStatModifier";
|
||||||
|
} else if (m.className === "PokemonResetNegativeStatStageModifier") {
|
||||||
|
m.className = "ResetNegativeStatStageModifier";
|
||||||
|
} else if (m.className === "TempBattleStatBoosterModifier") {
|
||||||
|
const maxBattles = 5;
|
||||||
|
// Dire Hit no longer a part of the TempBattleStatBoosterModifierTypeGenerator
|
||||||
|
if (m.typeId !== "DIRE_HIT") {
|
||||||
|
m.className = "TempStatStageBoosterModifier";
|
||||||
|
m.typeId = "TEMP_STAT_STAGE_BOOSTER";
|
||||||
|
|
||||||
|
// Migration from TempBattleStat to Stat
|
||||||
|
const newStat = m.typePregenArgs[0] + 1;
|
||||||
|
m.typePregenArgs[0] = newStat;
|
||||||
|
|
||||||
|
// From [ stat, battlesLeft ] to [ stat, maxBattles, battleCount ]
|
||||||
|
m.args = [ newStat, maxBattles, Math.min(m.args[1], maxBattles) ];
|
||||||
|
} else {
|
||||||
|
m.className = "TempCritBoosterModifier";
|
||||||
|
m.typePregenArgs = [];
|
||||||
|
|
||||||
|
// From [ stat, battlesLeft ] to [ maxBattles, battleCount ]
|
||||||
|
m.args = [ maxBattles, Math.min(m.args[1], maxBattles) ];
|
||||||
|
}
|
||||||
|
} else if (m.className === "DoubleBattleChanceBoosterModifier" && m.args.length === 1) {
|
||||||
|
let maxBattles: number;
|
||||||
|
switch (m.typeId) {
|
||||||
|
case "MAX_LURE":
|
||||||
|
maxBattles = 30;
|
||||||
|
break;
|
||||||
|
case "SUPER_LURE":
|
||||||
|
maxBattles = 15;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
maxBattles = 10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// From [ battlesLeft ] to [ maxBattles, battleCount ]
|
||||||
|
m.args = [ maxBattles, Math.min(m.args[0], maxBattles) ];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
data.enemyModifiers.forEach((m) => {
|
||||||
|
if (m.className === "PokemonBaseStatModifier") {
|
||||||
|
m.className = "BaseStatModifier";
|
||||||
|
} else if (m.className === "PokemonResetNegativeStatStageModifier") {
|
||||||
|
m.className = "ResetNegativeStatStageModifier";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
] as const;
|
@ -23,6 +23,7 @@ import KeyboardPlugin = Phaser.Input.Keyboard.KeyboardPlugin;
|
|||||||
import GamepadPlugin = Phaser.Input.Gamepad.GamepadPlugin;
|
import GamepadPlugin = Phaser.Input.Gamepad.GamepadPlugin;
|
||||||
import EventEmitter = Phaser.Events.EventEmitter;
|
import EventEmitter = Phaser.Events.EventEmitter;
|
||||||
import UpdateList = Phaser.GameObjects.UpdateList;
|
import UpdateList = Phaser.GameObjects.UpdateList;
|
||||||
|
import { version } from "../../../package.json";
|
||||||
|
|
||||||
Object.defineProperty(window, "localStorage", {
|
Object.defineProperty(window, "localStorage", {
|
||||||
value: mockLocalStorage(),
|
value: mockLocalStorage(),
|
||||||
@ -101,6 +102,7 @@ export default class GameWrapper {
|
|||||||
injectMandatory() {
|
injectMandatory() {
|
||||||
this.game.config = {
|
this.game.config = {
|
||||||
seed: ["test"],
|
seed: ["test"],
|
||||||
|
gameVersion: version
|
||||||
};
|
};
|
||||||
this.scene.game = this.game;
|
this.scene.game = this.game;
|
||||||
this.game.renderer = {
|
this.game.renderer = {
|
||||||
|
@ -17,6 +17,9 @@ import { IntegerHolder } from "./../utils";
|
|||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
|
|
||||||
export const SHOP_OPTIONS_ROW_LIMIT = 7;
|
export const SHOP_OPTIONS_ROW_LIMIT = 7;
|
||||||
|
const SINGLE_SHOP_ROW_YOFFSET = 12;
|
||||||
|
const DOUBLE_SHOP_ROW_YOFFSET = 24;
|
||||||
|
const OPTION_BUTTON_YPOSITION = -62;
|
||||||
|
|
||||||
export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||||
private modifierContainer: Phaser.GameObjects.Container;
|
private modifierContainer: Phaser.GameObjects.Container;
|
||||||
@ -68,7 +71,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
this.checkButtonWidth = context.measureText(i18next.t("modifierSelectUiHandler:checkTeam")).width;
|
this.checkButtonWidth = context.measureText(i18next.t("modifierSelectUiHandler:checkTeam")).width;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transferButtonContainer = this.scene.add.container((this.scene.game.canvas.width - this.checkButtonWidth) / 6 - 21, -64);
|
this.transferButtonContainer = this.scene.add.container((this.scene.game.canvas.width - this.checkButtonWidth) / 6 - 21, OPTION_BUTTON_YPOSITION);
|
||||||
this.transferButtonContainer.setName("transfer-btn");
|
this.transferButtonContainer.setName("transfer-btn");
|
||||||
this.transferButtonContainer.setVisible(false);
|
this.transferButtonContainer.setVisible(false);
|
||||||
ui.add(this.transferButtonContainer);
|
ui.add(this.transferButtonContainer);
|
||||||
@ -78,7 +81,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
transferButtonText.setOrigin(1, 0);
|
transferButtonText.setOrigin(1, 0);
|
||||||
this.transferButtonContainer.add(transferButtonText);
|
this.transferButtonContainer.add(transferButtonText);
|
||||||
|
|
||||||
this.checkButtonContainer = this.scene.add.container((this.scene.game.canvas.width) / 6 - 1, -64);
|
this.checkButtonContainer = this.scene.add.container((this.scene.game.canvas.width) / 6 - 1, OPTION_BUTTON_YPOSITION);
|
||||||
this.checkButtonContainer.setName("use-btn");
|
this.checkButtonContainer.setName("use-btn");
|
||||||
this.checkButtonContainer.setVisible(false);
|
this.checkButtonContainer.setVisible(false);
|
||||||
ui.add(this.checkButtonContainer);
|
ui.add(this.checkButtonContainer);
|
||||||
@ -88,7 +91,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
checkButtonText.setOrigin(1, 0);
|
checkButtonText.setOrigin(1, 0);
|
||||||
this.checkButtonContainer.add(checkButtonText);
|
this.checkButtonContainer.add(checkButtonText);
|
||||||
|
|
||||||
this.rerollButtonContainer = this.scene.add.container(16, -64);
|
this.rerollButtonContainer = this.scene.add.container(16, OPTION_BUTTON_YPOSITION);
|
||||||
this.rerollButtonContainer.setName("reroll-brn");
|
this.rerollButtonContainer.setName("reroll-brn");
|
||||||
this.rerollButtonContainer.setVisible(false);
|
this.rerollButtonContainer.setVisible(false);
|
||||||
ui.add(this.rerollButtonContainer);
|
ui.add(this.rerollButtonContainer);
|
||||||
@ -104,7 +107,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
this.rerollCostText.setPositionRelative(rerollButtonText, rerollButtonText.displayWidth + 5, 1);
|
this.rerollCostText.setPositionRelative(rerollButtonText, rerollButtonText.displayWidth + 5, 1);
|
||||||
this.rerollButtonContainer.add(this.rerollCostText);
|
this.rerollButtonContainer.add(this.rerollCostText);
|
||||||
|
|
||||||
this.lockRarityButtonContainer = this.scene.add.container(16, -64);
|
this.lockRarityButtonContainer = this.scene.add.container(16, OPTION_BUTTON_YPOSITION);
|
||||||
this.lockRarityButtonContainer.setVisible(false);
|
this.lockRarityButtonContainer.setVisible(false);
|
||||||
ui.add(this.lockRarityButtonContainer);
|
ui.add(this.lockRarityButtonContainer);
|
||||||
|
|
||||||
@ -191,7 +194,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
const shopTypeOptions = !removeHealShop
|
const shopTypeOptions = !removeHealShop
|
||||||
? getPlayerShopModifierTypeOptionsForWave(this.scene.currentBattle.waveIndex, baseShopCost.value)
|
? getPlayerShopModifierTypeOptionsForWave(this.scene.currentBattle.waveIndex, baseShopCost.value)
|
||||||
: [];
|
: [];
|
||||||
const optionsYOffset = shopTypeOptions.length >= SHOP_OPTIONS_ROW_LIMIT ? -8 : -24;
|
const optionsYOffset = shopTypeOptions.length > SHOP_OPTIONS_ROW_LIMIT ? -SINGLE_SHOP_ROW_YOFFSET : -DOUBLE_SHOP_ROW_YOFFSET;
|
||||||
|
|
||||||
for (let m = 0; m < typeOptions.length; m++) {
|
for (let m = 0; m < typeOptions.length; m++) {
|
||||||
const sliceWidth = (this.scene.game.canvas.width / 6) / (typeOptions.length + 2);
|
const sliceWidth = (this.scene.game.canvas.width / 6) / (typeOptions.length + 2);
|
||||||
@ -212,7 +215,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
const col = m < SHOP_OPTIONS_ROW_LIMIT ? m : m - SHOP_OPTIONS_ROW_LIMIT;
|
const col = m < SHOP_OPTIONS_ROW_LIMIT ? m : m - SHOP_OPTIONS_ROW_LIMIT;
|
||||||
const rowOptions = shopTypeOptions.slice(row ? SHOP_OPTIONS_ROW_LIMIT : 0, row ? undefined : SHOP_OPTIONS_ROW_LIMIT);
|
const rowOptions = shopTypeOptions.slice(row ? SHOP_OPTIONS_ROW_LIMIT : 0, row ? undefined : SHOP_OPTIONS_ROW_LIMIT);
|
||||||
const sliceWidth = (this.scene.game.canvas.width / 6) / (rowOptions.length + 2);
|
const sliceWidth = (this.scene.game.canvas.width / 6) / (rowOptions.length + 2);
|
||||||
const option = new ModifierOption(this.scene, sliceWidth * (col + 1) + (sliceWidth * 0.5), ((-this.scene.game.canvas.height / 12) - (this.scene.game.canvas.height / 32) - (40 - (28 * row - 1))), shopTypeOptions[m]);
|
const option = new ModifierOption(this.scene, sliceWidth * (col + 1) + (sliceWidth * 0.5), ((-this.scene.game.canvas.height / 12) - (this.scene.game.canvas.height / 32) - (42 - (28 * row - 1))), shopTypeOptions[m]);
|
||||||
option.setScale(0.375);
|
option.setScale(0.375);
|
||||||
this.scene.add.existing(option);
|
this.scene.add.existing(option);
|
||||||
this.modifierContainer.add(option);
|
this.modifierContainer.add(option);
|
||||||
@ -456,16 +459,18 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
if (this.rowCursor === 1 && options.length === 0) {
|
if (this.rowCursor === 1 && options.length === 0) {
|
||||||
// Continue button when no shop items
|
// Continue button when no shop items
|
||||||
this.cursorObj.setScale(1.25);
|
this.cursorObj.setScale(1.25);
|
||||||
this.cursorObj.setPosition((this.scene.game.canvas.width / 18) + 23, (-this.scene.game.canvas.height / 12) - (this.shopOptionsRows.length > 1 ? 6 : 22));
|
this.cursorObj.setPosition((this.scene.game.canvas.width / 18) + 23, (-this.scene.game.canvas.height / 12) - (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2));
|
||||||
ui.showText(i18next.t("modifierSelectUiHandler:continueNextWaveDescription"));
|
ui.showText(i18next.t("modifierSelectUiHandler:continueNextWaveDescription"));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sliceWidth = (this.scene.game.canvas.width / 6) / (options.length + 2);
|
const sliceWidth = (this.scene.game.canvas.width / 6) / (options.length + 2);
|
||||||
if (this.rowCursor < 2) {
|
if (this.rowCursor < 2) {
|
||||||
this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 20, (-this.scene.game.canvas.height / 12) - (this.shopOptionsRows.length > 1 ? 6 : 22));
|
// Cursor on free items
|
||||||
|
this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 20, (-this.scene.game.canvas.height / 12) - (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2));
|
||||||
} else {
|
} else {
|
||||||
this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 16, (-this.scene.game.canvas.height / 12 - this.scene.game.canvas.height / 32) - (-16 + 28 * (this.rowCursor - (this.shopOptionsRows.length - 1))));
|
// Cursor on paying items
|
||||||
|
this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 16, (-this.scene.game.canvas.height / 12 - this.scene.game.canvas.height / 32) - (-14 + 28 * (this.rowCursor - (this.shopOptionsRows.length - 1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
const type = options[this.cursor].modifierTypeOption.type;
|
const type = options[this.cursor].modifierTypeOption.type;
|
||||||
@ -475,16 +480,16 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
this.moveInfoOverlay.show(allMoves[type.moveId]);
|
this.moveInfoOverlay.show(allMoves[type.moveId]);
|
||||||
}
|
}
|
||||||
} else if (cursor === 0) {
|
} else if (cursor === 0) {
|
||||||
this.cursorObj.setPosition(6, this.lockRarityButtonContainer.visible ? -72 : -60);
|
this.cursorObj.setPosition(6, this.lockRarityButtonContainer.visible ? OPTION_BUTTON_YPOSITION - 8 : OPTION_BUTTON_YPOSITION + 4);
|
||||||
ui.showText(i18next.t("modifierSelectUiHandler:rerollDesc"));
|
ui.showText(i18next.t("modifierSelectUiHandler:rerollDesc"));
|
||||||
} else if (cursor === 1) {
|
} else if (cursor === 1) {
|
||||||
this.cursorObj.setPosition((this.scene.game.canvas.width - this.transferButtonWidth - this.checkButtonWidth) / 6 - 30, -60);
|
this.cursorObj.setPosition((this.scene.game.canvas.width - this.transferButtonWidth - this.checkButtonWidth) / 6 - 30, OPTION_BUTTON_YPOSITION + 4);
|
||||||
ui.showText(i18next.t("modifierSelectUiHandler:transferDesc"));
|
ui.showText(i18next.t("modifierSelectUiHandler:transferDesc"));
|
||||||
} else if (cursor === 2) {
|
} else if (cursor === 2) {
|
||||||
this.cursorObj.setPosition((this.scene.game.canvas.width - this.checkButtonWidth) / 6 - 10, -60);
|
this.cursorObj.setPosition((this.scene.game.canvas.width - this.checkButtonWidth) / 6 - 10, OPTION_BUTTON_YPOSITION + 4);
|
||||||
ui.showText(i18next.t("modifierSelectUiHandler:checkTeamDesc"));
|
ui.showText(i18next.t("modifierSelectUiHandler:checkTeamDesc"));
|
||||||
} else {
|
} else {
|
||||||
this.cursorObj.setPosition(6, -60);
|
this.cursorObj.setPosition(6, OPTION_BUTTON_YPOSITION + 4);
|
||||||
ui.showText(i18next.t("modifierSelectUiHandler:lockRaritiesDesc"));
|
ui.showText(i18next.t("modifierSelectUiHandler:lockRaritiesDesc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
import BattleScene from "../battle-scene";
|
|
||||||
import { ModalConfig, ModalUiHandler } from "./modal-ui-handler";
|
|
||||||
import { addTextObject, TextStyle } from "./text";
|
|
||||||
import { Mode } from "./ui";
|
|
||||||
|
|
||||||
export default class OutdatedModalUiHandler extends ModalUiHandler {
|
|
||||||
constructor(scene: BattleScene, mode: Mode | null = null) {
|
|
||||||
super(scene, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
getModalTitle(): string {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
getWidth(): number {
|
|
||||||
return 160;
|
|
||||||
}
|
|
||||||
|
|
||||||
getHeight(): number {
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
getMargin(): [number, number, number, number] {
|
|
||||||
return [ 0, 0, 48, 0 ];
|
|
||||||
}
|
|
||||||
|
|
||||||
getButtonLabels(): string[] {
|
|
||||||
return [ ];
|
|
||||||
}
|
|
||||||
|
|
||||||
setup(): void {
|
|
||||||
super.setup();
|
|
||||||
|
|
||||||
const label = addTextObject(this.scene, this.getWidth() / 2, this.getHeight() / 2, "Your client is currently outdated.\nPlease reload to update the game.\n\nIf this error persists, please clear your browser cache.", TextStyle.WINDOW, { fontSize: "48px", align: "center" });
|
|
||||||
label.setOrigin(0.5, 0.5);
|
|
||||||
|
|
||||||
this.modalContainer.add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
show(args: any[]): boolean {
|
|
||||||
const config: ModalConfig = {
|
|
||||||
buttonActions: []
|
|
||||||
};
|
|
||||||
|
|
||||||
return super.show([ config ]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,7 +34,6 @@ import SaveSlotSelectUiHandler from "./save-slot-select-ui-handler";
|
|||||||
import TitleUiHandler from "./title-ui-handler";
|
import TitleUiHandler from "./title-ui-handler";
|
||||||
import SavingIconHandler from "./saving-icon-handler";
|
import SavingIconHandler from "./saving-icon-handler";
|
||||||
import UnavailableModalUiHandler from "./unavailable-modal-ui-handler";
|
import UnavailableModalUiHandler from "./unavailable-modal-ui-handler";
|
||||||
import OutdatedModalUiHandler from "./outdated-modal-ui-handler";
|
|
||||||
import SessionReloadModalUiHandler from "./session-reload-modal-ui-handler";
|
import SessionReloadModalUiHandler from "./session-reload-modal-ui-handler";
|
||||||
import { Button } from "#enums/buttons";
|
import { Button } from "#enums/buttons";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
@ -90,7 +89,6 @@ export enum Mode {
|
|||||||
LOADING,
|
LOADING,
|
||||||
SESSION_RELOAD,
|
SESSION_RELOAD,
|
||||||
UNAVAILABLE,
|
UNAVAILABLE,
|
||||||
OUTDATED,
|
|
||||||
CHALLENGE_SELECT,
|
CHALLENGE_SELECT,
|
||||||
RENAME_POKEMON,
|
RENAME_POKEMON,
|
||||||
RUN_HISTORY,
|
RUN_HISTORY,
|
||||||
@ -134,7 +132,6 @@ const noTransitionModes = [
|
|||||||
Mode.LOADING,
|
Mode.LOADING,
|
||||||
Mode.SESSION_RELOAD,
|
Mode.SESSION_RELOAD,
|
||||||
Mode.UNAVAILABLE,
|
Mode.UNAVAILABLE,
|
||||||
Mode.OUTDATED,
|
|
||||||
Mode.RENAME_POKEMON,
|
Mode.RENAME_POKEMON,
|
||||||
Mode.TEST_DIALOGUE,
|
Mode.TEST_DIALOGUE,
|
||||||
Mode.AUTO_COMPLETE,
|
Mode.AUTO_COMPLETE,
|
||||||
@ -200,7 +197,6 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||||||
new LoadingModalUiHandler(scene),
|
new LoadingModalUiHandler(scene),
|
||||||
new SessionReloadModalUiHandler(scene),
|
new SessionReloadModalUiHandler(scene),
|
||||||
new UnavailableModalUiHandler(scene),
|
new UnavailableModalUiHandler(scene),
|
||||||
new OutdatedModalUiHandler(scene),
|
|
||||||
new GameChallengesUiHandler(scene),
|
new GameChallengesUiHandler(scene),
|
||||||
new RenameFormUiHandler(scene),
|
new RenameFormUiHandler(scene),
|
||||||
new RunHistoryUiHandler(scene),
|
new RunHistoryUiHandler(scene),
|
||||||
|
Loading…
Reference in New Issue
Block a user