From c1b83402680a84513fad2fcd41ca5f9d04be49ae Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Wed, 2 Nov 2022 22:20:36 +0100 Subject: [PATCH] Curated Geo country file, improved hint letter spacing. --- assets/countries-curated.json | 3 +- assets/countries.js | 17 + assets/countries.json | 1257 ++++++++++++++++++++++++++++++++- src/games/geo.js | 18 +- 4 files changed, 1280 insertions(+), 15 deletions(-) diff --git a/assets/countries-curated.json b/assets/countries-curated.json index e9f604c..db6ffc9 100644 --- a/assets/countries-curated.json +++ b/assets/countries-curated.json @@ -985,7 +985,8 @@ "file": "174f.png", "code": 760, "alpha2": "SY", - "name": "Syrian Arab Republic" + "name": "Syria", + "fullName": "Syrian Arab Republic" }, { "file": "715f.png", diff --git a/assets/countries.js b/assets/countries.js index 8b84473..7d52ffc 100644 --- a/assets/countries.js +++ b/assets/countries.js @@ -2,9 +2,25 @@ const fs = require('fs').promises; const crypto = require('crypto'); +// const bhttp = require('bhttp'); const countries = require('./countries.json'); +/* +async function fetchCountries() { + const res = await bhttp.get('http://localhost:3000/api/countries'); + + if (res.statusCode === 200) { + await fs.writeFile('./assets/countries.json', JSON.stringify(res.body, null, 4)); + console.log('Done fetching countries!'); + + return; + } + + console.log(`Failed to fetch countries: ${res.statusCode}`); +} +*/ + async function init() { const countryImgs = await fs.readdir('./assets/countries'); const countriesByCode = Object.fromEntries(countries.map((country) => [country.alpha2, country])); @@ -28,3 +44,4 @@ async function init() { } init(); +// fetchCountries(); diff --git a/assets/countries.json b/assets/countries.json index c364a70..1cdc220 100644 --- a/assets/countries.json +++ b/assets/countries.json @@ -1 +1,1256 @@ -[{"alpha2":"AF","code":4,"name":"Afghanistan"},{"alpha2":"AX","code":248,"name":"Åland Islands"},{"alpha2":"AL","code":8,"name":"Albania"},{"alpha2":"DZ","code":12,"name":"Algeria"},{"alpha2":"AS","code":16,"name":"American Samoa"},{"alpha2":"AD","code":20,"name":"Andorra"},{"alpha2":"AO","code":24,"name":"Angola"},{"alpha2":"AI","code":660,"name":"Anguilla"},{"alpha2":"AQ","code":10,"name":"Antarctica"},{"alpha2":"AG","code":28,"name":"Antigua and Barbuda"},{"alpha2":"AR","code":32,"name":"Argentina"},{"alpha2":"AM","code":51,"name":"Armenia"},{"alpha2":"AW","code":533,"name":"Aruba"},{"alpha2":"AU","code":36,"name":"Australia"},{"alpha2":"AT","code":40,"name":"Austria"},{"alpha2":"AZ","code":31,"name":"Azerbaijan"},{"alpha2":"BS","code":44,"name":"Bahamas"},{"alpha2":"BH","code":48,"name":"Bahrain"},{"alpha2":"BD","code":50,"name":"Bangladesh"},{"alpha2":"BB","code":52,"name":"Barbados"},{"alpha2":"BY","code":112,"name":"Belarus"},{"alpha2":"BE","code":56,"name":"Belgium"},{"alpha2":"BZ","code":84,"name":"Belize"},{"alpha2":"BJ","code":204,"name":"Benin"},{"alpha2":"BM","code":60,"name":"Bermuda"},{"alpha2":"BT","code":64,"name":"Bhutan"},{"alpha2":"BO","code":68,"name":"Bolivia"},{"alpha2":"BQ","code":535,"name":"Bonaire, Sint Eustatius and Saba"},{"alpha2":"BA","code":70,"name":"Bosnia and Herzegovina"},{"alpha2":"BW","code":72,"name":"Botswana"},{"alpha2":"BV","code":74,"name":"Bouvet Island"},{"alpha2":"BR","code":76,"name":"Brazil"},{"alpha2":"IO","code":86,"name":"British Indian Ocean Territory"},{"alpha2":"BN","code":96,"name":"Brunei Darussalam"},{"alpha2":"BG","code":100,"name":"Bulgaria"},{"alpha2":"BF","code":854,"name":"Burkina Faso"},{"alpha2":"BI","code":108,"name":"Burundi"},{"alpha2":"CV","code":132,"name":"Cabo Verde"},{"alpha2":"KH","code":116,"name":"Cambodia"},{"alpha2":"CM","code":120,"name":"Cameroon"},{"alpha2":"CA","code":124,"name":"Canada"},{"alpha2":"KY","code":136,"name":"Cayman Islands"},{"alpha2":"CF","code":140,"name":"Central African Republic"},{"alpha2":"TD","code":148,"name":"Chad"},{"alpha2":"CL","code":152,"name":"Chile"},{"alpha2":"CN","code":156,"name":"China"},{"alpha2":"CX","code":162,"name":"Christmas Island"},{"alpha2":"CC","code":166,"name":"Cocos (Keeling) Islands"},{"alpha2":"CO","code":170,"name":"Colombia"},{"alpha2":"KM","code":174,"name":"Comoros"},{"alpha2":"CD","code":180,"name":"Congo"},{"alpha2":"CG","code":178,"name":"Congo"},{"alpha2":"CK","code":184,"name":"Cook Islands"},{"alpha2":"CR","code":188,"name":"Costa Rica"},{"alpha2":"CI","code":384,"name":"Côte d'Ivoire"},{"alpha2":"HR","code":191,"name":"Croatia"},{"alpha2":"CU","code":192,"name":"Cuba"},{"alpha2":"CW","code":531,"name":"Curaçao"},{"alpha2":"CY","code":196,"name":"Cyprus"},{"alpha2":"CZ","code":203,"name":"Czechia"},{"alpha2":"DK","code":208,"name":"Denmark"},{"alpha2":"DJ","code":262,"name":"Djibouti"},{"alpha2":"DM","code":212,"name":"Dominica"},{"alpha2":"DO","code":214,"name":"Dominican Republic"},{"alpha2":"EC","code":218,"name":"Ecuador"},{"alpha2":"EG","code":818,"name":"Egypt"},{"alpha2":"SV","code":222,"name":"El Salvador"},{"alpha2":"GQ","code":226,"name":"Equatorial Guinea"},{"alpha2":"ER","code":232,"name":"Eritrea"},{"alpha2":"EE","code":233,"name":"Estonia"},{"alpha2":"ET","code":231,"name":"Ethiopia"},{"alpha2":"FK","code":238,"name":"Falkland Islands"},{"alpha2":"FO","code":234,"name":"Faroe Islands"},{"alpha2":"FJ","code":242,"name":"Fiji"},{"alpha2":"FI","code":246,"name":"Finland"},{"alpha2":"FR","code":250,"name":"France"},{"alpha2":"GF","code":254,"name":"French Guiana"},{"alpha2":"PF","code":258,"name":"French Polynesia"},{"alpha2":"TF","code":260,"name":"French Southern Territories"},{"alpha2":"GA","code":266,"name":"Gabon"},{"alpha2":"GM","code":270,"name":"Gambia"},{"alpha2":"GE","code":268,"name":"Georgia"},{"alpha2":"DE","code":276,"name":"Germany"},{"alpha2":"GH","code":288,"name":"Ghana"},{"alpha2":"GI","code":292,"name":"Gibraltar"},{"alpha2":"GR","code":300,"name":"Greece"},{"alpha2":"GL","code":304,"name":"Greenland"},{"alpha2":"GD","code":308,"name":"Grenada"},{"alpha2":"GP","code":312,"name":"Guadeloupe"},{"alpha2":"GU","code":316,"name":"Guam"},{"alpha2":"GT","code":320,"name":"Guatemala"},{"alpha2":"GG","code":831,"name":"Guernsey"},{"alpha2":"GN","code":324,"name":"Guinea"},{"alpha2":"GW","code":624,"name":"Guinea-Bissau"},{"alpha2":"GY","code":328,"name":"Guyana"},{"alpha2":"HT","code":332,"name":"Haiti"},{"alpha2":"HM","code":334,"name":"Heard Island and McDonald Islands"},{"alpha2":"VA","code":336,"name":"Holy See"},{"alpha2":"HN","code":340,"name":"Honduras"},{"alpha2":"HK","code":344,"name":"Hong Kong"},{"alpha2":"HU","code":348,"name":"Hungary"},{"alpha2":"IS","code":352,"name":"Iceland"},{"alpha2":"IN","code":356,"name":"India"},{"alpha2":"ID","code":360,"name":"Indonesia"},{"alpha2":"IR","code":364,"name":"Iran"},{"alpha2":"IQ","code":368,"name":"Iraq"},{"alpha2":"IE","code":372,"name":"Ireland"},{"alpha2":"IM","code":833,"name":"Isle of Man"},{"alpha2":"IL","code":376,"name":"Israel"},{"alpha2":"IT","code":380,"name":"Italy"},{"alpha2":"JM","code":388,"name":"Jamaica"},{"alpha2":"JP","code":392,"name":"Japan"},{"alpha2":"JE","code":832,"name":"Jersey"},{"alpha2":"JO","code":400,"name":"Jordan"},{"alpha2":"KZ","code":398,"name":"Kazakhstan"},{"alpha2":"KE","code":404,"name":"Kenya"},{"alpha2":"KI","code":296,"name":"Kiribati"},{"alpha2":"KW","code":414,"name":"Kuwait"},{"alpha2":"KG","code":417,"name":"Kyrgyzstan"},{"alpha2":"LA","code":418,"name":"Laos"},{"alpha2":"LV","code":428,"name":"Latvia"},{"alpha2":"LB","code":422,"name":"Lebanon"},{"alpha2":"LS","code":426,"name":"Lesotho"},{"alpha2":"LR","code":430,"name":"Liberia"},{"alpha2":"LY","code":434,"name":"Libya"},{"alpha2":"LI","code":438,"name":"Liechtenstein"},{"alpha2":"LT","code":440,"name":"Lithuania"},{"alpha2":"LU","code":442,"name":"Luxembourg"},{"alpha2":"MO","code":446,"name":"Macao"},{"alpha2":"MK","code":807,"name":"Macedonia"},{"alpha2":"MG","code":450,"name":"Madagascar"},{"alpha2":"MW","code":454,"name":"Malawi"},{"alpha2":"MY","code":458,"name":"Malaysia"},{"alpha2":"MV","code":462,"name":"Maldives"},{"alpha2":"ML","code":466,"name":"Mali"},{"alpha2":"MT","code":470,"name":"Malta"},{"alpha2":"MH","code":584,"name":"Marshall Islands"},{"alpha2":"MQ","code":474,"name":"Martinique"},{"alpha2":"MR","code":478,"name":"Mauritania"},{"alpha2":"MU","code":480,"name":"Mauritius"},{"alpha2":"YT","code":175,"name":"Mayotte"},{"alpha2":"MX","code":484,"name":"Mexico"},{"alpha2":"FM","code":583,"name":"Micronesia"},{"alpha2":"MD","code":498,"name":"Moldova"},{"alpha2":"MC","code":492,"name":"Monaco"},{"alpha2":"MN","code":496,"name":"Mongolia"},{"alpha2":"ME","code":499,"name":"Montenegro"},{"alpha2":"MS","code":500,"name":"Montserrat"},{"alpha2":"MA","code":504,"name":"Morocco"},{"alpha2":"MZ","code":508,"name":"Mozambique"},{"alpha2":"MM","code":104,"name":"Myanmar"},{"alpha2":"NA","code":516,"name":"Namibia"},{"alpha2":"NR","code":520,"name":"Nauru"},{"alpha2":"NP","code":524,"name":"Nepal"},{"alpha2":"NL","code":528,"name":"Netherlands"},{"alpha2":"NC","code":540,"name":"New Caledonia"},{"alpha2":"NZ","code":554,"name":"New Zealand"},{"alpha2":"NI","code":558,"name":"Nicaragua"},{"alpha2":"NE","code":562,"name":"Niger"},{"alpha2":"NG","code":566,"name":"Nigeria"},{"alpha2":"NU","code":570,"name":"Niue"},{"alpha2":"NF","code":574,"name":"Norfolk Island"},{"alpha2":"KP","code":408,"name":"North Korea"},{"alpha2":"MP","code":580,"name":"Northern Mariana Islands"},{"alpha2":"NO","code":578,"name":"Norway"},{"alpha2":"OM","code":512,"name":"Oman"},{"alpha2":"PK","code":586,"name":"Pakistan"},{"alpha2":"PW","code":585,"name":"Palau"},{"alpha2":"PS","code":275,"name":"Palestine"},{"alpha2":"PA","code":591,"name":"Panama"},{"alpha2":"PG","code":598,"name":"Papua New Guinea"},{"alpha2":"PY","code":600,"name":"Paraguay"},{"alpha2":"PE","code":604,"name":"Peru"},{"alpha2":"PH","code":608,"name":"Philippines"},{"alpha2":"PN","code":612,"name":"Pitcairn"},{"alpha2":"PL","code":616,"name":"Poland"},{"alpha2":"PT","code":620,"name":"Portugal"},{"alpha2":"PR","code":630,"name":"Puerto Rico"},{"alpha2":"QA","code":634,"name":"Qatar"},{"alpha2":"RE","code":638,"name":"Réunion"},{"alpha2":"RO","code":642,"name":"Romania"},{"alpha2":"RU","code":643,"name":"Russian Federation"},{"alpha2":"RW","code":646,"name":"Rwanda"},{"alpha2":"BL","code":652,"name":"Saint Barthélemy"},{"alpha2":"SH","code":654,"name":"Saint Helena, Ascension and Tristan da Cunha"},{"alpha2":"KN","code":659,"name":"Saint Kitts and Nevis"},{"alpha2":"LC","code":662,"name":"Saint Lucia"},{"alpha2":"MF","code":663,"name":"Saint Martin (French)"},{"alpha2":"PM","code":666,"name":"Saint Pierre and Miquelon"},{"alpha2":"VC","code":670,"name":"Saint Vincent and the Grenadines"},{"alpha2":"WS","code":882,"name":"Samoa"},{"alpha2":"SM","code":674,"name":"San Marino"},{"alpha2":"ST","code":678,"name":"Sao Tome and Principe"},{"alpha2":"SA","code":682,"name":"Saudi Arabia"},{"alpha2":"SN","code":686,"name":"Senegal"},{"alpha2":"RS","code":688,"name":"Serbia"},{"alpha2":"SC","code":690,"name":"Seychelles"},{"alpha2":"SL","code":694,"name":"Sierra Leone"},{"alpha2":"SG","code":702,"name":"Singapore"},{"alpha2":"SX","code":534,"name":"Sint Maarten (Dutch)"},{"alpha2":"SK","code":703,"name":"Slovakia"},{"alpha2":"SI","code":705,"name":"Slovenia"},{"alpha2":"SB","code":90,"name":"Solomon Islands"},{"alpha2":"SO","code":706,"name":"Somalia"},{"alpha2":"ZA","code":710,"name":"South Africa"},{"alpha2":"GS","code":239,"name":"South Georgia and the South Sandwich Islands"},{"alpha2":"KR","code":410,"name":"South Korea"},{"alpha2":"SS","code":728,"name":"South Sudan"},{"alpha2":"ES","code":724,"name":"Spain"},{"alpha2":"LK","code":144,"name":"Sri Lanka"},{"alpha2":"SD","code":729,"name":"Sudan"},{"alpha2":"SR","code":740,"name":"Suriname"},{"alpha2":"SJ","code":744,"name":"Svalbard and Jan Mayen"},{"alpha2":"SZ","code":748,"name":"Swaziland"},{"alpha2":"SE","code":752,"name":"Sweden"},{"alpha2":"CH","code":756,"name":"Switzerland"},{"alpha2":"SY","code":760,"name":"Syrian Arab Republic"},{"alpha2":"TW","code":158,"name":"Taiwan, Province of China"},{"alpha2":"TJ","code":762,"name":"Tajikistan"},{"alpha2":"TZ","code":834,"name":"Tanzania"},{"alpha2":"TH","code":764,"name":"Thailand"},{"alpha2":"TL","code":626,"name":"Timor-Leste"},{"alpha2":"TG","code":768,"name":"Togo"},{"alpha2":"TK","code":772,"name":"Tokelau"},{"alpha2":"TO","code":776,"name":"Tonga"},{"alpha2":"TT","code":780,"name":"Trinalpha2ad and Tobago"},{"alpha2":"TN","code":788,"name":"Tunisia"},{"alpha2":"TR","code":792,"name":"Turkey"},{"alpha2":"TM","code":795,"name":"Turkmenistan"},{"alpha2":"TC","code":796,"name":"Turks and Caicos Islands"},{"alpha2":"TV","code":798,"name":"Tuvalu"},{"alpha2":"UG","code":800,"name":"Uganda"},{"alpha2":"UA","code":804,"name":"Ukraine"},{"alpha2":"AE","code":784,"name":"United Arab Emirates"},{"alpha2":"GB","code":826,"name":"United Kingdom"},{"alpha2":"US","code":840,"name":"United States"},{"alpha2":"UM","code":581,"name":"United States, Minor Outlying Islands"},{"alpha2":"UY","code":858,"name":"Uruguay"},{"alpha2":"UZ","code":860,"name":"Uzbekistan"},{"alpha2":"VU","code":548,"name":"Vanuatu"},{"alpha2":"VE","code":862,"name":"Venezuela"},{"alpha2":"VN","code":704,"name":"Vietnam"},{"alpha2":"VG","code":92,"name":"Virgin Islands (UK)"},{"alpha2":"VI","code":850,"name":"Virgin Islands (US)"},{"alpha2":"WF","code":876,"name":"Wallis and Futuna"},{"alpha2":"EH","code":732,"name":"Western Sahara"},{"alpha2":"YE","code":887,"name":"Yemen"},{"alpha2":"ZM","code":894,"name":"Zambia"},{"alpha2":"ZW","code":716,"name":"Zimbabwe"}] \ No newline at end of file +[ + { + "alpha2": "AF", + "code": 4, + "name": "Afghanistan" + }, + { + "alpha2": "AX", + "code": 248, + "name": "Aland Islands", + "fullName": "Åland Islands" + }, + { + "alpha2": "AL", + "code": 8, + "name": "Albania" + }, + { + "alpha2": "DZ", + "code": 12, + "name": "Algeria" + }, + { + "alpha2": "AS", + "code": 16, + "name": "American Samoa" + }, + { + "alpha2": "AD", + "code": 20, + "name": "Andorra" + }, + { + "alpha2": "AO", + "code": 24, + "name": "Angola" + }, + { + "alpha2": "AI", + "code": 660, + "name": "Anguilla" + }, + { + "alpha2": "AQ", + "code": 10, + "name": "Antarctica" + }, + { + "alpha2": "AG", + "code": 28, + "name": "Antigua and Barbuda" + }, + { + "alpha2": "AR", + "code": 32, + "name": "Argentina" + }, + { + "alpha2": "AM", + "code": 51, + "name": "Armenia" + }, + { + "alpha2": "AW", + "code": 533, + "name": "Aruba" + }, + { + "alpha2": "AU", + "code": 36, + "name": "Australia" + }, + { + "alpha2": "AT", + "code": 40, + "name": "Austria" + }, + { + "alpha2": "AZ", + "code": 31, + "name": "Azerbaijan" + }, + { + "alpha2": "BS", + "code": 44, + "name": "Bahamas" + }, + { + "alpha2": "BH", + "code": 48, + "name": "Bahrain" + }, + { + "alpha2": "BD", + "code": 50, + "name": "Bangladesh" + }, + { + "alpha2": "BB", + "code": 52, + "name": "Barbados" + }, + { + "alpha2": "BY", + "code": 112, + "name": "Belarus" + }, + { + "alpha2": "BE", + "code": 56, + "name": "Belgium" + }, + { + "alpha2": "BZ", + "code": 84, + "name": "Belize" + }, + { + "alpha2": "BJ", + "code": 204, + "name": "Benin" + }, + { + "alpha2": "BM", + "code": 60, + "name": "Bermuda" + }, + { + "alpha2": "BT", + "code": 64, + "name": "Bhutan" + }, + { + "alpha2": "BO", + "code": 68, + "name": "Bolivia" + }, + { + "alpha2": "BQ", + "code": 535, + "name": "Bonaire", + "fullName": "Bonaire, Sint Eustatius and Saba" + }, + { + "alpha2": "BA", + "code": 70, + "name": "Bosnia", + "fullName": "Bosnia and Herzegovina" + }, + { + "alpha2": "BW", + "code": 72, + "name": "Botswana" + }, + { + "alpha2": "BV", + "code": 74, + "name": "Bouvet Island" + }, + { + "alpha2": "BR", + "code": 76, + "name": "Brazil" + }, + { + "alpha2": "IO", + "code": 86, + "name": "British Indian Ocean Territory" + }, + { + "alpha2": "BN", + "code": 96, + "name": "Brunei Darussalam" + }, + { + "alpha2": "BG", + "code": 100, + "name": "Bulgaria" + }, + { + "alpha2": "BF", + "code": 854, + "name": "Burkina Faso" + }, + { + "alpha2": "BI", + "code": 108, + "name": "Burundi" + }, + { + "alpha2": "CV", + "code": 132, + "name": "Cabo Verde" + }, + { + "alpha2": "KH", + "code": 116, + "name": "Cambodia" + }, + { + "alpha2": "CM", + "code": 120, + "name": "Cameroon" + }, + { + "alpha2": "CA", + "code": 124, + "name": "Canada" + }, + { + "alpha2": "KY", + "code": 136, + "name": "Cayman Islands" + }, + { + "alpha2": "CF", + "code": 140, + "name": "Central African Republic" + }, + { + "alpha2": "TD", + "code": 148, + "name": "Chad" + }, + { + "alpha2": "CL", + "code": 152, + "name": "Chile" + }, + { + "alpha2": "CN", + "code": 156, + "name": "China" + }, + { + "alpha2": "CX", + "code": 162, + "name": "Christmas Island" + }, + { + "alpha2": "CC", + "code": 166, + "name": "Cocos Islands", + "fullName": "Cocos (Keeling) Islands" + }, + { + "alpha2": "CO", + "code": 170, + "name": "Colombia" + }, + { + "alpha2": "KM", + "code": 174, + "name": "Comoros" + }, + { + "alpha2": "CD", + "code": 180, + "name": "Congo" + }, + { + "alpha2": "CG", + "code": 178, + "name": "Congo" + }, + { + "alpha2": "CK", + "code": 184, + "name": "Cook Islands" + }, + { + "alpha2": "CR", + "code": 188, + "name": "Costa Rica" + }, + { + "alpha2": "CI", + "code": 384, + "name": "Côte d'Ivoire" + }, + { + "alpha2": "HR", + "code": 191, + "name": "Croatia" + }, + { + "alpha2": "CU", + "code": 192, + "name": "Cuba" + }, + { + "alpha2": "CW", + "code": 531, + "name": "Curaçao" + }, + { + "alpha2": "CY", + "code": 196, + "name": "Cyprus" + }, + { + "alpha2": "CZ", + "code": 203, + "name": "Czechia" + }, + { + "alpha2": "DK", + "code": 208, + "name": "Denmark" + }, + { + "alpha2": "DJ", + "code": 262, + "name": "Djibouti" + }, + { + "alpha2": "DM", + "code": 212, + "name": "Dominica" + }, + { + "alpha2": "DO", + "code": 214, + "name": "Dominican Republic" + }, + { + "alpha2": "EC", + "code": 218, + "name": "Ecuador" + }, + { + "alpha2": "EG", + "code": 818, + "name": "Egypt" + }, + { + "alpha2": "SV", + "code": 222, + "name": "El Salvador" + }, + { + "alpha2": "GQ", + "code": 226, + "name": "Equatorial Guinea" + }, + { + "alpha2": "ER", + "code": 232, + "name": "Eritrea" + }, + { + "alpha2": "EE", + "code": 233, + "name": "Estonia" + }, + { + "alpha2": "ET", + "code": 231, + "name": "Ethiopia" + }, + { + "alpha2": "FK", + "code": 238, + "name": "Falkland Islands" + }, + { + "alpha2": "FO", + "code": 234, + "name": "Faroe Islands" + }, + { + "alpha2": "FJ", + "code": 242, + "name": "Fiji" + }, + { + "alpha2": "FI", + "code": 246, + "name": "Finland" + }, + { + "alpha2": "FR", + "code": 250, + "name": "France" + }, + { + "alpha2": "GF", + "code": 254, + "name": "French Guiana" + }, + { + "alpha2": "PF", + "code": 258, + "name": "French Polynesia" + }, + { + "alpha2": "TF", + "code": 260, + "name": "French Southern Territories" + }, + { + "alpha2": "GA", + "code": 266, + "name": "Gabon" + }, + { + "alpha2": "GM", + "code": 270, + "name": "Gambia" + }, + { + "alpha2": "GE", + "code": 268, + "name": "Georgia" + }, + { + "alpha2": "DE", + "code": 276, + "name": "Germany" + }, + { + "alpha2": "GH", + "code": 288, + "name": "Ghana" + }, + { + "alpha2": "GI", + "code": 292, + "name": "Gibraltar" + }, + { + "alpha2": "GR", + "code": 300, + "name": "Greece" + }, + { + "alpha2": "GL", + "code": 304, + "name": "Greenland" + }, + { + "alpha2": "GD", + "code": 308, + "name": "Grenada" + }, + { + "alpha2": "GP", + "code": 312, + "name": "Guadeloupe" + }, + { + "alpha2": "GU", + "code": 316, + "name": "Guam" + }, + { + "alpha2": "GT", + "code": 320, + "name": "Guatemala" + }, + { + "alpha2": "GG", + "code": 831, + "name": "Guernsey" + }, + { + "alpha2": "GN", + "code": 324, + "name": "Guinea" + }, + { + "alpha2": "GW", + "code": 624, + "name": "Guinea-Bissau" + }, + { + "alpha2": "GY", + "code": 328, + "name": "Guyana" + }, + { + "alpha2": "HT", + "code": 332, + "name": "Haiti" + }, + { + "alpha2": "HM", + "code": 334, + "name": "Heard Island and McDonald Islands" + }, + { + "alpha2": "VA", + "code": 336, + "name": "Holy See" + }, + { + "alpha2": "HN", + "code": 340, + "name": "Honduras" + }, + { + "alpha2": "HK", + "code": 344, + "name": "Hong Kong" + }, + { + "alpha2": "HU", + "code": 348, + "name": "Hungary" + }, + { + "alpha2": "IS", + "code": 352, + "name": "Iceland" + }, + { + "alpha2": "IN", + "code": 356, + "name": "India" + }, + { + "alpha2": "ID", + "code": 360, + "name": "Indonesia" + }, + { + "alpha2": "IR", + "code": 364, + "name": "Iran" + }, + { + "alpha2": "IQ", + "code": 368, + "name": "Iraq" + }, + { + "alpha2": "IE", + "code": 372, + "name": "Ireland" + }, + { + "alpha2": "IM", + "code": 833, + "name": "Isle of Man" + }, + { + "alpha2": "IL", + "code": 376, + "name": "Israel" + }, + { + "alpha2": "IT", + "code": 380, + "name": "Italy" + }, + { + "alpha2": "JM", + "code": 388, + "name": "Jamaica" + }, + { + "alpha2": "JP", + "code": 392, + "name": "Japan" + }, + { + "alpha2": "JE", + "code": 832, + "name": "Jersey" + }, + { + "alpha2": "JO", + "code": 400, + "name": "Jordan" + }, + { + "alpha2": "KZ", + "code": 398, + "name": "Kazakhstan" + }, + { + "alpha2": "KE", + "code": 404, + "name": "Kenya" + }, + { + "alpha2": "KI", + "code": 296, + "name": "Kiribati" + }, + { + "alpha2": "KW", + "code": 414, + "name": "Kuwait" + }, + { + "alpha2": "KG", + "code": 417, + "name": "Kyrgyzstan" + }, + { + "alpha2": "LA", + "code": 418, + "name": "Laos" + }, + { + "alpha2": "LV", + "code": 428, + "name": "Latvia" + }, + { + "alpha2": "LB", + "code": 422, + "name": "Lebanon" + }, + { + "alpha2": "LS", + "code": 426, + "name": "Lesotho" + }, + { + "alpha2": "LR", + "code": 430, + "name": "Liberia" + }, + { + "alpha2": "LY", + "code": 434, + "name": "Libya" + }, + { + "alpha2": "LI", + "code": 438, + "name": "Liechtenstein" + }, + { + "alpha2": "LT", + "code": 440, + "name": "Lithuania" + }, + { + "alpha2": "LU", + "code": 442, + "name": "Luxembourg" + }, + { + "alpha2": "MO", + "code": 446, + "name": "Macao" + }, + { + "alpha2": "MK", + "code": 807, + "name": "Macedonia" + }, + { + "alpha2": "MG", + "code": 450, + "name": "Madagascar" + }, + { + "alpha2": "MW", + "code": 454, + "name": "Malawi" + }, + { + "alpha2": "MY", + "code": 458, + "name": "Malaysia" + }, + { + "alpha2": "MV", + "code": 462, + "name": "Maldives" + }, + { + "alpha2": "ML", + "code": 466, + "name": "Mali" + }, + { + "alpha2": "MT", + "code": 470, + "name": "Malta" + }, + { + "alpha2": "MH", + "code": 584, + "name": "Marshall Islands" + }, + { + "alpha2": "MQ", + "code": 474, + "name": "Martinique" + }, + { + "alpha2": "MR", + "code": 478, + "name": "Mauritania" + }, + { + "alpha2": "MU", + "code": 480, + "name": "Mauritius" + }, + { + "alpha2": "YT", + "code": 175, + "name": "Mayotte" + }, + { + "alpha2": "MX", + "code": 484, + "name": "Mexico" + }, + { + "alpha2": "FM", + "code": 583, + "name": "Micronesia" + }, + { + "alpha2": "MD", + "code": 498, + "name": "Moldova" + }, + { + "alpha2": "MC", + "code": 492, + "name": "Monaco" + }, + { + "alpha2": "MN", + "code": 496, + "name": "Mongolia" + }, + { + "alpha2": "ME", + "code": 499, + "name": "Montenegro" + }, + { + "alpha2": "MS", + "code": 500, + "name": "Montserrat" + }, + { + "alpha2": "MA", + "code": 504, + "name": "Morocco" + }, + { + "alpha2": "MZ", + "code": 508, + "name": "Mozambique" + }, + { + "alpha2": "MM", + "code": 104, + "name": "Myanmar" + }, + { + "alpha2": "NA", + "code": 516, + "name": "Namibia" + }, + { + "alpha2": "NR", + "code": 520, + "name": "Nauru" + }, + { + "alpha2": "NP", + "code": 524, + "name": "Nepal" + }, + { + "alpha2": "NL", + "code": 528, + "name": "Netherlands" + }, + { + "alpha2": "NC", + "code": 540, + "name": "New Caledonia" + }, + { + "alpha2": "NZ", + "code": 554, + "name": "New Zealand" + }, + { + "alpha2": "NI", + "code": 558, + "name": "Nicaragua" + }, + { + "alpha2": "NE", + "code": 562, + "name": "Niger" + }, + { + "alpha2": "NG", + "code": 566, + "name": "Nigeria" + }, + { + "alpha2": "NU", + "code": 570, + "name": "Niue" + }, + { + "alpha2": "NF", + "code": 574, + "name": "Norfolk Island" + }, + { + "alpha2": "KP", + "code": 408, + "name": "North Korea" + }, + { + "alpha2": "MP", + "code": 580, + "name": "Northern Mariana Islands" + }, + { + "alpha2": "NO", + "code": 578, + "name": "Norway" + }, + { + "alpha2": "OM", + "code": 512, + "name": "Oman" + }, + { + "alpha2": "PK", + "code": 586, + "name": "Pakistan" + }, + { + "alpha2": "PW", + "code": 585, + "name": "Palau" + }, + { + "alpha2": "PS", + "code": 275, + "name": "Palestine" + }, + { + "alpha2": "PA", + "code": 591, + "name": "Panama" + }, + { + "alpha2": "PG", + "code": 598, + "name": "Papua New Guinea" + }, + { + "alpha2": "PY", + "code": 600, + "name": "Paraguay" + }, + { + "alpha2": "PE", + "code": 604, + "name": "Peru" + }, + { + "alpha2": "PH", + "code": 608, + "name": "Philippines" + }, + { + "alpha2": "PN", + "code": 612, + "name": "Pitcairn" + }, + { + "alpha2": "PL", + "code": 616, + "name": "Poland" + }, + { + "alpha2": "PT", + "code": 620, + "name": "Portugal" + }, + { + "alpha2": "PR", + "code": 630, + "name": "Puerto Rico" + }, + { + "alpha2": "QA", + "code": 634, + "name": "Qatar" + }, + { + "alpha2": "RE", + "code": 638, + "name": "Réunion" + }, + { + "alpha2": "RO", + "code": 642, + "name": "Romania" + }, + { + "alpha2": "RU", + "code": 643, + "name": "Russia", + "fullName": "Russian Federation" + }, + { + "alpha2": "RW", + "code": 646, + "name": "Rwanda" + }, + { + "alpha2": "BL", + "code": 652, + "name": "Saint Barthélemy" + }, + { + "alpha2": "SH", + "code": 654, + "name": "Saint Helena, Ascension and Tristan da Cunha" + }, + { + "alpha2": "KN", + "code": 659, + "name": "Saint Kitts and Nevis" + }, + { + "alpha2": "LC", + "code": 662, + "name": "Saint Lucia" + }, + { + "alpha2": "MF", + "code": 663, + "name": "Saint Martin (French)" + }, + { + "alpha2": "PM", + "code": 666, + "name": "Saint Pierre and Miquelon" + }, + { + "alpha2": "VC", + "code": 670, + "name": "Saint Vincent and the Grenadines" + }, + { + "alpha2": "WS", + "code": 882, + "name": "Samoa" + }, + { + "alpha2": "SM", + "code": 674, + "name": "San Marino" + }, + { + "alpha2": "ST", + "code": 678, + "name": "Sao Tome and Principe" + }, + { + "alpha2": "SA", + "code": 682, + "name": "Saudi Arabia" + }, + { + "alpha2": "SN", + "code": 686, + "name": "Senegal" + }, + { + "alpha2": "RS", + "code": 688, + "name": "Serbia" + }, + { + "alpha2": "SC", + "code": 690, + "name": "Seychelles" + }, + { + "alpha2": "SL", + "code": 694, + "name": "Sierra Leone" + }, + { + "alpha2": "SG", + "code": 702, + "name": "Singapore" + }, + { + "alpha2": "SX", + "code": 534, + "name": "Sint Maarten", + "fullName": "Sint Maarten (Dutch)" + }, + { + "alpha2": "SK", + "code": 703, + "name": "Slovakia" + }, + { + "alpha2": "SI", + "code": 705, + "name": "Slovenia" + }, + { + "alpha2": "SB", + "code": 90, + "name": "Solomon Islands" + }, + { + "alpha2": "SO", + "code": 706, + "name": "Somalia" + }, + { + "alpha2": "ZA", + "code": 710, + "name": "South Africa" + }, + { + "alpha2": "GS", + "code": 239, + "name": "South Georgia and the South Sandwich Islands" + }, + { + "alpha2": "KR", + "code": 410, + "name": "South Korea" + }, + { + "alpha2": "SS", + "code": 728, + "name": "South Sudan" + }, + { + "alpha2": "ES", + "code": 724, + "name": "Spain" + }, + { + "alpha2": "LK", + "code": 144, + "name": "Sri Lanka" + }, + { + "alpha2": "SD", + "code": 729, + "name": "Sudan" + }, + { + "alpha2": "SR", + "code": 740, + "name": "Suriname" + }, + { + "alpha2": "SJ", + "code": 744, + "name": "Svalbard", + "fullName": "Svalbard and Jan Mayen" + }, + { + "alpha2": "SZ", + "code": 748, + "name": "Swaziland" + }, + { + "alpha2": "SE", + "code": 752, + "name": "Sweden" + }, + { + "alpha2": "CH", + "code": 756, + "name": "Switzerland" + }, + { + "alpha2": "SY", + "code": 760, + "name": "Syria", + "fullName": "Syrian Arab Republic" + }, + { + "alpha2": "TW", + "code": 158, + "name": "Taiwan", + "fullName": "Taiwan, Province of China" + }, + { + "alpha2": "TJ", + "code": 762, + "name": "Tajikistan" + }, + { + "alpha2": "TZ", + "code": 834, + "name": "Tanzania" + }, + { + "alpha2": "TH", + "code": 764, + "name": "Thailand" + }, + { + "alpha2": "TL", + "code": 626, + "name": "Timor-Leste" + }, + { + "alpha2": "TG", + "code": 768, + "name": "Togo" + }, + { + "alpha2": "TK", + "code": 772, + "name": "Tokelau" + }, + { + "alpha2": "TO", + "code": 776, + "name": "Tonga" + }, + { + "alpha2": "TT", + "code": 780, + "name": "Trinidad and Tobago" + }, + { + "alpha2": "TN", + "code": 788, + "name": "Tunisia" + }, + { + "alpha2": "TR", + "code": 792, + "name": "Turkey" + }, + { + "alpha2": "TM", + "code": 795, + "name": "Turkmenistan" + }, + { + "alpha2": "TC", + "code": 796, + "name": "Turks and Caicos Islands" + }, + { + "alpha2": "TV", + "code": 798, + "name": "Tuvalu" + }, + { + "alpha2": "UG", + "code": 800, + "name": "Uganda" + }, + { + "alpha2": "UA", + "code": 804, + "name": "Ukraine" + }, + { + "alpha2": "AE", + "code": 784, + "name": "United Arab Emirates" + }, + { + "alpha2": "GB", + "code": 826, + "name": "United Kingdom" + }, + { + "alpha2": "US", + "code": 840, + "name": "United States" + }, + { + "alpha2": "UM", + "code": 581, + "name": "United States, Minor Outlying Islands" + }, + { + "alpha2": "UY", + "code": 858, + "name": "Uruguay" + }, + { + "alpha2": "UZ", + "code": 860, + "name": "Uzbekistan" + }, + { + "alpha2": "VU", + "code": 548, + "name": "Vanuatu" + }, + { + "alpha2": "VE", + "code": 862, + "name": "Venezuela" + }, + { + "alpha2": "VN", + "code": 704, + "name": "Vietnam" + }, + { + "alpha2": "VG", + "code": 92, + "name": "Virgin Islands (UK)" + }, + { + "alpha2": "VI", + "code": 850, + "name": "Virgin Islands (US)" + }, + { + "alpha2": "WF", + "code": 876, + "name": "Wallis and Futuna" + }, + { + "alpha2": "EH", + "code": 732, + "name": "Western Sahara" + }, + { + "alpha2": "YE", + "code": 887, + "name": "Yemen" + }, + { + "alpha2": "ZM", + "code": 894, + "name": "Zambia" + }, + { + "alpha2": "ZW", + "code": 716, + "name": "Zimbabwe" + } +] diff --git a/src/games/geo.js b/src/games/geo.js index ebb04cf..d213829 100644 --- a/src/games/geo.js +++ b/src/games/geo.js @@ -19,20 +19,12 @@ const questions = [ function hint(game, context) { if (game.name.length >= 5) { - context.sendMessage(`${style.bold(game.name - .split('') - .map((letter, index) => (index === 0 || index === game.name.length - 1 ? letter : '_')) - .join(' ') - .toUpperCase())}, the country code is ${style.bold(game.alpha2)}`, context.room.id); + context.sendMessage(`${style.bold(`${game.name.slice(0, 1)} ${game.name.slice(1, -1).replace(/\s/g, ' ').replace(/[^\s]/g, '_ ')}${game.name.slice(-1)}`.toUpperCase())}, the country code s ${style.bold(game.alpha2)}`, context.room.id); // eslint-disable-line no-irregular-whitespace return; } - context.sendMessage(`${style.bold(game.name - .split('') - .map((letter, index) => (index === 0 ? letter : '_')) - .join(' ') - .toUpperCase())}, the country code is ${style.bold(game.alpha2)}`, context.room.id); + context.sendMessage(`${style.bold(`${game.name.slice(0, 1)} ${game.name.slice(1).replace(/\s/g, ' ').replace(/[^\s]/g, '_ ').trim()}`.toUpperCase())}, the country code is ${style.bold(game.alpha2)}`, context.room.id); // eslint-disable-line no-irregular-whitespace } function play(context) { @@ -42,7 +34,7 @@ function play(context) { games.set(context.room.id, { ...country, url, - regexp: new RegExp(country.name, 'i'), + regexp: new RegExp(country.fullName ? `(${country.name})|(${country.fullName})` : country.name, 'i'), }); context.sendMessage(`${url} ${pickRandom(questions)}`, context.room.id); @@ -59,7 +51,7 @@ async function onCommand(args, context) { const game = games.get(context.room.id); games.delete(context.room.id); - context.sendMessage(`Geo was skipped by ${context.user.prefixedUsername}. The country was ${style.bold(game.name)}.`, context.room.id); + context.sendMessage(`Geo was skipped by ${context.user.prefixedUsername}. The country was ${style.bold(game.fullName ? `${game.fullName} (${game.name})` : game.name)}.`, context.room.id); await timers.setTimeout(2000); } @@ -87,7 +79,7 @@ async function onMessage(message, context) { } if (game.regexp.test(message.body)) { - context.sendMessage(`${style.answer(game.name)} is the right answer! ${style.username(context.user.prefixedUsername)} gets a point.`, context.room.id); + context.sendMessage(`${style.answer(game.fullName || game.name)} is the right answer! ${style.username(context.user.prefixedUsername)} gets a point.`, context.room.id); context.setPoints(context.user); games.delete(context.room.id);