This reverts commit 806585f1a6
.
This commit is contained in:
parent
806585f1a6
commit
29a079cfd3
|
@ -2,7 +2,7 @@
|
||||||
export const PLAYER_PARTY_MAX_SIZE: number = 6;
|
export const PLAYER_PARTY_MAX_SIZE: number = 6;
|
||||||
|
|
||||||
/** Whether to use seasonal splash messages in general */
|
/** 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 */
|
/** Name of the session ID cookie */
|
||||||
export const SESSION_ID_COOKIE_NAME: string = "pokerogue_sessionId";
|
export const SESSION_ID_COOKIE_NAME: string = "pokerogue_sessionId";
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { USE_SEASONAL_SPLASH_MESSAGES } from "#app/constants";
|
import { USE_SEASONAL_SPLASH_MESSAGES } from "#app/constants";
|
||||||
import i18next from "i18next";
|
|
||||||
|
|
||||||
//#region Interfaces/Types
|
//#region Interfaces/Types
|
||||||
|
|
||||||
|
@ -38,6 +37,8 @@ interface Season {
|
||||||
start: `${Month}-${Day}`;
|
start: `${Month}-${Day}`;
|
||||||
/** The end day and month of the season. Format `MM-DD` */
|
/** The end day and month of the season. Format `MM-DD` */
|
||||||
end: `${Month}-${Day}`;
|
end: `${Month}-${Day}`;
|
||||||
|
/** Collection of the messages to display (without the `i18next.t()` call!) */
|
||||||
|
messages: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
//#region Constants
|
//#region Constants
|
||||||
|
@ -45,57 +46,176 @@ interface Season {
|
||||||
/** The weight multiplier for the battles-won splash message */
|
/** The weight multiplier for the battles-won splash message */
|
||||||
const BATTLES_WON_WEIGHT_MULTIPLIER = 10;
|
const BATTLES_WON_WEIGHT_MULTIPLIER = 10;
|
||||||
/** The weight multiplier for the seasonal splash messages */
|
/** 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
|
//#region Seasonal Messages
|
||||||
|
|
||||||
const seasonalSplashMessages: Season[] = [
|
const seasonalSplashMessages: Season[] = [
|
||||||
{
|
{
|
||||||
name: "halloween",
|
name: "Halloween",
|
||||||
start: "10-15",
|
start: "09-15",
|
||||||
end: "10-31"
|
end: "10-31",
|
||||||
|
messages: [ "halloween.pumpkabooAbout", "halloween.mayContainSpiders", "halloween.spookyScarySkeledirge", "halloween.gourgeistUsedTrickOrTreat", "halloween.letsSnuggleForever" ],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "xmas",
|
name: "XMAS",
|
||||||
start: "12-16",
|
start: "12-01",
|
||||||
end: "12-31"
|
end: "12-26",
|
||||||
|
messages: [ "xmas.happyHolidays", "xmas.unaffilicatedWithDelibirdServices", "xmas.delibirdSeason", "xmas.diamondsFromTheSky", "xmas.holidayStylePikachuNotIncluded" ],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "newYears",
|
name: "New Year's",
|
||||||
start: "12-31",
|
start: "01-01",
|
||||||
end: "01-14"
|
end: "01-31",
|
||||||
|
messages: [ "newYears.happyNewYear" ],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
export function getSplashMessages(): string[] {
|
export function getSplashMessages(): string[] {
|
||||||
const existingKeys = i18next.getResourceBundle(i18next.language, "splashMessages");
|
const splashMessages: string[] = [ ...commonSplashMessages ];
|
||||||
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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("use seasonal splash messages", USE_SEASONAL_SPLASH_MESSAGES);
|
console.log("use seasonal splash messages", USE_SEASONAL_SPLASH_MESSAGES);
|
||||||
if (USE_SEASONAL_SPLASH_MESSAGES) {
|
if (USE_SEASONAL_SPLASH_MESSAGES) {
|
||||||
// add seasonal splash messages if the season is active
|
// 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 now = new Date();
|
||||||
const startDate = new Date(`${start}-${now.getFullYear()}`);
|
const startDate = new Date(`${start}-${now.getFullYear()}`);
|
||||||
const endDate = new Date(`${end}-${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) {
|
if (now >= startDate && now <= endDate) {
|
||||||
const existingMessages: string[] = [ ...Object.keys(existingKeys[name]) ].map(m=>`${name}.${m}`);
|
console.log(`Adding ${messages.length} ${name} splash messages (weight: x${SEASONAL_WEIGHT_MULTIPLIER})`);
|
||||||
console.log(`Adding ${existingMessages.length} ${name} splash messages from ${i18next.language} (weight: x${SEASONAL_WEIGHT_MULTIPLIER})`);
|
messages.forEach((message) => {
|
||||||
existingMessages.forEach((message) => {
|
|
||||||
const weightedMessage = Array(SEASONAL_WEIGHT_MULTIPLIER).fill(message);
|
const weightedMessage = Array(SEASONAL_WEIGHT_MULTIPLIER).fill(message);
|
||||||
splashMessages.push(...weightedMessage);
|
splashMessages.push(...weightedMessage);
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe("Data - Splash Messages", () => {
|
||||||
|
|
||||||
// make sure to adjust this test if the weight it changed!
|
// make sure to adjust this test if the weight it changed!
|
||||||
it("should add contain 10 `battlesWon` splash messages", () => {
|
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);
|
expect(battlesWonMessages).toHaveLength(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,16 +22,16 @@ describe("Data - Splash Messages", () => {
|
||||||
vi.useRealTimers(); // reset system time
|
vi.useRealTimers(); // reset system time
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should contain halloween messages from Oct 15 to Oct 31", () => {
|
it("should contain halloween messages from Sep 15 to Oct 31", () => {
|
||||||
testSeason(new Date("2024-10-15"), new Date("2024-10-31"), "halloween");
|
testSeason(new Date("2024-09-15"), new Date("2024-10-31"), "halloween");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should contain xmas messages from Dec 16 to Dec 31", () => {
|
it("should contain xmas messages from Dec 1 to Dec 26", () => {
|
||||||
testSeason(new Date("2024-12-16"), new Date("2024-12-31"), "xmas");
|
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", () => {
|
it("should contain new years messages frm Jan 1 to Jan 31", () => {
|
||||||
testSeason(new Date("2024-12-31"), new Date("2025-01-14"), "newYears");
|
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(before).toBe(0);
|
||||||
expect(start).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(20); // make sure to adjust if weight is changed!
|
expect(end).toBeGreaterThanOrEqual(10); // make sure to adjust if weight is changed!
|
||||||
expect(after).toBe(0);
|
expect(after).toBe(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
|
||||||
.then(stats => {
|
.then(stats => {
|
||||||
if (stats) {
|
if (stats) {
|
||||||
this.playerCountLabel.setText(`${stats.playerCount} ${i18next.t("menu:playersOnline")}`);
|
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 }));
|
this.splashMessageText.setText(i18next.t(this.splashMessage, { count: stats.battleCount }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,6 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
this.splashMessage = Utils.randItem(getSplashMessages());
|
this.splashMessage = Utils.randItem(getSplashMessages());
|
||||||
console.log(this.splashMessage);
|
|
||||||
this.splashMessageText.setText(i18next.t(this.splashMessage, { count: TitleUiHandler.BATTLES_WON_FALLBACK }));
|
this.splashMessageText.setText(i18next.t(this.splashMessage, { count: TitleUiHandler.BATTLES_WON_FALLBACK }));
|
||||||
|
|
||||||
this.appVersionText.setText("v" + version);
|
this.appVersionText.setText("v" + version);
|
||||||
|
|
Loading…
Reference in New Issue