# 7360 MINCountry Guess
# 73
60 MIN
Overview
Build a 10-round timed globe-guessing game that practices useEffect cleanup, self-scheduling countdown timers, and resetting round state with useState.
Solution preview
Here's the result you'll build by completing this challenge.
Requirements
- Implement the game in
App.tsx.WorldMap.tsx,AnswerOverlay.tsx,SuggestionsList.tsx,TimerPie.tsx,utils.tsandindex.cssare read-only;world.tsis hidden but importable. - The app starts idle:
start-gamereads "Start", the globe has nodata-active-code,guess-formis not rendered,timerreads15s, andscorereadsSolved 0 of 0. - Clicking
start-gamestarts round 1: the form appears,start-gamehides, andworld-mapgets adata-active-code. - During a round the globe highlights exactly one
active-country, exposes the target asdata-active-code, its center asdata-center="lon,lat"(one decimal) and adata-zoomgreater than 1. timercounts down one second per tick from 15 using the${timeLeft}sformat, andscorereadsSolved {solved} of {played}.time-pieanimates while playing and pauses once the round is revealed.guess-formcontainsguess-input(withautoCompleteoff) andguess-submit; guesses are trimmed and compared case-insensitively against the country name or ISO code.- Empty or whitespace-only guesses are ignored and keep the round alive.
- Typing filters up to six name matches through
SuggestionsList; clicking a suggestion submits that country. - A correct guess adds one solved and one played round; a wrong guess adds only one played round. Both reveal
AnswerOverlaywith the country name and disable the input. revealends the round without a point, disables the input and ignores later submissions.- The countdown stops as soon as the round is revealed, and reaching 0 ends the round without a point.
- After
AUTO_ADVANCE_MSthe next round starts with a different country, a 15s clock, an empty input and no overlay; the score persists. - After 10 rounds the game ends:
timerreadsDone, the form hides, the final score stays visible, andstart-gamereads "Play again" and starts a fresh game atSolved 0 of 0.
Notes
- Use a self-rescheduling
setTimeout(notsetInterval) and returnclearTimeout; stop scheduling once the round is revealed. - Update the clock with a functional setter:
setTimeLeft((current: number) => current - 1). - Pick the target with a lazy
useStateinitializer and pass the previous code topickCountryso rounds never repeat. - A round is revealed when
outcome !== null; use it to stop the timer and disable the form. - Auto-advance from an effect that watches
outcomewithAUTO_ADVANCE_MS. Guardround >= TOTAL_ROUNDSso no 11th round starts, and clean up the timeout. - Reset target, clock, guess and outcome together on a new round; keep
solvedandplayedoutside that reset. - Wire the read-only
TimerPie,AnswerOverlayandSuggestionsListinstead of reimplementing them. Passpaused/doneto the pie and the filtered countries to the suggestions. - Tests find the random target through
data-active-code, so the globe must expose it.
Tests
- renders the visible hemisphere with exactly one active country
- centers the globe on the highlighted country
- zooms the globe in to make the target easier to read
- only shows the locator for tiny target countries
- starts idle and begins a game from the Start button
- counts down one second per tick
- filters suggestions as the user types and caps them at six
- submits the clicked suggestion as a guess
- ends the round after a wrong guess and advances automatically
- ignores empty and whitespace-only guesses
- accepts the country name case-insensitively
- accepts the ISO country code
- shows the answer over the globe and advances when time runs out
- disables the input and ignores guesses after the reveal
- stops the countdown while the revealed answer is shown
- pauses the radial timer when the round is revealed
- starts a new round with a different country and a reset clock
- plays exactly 10 rounds and offers a replay
- tracks solved and played across rounds