diff --git a/.vscode/settings.json b/.vscode/settings.json index bc31e15..972419a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,9 @@ { "files.associations": { "*.css": "tailwindcss" + }, + "workbench.colorCustomizations": { + "titleBar.activeBackground": "#7e498b", + "settings.headerBorder": "#fff" } } diff --git a/src/lib/components/Feedback.svelte b/src/lib/components/Feedback.svelte index 6643361..2892017 100644 --- a/src/lib/components/Feedback.svelte +++ b/src/lib/components/Feedback.svelte @@ -3,7 +3,7 @@
Thank you so much for playing! Feel free to email me directly with feedback: diff --git a/src/lib/components/WinScreen.svelte b/src/lib/components/WinScreen.svelte index 2665e2c..08653b3 100644 --- a/src/lib/components/WinScreen.svelte +++ b/src/lib/components/WinScreen.svelte @@ -9,16 +9,66 @@ averageGuesses: number; } + interface WeightedMessage { + text: string; + weight: number; + } + let { grade, statsData, correctBookId, handleShare, + copyToClipboard, copied = $bindable(false), statsSubmitted, + guessCount, } = $props(); let bookName = $derived(getBookById(correctBookId)?.name ?? ""); + let hasWebShare = $derived( + typeof navigator !== "undefined" && "share" in navigator, + ); + + // List of congratulations messages with weights + const congratulationsMessages: WeightedMessage[] = [ + { text: "🎉 Congratulations! 🎉", weight: 1000 }, + { text: "⭐ You got it! ⭐", weight: 10 }, + { text: "🎉 Yup 🎉", weight: 5 }, + { text: "👍🏻 Very nice! 👍🏻", weight: 1 }, + ]; + + // Function to select a random message based on weights + function getRandomCongratulationsMessage(): string { + // Special case for first try success + if (guessCount === 1) { + const n = Math.random(); + if (n < 0.95) { + return "🤯 First try! 🤯"; + } else { + return "‼️ Axios ‼️"; + } + } + + const totalWeight = congratulationsMessages.reduce( + (sum, msg) => sum + msg.weight, + 0, + ); + let random = Math.random() * totalWeight; + + for (const message of congratulationsMessages) { + random -= message.weight; + if (random <= 0) { + return message.text; + } + } + + // Fallback to first message if something goes wrong + return congratulationsMessages[0].text; + } + + // Generate the congratulations message + let congratulationsMessage = $derived(getRandomCongratulationsMessage());

- 🎉 Congratulations! 🎉 + {congratulationsMessage}

The verse is from - + {#if hasWebShare} + + + {:else} + + {/if} {#if statsData}

-

+

You were the {toOrdinal(statsData.solveRank)} person to solve today.

-

- You rank {toOrdinal(statsData.guessRank)} in guesses. +

+ You rank {toOrdinal(statsData.guessRank)} in + guesses.

Average: {statsData.averageGuesses.toFixed(1)}{Math.ceil(statsData.averageGuesses)} guesses

diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 9b99ed8..a7fdb4e 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,16 +1,8 @@