From dc6df7c344b554dce8f981cf00faea505a863af9 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Fri, 28 Oct 2022 03:44:09 +0200 Subject: [PATCH] Added letter generator to letters game. --- config/default.js | 2 +- src/games/letters.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/default.js b/config/default.js index 14d5651..5b0177d 100755 --- a/config/default.js +++ b/config/default.js @@ -21,7 +21,7 @@ module.exports = { greeting: 'Hi, I am aisha, your game host!', usernamePrefix: '@', channels: ['GamesNight'], - games: ['mash', 'trivia', 'letters', 'duck', '8ball', 'dice', 'rock-paper-scissors', 'ping', 'say', 'kill', 'uptime', 'help'], + games: ['mash', 'trivia', 'letters', 'duck', '8ball', 'riddle', 'dice', 'rock-paper-scissors', 'ping', 'say', 'kill', 'uptime', 'help'], schatColors: { white: 'white', blue: 'var(--message-40)', diff --git a/src/games/letters.js b/src/games/letters.js index 18faf49..4b515ef 100755 --- a/src/games/letters.js +++ b/src/games/letters.js @@ -122,7 +122,7 @@ function pickLetters(type, context) { context.sendMessage(`${getBoard(context)} Would you like a consonant or a vowel?`, context.room.id); } -function start(context) { +function start(context, letters) { if (games.has(context.room.id)) { context.sendMessage(`${getBoard(context)} This is the current board. Use ${config.prefix}letters:stop to reset.`, context.room.id); return; @@ -136,6 +136,11 @@ function start(context) { ac: new AbortController(), // eslint-disable-line no-undef }); + if (letters) { + pickLetters(letters.toLowerCase(), context); + return; + } + context.sendMessage('Let\'s play the letters! Would you like a consonant or a vowel?', context.room.id); } @@ -145,6 +150,11 @@ function onCommand(args, context) { return; } + if (['start', 'go', 'auto', 'random'].includes(context.subcommand)) { + start(context, Array.from({ length: config.letters.length }, () => (Math.random() < 0.55 ? 'c' : 'v')).join('')); // a slight bias towards consonants seems to give better boards + return; + } + if (!context.subcommand) { start(context); }