mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 23:00:52 +00:00
## Description: Public rotation lobbies can run the **Doomsday Clock** at one of four presets (slow/normal/fast/veryfast), and lobbies can **anonymize player names**, but the lobby UI surfaced neither: the Doomsday Clock badge was generic and there were no settings cards for either. Players couldn't tell what a lobby was actually set to. This surfaces both as regular lobby settings, matching how the other modifiers already display: - **Settings cards** (join/waiting view): adds a "Doomsday Clock" card showing the active preset name, and an "Anonymous Players" card, alongside the existing modifier cards. - **Lobby badge** (home lobby list): the Doomsday Clock badge now reads "Doomsday Clock: Fast" instead of the generic label. Falls back to the plain label when no speed is present (older payloads / non-rotation lobbies). Client-only. Both `doomsdayClock.speed` and `anonymizeNames` already ship in the public `GameConfig`, so no server or schema changes are needed. ## Please complete the following: - [] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: zixer._
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getActiveModifiers } from "../../src/client/Utils";
|
|
|
|
// The doomsday clock is part of the public "special" modifier rotation, so an
|
|
// active isDoomsdayClock modifier must surface a lobby badge like every other
|
|
// rotation modifier.
|
|
describe("doomsday clock public modifier", () => {
|
|
it("surfaces a doomsday-clock badge when the modifier is active", () => {
|
|
const mods = getActiveModifiers({ isDoomsdayClock: true });
|
|
expect(mods).toHaveLength(1);
|
|
expect(mods[0].badgeKey).toBe("public_game_modifier.doomsday_clock");
|
|
expect(mods[0].labelKey).toBe("public_game_modifier.doomsday_clock_label");
|
|
});
|
|
|
|
it("names the preset when a speed is provided", () => {
|
|
const mods = getActiveModifiers({ isDoomsdayClock: true }, "fast");
|
|
expect(mods).toHaveLength(1);
|
|
expect(mods[0].badgeKey).toBe(
|
|
"public_game_modifier.doomsday_clock_with_speed",
|
|
);
|
|
expect(mods[0].labelKey).toBe("public_game_modifier.doomsday_clock_label");
|
|
// The speed is resolved to its translated label and passed as a badge param.
|
|
expect(mods[0].badgeParams?.speed).toBeDefined();
|
|
});
|
|
|
|
it("omits the badge when the modifier is absent", () => {
|
|
expect(getActiveModifiers({})).toHaveLength(0);
|
|
expect(getActiveModifiers(undefined)).toHaveLength(0);
|
|
});
|
|
});
|