/** * @file Fin d'une partie de la Carte du jour : résultat, description, réponse détaillée, gains et résultat à * partager. */ import { useState } from "react"; import { SubjectChips } from "./DailyFeedback.jsx"; import { dailyKnowledge } from "./dailyKnowledge.js"; import { dailyShareText, fillTemplate, formatCountdown, formatStreak } from "../dailyShare.js"; import { DailyTrack } from "./DailyTrack.jsx"; import { formatStardust } from "../stardustFormat.js"; function wonTitle(count, content) { return count === 1 ? content.wonFirstTitle : fillTemplate(content.wonTitle, { count }); } // Récompense au choix : de la poussière, ou moins de poussière et une étoile dorée pour le prochain recrutement. function RewardChoice({ offer, content, busy, onReward }) { return

{content.rewardTitle}

{fillTemplate(offer.starAvailable ? content.rewardStarHelp : content.rewardStarUnavailable, { count: offer.goldStars, max: offer.maxGoldStars })}

; } export function DailyResult({ catalog, card, daily, content, now, busy = false, notice = "", onReward }) { const [copied, setCopied] = useState(false); const won = daily.status === "won"; const collection = catalog.collections.find((item) => item.id === card?.collectionId)?.name; const { subject, theme } = daily.answerClues; // Après une défaite, ce que les essais et l'indice ont trouvé reste en vert, le reste est en gris. const known = dailyKnowledge(daily.guesses, daily.hints.find((hint) => hint.id === "theme")?.value ?? null); async function share() { const text = dailyShareText(daily, { title: content.shareTitle, url: `${window.location.origin}/#/cards/daily` }); try { await navigator.clipboard.writeText(text); setCopied(true); } catch { setCopied(false); } } return

{won ? wonTitle(daily.guesses.length, content) : content.lostTitle}

{daily.hints.length > 0 && {fillTemplate(daily.hints.length > 1 ? content.hintsUsedMany : content.hintsUsedOne, { count: daily.hints.length })}}
{/* Seule action attendue du joueur : elle passe avant la réponse. */} {daily.rewardOffer && } {notice &&

{notice}

} {card?.description &&

{card.description}

}

{content.answerTitle}

{subject.length > 0 && <>
{content.columnSubject}
step.label)} isFound={(index) => won || index < known.path.length} />
} {theme && <>
{content.columnTheme}
won || Boolean(known.theme)} />{card && « {card.name.slice(...theme.span)} »}
} {collection && <>
{content.hints.collection.title}
{collection}
}
{won &&
    {daily.earned > 0 &&
  • {fillTemplate(content.earned, { reward: formatStardust(daily.earned) })}
  • } {daily.earnedStar &&
  • {content.earnedStar}
  • } {daily.streak > 0 &&
  • {fillTemplate(content.streak, { streak: formatStreak(daily.streak) })}
  • }
}
{fillTemplate(content.next, { time: formatCountdown(daily.nextAt - now) })}
; }