Added flags to Geo.
This commit is contained in:
@@ -3,16 +3,19 @@
|
||||
const config = require('config');
|
||||
const timers = require('timers/promises');
|
||||
|
||||
const countries = require('../../assets/countries-curated.json');
|
||||
const states = require('../../assets/states-curated.json');
|
||||
const pickRandom = require('../utils/pick-random');
|
||||
const style = require('../utils/style');
|
||||
|
||||
const data = { countries, states };
|
||||
const countries = require('../../assets/countries-curated.json');
|
||||
const states = require('../../assets/states-curated.json');
|
||||
const flags = require('../../assets/flags-curated.json');
|
||||
|
||||
const data = { countries, states, flags };
|
||||
|
||||
const games = {
|
||||
countries: new Map(),
|
||||
states: new Map(),
|
||||
flags: new Map(),
|
||||
};
|
||||
|
||||
const questions = [
|
||||
@@ -48,8 +51,20 @@ function play(context, type = 'countries') {
|
||||
context.logger.info(`Geo played '${country.name}' (${url})`);
|
||||
}
|
||||
|
||||
function getType(command) {
|
||||
if (['state', 'america'].includes(command)) {
|
||||
return 'states';
|
||||
}
|
||||
|
||||
if (['flag'].includes(command)) {
|
||||
return 'flags';
|
||||
}
|
||||
|
||||
return countries;
|
||||
}
|
||||
|
||||
async function onCommand(args, context) {
|
||||
const type = ['state', 'america'].includes(context.command) ? 'states' : 'countries';
|
||||
const type = getType(context.command);
|
||||
|
||||
if (context.subcommand && !games[type].has(context.room.id)) {
|
||||
context.sendMessage(`There is no country in play right now. Start a new round with ${config.prefix}geo!`, context.room.id);
|
||||
@@ -81,7 +96,7 @@ async function onCommand(args, context) {
|
||||
}
|
||||
|
||||
async function onMessage(message, context) {
|
||||
['countries', 'states'].forEach(async (type) => {
|
||||
['countries', 'states', 'flags'].forEach(async (type) => {
|
||||
const game = games[type].get(context.room.id);
|
||||
|
||||
if (!game) {
|
||||
@@ -104,6 +119,6 @@ async function onMessage(message, context) {
|
||||
module.exports = {
|
||||
onCommand,
|
||||
onMessage,
|
||||
commands: ['country', 'atlas', 'state', 'america'],
|
||||
commands: ['country', 'atlas', 'state', 'america', 'flag'],
|
||||
help: 'Name the country or US state on the map! Too hard? Try ~geo:hint or ~geo:skip.',
|
||||
};
|
||||
|
||||
@@ -101,7 +101,7 @@ function curateMessageBody(rawBody, game, key, options) {
|
||||
return body;
|
||||
}
|
||||
|
||||
const label = typeof options.label === 'string'
|
||||
const label = typeof options?.label === 'string'
|
||||
? capitalize(options.label)
|
||||
: game.name || capitalize(key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user