Compare commits
2 Commits
556540e7ec
...
f1c5b8afda
Author | SHA1 | Date |
---|---|---|
|
f1c5b8afda | |
|
6bc1048a90 |
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "schat2-clive",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bhttp": "^1.2.8",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "schat2-clive",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.3",
|
||||
"description": "Game host for SChat 2-powered chat sites",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -17,11 +17,11 @@ const help = {
|
|||
let game = null;
|
||||
|
||||
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 game.answers.map(({ user }) => {
|
||||
return Array.from(game.answers.values()).map(({ user }) => {
|
||||
if (user) {
|
||||
context.setPoints(user, 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 now = new Date();
|
||||
|
||||
game.answers = [];
|
||||
game.answers = new Map();
|
||||
game.round = round;
|
||||
game.ac = ac;
|
||||
|
||||
|
@ -80,7 +80,7 @@ async function playRound(context, round = 0) {
|
|||
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);
|
||||
} else {
|
||||
const scores = scoreRound(context, round);
|
||||
|
@ -185,8 +185,8 @@ async function onMessage(message, context) {
|
|||
|
||||
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 &
|
||||
game.answers.push({
|
||||
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.set(context.user.id, {
|
||||
user: context.user,
|
||||
answer: message.body,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue