mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 22:09:27 +02:00
Update splash text test
This commit is contained in:
parent
bda97b3ea6
commit
8727c37751
@ -61,7 +61,7 @@ const seasonalSplashMessages: Season[] = [
|
|||||||
end: "12-31"
|
end: "12-31"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "newyears",
|
name: "newYears",
|
||||||
start: "12-31",
|
start: "12-31",
|
||||||
end: "01-14"
|
end: "01-14"
|
||||||
},
|
},
|
||||||
@ -71,10 +71,9 @@ const seasonalSplashMessages: Season[] = [
|
|||||||
|
|
||||||
export function getSplashMessages(): string[] {
|
export function getSplashMessages(): string[] {
|
||||||
const existingKeys = i18next.getResourceBundle(i18next.language, "splashMessages");
|
const existingKeys = i18next.getResourceBundle(i18next.language, "splashMessages");
|
||||||
console.log(existingKeys);
|
|
||||||
const splashMessages: string[] = [ ...Object.keys(existingKeys["common"]) ].map((message) => `common.${message}`);
|
const splashMessages: string[] = [ ...Object.keys(existingKeys["common"]) ].map((message) => `common.${message}`);
|
||||||
if (splashMessages.includes("common.battlesWon")) {
|
if (splashMessages.includes("common.battlesWon")) {
|
||||||
splashMessages.push(...Array(BATTLES_WON_WEIGHT_MULTIPLIER).fill("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);
|
||||||
@ -85,8 +84,13 @@ export function getSplashMessages(): string[] {
|
|||||||
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 (endDate < startDate) { // If the end date is earlier in the year, that means it's next year
|
||||||
endDate.setFullYear(endDate.getFullYear() + 1);
|
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 (existingKeys.hasOwnProperty(name) && now >= startDate && now <= endDate) {
|
||||||
const existingMessages: string[] = [ ...Object.keys(existingKeys[name]) ].map(m=>`${name}.${m}`);
|
const existingMessages: string[] = [ ...Object.keys(existingKeys[name]) ].map(m=>`${name}.${m}`);
|
||||||
|
@ -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:battlesWon");
|
const battlesWonMessages = getSplashMessages().filter((message) => message === "splashMessages:common.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 Sep 15 to Oct 31", () => {
|
it("should contain halloween messages from Oct 15 to Oct 31", () => {
|
||||||
testSeason(new Date("2024-09-15"), new Date("2024-10-31"), "halloween");
|
testSeason(new Date("2024-10-15"), new Date("2024-10-31"), "halloween");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should contain xmas messages from Dec 1 to Dec 26", () => {
|
it("should contain xmas messages from Dec 16 to Dec 31", () => {
|
||||||
testSeason(new Date("2024-12-01"), new Date("2024-12-26"), "xmas");
|
testSeason(new Date("2024-12-16"), new Date("2024-12-31"), "xmas");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should contain new years messages frm Jan 1 to Jan 31", () => {
|
it("should contain new years messages from Dec 31 '24 to Jan 14 '25", () => {
|
||||||
testSeason(new Date("2024-01-01"), new Date("2024-01-31"), "newYears");
|
testSeason(new Date("2024-12-31"), new Date("2025-01-14"), "newYears");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -60,7 +60,7 @@ function testSeason(startDate: Date, endDate: Date, prefix: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(before).toBe(0);
|
expect(before).toBe(0);
|
||||||
expect(start).toBeGreaterThanOrEqual(10); // make sure to adjust if weight is changed!
|
expect(start).toBeGreaterThanOrEqual(20); // make sure to adjust if weight is changed!
|
||||||
expect(end).toBeGreaterThanOrEqual(10); // make sure to adjust if weight is changed!
|
expect(end).toBeGreaterThanOrEqual(20); // make sure to adjust if weight is changed!
|
||||||
expect(after).toBe(0);
|
expect(after).toBe(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user