Updated SChat color styling. Censoring answers in Mash hints. Restored Letters board.
This commit is contained in:
@@ -22,7 +22,7 @@ const games = new Map();
|
||||
function getBoard(context) {
|
||||
const game = games.get(context.room.id);
|
||||
|
||||
return `${style.grey('[')} ${game.word.split('').concat(Array.from({ length: config.letters.length - game.word.length })).map((letter) => style.bold(letter?.toUpperCase()) || ' ').join(style.grey(' | '))} ${style.grey(']')}`; // eslint-disable-line no-irregular-whitespace
|
||||
return `${style.grey('[')}${game.word.split('').concat(Array.from({ length: config.letters.length - game.word.length })).map((letter) => style.bold(letter?.toUpperCase()) || ' ').join(style.grey('|'))}${style.grey(']')}`; // eslint-disable-line no-irregular-whitespace
|
||||
}
|
||||
|
||||
function countLetters(word) {
|
||||
|
||||
@@ -142,6 +142,16 @@ function define(word, context) {
|
||||
context.sendMessage(`No definition available for ${style.bold(word)}, ${config.usernamePrefix}${context.user.username}`, context.room.id);
|
||||
}
|
||||
|
||||
function sanitizeDefinition(definition, answers) {
|
||||
return definition.replaceAll(/\w+/g, (word) => {
|
||||
if (answers.some((answer) => answer.word.includes(word))) {
|
||||
return '*'.repeat(word.length);
|
||||
}
|
||||
|
||||
return word;
|
||||
});
|
||||
}
|
||||
|
||||
function hint(context) {
|
||||
const mash = mashes.get(context.room.id);
|
||||
|
||||
@@ -156,11 +166,11 @@ function hint(context) {
|
||||
}
|
||||
|
||||
if (mash.anagram.length === 4) {
|
||||
context.sendMessage(`Hints for ${style.bold(style.pink(mash.anagram))}, ${config.usernamePrefix}${context.user.username}: ${mash.answers.map((answer) => `${style.bold(`${answer.word.slice(0, 1)} ${'_ '.repeat(answer.word.length - 1).trim()}`)} (${answer.definitions[0]})`).join(', ')}`, context.room.id);
|
||||
context.sendMessage(`Hints for ${style.bold(style.pink(mash.anagram))}, ${config.usernamePrefix}${context.user.username}: ${mash.answers.map((answer) => `${style.bold(`${answer.word.slice(0, 1)} ${'_ '.repeat(answer.word.length - 1).trim()}`)} (${sanitizeDefinition(answer.definitions[0], mash.answers)})`).join(', ')}`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
context.sendMessage(`Hints for ${style.bold(mash.anagram)}, ${config.usernamePrefix}${context.user.username}: ${mash.answers.map((answer) => `${style.bold(`${answer.word.slice(0, 1)} ${'_ '.repeat(answer.word.length - 2)}${answer.word.slice(-1)}`)} (${answer.definitions[0]})`).join(', ')}`, context.room.id);
|
||||
context.sendMessage(`Hints for ${style.bold(mash.anagram)}, ${config.usernamePrefix}${context.user.username}: ${mash.answers.map((answer) => `${style.bold(`${answer.word.slice(0, 1)} ${'_ '.repeat(answer.word.length - 2)}${answer.word.slice(-1)}`)} (${sanitizeDefinition(answer.definitions[0], mash.answers)})`).join(', ')}`, context.room.id);
|
||||
}
|
||||
|
||||
function onCommand(args, context) {
|
||||
@@ -194,7 +204,7 @@ function onCommand(args, context) {
|
||||
}
|
||||
|
||||
if (!word || !mash) {
|
||||
context.sendMessage(`Start a mash with ${config.prefix}mash [length]`, context.room.id);
|
||||
context.sendMessage(`Start a mash with ${config.prefix}mash [length]`, context.room.id, { styleCommands: true });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ function schatItalic(text) {
|
||||
}
|
||||
|
||||
function schatColor(text, color) {
|
||||
return `<span style="color: ${color}">${text}</span>`;
|
||||
return `{${color}}(${text})`;
|
||||
}
|
||||
|
||||
function curate(fn) {
|
||||
|
||||
Reference in New Issue
Block a user