Added leaderboard.
This commit is contained in:
@@ -44,28 +44,29 @@ function start(length, context, attempt = 0) {
|
||||
|
||||
function play(word, context) {
|
||||
if (word.length !== mash.key.length) {
|
||||
context.sendMessage(`Your answer needs to be ${mash.key.length} letters, ${context.user.username}`, context.room.id);
|
||||
context.sendMessage(`Your answer needs to be ${mash.key.length} letters, @${context.user.username}`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
const key = word.split('').sort().join('');
|
||||
|
||||
if (key !== mash.key) {
|
||||
context.sendMessage(`You are not using the letters in **${mash.anagram}**, ${context.user.username}`, context.room.id);
|
||||
context.sendMessage(`You are not using the letters in **${mash.anagram}**, @${context.user.username}`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (word === mash.anagram) {
|
||||
context.sendMessage(`${context.user.username}... :expressionless:`, context.room.id);
|
||||
context.sendMessage(`@${context.user.username}... :expressionless:`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mash.answers.includes(word)) {
|
||||
context.sendMessage(mash.answers.length === 1
|
||||
? `**${word}** is the right answer, ${context.user.username}! There were no other options for **${mash.anagram}**.`
|
||||
: `**${word}** is the right answer, ${context.user.username}! Other options for **${mash.anagram}**: ${mash.answers.filter((answer) => answer !== word).map((word) => `**${word}**`).join(', ')}`, context.room.id);
|
||||
? `**${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((word) => `**${word}**`).join(', ')}`, context.room.id);
|
||||
|
||||
context.logger.info(`Mash '${mash.anagram}' guessed by '${context.user.username}' with '${word}'`);
|
||||
context.setPoints(context.user, 1);
|
||||
|
||||
mash = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user