2.8 KiB
2.8 KiB
Game Hints System — Design Spec
Summary
Each row of the game grid provides a hint about the main actor to guess. Hints are pre-generated when the grid is created and stored on GameRow. Each hint has a type (film, character, award) represented by a distinct icon. Clicking the icon opens a popover showing the hint text.
Data Model
Two new columns on game_row:
| Column | Type | Description |
|---|---|---|
hint_type |
VARCHAR(20), NOT NULL |
One of: film, character, award |
hint_data |
VARCHAR(255), NOT NULL |
film → movie.id, character → movie_role.id, award → text "Nom du prix (année)" |
No foreign key constraints on hint_data — the column stores either an id (resolved at read time) or raw text depending on hint_type.
Hint Generation
Happens in GameGridGenerator::generate(), for each GameRow:
- Pick a random type from
[film, character, award] - Resolve based on type:
- film: pick a random
MovieRoleof the main actor → storemovie.idinhint_data - character: pick a random
MovieRoleof the main actor → storemovieRole.idinhint_data - award: call
WikidataAwardGatewayto fetch an award → store"Nom du prix (année)"inhint_data
- film: pick a random
- If the chosen type yields no result (e.g., no awards found), fallback to another random type
- Avoid duplicate hints across rows (don't show the same film/character/award twice)
Wikidata Award Gateway
New service: WikidataAwardGateway
- Input: actor (name or
tmdb_id) - Output: list of awards, each with name and year
- Uses Wikidata SPARQL API to query awards associated with the person
- Storage format in
hint_data:"Oscar du meilleur second rôle (2014)" - Results can be cached to avoid repeated Wikidata queries
Frontend
Icon Button
The current "?" button in ActorPopover is replaced by an icon representing the hint type:
| hint_type | Icon | Font Awesome class |
|---|---|---|
film |
Film/clap | fa-film |
character |
Theater masks | fa-masks-theater |
award |
Trophy | fa-trophy |
Popover Content
On click, the popover displays only the hint text:
- film: movie title (resolved from
movie.id) - character: character name (resolved from
movie_role.id) - award: the raw text from
hint_data
Data Flow
- Backend resolves
hint_datato display text inGameGridGenerator::computeGridData() - Hint type + resolved text are passed to the Twig template as part of the grid data
- Twig passes them as props to the React
GameGridcomponent ActorPopoverreceiveshintTypeandhintTextprops instead ofactorName
Future Extensibility
New hint types can be added by:
- Adding a new value for
hint_type - Adding resolution logic in
GameGridGenerator - Adding a new icon mapping in the frontend