diff --git a/src/lib/components/ChapterGuess.svelte b/src/lib/components/ChapterGuess.svelte
new file mode 100644
index 0000000..aa15a9d
--- /dev/null
+++ b/src/lib/components/ChapterGuess.svelte
@@ -0,0 +1,216 @@
+
+
+
+
+
Bonus Challenge
+
+ Guess the chapter for an even higher grade
+
+
+
+ {#each chapterOptions as chapter}
+
+ {/each}
+
+
+ {#if hasAnswered}
+
+ {isCorrect ? "✓ Correct!" : "✗ Incorrect"}
+
+
+ The verse is from chapter {correctChapter}
+
+ {#if isCorrect}
+
Grade: S++
+ {/if}
+ {/if}
+
+
diff --git a/src/lib/components/SearchInput.svelte b/src/lib/components/SearchInput.svelte
index 2eb9cad..753d589 100644
--- a/src/lib/components/SearchInput.svelte
+++ b/src/lib/components/SearchInput.svelte
@@ -16,16 +16,55 @@
}
-
-
+
+
+
+
+ {#if searchQuery}
+
+ {/if}
+
{#if searchQuery && filteredBooks.length > 0}
{#each filteredBooks as book (book.id)}
-
diff --git a/src/lib/components/VerseDisplay.svelte b/src/lib/components/VerseDisplay.svelte
index 54a27b8..9e7fb2b 100644
--- a/src/lib/components/VerseDisplay.svelte
+++ b/src/lib/components/VerseDisplay.svelte
@@ -2,17 +2,25 @@
import type { PageData } from "../../routes/$types.js"; // Approximate type; adjust if needed
import Container from "./Container.svelte";
- let { data, isWon }: { data: PageData; isWon: boolean } = $props();
+ let {
+ data,
+ isWon,
+ blurChapter = false,
+ }: { data: PageData; isWon: boolean; blurChapter?: boolean } = $props();
let dailyVerse = $derived(data.dailyVerse);
let displayReference = $derived(
- dailyVerse.reference.replace(/^Psalms /, "Psalm ")
+ blurChapter
+ ? dailyVerse.reference
+ .replace(/^Psalms /, "Psalm ")
+ .replace(/\s(\d+):/, " ?:")
+ : dailyVerse.reference.replace(/^Psalms /, "Psalm ")
);
let displayVerseText = $derived(
dailyVerse.verseText.replace(/^([a-z])/, (c) => c.toUpperCase())
);
-
+
diff --git a/src/lib/components/WinScreen.svelte b/src/lib/components/WinScreen.svelte
index 79e8eb8..a665a4d 100644
--- a/src/lib/components/WinScreen.svelte
+++ b/src/lib/components/WinScreen.svelte
@@ -4,6 +4,7 @@
import { onMount } from "svelte";
import Container from "./Container.svelte";
import CountdownTimer from "./CountdownTimer.svelte";
+ import ChapterGuess from "./ChapterGuess.svelte";
interface StatsData {
solveRank: number;
@@ -26,6 +27,8 @@
copied = $bindable(false),
statsSubmitted,
guessCount,
+ reference,
+ onChapterGuessCompleted,
} = $props();
let bookName = $derived(getBookById(correctBookId)?.name ?? "");
@@ -128,11 +131,22 @@
{/if}
-
- {getNextGradeMessage(guessCount)}
-
+ {#if guessCount !== 1}
+
+ {getNextGradeMessage(guessCount)}
+
+ {/if}
+
+ {#if guessCount === 1}
+
+ {/if}
+
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 1305e5b..61aacc5 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -30,6 +30,8 @@
let copied = $state(false);
let isDev = $state(false);
+ let chapterGuessCompleted = $state(false);
+ let chapterCorrect = $state(false);
let anonymousId = $state("");
let statsSubmitted = $state(false);
@@ -54,9 +56,14 @@
let isWon = $derived(guesses.some((g) => g.book.id === correctBookId));
let grade = $derived(
isWon
- ? getGrade(guesses.length, getBookById(correctBookId)?.popularity ?? 0)
+ ? guesses.length === 1 && chapterCorrect
+ ? "S++"
+ : getGrade(guesses.length, getBookById(correctBookId)?.popularity ?? 0)
: ""
);
+ let blurChapter = $derived(
+ isWon && guesses.length === 1 && !chapterGuessCompleted
+ );
function getBookById(id: string): BibleBook | undefined {
return bibleBooks.find((b) => b.id === id);
@@ -79,7 +86,7 @@
const testamentMatch = book.testament === correctBook.testament;
const sectionMatch = book.section === correctBook.section;
- const adjacent = isAdjacent(book.id, correctBookId);
+ const adjacent = isAdjacent(bookId, correctBookId);
console.log(
`Guess: ${book.name} (order ${book.order}), Correct: ${correctBook.name} (order ${correctBook.order}), Adjacent: ${adjacent}`
@@ -141,6 +148,17 @@
anonymousId = getOrCreateAnonymousId();
const statsKey = `bibdle-stats-submitted-${dailyVerse.date}`;
statsSubmitted = localStorage.getItem(statsKey) === "true";
+ const chapterGuessKey = `bibdle-chapter-guess-${dailyVerse.reference}`;
+ chapterGuessCompleted = localStorage.getItem(chapterGuessKey) !== null;
+ if (chapterGuessCompleted) {
+ const saved = localStorage.getItem(chapterGuessKey);
+ if (saved) {
+ const data = JSON.parse(saved);
+ const match = dailyVerse.reference.match(/\s(\d+):/);
+ const correctChapter = match ? parseInt(match[1], 10) : 1;
+ chapterCorrect = data.selectedChapter === correctChapter;
+ }
+ }
});
$effect(() => {
@@ -307,8 +325,8 @@
const siteUrl = window.location.origin;
return [
`📖 Bibdle | ${formattedDate} 📖`,
- `${grade} (${guesses.length} ${guesses.length == 1 ? "guess" : "guesses"})`,
- `${emojis}`,
+ `${grade} (${guesses.length} ${guesses.length === 1 ? "guess" : "guesses"})`,
+ `${emojis}${guesses.length === 1 && chapterCorrect ? " ⭐" : ""}`,
siteUrl,
].join("\n");
}
@@ -408,7 +426,7 @@