mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-04-27 16:20:37 +00:00
3ac06bffaa
Closes deferred phases 04 + 05 of loldle-new-modes plan. - loldle-ability: 5 guesses, DDragon ability icon as photo. State pins slot (P/Q/W/E/R) so the same icon shows every turn. Abilities pulled from DDragon per-champion — same source loldle.net uses at runtime. - loldle-splash: 4 guesses, random skin splash as photo. Skin pool scraped from loldle.net bundle (var Ad=[…] — 172 champs × 1939 skins, non-chroma, matches their splash mode exactly). URLs from Riot DDragon CDN (no version segment, stable across patches). - fetch-ddragon-data.js: extended to write all four JSONs in one run. Shares a single DDragon per-champion fetch cycle (concurrency 10). - Credits loldle.net + Riot Games in all loldle-family READMEs. 19 new tests (503 total). Lint clean. register:dry reports 12 loldle_* commands with no conflicts.
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import { beforeEach, describe, expect, it } from "vitest";
|
|
import { createStore } from "../../../src/db/create-store.js";
|
|
import {
|
|
clearGame,
|
|
loadGame,
|
|
loadStats,
|
|
recordResult,
|
|
saveGame,
|
|
} from "../../../src/modules/loldle-splash/state.js";
|
|
import { makeFakeKv } from "../../fakes/fake-kv-namespace.js";
|
|
|
|
describe("loldle-splash state", () => {
|
|
let db;
|
|
|
|
beforeEach(() => {
|
|
db = createStore("loldle-splash", { KV: makeFakeKv() });
|
|
});
|
|
|
|
it("round-trips a game with skinId field", async () => {
|
|
const state = { target: "Ahri", skinId: 9, guesses: [], startedAt: null };
|
|
await saveGame(db, 99, state);
|
|
expect(await loadGame(db, 99)).toEqual(state);
|
|
});
|
|
|
|
it("clearGame removes the record", async () => {
|
|
await saveGame(db, 99, { target: "Ahri", skinId: 0, guesses: [], startedAt: null });
|
|
await clearGame(db, 99);
|
|
expect(await loadGame(db, 99)).toBeNull();
|
|
});
|
|
|
|
it("recordResult tracks streaks + bestStreak", async () => {
|
|
await recordResult(db, 99, true);
|
|
await recordResult(db, 99, true);
|
|
const s = await loadStats(db, 99);
|
|
expect(s).toMatchObject({ played: 2, wins: 2, streak: 2, bestStreak: 2 });
|
|
});
|
|
});
|