I have forked the Val Town React Hono Starter, but made no other changes to the code outside of this todo.md file. help me create make this word game.
Let's focus on building out the front-end for now.
The player is prompted with some constraints and must think of the biggest word they can that fulfills the constraints.
examples:
gameState: [preGame, inGame, postGame]
inGame: currentRound currentGuess cursorPosition
The trash button resets the currentGuess to blank without submitting. It should be a trash icon.
Submit and Trash buttons should appear on the same line, with trash being to the left of submit, and submit taking up 4x the width of the trash button.
make the following tweaks:
make the letterCount bigger, keep it's position visually anchored to the top right of the currentGuess (not the container)
undo the last update and try again: I liked how the currentGuess looked (the size of the box should never change), I just want to move the counter down so it's not floating on its own. The counter should display 0 when the current guess is blank
The changes to the make the length counter bigger were successful and you should repeat them. Made the length counter bigger:
Increased font size from 0.9rem to 1rem Increased padding from 3px 9px to 4px 10px Increased min-width from 28px to 32px Increased border-radius to 16px for a larger, rounder look
that's better but not quite there yet. I want the letterCount to partially overlap with the white div with currentGuess at the top right corner.
This is an export from an Observable notebook.
I want you to read it, and return a fully formed duckDB query against the wordnik table
the query should be a union all of the results of the separate sql queries in the file
try to preserve the sql coding style in the query (from-first, lowercase, etc.)
fields in result:
update todo.md with the correct query but make no other changes to todo.md:
from (
-- 1: ends with p
from wordnik
select 1 as id, 'ends with p' as rule, word, length(word) as n_letters
where word like '%p'
union all
-- 2: starts and ends with p
from wordnik
select 2 as id, 'starts and ends with p' as rule, word, length(word) as n_letters
where word like 'p%p'
union all
-- 3: has the letters dog in sequence
from wordnik
select 3 as id, 'has the letters dog in sequence' as rule, word, length(word) as n_letters
where word like '%d%o%g%'
union all
-- 4: starts with the letters OVER
from wordnik
select 4 as id, 'starts with the letters OVER' as rule, word, length(word) as n_letters
where word like 'over%'
union all
-- 5: ends with the letters OVER
from wordnik
select 5 as id, 'ends with the letters OVER' as rule, word, length(word) as n_letters
where word like '%over'
union all
-- 6: all vowels are As
from wordnik
select 6 as id, 'all vowels are As' as rule, word, length(word) as n_letters
where word similar to '[^eiouy]+'
union all
-- 7: only uses QWERTY
from wordnik
select 7 as id, 'only uses QWERTY' as rule, word, length(word) as n_letters
where word similar to '[qwerty]+'
union all
-- 8: can be typed only using your left hand
from wordnik
select 8 as id, 'can be typed only using your left hand' as rule, word, length(word) as n_letters
where word similar to '[qwertasdfgzxcvb]+'
union all
-- 9: has exactly two Cs
from wordnik
select 9 as id, 'has exactly two Cs' as rule, word, length(word) as n_letters
where length(word) - length(replace(word, 'c', '')) = 2
union all
-- 10: has the letters ABC in any order
from wordnik
select 10 as id, 'has the letters ABC in any order' as rule, word, length(word) as n_letters
where word like '%a%'
and word like '%b%'
and word like '%c%'
union all
-- 11: no s no t no e no a
from wordnik
select 11 as id, 'no s no t no e no a' as rule, word, length(word) as n_letters
where word similar to '[^stea]+'
)
select *
order by id, n_letters desc
Help me begin to build out the postGame view:
help me devise a good strategy for validation. Currently, I have a list of valid words in a table format.
create a database initialization script that loads the csv into sql.
update the project readme with instructions to run the this initialization (so the project is easy to remix)
update the validation logic build earlier in the conversation.
below the first few lines of the csv.
A version currently lives at https://gist.githubusercontent.com/a-lexwein/e3e6a0817c71d57c063c238f519f8b45/raw/9a06a1e2f5e4c479bb653ff39dbb65f77cd60cff/thinkOfWords.csv
id,rule,word,n_letters
1,starts with HI,histocompatibilities,20
1,starts with HI,histopathologically,19
1,starts with HI,historiographically,19
1,starts with HI,histocompatibility,18
don't suggest code changes yet, instead, build out a strategy in markdown that I can freshly prompt townie with.
Put that prompt immediately below here in this file todo.md:
This is a word game where players must think of the biggest word that fits a given constraint (e.g., "starts with HI"). We need to validate that submitted words are real English words AND that they satisfy the round's constraint.
A CSV file containing valid words for each round is available at: https://gist.githubusercontent.com/a-lexwein/e3e6a0817c71d57c063c238f519f8b45/raw/9a06a1e2f5e4c479bb653ff39dbb65f77cd60cff/thinkOfWords.csv
The CSV format is:
id,rule,word,n_letters
1,starts with HI,histocompatibilities,20
1,starts with HI,histopathologically,19
...
Where id corresponds to the round number and rule describes the constraint.
Create a new file scripts/initDb.ts that:
valid_words with columns:
id (INTEGER) - the round numberrule (TEXT) - the constraint descriptionword (TEXT) - the valid word (lowercase)n_letters (INTEGER) - word length(id, word) for fast lookupsUse Val Town's SQLite: import { sqlite } from "https://esm.town/v/std/sqlite";
Add a "Setup" or "Database Initialization" section that explains:
Modify the /api/validate endpoint in index.ts to:
{ submissions: [{ round: number, word: string }] }valid_words table to check if the word exists for that roundSELECT 1 FROM valid_words WHERE id = ? AND word = ? (lowercase the word before querying){ results: [{ round, word, isValid: boolean }] }index.ts # Main HTTP handler with /api/validate endpoint
scripts/
initDb.ts # Database initialization script (HTTP type so it can be triggered)
README.md # Updated with setup instructions
frontend/ # (no changes needed)
valid_words table pre-validates words against round constraints, so we only need to check if the (round, word) pair existspick a complete coherent color pallet: use a dark background and light text. maintain color-blind friendly coloring for valid and invalid words, but you can pick new colors.
the size of the text in the prompt-title should be smaller than the prompt-constraint.
ensure that the height of the in-game element never changes and fully fills the screen on mobile.
use the same header component across all states. start with this, but make it its own component so we can tweak later
refactor if needed and add comments and documentation so that is is easy to adjust the color palette
change it back to something with dark text on a light background
on postGame view, the results table would be the full width of the screen/gameContainer.
the gameContainer shouldn't grow in width, once the text gets too long, resize the text