Merge branch 'beta' into refactor/api-requests

This commit is contained in:
NightKev 2024-11-02 08:57:07 -07:00 committed by GitHub
commit f703cbb339
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 77 additions and 47 deletions

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,7 +1,7 @@
{ {
"textures": [ "textures": [
{ {
"image": "statuses_es.png", "image": "statuses_es-ES.png",
"format": "RGBA8888", "format": "RGBA8888",
"size": { "size": {
"w": 22, "w": 22,

View File

Before

Width:  |  Height:  |  Size: 441 B

After

Width:  |  Height:  |  Size: 441 B

View File

@ -1,7 +1,7 @@
{ {
"textures": [ "textures": [
{ {
"image": "types_es.png", "image": "types_es-ES.png",
"format": "RGBA8888", "format": "RGBA8888",
"size": { "size": {
"w": 32, "w": 32,

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

@ -1 +1 @@
Subproject commit 71390cba88f4103d0d2273d59a6dd8340a4fa54f Subproject commit 3cf6d553541d79ba165387bc73fb06544d00f1f9

View File

@ -323,6 +323,7 @@ export default class BattleScene extends SceneBase {
this.conditionalQueue = []; this.conditionalQueue = [];
this.phaseQueuePrependSpliceIndex = -1; this.phaseQueuePrependSpliceIndex = -1;
this.nextCommandPhaseQueue = []; this.nextCommandPhaseQueue = [];
this.eventManager = new TimedEventManager();
this.updateGameInfo(); this.updateGameInfo();
} }
@ -378,7 +379,6 @@ export default class BattleScene extends SceneBase {
this.fieldSpritePipeline = new FieldSpritePipeline(this.game); this.fieldSpritePipeline = new FieldSpritePipeline(this.game);
(this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add("FieldSprite", this.fieldSpritePipeline); (this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add("FieldSprite", this.fieldSpritePipeline);
this.eventManager = new TimedEventManager();
this.launchBattle(); this.launchBattle();
} }

View File

@ -5750,6 +5750,11 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
return false; return false;
} }
// Don't allow wild mons to flee with U-turn et al
if (this.selfSwitch && !user.isPlayer() && move.category !== MoveCategory.STATUS) {
return false;
}
if (switchOutTarget.hp > 0) { if (switchOutTarget.hp > 0) {
switchOutTarget.leaveField(false); switchOutTarget.leaveField(false);
user.scene.queueMessage(i18next.t("moveTriggers:fled", { pokemonName: getPokemonNameWithAffix(switchOutTarget) }), null, true, 500); user.scene.queueMessage(i18next.t("moveTriggers:fled", { pokemonName: getPokemonNameWithAffix(switchOutTarget) }), null, true, 500);

View File

@ -1,7 +1,7 @@
import { EnemyPartyConfig, generateModifierType, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, loadCustomMovesForEncounter, selectPokemonForOption, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { EnemyPartyConfig, generateModifierType, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, loadCustomMovesForEncounter, selectPokemonForOption, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { trainerConfigs, TrainerPartyCompoundTemplate, TrainerPartyTemplate, } from "#app/data/trainer-config"; import { trainerConfigs, TrainerPartyCompoundTemplate, TrainerPartyTemplate, } from "#app/data/trainer-config";
import { ModifierTier } from "#app/modifier/modifier-tier"; import { ModifierTier } from "#app/modifier/modifier-tier";
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { ModifierPoolType, modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { PartyMemberStrength } from "#enums/party-member-strength"; import { PartyMemberStrength } from "#enums/party-member-strength";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
@ -280,7 +280,7 @@ export const ClowningAroundEncounter: MysteryEncounter =
let numRogue = 0; let numRogue = 0;
items.filter(m => m.isTransferable && !(m instanceof BerryModifier)) items.filter(m => m.isTransferable && !(m instanceof BerryModifier))
.forEach(m => { .forEach(m => {
const type = m.type.withTierFromPool(); const type = m.type.withTierFromPool(ModifierPoolType.PLAYER, party);
const tier = type.tier ?? ModifierTier.ULTRA; const tier = type.tier ?? ModifierTier.ULTRA;
if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) { if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) {
numRogue += m.stackCount; numRogue += m.stackCount;

View File

@ -418,7 +418,7 @@ export function generateModifierType(scene: BattleScene, modifier: () => Modifie
// Populates item id and tier (order matters) // Populates item id and tier (order matters)
result = result result = result
.withIdFromFunc(modifierTypes[modifierId]) .withIdFromFunc(modifierTypes[modifierId])
.withTierFromPool(); .withTierFromPool(ModifierPoolType.PLAYER, scene.getParty());
return result instanceof ModifierTypeGenerator ? result.generateType(scene.getParty(), pregenArgs) : result; return result instanceof ModifierTypeGenerator ? result.generateType(scene.getParty(), pregenArgs) : result;
} }

View File

@ -244,7 +244,7 @@ export class LoadingScene extends SceneBase {
this.loadAtlas("statuses", ""); this.loadAtlas("statuses", "");
this.loadAtlas("types", ""); this.loadAtlas("types", "");
} }
const availableLangs = [ "en", "de", "it", "fr", "ja", "ko", "es", "pt-BR", "zh-CN" ]; const availableLangs = [ "en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN" ];
if (lang && availableLangs.includes(lang)) { if (lang && availableLangs.includes(lang)) {
this.loadImage("halloween2024-event-" + lang, "events"); this.loadImage("halloween2024-event-" + lang, "events");
} else { } else {

View File

@ -19,7 +19,7 @@ import { Unlockables } from "#app/system/unlockables";
import { getVoucherTypeIcon, getVoucherTypeName, VoucherType } from "#app/system/voucher"; import { getVoucherTypeIcon, getVoucherTypeName, VoucherType } from "#app/system/voucher";
import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from "#app/ui/party-ui-handler"; import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from "#app/ui/party-ui-handler";
import { getModifierTierTextTint } from "#app/ui/text"; import { getModifierTierTextTint } from "#app/ui/text";
import { formatMoney, getEnumKeys, getEnumValues, IntegerHolder, NumberHolder, padInt, randSeedInt, randSeedItem } from "#app/utils"; import { formatMoney, getEnumKeys, getEnumValues, IntegerHolder, isNullOrUndefined, NumberHolder, padInt, randSeedInt, randSeedItem } from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { BerryType } from "#enums/berry-type"; import { BerryType } from "#enums/berry-type";
@ -121,17 +121,40 @@ export class ModifierType {
* Populates item tier for ModifierType instance * Populates item tier for ModifierType instance
* Tier is a necessary field for items that appear in player shop (determines the Pokeball visual they use) * Tier is a necessary field for items that appear in player shop (determines the Pokeball visual they use)
* To find the tier, this function performs a reverse lookup of the item type in modifier pools * To find the tier, this function performs a reverse lookup of the item type in modifier pools
* It checks the weight of the item and will use the first tier for which the weight is greater than 0
* This is to allow items to be in multiple item pools depending on the conditions, for example for events
* If all tiers have a weight of 0 for the item, the first tier where the item was found is used
* @param poolType Default 'ModifierPoolType.PLAYER'. Which pool to lookup item tier from * @param poolType Default 'ModifierPoolType.PLAYER'. Which pool to lookup item tier from
* @param party optional. Needed to check the weight of modifiers with conditional weight (see {@linkcode WeightedModifierTypeWeightFunc})
* if not provided or empty, the weight check will be ignored
* @param rerollCount Default `0`. Used to check the weight of modifiers with conditional weight (see {@linkcode WeightedModifierTypeWeightFunc})
*/ */
withTierFromPool(poolType: ModifierPoolType = ModifierPoolType.PLAYER): ModifierType { withTierFromPool(poolType: ModifierPoolType = ModifierPoolType.PLAYER, party?: PlayerPokemon[], rerollCount: number = 0): ModifierType {
let defaultTier: undefined | ModifierTier;
for (const tier of Object.values(getModifierPoolForType(poolType))) { for (const tier of Object.values(getModifierPoolForType(poolType))) {
for (const modifier of tier) { for (const modifier of tier) {
if (this.id === modifier.modifierType.id) { if (this.id === modifier.modifierType.id) {
let weight: number;
if (modifier.weight instanceof Function) {
weight = party ? modifier.weight(party, rerollCount) : 0;
} else {
weight = modifier.weight;
}
if (weight > 0) {
this.tier = modifier.modifierType.tier; this.tier = modifier.modifierType.tier;
return this; return this;
} else if (isNullOrUndefined(defaultTier)) {
// If weight is 0, keep track of the first tier where the item was found
defaultTier = modifier.modifierType.tier;
} }
} }
} }
}
// Didn't find a pool with weight > 0, fallback to first tier where the item was found, if any
if (defaultTier) {
this.tier = defaultTier;
}
return this; return this;
} }
@ -2117,7 +2140,7 @@ export function getPlayerModifierTypeOptions(count: integer, party: PlayerPokemo
// Populates item id and tier // Populates item id and tier
guaranteedMod = guaranteedMod guaranteedMod = guaranteedMod
.withIdFromFunc(modifierTypes[modifierId]) .withIdFromFunc(modifierTypes[modifierId])
.withTierFromPool(); .withTierFromPool(ModifierPoolType.PLAYER, party);
const modType = guaranteedMod instanceof ModifierTypeGenerator ? guaranteedMod.generateType(party) : guaranteedMod; const modType = guaranteedMod instanceof ModifierTypeGenerator ? guaranteedMod.generateType(party) : guaranteedMod;
if (modType) { if (modType) {
@ -2186,7 +2209,7 @@ export function overridePlayerModifierTypeOptions(options: ModifierTypeOption[],
} }
if (modifierType) { if (modifierType) {
options[i].type = modifierType.withIdFromFunc(modifierFunc).withTierFromPool(); options[i].type = modifierType.withIdFromFunc(modifierFunc).withTierFromPool(ModifierPoolType.PLAYER, party);
} }
} }
} }

View File

@ -153,7 +153,7 @@ export async function initI18n(): Promise<void> {
i18next.use(new KoreanPostpositionProcessor()); i18next.use(new KoreanPostpositionProcessor());
await i18next.init({ await i18next.init({
fallbackLng: "en", fallbackLng: "en",
supportedLngs: [ "en", "es", "fr", "it", "de", "zh-CN", "zh-TW", "pt-BR", "ko", "ja", "ca-ES" ], supportedLngs: [ "en", "es-ES", "fr", "it", "de", "zh-CN", "zh-TW", "pt-BR", "ko", "ja", "ca-ES" ],
backend: { backend: {
loadPath(lng: string, [ ns ]: string[]) { loadPath(lng: string, [ ns ]: string[]) {
let fileName: string; let fileName: string;

View File

@ -866,8 +866,8 @@ export function setSetting(scene: BattleScene, setting: string, value: integer):
handler: () => changeLocaleHandler("en") handler: () => changeLocaleHandler("en")
}, },
{ {
label: "Español", label: "Español (ES)",
handler: () => changeLocaleHandler("es") handler: () => changeLocaleHandler("es-ES")
}, },
{ {
label: "Italiano", label: "Italiano",

View File

@ -24,6 +24,7 @@ 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"; import { version } from "../../../package.json";
import { MockTimedEventManager } from "./mocks/mockTimedEventManager";
Object.defineProperty(window, "localStorage", { Object.defineProperty(window, "localStorage", {
value: mockLocalStorage(), value: mockLocalStorage(),
@ -232,6 +233,7 @@ export default class GameWrapper {
this.scene.make = new MockGameObjectCreator(mockTextureManager); this.scene.make = new MockGameObjectCreator(mockTextureManager);
this.scene.time = new MockClock(this.scene); this.scene.time = new MockClock(this.scene);
this.scene.remove = vi.fn(); // TODO: this should be stubbed differently this.scene.remove = vi.fn(); // TODO: this should be stubbed differently
this.scene.eventManager = new MockTimedEventManager(); // Disable Timed Events
} }
} }

View File

@ -0,0 +1,17 @@
import { TimedEventManager } from "#app/timed-event-manager";
/** Mock TimedEventManager so that ongoing events don't impact tests */
export class MockTimedEventManager extends TimedEventManager {
override activeEvent() {
return undefined;
}
override isEventActive(): boolean {
return false;
}
override getFriendshipMultiplier(): number {
return 1;
}
override getShinyMultiplier(): number {
return 1;
}
}

View File

@ -35,7 +35,7 @@ const timedEvents: TimedEvent[] = [
endDate: new Date(Date.UTC(2024, 10, 4, 0)), endDate: new Date(Date.UTC(2024, 10, 4, 0)),
bannerKey: "halloween2024-event-", bannerKey: "halloween2024-event-",
scale: 0.21, scale: 0.21,
availableLangs: [ "en", "de", "it", "fr", "ja", "ko", "es", "pt-BR", "zh-CN" ] availableLangs: [ "en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN" ]
} }
]; ];

View File

@ -107,7 +107,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
let pokemonIconX = -20; let pokemonIconX = -20;
let pokemonIconY = 6; let pokemonIconY = 6;
if ([ "de", "es", "fr", "ko", "pt-BR" ].includes(currentLanguage)) { if ([ "de", "es-ES", "fr", "ko", "pt-BR" ].includes(currentLanguage)) {
gachaTextStyle = TextStyle.SMALLER_WINDOW_ALT; gachaTextStyle = TextStyle.SMALLER_WINDOW_ALT;
gachaX = 2; gachaX = 2;
gachaY = 2; gachaY = 2;
@ -115,7 +115,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
let legendaryLabelX = gachaX; let legendaryLabelX = gachaX;
let legendaryLabelY = gachaY; let legendaryLabelY = gachaY;
if ([ "de", "es" ].includes(currentLanguage)) { if ([ "de", "es-ES" ].includes(currentLanguage)) {
pokemonIconX = -25; pokemonIconX = -25;
pokemonIconY = 10; pokemonIconY = 10;
legendaryLabelX = -6; legendaryLabelX = -6;
@ -128,7 +128,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
switch (gachaType as GachaType) { switch (gachaType as GachaType) {
case GachaType.LEGENDARY: case GachaType.LEGENDARY:
if ([ "de", "es" ].includes(currentLanguage)) { if ([ "de", "es-ES" ].includes(currentLanguage)) {
gachaUpLabel.setAlign("center"); gachaUpLabel.setAlign("center");
gachaUpLabel.setY(0); gachaUpLabel.setY(0);
} }
@ -149,7 +149,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
gachaInfoContainer.add(pokemonIcon); gachaInfoContainer.add(pokemonIcon);
break; break;
case GachaType.MOVE: case GachaType.MOVE:
if ([ "de", "es", "fr", "pt-BR" ].includes(currentLanguage)) { if ([ "de", "es-ES", "fr", "pt-BR" ].includes(currentLanguage)) {
gachaUpLabel.setAlign("center"); gachaUpLabel.setAlign("center");
gachaUpLabel.setY(0); gachaUpLabel.setY(0);
} }

View File

@ -21,24 +21,6 @@ interface LanguageSetting {
} }
const languageSettings: { [key: string]: LanguageSetting } = { const languageSettings: { [key: string]: LanguageSetting } = {
"en": {
infoContainerTextSize: "64px"
},
"de": {
infoContainerTextSize: "64px",
},
"es": {
infoContainerTextSize: "64px"
},
"fr": {
infoContainerTextSize: "64px"
},
"it": {
infoContainerTextSize: "64px"
},
"zh": {
infoContainerTextSize: "64px"
},
"pt": { "pt": {
infoContainerTextSize: "60px", infoContainerTextSize: "60px",
infoContainerLabelXPos: -15, infoContainerLabelXPos: -15,

View File

@ -13,7 +13,7 @@ interface LanguageSetting {
} }
const languageSettings: { [key: string]: LanguageSetting } = { const languageSettings: { [key: string]: LanguageSetting } = {
"es":{ "es-ES": {
inputFieldFontSize: "50px", inputFieldFontSize: "50px",
errorMessageFontSize: "40px", errorMessageFontSize: "40px",
} }

View File

@ -674,7 +674,7 @@ export default class RunInfoUiHandler extends UiHandler {
const def = i18next.t("pokemonInfo:Stat.DEFshortened") + ": " + pStats[2]; const def = i18next.t("pokemonInfo:Stat.DEFshortened") + ": " + pStats[2];
const spatk = i18next.t("pokemonInfo:Stat.SPATKshortened") + ": " + pStats[3]; const spatk = i18next.t("pokemonInfo:Stat.SPATKshortened") + ": " + pStats[3];
const spdef = i18next.t("pokemonInfo:Stat.SPDEFshortened") + ": " + pStats[4]; const spdef = i18next.t("pokemonInfo:Stat.SPDEFshortened") + ": " + pStats[4];
const speedLabel = (currentLanguage === "es" || currentLanguage === "pt_BR") ? i18next.t("runHistory:SPDshortened") : i18next.t("pokemonInfo:Stat.SPDshortened"); const speedLabel = (currentLanguage === "es-ES" || currentLanguage === "pt_BR") ? i18next.t("runHistory:SPDshortened") : i18next.t("pokemonInfo:Stat.SPDshortened");
const speed = speedLabel + ": " + pStats[5]; const speed = speedLabel + ": " + pStats[5];
// Column 1: HP Atk Def // Column 1: HP Atk Def
const pokeStatText1 = addBBCodeTextObject(this.scene, -5, 0, hp, TextStyle.SUMMARY, { fontSize: textContainerFontSize, lineSpacing: lineSpacing }); const pokeStatText1 = addBBCodeTextObject(this.scene, -5, 0, hp, TextStyle.SUMMARY, { fontSize: textContainerFontSize, lineSpacing: lineSpacing });

View File

@ -29,10 +29,10 @@ export default class SettingsDisplayUiHandler extends AbstractSettingsUiHandler
label: "English", label: "English",
}; };
break; break;
case "es": case "es-ES":
this.settings[languageIndex].options[0] = { this.settings[languageIndex].options[0] = {
value: "Español", value: "Español (ES)",
label: "Español", label: "Español (ES)",
}; };
break; break;
case "it": case "it":

View File

@ -81,7 +81,7 @@ const languageSettings: { [key: string]: LanguageSetting } = {
instructionTextSize: "35px", instructionTextSize: "35px",
starterInfoXPos: 33, starterInfoXPos: 33,
}, },
"es":{ "es-ES":{
starterInfoTextSize: "56px", starterInfoTextSize: "56px",
instructionTextSize: "35px", instructionTextSize: "35px",
}, },

View File

@ -184,6 +184,7 @@ export default class TargetSelectUiHandler extends UiHandler {
} }
clear() { clear() {
this.cursor = -1;
super.clear(); super.clear();
this.eraseCursor(); this.eraseCursor();
} }

View File

@ -454,7 +454,7 @@ export function verifyLang(lang?: string): boolean {
} }
switch (lang) { switch (lang) {
case "es": case "es-ES":
case "fr": case "fr":
case "de": case "de":
case "it": case "it":