diff --git a/src/routes/sunrise-sunset/+page.svelte b/src/routes/sunrise-sunset/+page.svelte index 7a76213..2c8547f 100644 --- a/src/routes/sunrise-sunset/+page.svelte +++ b/src/routes/sunrise-sunset/+page.svelte @@ -1,69 +1,153 @@ -
-

Sunrise, Sunset?

-
- -
- Sunrise or Sunset? -
- -
-
- - -
-
- -
- {#if $guessHistory.total > 0} -

- You've guessed correctly {Number( - $guessHistory.correct / $guessHistory.total - )}% of the time +

+
+

Sunrise, Sunset?

+

+ It's a simple game. Is the picture below a sunrise, or a sunet?

- {:else} -

You've not guessed yet.

+
+ +
+ Sunrise or Sunset? +
+ + {#if hasGuessingHistoryBeenLoaded} +
+
+ + +
+ {#if $guessingHistory.mostRecentGuessDate === todaysDateString} +

+ You've already guessed today. Come back tomorrow. +

+ {/if} +
+ +
+
+

Your Score

+ {#if $guessingHistory.mostRecentGuessDate !== undefined} +

+ You've guessed correctly {Number( + $guessingHistory.correctDays.length / + $guessingHistory.totalNumberOfGuesses + ) * 100}% of the time +

+ {:else} +

You've not guessed yet.

+ {/if} +
+
{/if} -
+ diff --git a/src/routes/sunrise-sunset/ISunriseSunsetGuessingHistory.ts b/src/routes/sunrise-sunset/ISunriseSunsetGuessingHistory.ts new file mode 100644 index 0000000..9cdf2eb --- /dev/null +++ b/src/routes/sunrise-sunset/ISunriseSunsetGuessingHistory.ts @@ -0,0 +1,9 @@ +type SunriseSunsetOption = 'sunrise' | 'sunset'; + +export interface ISunriseSunsetGuessingHistory { + mostRecentGuessDate: undefined | string; // e.g. "2023-01-26" + totalNumberOfGuesses: number; + guesses: SunriseSunsetOption[]; + incorrectDays: string[]; // e.g. ["2023-01-26", "2023-01-27"] + correctDays: string[]; // e.g. ["2023-01-28", "2023-01-29"] +}