From 29a079cfd3f188c3975ab0eff1ae9f73e44e139d Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:04:12 -0800 Subject: [PATCH] Revert "[UI/UX] Refactor and enable seasonal splash messages (#5009)" (#5014) This reverts commit 806585f1a69a8059444c00aa87ca5ecedc71cf9b. --- src/constants.ts | 2 +- src/data/splash-messages.ts | 180 +++++++++++++++++++++----- src/test/data/splash_messages.test.ts | 18 +-- src/ui/title-ui-handler.ts | 3 +- 4 files changed, 161 insertions(+), 42 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 927575c0a28..63f00b9f33f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -2,7 +2,7 @@ export const PLAYER_PARTY_MAX_SIZE: number = 6; /** Whether to use seasonal splash messages in general */ -export const USE_SEASONAL_SPLASH_MESSAGES: boolean = true; +export const USE_SEASONAL_SPLASH_MESSAGES: boolean = false; /** Name of the session ID cookie */ export const SESSION_ID_COOKIE_NAME: string = "pokerogue_sessionId"; diff --git a/src/data/splash-messages.ts b/src/data/splash-messages.ts index 086a55189d0..1f00ce0d555 100644 --- a/src/data/splash-messages.ts +++ b/src/data/splash-messages.ts @@ -1,5 +1,4 @@ import { USE_SEASONAL_SPLASH_MESSAGES } from "#app/constants"; -import i18next from "i18next"; //#region Interfaces/Types @@ -38,6 +37,8 @@ interface Season { start: `${Month}-${Day}`; /** The end day and month of the season. Format `MM-DD` */ end: `${Month}-${Day}`; + /** Collection of the messages to display (without the `i18next.t()` call!) */ + messages: string[]; } //#region Constants @@ -45,57 +46,176 @@ interface Season { /** The weight multiplier for the battles-won splash message */ const BATTLES_WON_WEIGHT_MULTIPLIER = 10; /** The weight multiplier for the seasonal splash messages */ -const SEASONAL_WEIGHT_MULTIPLIER = 20; +const SEASONAL_WEIGHT_MULTIPLIER = 10; + +//#region Common Messages + +const commonSplashMessages = [ + ...Array(BATTLES_WON_WEIGHT_MULTIPLIER).fill("battlesWon"), + "joinTheDiscord", + "infiniteLevels", + "everythingIsStackable", + "optionalSaveScumming", + "biomes", + "openSource", + "playWithSpeed", + "liveBugTesting", + "heavyInfluence", + "pokemonRiskAndPokemonRain", + "nowWithMoreSalt", + "infiniteFusionAtHome", + "brokenEggMoves", + "magnificent", + "doPeopleReadThis", + "thatsCrazy", + "gottaCatchEmAll", + "questionableBalancing", + "coolShaders", + "aiFree", + "suddenDifficultySpikes", + "basedOnAnUnfinishedFlashGame", + "moreAddictiveThanIntended", + "mostlyConsistentSeeds", + "achievementPointsDontDoAnything", + "nothingBeatsAJellyFilledDonut", + "dontTalkAboutTheTinkatonIncident", + "alsoTryPokengine", + "alsoTryEmeraldRogue", + "alsoTryRadicalRed", + "eeveeExpo", + "checkOutYnoproject", + "breedersInSpace", + "alsoTryPokemonUnbound", + "tryTheJohtoDragonChallenge", + "basicReadingAbilityRecommended", + "shoutoutsToTheArtists", + "gamblingNotEncouraged", + "dontForgetToTakeABreak", + "wEvent", + "ifItsNotAccurateItsAccurate", + "everyLossIsProgressMade", + "liveWoChienReaction", + "itsAFeatureNotABug", + "theEggsAreNotForEating", + "7.8outOf10TooManyWaterBiomes", + "butNothingHappened", + "thePowerOfScienceIsAmazing", + "freeToPlay", + "theresATimeAndPlaceForEverything", + "nowWithShinierShinies", + "smilesGoForMiles", + "certainlyNotDragonFree", + "haveANiceDay", + "redacted", + "hi", + "transRights", + "shinyOddsHigherThanYouThink", + "noFalseTrades", + "notForProfit", + "timeForYourDailyRun", + "moreEggsThanADaycare", + "disclaimerHarshSunDoesNotGiveVitaminD", + "whoNeedsAMap", + "luxrayIsNotADarkType", + "selfDestructiveEncounters", + "mostOptionsAreViable", + "pokerogueMorse", + "smiley", + "beAwareOfPassives", + "asSeenOnTheWorldWideWeb", + "vaultinVeluzas", + "tooManyStarters", + "checkTheWiki", + "winWithYourFavorites", + "alsoTryPokerogueWait", + "theWayISeeItKyogreIsSurrounded", + "tryOutHoneyGather", + "notForTheFaintOfHeart", + "p", + "flipYourDeviceToEvolveInkay", + "inArceusWeTrust", + "whyDidTheTorchicCrossTheRoad", + "goodLuck", + "fuseWisely", + "compensation", + "prepareForTroubleAndMakeItDouble", + "anEggForYourTroubles", + "regirock", + "hereForAGoodTime", + "getGoodOrDont", + "checkTheSubreddit", + "betterNerfGreninja", + "inCaseOfUpdateClearYourCache", + "insertTextHere", + "endingEndlessNotFound", + "iLikeMyEggsVouchered", + "YOU", + "noAddedSugar", + "notSponsored", + "notRated", + "justOneMoreWaveMom", + "saltCured", + "onlyOnPokerogueNet", + "pixelPerfection", + "openSource", + "probablyGood", + "itsAMonsterHouse", + "dontForgetYourPassword", + "tripleTripleTripleAxel", + "questionExclamation", + "clownEncounters", + "fullOfBerries", + "limitsAreMeantToBeBrokenSometimes", + "keepItCasual", + "serversProbablyWorking", + "mew", + "makeItRainAndYourProblemsGoAway", + "customMusicTracks", + "youAreValid", + "number591IsLookingOff", + "timeForYourDeliDelivery", + "goodFirstImpression", + "iPreferRarerCandies", +]; //#region Seasonal Messages const seasonalSplashMessages: Season[] = [ { - name: "halloween", - start: "10-15", - end: "10-31" + name: "Halloween", + start: "09-15", + end: "10-31", + messages: [ "halloween.pumpkabooAbout", "halloween.mayContainSpiders", "halloween.spookyScarySkeledirge", "halloween.gourgeistUsedTrickOrTreat", "halloween.letsSnuggleForever" ], }, { - name: "xmas", - start: "12-16", - end: "12-31" + name: "XMAS", + start: "12-01", + end: "12-26", + messages: [ "xmas.happyHolidays", "xmas.unaffilicatedWithDelibirdServices", "xmas.delibirdSeason", "xmas.diamondsFromTheSky", "xmas.holidayStylePikachuNotIncluded" ], }, { - name: "newYears", - start: "12-31", - end: "01-14" + name: "New Year's", + start: "01-01", + end: "01-31", + messages: [ "newYears.happyNewYear" ], }, ]; //#endregion export function getSplashMessages(): string[] { - const existingKeys = i18next.getResourceBundle(i18next.language, "splashMessages"); - const splashMessages: string[] = [ ...Object.keys(existingKeys["common"]) ].map((message) => `common.${message}`); - if (splashMessages.includes("common.battlesWon")) { - splashMessages.push(...Array(Math.max(BATTLES_WON_WEIGHT_MULTIPLIER - 1, 1)).fill("common.battlesWon")); - } - + const splashMessages: string[] = [ ...commonSplashMessages ]; console.log("use seasonal splash messages", USE_SEASONAL_SPLASH_MESSAGES); if (USE_SEASONAL_SPLASH_MESSAGES) { // add seasonal splash messages if the season is active - for (const { name, start, end } of seasonalSplashMessages) { + for (const { name, start, end, messages } of seasonalSplashMessages) { const now = new Date(); const startDate = new Date(`${start}-${now.getFullYear()}`); const endDate = new Date(`${end}-${now.getFullYear()}`); - if (endDate < startDate) { // If the end date is earlier in the year, that means it's next year - if (now >= startDate) { - endDate.setFullYear(endDate.getFullYear() + 1); //Ends next year - } else if (now <= endDate) { - startDate.setFullYear(startDate.getFullYear() - 1); //Started last year - } - } - console.log(`${name} event starts ${startDate} and ends ${endDate}`); - if (existingKeys.hasOwnProperty(name) && now >= startDate && now <= endDate) { - const existingMessages: string[] = [ ...Object.keys(existingKeys[name]) ].map(m=>`${name}.${m}`); - console.log(`Adding ${existingMessages.length} ${name} splash messages from ${i18next.language} (weight: x${SEASONAL_WEIGHT_MULTIPLIER})`); - existingMessages.forEach((message) => { + if (now >= startDate && now <= endDate) { + console.log(`Adding ${messages.length} ${name} splash messages (weight: x${SEASONAL_WEIGHT_MULTIPLIER})`); + messages.forEach((message) => { const weightedMessage = Array(SEASONAL_WEIGHT_MULTIPLIER).fill(message); splashMessages.push(...weightedMessage); }); diff --git a/src/test/data/splash_messages.test.ts b/src/test/data/splash_messages.test.ts index e4ad547b704..b9ed5b9d365 100644 --- a/src/test/data/splash_messages.test.ts +++ b/src/test/data/splash_messages.test.ts @@ -9,7 +9,7 @@ describe("Data - Splash Messages", () => { // make sure to adjust this test if the weight it changed! it("should add contain 10 `battlesWon` splash messages", () => { - const battlesWonMessages = getSplashMessages().filter((message) => message === "splashMessages:common.battlesWon"); + const battlesWonMessages = getSplashMessages().filter((message) => message === "splashMessages:battlesWon"); expect(battlesWonMessages).toHaveLength(10); }); @@ -22,16 +22,16 @@ describe("Data - Splash Messages", () => { vi.useRealTimers(); // reset system time }); - it("should contain halloween messages from Oct 15 to Oct 31", () => { - testSeason(new Date("2024-10-15"), new Date("2024-10-31"), "halloween"); + it("should contain halloween messages from Sep 15 to Oct 31", () => { + testSeason(new Date("2024-09-15"), new Date("2024-10-31"), "halloween"); }); - it("should contain xmas messages from Dec 16 to Dec 31", () => { - testSeason(new Date("2024-12-16"), new Date("2024-12-31"), "xmas"); + it("should contain xmas messages from Dec 1 to Dec 26", () => { + testSeason(new Date("2024-12-01"), new Date("2024-12-26"), "xmas"); }); - it("should contain new years messages from Dec 31 '24 to Jan 14 '25", () => { - testSeason(new Date("2024-12-31"), new Date("2025-01-14"), "newYears"); + it("should contain new years messages frm Jan 1 to Jan 31", () => { + testSeason(new Date("2024-01-01"), new Date("2024-01-31"), "newYears"); }); }); }); @@ -60,7 +60,7 @@ function testSeason(startDate: Date, endDate: Date, prefix: string) { }); expect(before).toBe(0); - expect(start).toBeGreaterThanOrEqual(20); // make sure to adjust if weight is changed! - expect(end).toBeGreaterThanOrEqual(20); // make sure to adjust if weight is changed! + expect(start).toBeGreaterThanOrEqual(10); // make sure to adjust if weight is changed! + expect(end).toBeGreaterThanOrEqual(10); // make sure to adjust if weight is changed! expect(after).toBe(0); } diff --git a/src/ui/title-ui-handler.ts b/src/ui/title-ui-handler.ts index f1b0a673ea0..aec80f049c9 100644 --- a/src/ui/title-ui-handler.ts +++ b/src/ui/title-ui-handler.ts @@ -83,7 +83,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler { .then(stats => { if (stats) { this.playerCountLabel.setText(`${stats.playerCount} ${i18next.t("menu:playersOnline")}`); - if (this.splashMessage === "splashMessages:common.battlesWon") { + if (this.splashMessage === "splashMessages:battlesWon") { this.splashMessageText.setText(i18next.t(this.splashMessage, { count: stats.battleCount })); } } @@ -98,7 +98,6 @@ export default class TitleUiHandler extends OptionSelectUiHandler { if (ret) { this.splashMessage = Utils.randItem(getSplashMessages()); - console.log(this.splashMessage); this.splashMessageText.setText(i18next.t(this.splashMessage, { count: TitleUiHandler.BATTLES_WON_FALLBACK })); this.appVersionText.setText("v" + version);