Added hints to Trivia. Curated Joepardy answers to be more lenient.

This commit is contained in:
2021-11-14 17:56:07 +01:00
parent 5e36eff8f5
commit 220f4fe727
70 changed files with 2424700 additions and 7 deletions

View File

@@ -54,11 +54,26 @@ async function playRound(context, round = 0) {
context.logger.info(`Trivia asked "${question.question}" with answer: ${question.answer}`);
try {
await timers.setTimeout(game.timeout * 1000, null, {
await timers.setTimeout((game.timeout / 3) * 1000, null, {
signal: ac.signal,
});
// 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 round ${round + 1}/${game.questions.length}: ${question.answer.replace(/\s/g, '').replace(/[^\s]/g, '_ ')}`, context.room.id);
await timers.setTimeout((game.timeout / 3) * 1000, null, {
signal: ac.signal,
});
if (question.answer.length > 3) {
context.sendMessage(`**${Math.floor(game.timeout / 3)} seconds** left, second hint for round ${round + 1}/${game.questions.length}: **${question.answer.slice(0, 1)} ${question.answer.slice(1).replace(/\s/g, '').replace(/[^\s]/g, '_ ')}${question.answer.slice(-1)}**`, context.room.id);
}
await timers.setTimeout((game.timeout / 3) * 1000, null, {
signal: ac.signal,
});
} catch (error) {
// abort expected, not an error
// abort expected, probably not an error
}
if (!ac.signal.aborted) {
@@ -78,7 +93,7 @@ async function playRound(context, round = 0) {
const scores = scoreRound(context, round);
if (game.mode === 'first') {
context.sendMessage(`**${question.answer}** is the right answer, played in **${((new Date() - now) / 1000).toFixed(3)}s**! ${scores}`, context.room.id);
context.sendMessage(`**${question.fullAnswer || question.answer}** is the right answer, played in **${((new Date() - now) / 1000).toFixed(3)}s**! ${scores}`, context.room.id);
}
if (game.mode === 'timeout') {
@@ -141,7 +156,7 @@ function onCommand(args, context) {
}
if (!context.subcommand && game) {
context.sendMessage(`There is already a game going on! The current question for round ${game.round + 1} is: ${game.questions[game.round].question}`, context.room.id);
context.sendMessage(`There is already a game going on! Use ${config.prefix}trivia:stop to reset. The current question for round ${game.round + 1} is: ${game.questions[game.round].question}`, context.room.id);
return;
}
@@ -155,7 +170,7 @@ function onCommand(args, context) {
const subcommand = context.subcommand?.toLowerCase();
if (subcommand) {
if (subcommand && settings[subcommand]) {
settings[subcommand] = typeof settings[subcommand] === 'number' ? (Number(args[0]) || settings[subcommand]) : args[0];
context.sendMessage(`${subcommand} set to ${settings[subcommand]}`, context.room.id);