From 6cd18992f61457de4e3f0f51ff792fdd5d79ea95 Mon Sep 17 00:00:00 2001 From: whidix Date: Mon, 2 Mar 2026 23:19:51 +0100 Subject: [PATCH] feat: enhance WinPanel with dynamic attempt messages based on user performance --- src/lib/components/WinPanel.svelte | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/lib/components/WinPanel.svelte b/src/lib/components/WinPanel.svelte index 6ff97d5..02be676 100644 --- a/src/lib/components/WinPanel.svelte +++ b/src/lib/components/WinPanel.svelte @@ -2,6 +2,43 @@ export let dailyCharacter: any; export let selectedCharacters: any[]; export let isGeckoMoriaWin: boolean = false; + + const oneTryMessages = ['Tricheur 👀', '1 essai ? Avoue, tu avais la réponse 😏', 'Premier coup direct... suspect 🤨']; + const twoTryMessages = ['Bien joué ! ⚡', 'Deux essais, propre ! 👏', 'Tu chauffes vite, bien joué 🔥']; + const tenPlusMessages = [ + '${attempts} essais... même un escargophone aurait trouvé plus vite 📞', + '${attempts} tentatives ? Le Grand Line est moins long que ça 😵', + '${attempts} essais : performance légendaire... dans le mauvais sens 🫠' + ]; + const fivePlusMessages = [ + "${attempts} essais ? On va dire que c'était pour le suspense 😅", + 'Ça en fait des essais... mais au moins tu y es arrivé 😬', + 'Tu ne lâches rien, même après plusieurs essais 😂' + ]; + const defaultMessages = ['Pas mal du tout !', 'Bien tenté, bon rythme 👍', 'Ça se passe bien, continue comme ça ✨']; + + const pickMessage = (messages: string[]) => messages[Math.floor(Math.random() * messages.length)]; + + const getAttemptMessage = (attempts: number): string => { + if (attempts <= 0) return ''; + if (attempts === 1) { + return pickMessage(oneTryMessages); + } + if (attempts === 2) { + return pickMessage(twoTryMessages); + } + if (attempts >= 10) { + return pickMessage(tenPlusMessages).replace('${attempts}', String(attempts)); + } + if (attempts >= 5) { + return pickMessage(fivePlusMessages).replace('${attempts}', String(attempts)); + } + + return pickMessage(defaultMessages); + }; + + $: attempts = selectedCharacters.length; + $: attemptMessage = getAttemptMessage(attempts); {#if isGeckoMoriaWin} @@ -10,6 +47,7 @@
🌑

Moria vous contrôle...

Vous avez succombé à l'ombre en {selectedCharacters.length} {selectedCharacters.length > 1 ? 'tentatives' : 'tentative'} !

+

{attemptMessage}

{#if dailyCharacter.pictureUrl} 🎉

Félicitations !

Vous avez trouvé le personnage en {selectedCharacters.length} {selectedCharacters.length > 1 ? 'tentatives' : 'tentative'} !

+

{attemptMessage}

{#if dailyCharacter.pictureUrl}