Devlog 2 - Hints!
So over the last 2 days I added hints to the website, I did it by firstly making an object to store the different types of hints there can be, eg. BORDERS-3 would be 3 countries that this country borders, LANGUAGES are the languages this country speaks, etc. I grouped them by HARD, MEDIUM and EASY so that you get more obvious hints as you go on (easy is most obvious, hard is least obvious) I also made a massive 150 line function: get_hint_text(country_name, hint_type)
which gets the hint text for a hint type and a country using a switch for every hint type (there’s probably a better way of doing this but I cba lol) Using this, I made another function:
add_hint(country_name, hint_number, hint_type)
which i can use to give the user a hint in JS.
Issues Encountered
There was largely no major issues - apart from one hint_type: FLAG-DESC. FLAG-DESC is simply a description of the flag of the country provided by the REST Countries API, however, the descriptions provided by the API have the country name in them, eg.
The flag of Canada is composed of a red vertical band on the …
which makes it pretty obvious what the answer is! To fix this, I initially simply replaced the name of the country to ‘this country’, which worked fine, unless for exceptions like DRC, where if I did that the FLAG-DESC would be:
The flag of the Democratic Republic of the Congo has a sky-blue field with a …
as the name of that country in the API is DRC.
Similar things also happen with Afghanistan and Congo, where the name given in the description is different than that of the API.
Targets for next Devlog:
- Fix the FLAG-DESC bug
- Give the user a hint every guess
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.