Show the expedition's state on the Guild tile button
The Expeditions tile now reads "En cours" while an expedition is on its way, "Récupérer le butin" once one has returned, and "Préparer" otherwise. The tile also refreshes at the next return time, so the button switches to the loot without reloading the page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2c10df0370
commit
c1ef7b6ce7
6 changed files with 328 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// Rôle : présente la Guilde des Veilleurs et la tuile de chacune de ses quêtes, avec leur état.
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { dailyQuestStatus, fillTemplate, formatStreak } from "./dailyShare.js";
|
||||
import { expeditionQuestStatus } from "./expeditionFormat.js";
|
||||
import { guildQuests } from "./guildQuests.js";
|
||||
|
|
@ -30,8 +30,8 @@ function DailyQuest({ summary: daily, content }) {
|
|||
</article>;
|
||||
}
|
||||
|
||||
// Expéditions : la couverture montre le Grand Vide et son bateau à la lanterne, et le bouton mène au butin dès qu'une expédition
|
||||
// est revenue.
|
||||
// Expéditions : la couverture montre le Grand Vide et son bateau à la lanterne. Le bouton dit ce qui attend le joueur : le butin
|
||||
// d'une expédition revenue, une expédition encore en route, sinon la préparation (ou « Voir » quand les Expéditions sont fermées).
|
||||
const EXPEDITIONS_COVER = "/static/img/cards/watchers-logbooks/rare/great_void.webp";
|
||||
|
||||
function ExpeditionsQuest({ summary, pending, content, now }) {
|
||||
|
|
@ -46,7 +46,7 @@ function ExpeditionsQuest({ summary, pending, content, now }) {
|
|||
<p>{content.expeditionsDescription}</p>
|
||||
<p className="nebula-quest-status">{expeditionQuestStatus(summary, content, now)}</p>
|
||||
<div className="nds-card-actions">
|
||||
<a className="nds-button" data-size="sm" data-variant={pending ? "primary" : "secondary"} href="#/cards/expeditions">{returned ? content.expeditionsClaim : summary.enabled ? content.expeditionsAction : content.expeditionsOpen}</a>
|
||||
<a className="nds-button" data-size="sm" data-variant={pending ? "primary" : "secondary"} href="#/cards/expeditions">{returned ? content.expeditionsClaim : summary.running ? content.expeditionsInProgress : summary.enabled ? content.expeditionsAction : content.expeditionsOpen}</a>
|
||||
</div>
|
||||
</div>
|
||||
</article>;
|
||||
|
|
@ -56,8 +56,15 @@ function ExpeditionsQuest({ summary, pending, content, now }) {
|
|||
const QUEST_TILES = { daily: DailyQuest, expeditions: ExpeditionsQuest };
|
||||
|
||||
export function GuildPanel({ catalog, state, content }) {
|
||||
// Heure d'affichage de la page : elle suffit pour savoir si une expédition est déjà rentrée.
|
||||
const [now] = useState(() => Date.now());
|
||||
// Heure d'affichage de la page, remise à jour au prochain retour d'expédition : la tuile passe alors d'elle-même au butin.
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const nextReturnAt = state.expeditions?.nextReturnAt ?? null;
|
||||
useEffect(() => {
|
||||
if (nextReturnAt == null || nextReturnAt <= now) return undefined;
|
||||
// Un délai au-delà de 2^31 ms déborderait setTimeout ; l'expédition la plus longue reste bien en deçà.
|
||||
const timer = setTimeout(() => setNow(Date.now()), Math.min(nextReturnAt - now + 500, 2 ** 31 - 1));
|
||||
return () => clearTimeout(timer);
|
||||
}, [nextReturnAt, now]);
|
||||
const quests = guildQuests(state, now).filter((quest) => QUEST_TILES[quest.id]);
|
||||
return <section className="nebula-quests" aria-labelledby="nebula-guild-title">
|
||||
<div className="nds-section-heading nebula-section-heading">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue