Show a full reserve count on the Sokko TCG menu icon and remaining openings while opening a pack

A gold count now sits on the Sokko TCG menu icon while the opening reserve is
full, so players notice it from any page. A light reserve route keeps it up to
date outside the game, and the game page updates it with every state it gets.
The opening stage also lists the remaining openings, apart for the automatic
recharge and for openings bought one at a time, since the sidebar reserve is
hidden there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-07 23:16:47 +01:00
parent 2231bf05e1
commit 498e171bc3
14 changed files with 186 additions and 4 deletions

View file

@ -278,6 +278,12 @@ export function createCardsApiHandler({
return true;
}
// Lue par le menu sur toutes les pages : un visiteur sans compte reçoit une réserve vide plutôt qu'une erreur.
if (req.method === "GET" && url.pathname === "/api/cards/reserve") {
json(res, 200, { recharge: session ? service.getReserve(session.player.id) : null });
return true;
}
if (!session) throw Object.assign(new Error("Connectez-vous pour accéder à votre collection."), { status: 401, code: "AUTH_REQUIRED" });
if (req.method !== "GET") {
const origin = req.headers.origin;

View file

@ -329,6 +329,11 @@ export class CardsService {
return recharge;
}
// Réserve rechargeable seule, pour la pastille du menu : bien plus légère que l'état complet.
getReserve(playerId) {
return this.database.transaction(() => this.refreshRecharge(playerId));
}
// Carte affichable à partir d'une édition (catalogue publié).
cardEntry(editionId, extra = {}) {
const edition = this.index.editions.get(editionId);