Compare commits
2 Commits
556540e7ec
...
f1c5b8afda
Author | SHA1 | Date |
---|---|---|
|
f1c5b8afda | |
|
6bc1048a90 |
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.2",
|
"version": "1.7.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.2",
|
"version": "1.7.3",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bhttp": "^1.2.8",
|
"bhttp": "^1.2.8",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.2",
|
"version": "1.7.3",
|
||||||
"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": {
|
||||||
|
|
|
@ -17,11 +17,11 @@ const help = {
|
||||||
let game = null;
|
let game = null;
|
||||||
|
|
||||||
function scoreRound(context, round) {
|
function scoreRound(context, round) {
|
||||||
if (game.answers.length === 0) {
|
if (game.answers.size === 0) {
|
||||||
return `No one scored in round ${round + 1}, better luck next time!`;
|
return `No one scored in round ${round + 1}, better luck next time!`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return game.answers.map(({ user }) => {
|
return Array.from(game.answers.values()).map(({ user }) => {
|
||||||
if (user) {
|
if (user) {
|
||||||
context.setPoints(user, 1);
|
context.setPoints(user, 1);
|
||||||
game.points[user.username] = (game.points[user.username] || 0) + 1;
|
game.points[user.username] = (game.points[user.username] || 0) + 1;
|
||||||
|
@ -37,7 +37,7 @@ async function playRound(context, round = 0) {
|
||||||
const ac = new AbortController(); // eslint-disable-line no-undef
|
const ac = new AbortController(); // eslint-disable-line no-undef
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
game.answers = [];
|
game.answers = new Map();
|
||||||
game.round = round;
|
game.round = round;
|
||||||
game.ac = ac;
|
game.ac = ac;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ async function playRound(context, round = 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.answers.length === 0) {
|
if (game.answers.size === 0) {
|
||||||
context.sendMessage(`**TIME'S UP!** No one guessed the answer: **${question.answer}**`, context.room.id);
|
context.sendMessage(`**TIME'S UP!** No one guessed the answer: **${question.answer}**`, context.room.id);
|
||||||
} else {
|
} else {
|
||||||
const scores = scoreRound(context, round);
|
const scores = scoreRound(context, round);
|
||||||
|
@ -185,8 +185,8 @@ async function onMessage(message, context) {
|
||||||
|
|
||||||
const { answer, fullAnswer } = game.questions[game.round];
|
const { answer, fullAnswer } = game.questions[game.round];
|
||||||
|
|
||||||
if (new RegExp(answer, 'i').test(decode(message.originalBody || message.body))) { // resolve HTML entities in case original body is not available, such as & to &
|
if (new RegExp(answer, 'i').test(decode(message.originalBody || message.body)) && !game.answers.has(context.user.id)) { // resolve HTML entities in case original body is not available, such as & to &
|
||||||
game.answers.push({
|
game.answers.set(context.user.id, {
|
||||||
user: context.user,
|
user: context.user,
|
||||||
answer: message.body,
|
answer: message.body,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue