Added larger mash dictionary with definitions.
This commit is contained in:
19
src/games/cursed.js
Normal file
19
src/games/cursed.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
const packs = require('../../assets/cah-cards-full.json');
|
||||
|
||||
function start() {
|
||||
const blackCards = packs.map((pack) => pack.black).flat();
|
||||
const whiteCards = packs.map((pack) => pack.white).flat();
|
||||
|
||||
console.log(blackCards, whiteCards);
|
||||
}
|
||||
|
||||
function onCommand() {
|
||||
start();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'Cursed Cards',
|
||||
onCommand,
|
||||
};
|
||||
@@ -16,7 +16,7 @@ function start(length, context, attempt = 0) {
|
||||
}
|
||||
|
||||
if (mash) {
|
||||
context.sendMessage(`The mash **${mash.anagram}** was not guessed, possible answers: ${mash.answers.map((answer) => `**${answer}**`).join(', ')}`, context.room.id);
|
||||
context.sendMessage(`The mash **${mash.anagram}** was not guessed, possible answers: ${mash.answers.map((answer) => `**${answer.word}**`).join(', ')}`, context.room.id);
|
||||
context.logger.info(`Mash '${mash.anagram}' discarded`);
|
||||
|
||||
mash = null;
|
||||
@@ -27,7 +27,7 @@ function start(length, context, attempt = 0) {
|
||||
|
||||
const anagram = key.split('').sort(() => (Math.random() > 0.5 ? 1 : -1)).join('');
|
||||
|
||||
if (answers.includes(anagram)) {
|
||||
if (answers.some((answer) => answer.word === anagram)) {
|
||||
if (attempt >= 10) {
|
||||
context.sendMessage(`Sorry, I did not find a mashable ${length}-letter word`);
|
||||
return;
|
||||
@@ -41,7 +41,7 @@ function start(length, context, attempt = 0) {
|
||||
mash = { key, anagram, answers };
|
||||
|
||||
context.sendMessage(`Stomp stomp, here's your mash: **${mash.anagram}**`, context.room.id);
|
||||
context.logger.info(`Mash started, '${anagram}' with answers ${answers.map((answer) => `'${answer}'`).join(', ')}`);
|
||||
context.logger.info(`Mash started, '${anagram}' with answers ${answers.map((answer) => `'${answer.word}'`).join(', ')}`);
|
||||
}
|
||||
|
||||
function play(word, context) {
|
||||
@@ -62,10 +62,12 @@ function play(word, context) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mash.answers.includes(word)) {
|
||||
if (mash.answers.some((answer) => answer.word === word)) {
|
||||
const definition = mash.answers[0].definitions[0] ? `: *${mash.answers[0].definitions[0].slice(0, 100)}${mash.answers[0].definitions[0].length > 100 ? '...*' : '*'}` : '';
|
||||
|
||||
context.sendMessage(mash.answers.length === 1
|
||||
? `**${word}** is the right answer, @${context.user.username} now has **${context.user.points + 1} ${context.user.points === 0 ? 'point' : 'points'}**! There were no other options for **${mash.anagram}**.`
|
||||
: `**${word}** is the right answer, @${context.user.username} now has **${context.user.points + 1} ${context.user.points === 0 ? 'point' : 'points'}**! Other options for **${mash.anagram}**: ${mash.answers.filter((answer) => answer !== word).map((answer) => `**${answer}**`).join(', ')}`, context.room.id);
|
||||
? `**${word}** is the right answer${definition}, @${context.user.username} now has **${context.user.points + 1} ${context.user.points === 0 ? 'point' : 'points'}**! There were no other options for **${mash.anagram}**.`
|
||||
: `**${word}** is the right answer${definition}, @${context.user.username} now has **${context.user.points + 1} ${context.user.points === 0 ? 'point' : 'points'}**! Other options for **${mash.anagram}**: ${mash.answers.filter((answer) => answer.word !== word).map((answer) => `*${answer.word}*`).join(', ')}`, context.room.id);
|
||||
|
||||
context.logger.info(`Mash '${mash.anagram}' guessed by '${context.user.username}' with '${word}'`);
|
||||
context.setPoints(context.user, 1);
|
||||
|
||||
Reference in New Issue
Block a user