Compare commits
3 Commits
dc8830feea
...
59594ae255
Author | SHA1 | Date |
---|---|---|
|
59594ae255 | |
|
2daf52477d | |
|
6831330e35 |
|
@ -24,6 +24,10 @@ module.exports = {
|
|||
mode: 'first', // first or timeout
|
||||
rounds: 10,
|
||||
timeout: 60,
|
||||
bounds: {
|
||||
rounds: [1, 30],
|
||||
timeout: [5, 300],
|
||||
},
|
||||
},
|
||||
duck: {
|
||||
interval: [10, 3600], // seconds
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "schat2-clive",
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bhttp": "^1.2.8",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.3",
|
||||
"description": "Game host for SChat 2-powered chat sites",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -7,6 +7,9 @@ const words = require('../../assets/mash-words.json');
|
|||
|
||||
const mashes = new Map();
|
||||
|
||||
const defineCommands = ['define', 'dict', 'dictionary'];
|
||||
const resolveCommands = ['solve', 'resolve', 'lookup'];
|
||||
|
||||
function getWordKey(word) {
|
||||
return word.split('').sort().join('');
|
||||
}
|
||||
|
@ -97,8 +100,14 @@ function resolve(word, context) {
|
|||
return;
|
||||
}
|
||||
|
||||
const anagram = getWordKey(word);
|
||||
const answers = words[word.length]?.[anagram];
|
||||
const anagramKey = getWordKey(word);
|
||||
const answers = words[word.length]?.[anagramKey];
|
||||
|
||||
if (mashes.get(context.room.id)?.key === anagramKey) {
|
||||
context.sendMessage(`Nice try, ${config.usernamePrefix}${context.user.username}. Starting a new mash will cancel the current one, and reveal the answer.`, context.room.id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (answers?.length > 1 && answers.some((answer) => answer.word === word)) {
|
||||
context.sendMessage(`${style.bold(word)} is a valid word in itself, and has the following anagrams, ${config.usernamePrefix}${context.user.username}: ${answers.filter((answer) => answer.word !== word).map((answer) => style.italic(answer.word)).join(', ')}`, context.room.id);
|
||||
|
@ -129,7 +138,7 @@ function define(word, context) {
|
|||
const answer = answers?.find((answerX) => answerX.word === word);
|
||||
|
||||
if (answer && answer.definitions?.length > 0) {
|
||||
context.sendMessage(`${word} can be defined as follows, ${config.usernamePrefix}${context.user.username}: ${style.italic(answer.definitions[0])}`, context.room.id);
|
||||
context.sendMessage(`${style.bold(word)} can be defined as follows, ${config.usernamePrefix}${context.user.username}: ${style.italic(answer.definitions[0])}`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -162,12 +171,12 @@ function onCommand(args, context) {
|
|||
const word = args[0];
|
||||
const length = Number(word);
|
||||
|
||||
if (['solve', 'resolve', 'lookup'].includes(context.subcommand)) {
|
||||
if (resolveCommands.includes(context.command) || resolveCommands.includes(context.subcommand)) {
|
||||
resolve(word, context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (['define', 'dict', 'dictionary'].includes(context.subcommand)) {
|
||||
if (defineCommands.includes(context.command) || defineCommands.includes(context.subcommand)) {
|
||||
define(word, context);
|
||||
return;
|
||||
}
|
||||
|
@ -205,6 +214,7 @@ function onMessage(message, context) {
|
|||
|
||||
module.exports = {
|
||||
name: 'Mash',
|
||||
commands: ['mash', ...defineCommands, ...resolveCommands],
|
||||
onCommand,
|
||||
onMessage,
|
||||
};
|
||||
|
|
|
@ -182,7 +182,19 @@ function onCommand(args, context) {
|
|||
|
||||
if (subcommand && settings[subcommand]) {
|
||||
if (args[0]) {
|
||||
settings[subcommand] = typeof settings[subcommand] === 'number' ? (Number(args[0]) || settings[subcommand]) : args[0];
|
||||
const bounds = config.trivia.bounds[subcommand];
|
||||
const curatedSetting = typeof settings[subcommand] === 'number' ? Number(args[0]) : args[0];
|
||||
|
||||
if (Number.isNaN(curatedSetting)) {
|
||||
context.sendMessage(`${subcommand} must be a valid number`, context.room.id);
|
||||
}
|
||||
|
||||
if (Array.isArray(bounds) && typeof settings[subcommand] === 'number' && (curatedSetting < bounds[0] || curatedSetting > bounds[1])) {
|
||||
context.sendMessage(`${subcommand} must be between ${bounds[0]} and ${bounds[1]}`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
settings[subcommand] = curatedSetting;
|
||||
|
||||
context.sendMessage(`${subcommand} set to ${settings[subcommand]}`, context.room.id);
|
||||
} else if (help[subcommand]) {
|
||||
|
|
Loading…
Reference in New Issue