Improved Letters distribution. Added conundrum to mash.
This commit is contained in:
parent
f4776df853
commit
91eaa9d709
|
@ -133,7 +133,7 @@ function onCommand(args, context) {
|
||||||
games.set(context.room.id, {
|
games.set(context.room.id, {
|
||||||
word: word.word,
|
word: word.word,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
defintiions: word.definitions,
|
definitions: word.definitions,
|
||||||
partial: word.word.split('').map(() => null),
|
partial: word.word.split('').map(() => null),
|
||||||
flower: pickRandom(flowers),
|
flower: pickRandom(flowers),
|
||||||
target: pickRandom(targets),
|
target: pickRandom(targets),
|
||||||
|
|
|
@ -9,9 +9,38 @@ const getWordKey = require('../utils/get-word-key');
|
||||||
const pickRandom = require('../utils/pick-random');
|
const pickRandom = require('../utils/pick-random');
|
||||||
const words = require('../../assets/mash-words.json');
|
const words = require('../../assets/mash-words.json');
|
||||||
|
|
||||||
|
// http://www.thecountdownpage.com/letters.htm
|
||||||
const availableLetters = {
|
const availableLetters = {
|
||||||
vowel: ['a', 'e', 'i', 'o', 'u'],
|
vowel: [
|
||||||
consonant: ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'], // Countdown regards y as a consonant
|
...Array.from({ length: 15 }, () => 'a'),
|
||||||
|
...Array.from({ length: 21 }, () => 'e'),
|
||||||
|
...Array.from({ length: 13 }, () => 'i'),
|
||||||
|
...Array.from({ length: 13 }, () => 'o'),
|
||||||
|
...Array.from({ length: 5 }, () => 'u'),
|
||||||
|
],
|
||||||
|
consonant: [
|
||||||
|
...Array.from({ length: 2 }, () => 'b'),
|
||||||
|
...Array.from({ length: 3 }, () => 'c'),
|
||||||
|
...Array.from({ length: 6 }, () => 'd'),
|
||||||
|
...Array.from({ length: 2 }, () => 'f'),
|
||||||
|
...Array.from({ length: 3 }, () => 'g'),
|
||||||
|
...Array.from({ length: 2 }, () => 'h'),
|
||||||
|
...Array.from({ length: 1 }, () => 'j'),
|
||||||
|
...Array.from({ length: 1 }, () => 'k'),
|
||||||
|
...Array.from({ length: 5 }, () => 'l'),
|
||||||
|
...Array.from({ length: 4 }, () => 'm'),
|
||||||
|
...Array.from({ length: 8 }, () => 'n'),
|
||||||
|
...Array.from({ length: 4 }, () => 'p'),
|
||||||
|
...Array.from({ length: 1 }, () => 'q'),
|
||||||
|
...Array.from({ length: 9 }, () => 'r'),
|
||||||
|
...Array.from({ length: 9 }, () => 's'),
|
||||||
|
...Array.from({ length: 9 }, () => 't'),
|
||||||
|
...Array.from({ length: 1 }, () => 'v'),
|
||||||
|
...Array.from({ length: 1 }, () => 'w'),
|
||||||
|
...Array.from({ length: 1 }, () => 'x'),
|
||||||
|
...Array.from({ length: 1 }, () => 'y'), // Countdown regards Y as a consonant
|
||||||
|
...Array.from({ length: 1 }, () => 'z'),
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const types = { v: 'vowel', c: 'consonant' };
|
const types = { v: 'vowel', c: 'consonant' };
|
||||||
|
@ -74,9 +103,11 @@ function stop(context, aborted) {
|
||||||
game.ac.abort();
|
game.ac.abort();
|
||||||
games.delete(context.room.id);
|
games.delete(context.room.id);
|
||||||
|
|
||||||
if (aborted) {
|
const wrap = aborted
|
||||||
context.sendMessage(`The game was stopped by ${style.cyan(`${config.usernamePrefix}${context.user.username}`)}. Best players: ${getLeaders(game.points)}`, context.room.id);
|
? `The game was stopped by ${style.cyan(`${config.usernamePrefix}${context.user.username}`)}.`
|
||||||
}
|
: style.bold('Time\'s up!');
|
||||||
|
|
||||||
|
context.sendMessage(`${wrap} Best players: ${getLeaders(game.points)}`, context.room.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function play(context) {
|
async function play(context) {
|
||||||
|
@ -95,8 +126,6 @@ async function play(context) {
|
||||||
context.sendMessage(`${getBoard(context)} You have ${style.bold(style.green(`${Math.round(settings.timeout / 3)} seconds`))} left`, context.room.id);
|
context.sendMessage(`${getBoard(context)} You have ${style.bold(style.green(`${Math.round(settings.timeout / 3)} seconds`))} left`, context.room.id);
|
||||||
|
|
||||||
await timers.setTimeout((settings.timeout / 3) * 1000, null, { signal: game.ac.signal });
|
await timers.setTimeout((settings.timeout / 3) * 1000, null, { signal: game.ac.signal });
|
||||||
context.sendMessage(`${style.bold('Time\'s up!')} Best players: ${getLeaders(game.points)}`, context.room.id);
|
|
||||||
|
|
||||||
stop(context);
|
stop(context);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// abort expected, probably not an error
|
// abort expected, probably not an error
|
||||||
|
|
|
@ -48,7 +48,12 @@ function start(length, context, attempt = 0) {
|
||||||
|
|
||||||
const newMash = mashes.get(context.room.id);
|
const newMash = mashes.get(context.room.id);
|
||||||
|
|
||||||
context.sendMessage(`Stomp stomp, here's your mash: ${style.bold(style.pink(newMash.anagram))}`, context.room.id);
|
if (context.command === 'conundrum') {
|
||||||
|
context.sendMessage(`Here is your conundrum: ${style.bold(style.pink(newMash.anagram))}`, context.room.id);
|
||||||
|
} else {
|
||||||
|
context.sendMessage(`Stomp stomp, here's your mash: ${style.bold(style.pink(newMash.anagram))}`, context.room.id);
|
||||||
|
}
|
||||||
|
|
||||||
context.logger.info(`Mash started, '${anagram}' with answers ${answers.map((answer) => `'${answer.word}'`).join(', ')}`);
|
context.logger.info(`Mash started, '${anagram}' with answers ${answers.map((answer) => `'${answer.word}'`).join(', ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +198,11 @@ function onCommand(args, context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.command === 'conundrum') {
|
||||||
|
start(9, context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Number.isNaN(length)) {
|
if (!Number.isNaN(length)) {
|
||||||
start(length, context);
|
start(length, context);
|
||||||
return;
|
return;
|
||||||
|
@ -221,7 +231,7 @@ function onMessage(message, context) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'Mash',
|
name: 'Mash',
|
||||||
commands: ['mash', 'wordmash', ...defineCommands, ...resolveCommands],
|
commands: ['mash', 'wordmash', 'conundrum', ...defineCommands, ...resolveCommands],
|
||||||
onCommand,
|
onCommand,
|
||||||
onMessage,
|
onMessage,
|
||||||
help: `Resolve the anagram. Get a new mash with ${config.prefix}mash [length], look up definitions with ${config.prefix}define [word], resolve an anagram (that's not currently in play) with ${config.prefix}solve [anagram].`,
|
help: `Resolve the anagram. Get a new mash with ${config.prefix}mash [length], look up definitions with ${config.prefix}define [word], resolve an anagram (that's not currently in play) with ${config.prefix}solve [anagram].`,
|
||||||
|
|
|
@ -365,7 +365,7 @@ function onMessage(message, context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game?.state === 'solutions') {
|
if (game?.state === 'solutions' && body.match(/\d+/g)?.length > 1) {
|
||||||
playSolution(body, context);
|
playSolution(body, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue