mirror of
https://github.com/pupperpowell/bibdle.git
synced 2026-02-04 02:44:43 -05:00
fixed "first letter" clue edge cases
This commit is contained in:
20
clear-today-verse.sh
Executable file
20
clear-today-verse.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
# Clear today's verse from daily_verses table
|
||||||
|
DB_PATH="dev.db"
|
||||||
|
TODAY=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
echo "Deleting verse for date: $TODAY"
|
||||||
|
|
||||||
|
sqlite3 "$DB_PATH" "DELETE FROM daily_verses WHERE date = '$TODAY';"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✓ Successfully deleted verse for $TODAY"
|
||||||
|
|
||||||
|
# Show remaining verses in table
|
||||||
|
COUNT=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM daily_verses;")
|
||||||
|
echo "Remaining verses in database: $COUNT"
|
||||||
|
else
|
||||||
|
echo "✗ Failed to delete verse"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -28,6 +28,11 @@
|
|||||||
return "bg-red-500 border-red-600";
|
return "bg-red-500 border-red-600";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFirstLetter(bookName: string): string {
|
||||||
|
const match = bookName.match(/[a-zA-Z]/);
|
||||||
|
return match ? match[0] : bookName[0];
|
||||||
|
}
|
||||||
|
|
||||||
function getBoxContent(
|
function getBoxContent(
|
||||||
guess: Guess,
|
guess: Guess,
|
||||||
column: "book" | "firstLetter" | "testament" | "section",
|
column: "book" | "firstLetter" | "testament" | "section",
|
||||||
@@ -44,16 +49,20 @@
|
|||||||
(correctBook?.section === "Pauline Epistles" ||
|
(correctBook?.section === "Pauline Epistles" ||
|
||||||
correctBook?.section === "General Epistles") &&
|
correctBook?.section === "General Epistles") &&
|
||||||
correctBook.name[0] === "1";
|
correctBook.name[0] === "1";
|
||||||
const guessStartsWithNumber = guess.book.name[0] === "1";
|
const guessIsEpistlesWithNumber =
|
||||||
|
(guess.book.section === "Pauline Epistles" ||
|
||||||
|
guess.book.section === "General Epistles") &&
|
||||||
|
guess.book.name[0] === "1";
|
||||||
|
|
||||||
if (
|
if (
|
||||||
correctIsEpistlesWithNumber &&
|
correctIsEpistlesWithNumber &&
|
||||||
guessStartsWithNumber &&
|
guessIsEpistlesWithNumber &&
|
||||||
guess.firstLetterMatch
|
guess.firstLetterMatch
|
||||||
) {
|
) {
|
||||||
return "Yes"; // Special wordplay case
|
const words = ["Exactly", "Right", "Yes", "Naturally"];
|
||||||
|
return words[Math.floor(Math.random() * words.length)]; // Special wordplay case
|
||||||
}
|
}
|
||||||
return guess.book.name[0]; // Normal case: just show the first letter
|
return getFirstLetter(guess.book.name); // Normal case: show first letter, ignoring numbers
|
||||||
case "testament":
|
case "testament":
|
||||||
return (
|
return (
|
||||||
guess.book.testament.charAt(0).toUpperCase() +
|
guess.book.testament.charAt(0).toUpperCase() +
|
||||||
|
|||||||
@@ -82,6 +82,11 @@
|
|||||||
return !!(b1 && b2 && Math.abs(b1.order - b2.order) === 1);
|
return !!(b1 && b2 && Math.abs(b1.order - b2.order) === 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFirstLetter(bookName: string): string {
|
||||||
|
const match = bookName.match(/[a-zA-Z]/);
|
||||||
|
return match ? match[0] : bookName[0];
|
||||||
|
}
|
||||||
|
|
||||||
function submitGuess(bookId: string) {
|
function submitGuess(bookId: string) {
|
||||||
if (guesses.some((g) => g.book.id === bookId)) return;
|
if (guesses.some((g) => g.book.id === bookId)) return;
|
||||||
|
|
||||||
@@ -98,15 +103,19 @@
|
|||||||
// Special case: if correct book is in the Epistles + starts with "1",
|
// Special case: if correct book is in the Epistles + starts with "1",
|
||||||
// any guess starting with "1" counts as first letter match
|
// any guess starting with "1" counts as first letter match
|
||||||
const correctIsEpistlesWithNumber =
|
const correctIsEpistlesWithNumber =
|
||||||
correctBook.section === "Pauline Epistles" &&
|
(correctBook.section === "Pauline Epistles" ||
|
||||||
|
correctBook.section === "General Epistles") &&
|
||||||
correctBook.name[0] === "1";
|
correctBook.name[0] === "1";
|
||||||
const guessStartsWithNumber = book.name[0] === "1";
|
const guessIsEpistlesWithNumber =
|
||||||
|
(book.section === "Pauline Epistles" ||
|
||||||
|
book.section === "General Epistles") &&
|
||||||
|
book.name[0] === "1";
|
||||||
|
|
||||||
const firstLetterMatch =
|
const firstLetterMatch =
|
||||||
correctIsEpistlesWithNumber && guessStartsWithNumber
|
correctIsEpistlesWithNumber && guessIsEpistlesWithNumber
|
||||||
? true
|
? true
|
||||||
: book.name[0].toUpperCase() ===
|
: getFirstLetter(book.name).toUpperCase() ===
|
||||||
correctBook.name[0].toUpperCase();
|
getFirstLetter(correctBook.name).toUpperCase();
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`Guess: ${book.name} (order ${book.order}), Correct: ${correctBook.name} (order ${correctBook.order}), Adjacent: ${adjacent}`,
|
`Guess: ${book.name} (order ${book.order}), Correct: ${correctBook.name} (order ${correctBook.order}), Adjacent: ${adjacent}`,
|
||||||
@@ -206,15 +215,19 @@
|
|||||||
|
|
||||||
// Apply same first letter logic as in submitGuess
|
// Apply same first letter logic as in submitGuess
|
||||||
const correctIsEpistlesWithNumber =
|
const correctIsEpistlesWithNumber =
|
||||||
correctBook.section === "Pauline Epistles" &&
|
(correctBook.section === "Pauline Epistles" ||
|
||||||
|
correctBook.section === "General Epistles") &&
|
||||||
correctBook.name[0] === "1";
|
correctBook.name[0] === "1";
|
||||||
const guessStartsWithNumber = book.name[0] === "1";
|
const guessIsEpistlesWithNumber =
|
||||||
|
(book.section === "Pauline Epistles" ||
|
||||||
|
book.section === "General Epistles") &&
|
||||||
|
book.name[0] === "1";
|
||||||
|
|
||||||
const firstLetterMatch =
|
const firstLetterMatch =
|
||||||
correctIsEpistlesWithNumber && guessStartsWithNumber
|
correctIsEpistlesWithNumber && guessIsEpistlesWithNumber
|
||||||
? true
|
? true
|
||||||
: book.name[0].toUpperCase() ===
|
: getFirstLetter(book.name).toUpperCase() ===
|
||||||
correctBook.name[0].toUpperCase();
|
getFirstLetter(correctBook.name).toUpperCase();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
book,
|
book,
|
||||||
|
|||||||
Reference in New Issue
Block a user