sokko-g/website/src/features/cards/guildQuests.js
Shinuwa 8c0771f06f
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 23m32s
Validate and deploy Sokko G / deploy (push) Successful in 16s
Rework the Broken Mirror screens and the Guild quest board
The mirror page opens on two illustrated cards, Normal and Hard, painted
with Codex, with three small rule reminders; a card opens or starts its
game. The five companions of the daily team show as tiles: one click uses
a help, two per game, with no selection step. Helps are renamed after
what they do (swap anywhere, show a piece's place, double the rewards,
undo the last move, see the model again), use the shared tooltip and
keep the same height. Selecting a piece no longer waits for the server,
and showing a place aims at the selected piece. Under 960 px of
dashboard, like the section menu, the board goes on top and the moves
panel keeps only the count. Stardust is always written in full.

The Guild board shows four tiles per row on full screen, aligned with
subgrids, solo quests first. Status lines give way to a wooden "Fait"
sign on finished quests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 16:25:35 +01:00

58 lines
3.9 KiB
JavaScript

// Rôle : recense les quêtes que la Guilde des Veilleurs propose au joueur et celles qui l'attendent.
// Chaque quête (Carte du jour, Expéditions…) s'ajoute à cette liste avec sa tuile dans GuildPanel.
// Expéditions en attente : un butin à récupérer, un groupe que le joueur peut rejoindre, ou aucune expédition lancée aujourd'hui
// alors qu'il a de quoi partir. Au plus un rappel par jour, plus les retours et les groupes ; sans cartes jouables, aucun rappel.
export function expeditionsPending(summary, now = Date.now()) {
if (!summary) return false;
if (summary.returned > 0 || (summary.nextReturnAt != null && summary.nextReturnAt <= now)) return true;
if (summary.joinableGroups > 0) return true;
return summary.enabled && !summary.running && !summary.forming && !summary.launchedToday && summary.eligible >= 1;
}
// Une quête : identifiant (qui choisit sa tuile), état fourni par le serveur et `pending` tant qu'elle attend le joueur.
// Les Expéditions n'apparaissent que si elles sont ouvertes, ou tant qu'une expédition du joueur n'est pas terminée.
export function guildQuests(state, now = Date.now()) {
const quests = [];
if (state.daily) quests.push({ id: "daily", pending: state.daily.status === "playing" || Boolean(state.daily.rewardPending), summary: state.daily });
// L'Équipe du jour n'apparaît que si elle est ouverte, ou tant qu'un recrutement n'est pas terminé.
const team = state.team;
if (team && (team.enabled || team.status === "recruiting")) quests.push({ id: "team", pending: team.status !== "ready", summary: team });
// La Course attend une équipe et sa propre ouverture ; une course commencée se termine même si elle ferme.
if (team && ((team.raceEnabled && team.status === "ready") || team.race === "running")) quests.push({ id: "race", pending: team.race !== "finished", summary: team });
// Le Miroir brisé n'apparaît que s'il est ouvert, ou tant qu'une partie du jour n'est pas terminée.
const mirror = state.mirror;
if (mirror && (mirror.enabled || mirror.normal === "playing" || mirror.hard === "playing")) quests.push({ id: "mirror", pending: !mirrorDone(mirror), summary: mirror });
const expeditions = state.expeditions;
if (expeditions && (expeditions.enabled || expeditions.running || expeditions.returned || expeditions.forming)) quests.push({ id: "expeditions", pending: expeditionsPending(expeditions, now), summary: expeditions });
return quests;
}
export const pendingQuestCount = (state) => guildQuests(state).filter((quest) => quest.pending).length;
// Miroir brisé terminé : le Normal puis le Difficile joués jusqu'au bout, gagnés ou non.
const finishedGame = (status) => status === "won" || status === "lost";
export const mirrorDone = (mirror) => finishedGame(mirror.normal) && finishedGame(mirror.hard);
// Quête quotidienne terminée aujourd'hui.
export function questDone({ id, summary }) {
if (id === "daily") return summary.status !== "playing" && !summary.rewardPending;
if (id === "race") return summary.race === "finished";
if (id === "mirror") return mirrorDone(summary);
return false;
}
// Ce que dit la Guilde au comptoir : la prochaine chose à faire, dans l'ordre du tableau (seul d'abord, puis en équipe), puis le
// butin d'une expédition revenue.
export function guildGreeting(state, now = Date.now()) {
const { daily, team, mirror, expeditions } = state;
const teamOpen = Boolean(team?.enabled);
if (daily?.rewardPending) return "reward";
if (daily?.status === "playing") return teamOpen && team.status !== "ready" ? "dailyFirst" : "daily";
if (mirror?.enabled && !mirrorDone(mirror)) return "mirror";
if (teamOpen && team.status === "recruiting") return "recruiting";
if (teamOpen && team.status !== "ready") return "recruit";
if (teamOpen && team.raceEnabled && team.race !== "finished") return "race";
if (expeditions && (expeditions.returned > 0 || (expeditions.nextReturnAt != null && expeditions.nextReturnAt <= now))) return "loot";
return "done";
}