Compare commits
3 Commits
f1c5b8afda
...
19fb233d8a
Author | SHA1 | Date |
---|---|---|
|
19fb233d8a | |
|
802639d830 | |
|
91c99428ff |
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.3",
|
"version": "1.7.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.7.3",
|
"version": "1.7.4",
|
||||||
"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.3",
|
"version": "1.7.4",
|
||||||
"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": {
|
||||||
|
|
|
@ -254,7 +254,7 @@ function getGames(bot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleError(error, socket, domain, data) {
|
function handleError(error, socket, domain, data) {
|
||||||
logger.error(`${domain} '${JSON.stringify(data)}' triggered error: ${error.message}`);
|
logger.error(`${domain} '${JSON.stringify(data)}' triggered error: ${error.message} ${error.stack}`);
|
||||||
|
|
||||||
if (data?.roomId) {
|
if (data?.roomId) {
|
||||||
socket.transmit('message', {
|
socket.transmit('message', {
|
||||||
|
|
|
@ -33,6 +33,16 @@ function scoreRound(context, round) {
|
||||||
}).filter(Boolean).join(', ');
|
}).filter(Boolean).join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLeaders() {
|
||||||
|
return Object.entries(game.points).sort(([, scoreA], [, scoreB]) => scoreB - scoreA).map(([username, score], index) => {
|
||||||
|
if (index === 0) {
|
||||||
|
return `**@${username}** with **${score}** points`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `**@${username}** with **${score}** points`;
|
||||||
|
}).join(', ');
|
||||||
|
}
|
||||||
|
|
||||||
async function playRound(context, round = 0) {
|
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();
|
||||||
|
@ -74,7 +84,7 @@ async function playRound(context, round = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.stopped) {
|
if (game.stopped) {
|
||||||
context.sendMessage(`The game was stopped by @${game.stopped.username}. The answer to the last question was: **${question.answer}**`, context.room.id);
|
context.sendMessage(`The game was stopped by @${game.stopped.username}. The answer to the last question was: **${question.answer}**. Best players: ${getLeaders()}`, context.room.id);
|
||||||
game = null;
|
game = null;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -98,7 +108,7 @@ async function playRound(context, round = 0) {
|
||||||
await timers.setTimeout(5000);
|
await timers.setTimeout(5000);
|
||||||
|
|
||||||
if (game.stopped) {
|
if (game.stopped) {
|
||||||
context.sendMessage(`The game was stopped by ${game.stopped.username}`, context.room.id);
|
context.sendMessage(`The game was stopped by @${game.stopped.username}. The answer to the last question was: **${question.answer}**. Best players: ${getLeaders()}`, context.room.id);
|
||||||
game = null;
|
game = null;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -110,15 +120,7 @@ async function playRound(context, round = 0) {
|
||||||
|
|
||||||
await timers.setTimeout(2000);
|
await timers.setTimeout(2000);
|
||||||
|
|
||||||
const leaders = Object.entries(game.points).sort(([, scoreA], [, scoreB]) => scoreB - scoreA).map(([username, score], index) => {
|
context.sendMessage(`That's the end of the game! Best players: ${getLeaders()}`, context.room.id);
|
||||||
if (index === 0) {
|
|
||||||
return `**@${username}** with **${score}** points`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `**@${username}** with **${score}** points`;
|
|
||||||
}).join(', ');
|
|
||||||
|
|
||||||
context.sendMessage(`That's the end of the game! Best players: ${leaders}`, context.room.id);
|
|
||||||
|
|
||||||
game = null;
|
game = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue