Compare commits

...

3 Commits

Author SHA1 Message Date
ThePendulum cb023f0c28 1.5.14 2021-11-15 23:59:34 +01:00
ThePendulum 3f2ec8abb9 Fixed bold markup in Trivia. 2021-11-15 23:59:31 +01:00
ThePendulum 3fe4cb4292 Added hints to wordmash. 2021-11-15 23:57:16 +01:00
4 changed files with 28 additions and 4 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "schat2-clive", "name": "schat2-clive",
"version": "1.5.13", "version": "1.5.14",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "schat2-clive", "name": "schat2-clive",
"version": "1.5.13", "version": "1.5.14",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"bhttp": "^1.2.8", "bhttp": "^1.2.8",

View File

@ -1,6 +1,6 @@
{ {
"name": "schat2-clive", "name": "schat2-clive",
"version": "1.5.13", "version": "1.5.14",
"description": "Game host for SChat 2-powered chat sites", "description": "Game host for SChat 2-powered chat sites",
"main": "src/app.js", "main": "src/app.js",
"scripts": { "scripts": {

View File

@ -129,6 +129,25 @@ function define(word, context) {
context.sendMessage(`No definition available for **${word}**, @${context.user.username}`, context.room.id); context.sendMessage(`No definition available for **${word}**, @${context.user.username}`, context.room.id);
} }
function hint(context) {
if (!mash) {
context.sendMessage(`There is no mash going on right now, @${context.user.username}. Start one with ${config.prefix}mash {length}`, context.room.id);
return;
}
if (mash.anagram.length <= 3) {
context.sendMessage(`The mash **${mash.anagram}** is too short for a hint, @${context.user.username}.`, context.room.id);
return;
}
if (mash.anagram.length === 4) {
context.sendMessage(`Hints for **${mash.anagram}**, @${context.user.username}: ${mash.answers.map((answer) => `**${answer.word.slice(0, 1)} ${'_ '.repeat(answer.word.length - 1).trim()}**`).join(', ')}`, context.room.id);
return;
}
context.sendMessage(`Hints for **${mash.anagram}**, @${context.user.username}: ${mash.answers.map((answer) => `**${answer.word.slice(0, 1)} ${'_ '.repeat(answer.word.length - 2)}${answer.word.slice(-1)}**`).join(', ')}`, context.room.id);
}
function onCommand(args, context) { function onCommand(args, context) {
const word = args[0]; const word = args[0];
const length = Number(word); const length = Number(word);
@ -143,6 +162,11 @@ function onCommand(args, context) {
return; return;
} }
if (['hint'].includes(context.subcommand)) {
hint(context);
return;
}
if (!Number.isNaN(length)) { if (!Number.isNaN(length)) {
start(length, context); start(length, context);
return; return;

View File

@ -47,7 +47,7 @@ async function playRound(context, round = 0) {
}); });
// replace space with U+2003 Em Space to separate words, since a single space separates the placeholders, and double spaces are removed during Markdown render // replace space with U+2003 Em Space to separate words, since a single space separates the placeholders, and double spaces are removed during Markdown render
context.sendMessage(`**${Math.floor(game.timeout / 3) * 2} seconds** left, first hint for **question ${round + 1}/${game.questions.length}**: ${question.answer.slice(0, 1)} ${question.answer.slice(1).replace(/\s/g, '').replace(/[^\s]/g, '_ ')}`, context.room.id); context.sendMessage(`**${Math.floor(game.timeout / 3) * 2} seconds** left, first hint for **question ${round + 1}/${game.questions.length}**: **${question.answer.slice(0, 1)} ${question.answer.slice(1).replace(/\s/g, '').replace(/[^\s]/g, '_ ').trim()}**`, context.room.id);
await timers.setTimeout((game.timeout / 3) * 1000, null, { await timers.setTimeout((game.timeout / 3) * 1000, null, {
signal: ac.signal, signal: ac.signal,