feat: enhance WinPanel with dynamic attempt messages based on user performance
Some checks failed
Build Docker Image / build (push) Has been cancelled
Some checks failed
Build Docker Image / build (push) Has been cancelled
This commit is contained in:
@@ -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);
|
||||
</script>
|
||||
|
||||
{#if isGeckoMoriaWin}
|
||||
@@ -10,6 +47,7 @@
|
||||
<div class="text-3xl mb-2">🌑</div>
|
||||
<h2 class="text-xl font-bold text-slate-300 mb-1">Moria vous contrôle...</h2>
|
||||
<p class="text-sm text-slate-400">Vous avez succombé à l'ombre en {selectedCharacters.length} {selectedCharacters.length > 1 ? 'tentatives' : 'tentative'} !</p>
|
||||
<p class="text-xs text-slate-300 mt-1">{attemptMessage}</p>
|
||||
<div class="mt-3">
|
||||
{#if dailyCharacter.pictureUrl}
|
||||
<a
|
||||
@@ -35,6 +73,7 @@
|
||||
<div class="text-3xl mb-2">🎉</div>
|
||||
<h2 class="text-xl font-bold text-emerald-400 mb-1">Félicitations !</h2>
|
||||
<p class="text-sm text-emerald-300">Vous avez trouvé le personnage en {selectedCharacters.length} {selectedCharacters.length > 1 ? 'tentatives' : 'tentative'} !</p>
|
||||
<p class="text-xs text-emerald-200 mt-1">{attemptMessage}</p>
|
||||
<div class="mt-3">
|
||||
{#if dailyCharacter.pictureUrl}
|
||||
<a
|
||||
|
||||
Reference in New Issue
Block a user