Scavengers: Update status command for hosts (#3944)

This commit is contained in:
CheeseMuffin 2017-11-06 18:53:18 -08:00 committed by Guangcong Luo
parent 098f69d94b
commit 218d35aa3d

View File

@ -779,8 +779,27 @@ let commands = {
if (!room.game || !room.game.scavGame) return this.errorReply(`There is no scavenger game currently running.`);
let game = room.game.childGame || room.game;
let elapsed = Date.now() - game.startTime;
this.sendReplyBox(`The current ${game.gameType ? `<em>${game.gameType}</em> ` : ""}scavenger hunt by <em>${Chat.escapeHTML(Chat.toListString(game.hosts.map(h => h.name)))}${(game.hosts.some(h => h.userid === game.staffHostId) ? '' : ` (started by - ${Chat.escapeHTML(game.staffHostName)})`)}</em> has been up for: ${Chat.toDurationString(elapsed, {hhmmss: true})}<br />Completed (${game.completed.length}): ${game.completed.map(u => Chat.escapeHTML(u.name)).join(', ')}<br />`);
if (game.hosts.some(h => h.userid === user.userid) || game.staffHostId === user.userid) {
let str = `<div class="ladder" style="overflow-y: scroll; max-height: 300px;"><table style="width: 100%"><th><b>Question</b></th><th><b>Users on this Question</b></th>`;
for (let i = 0; i < game.questions.length; i++) {
let questionNum = i + 1;
let players = Object.values(game.players).filter(player => player.currentQuestion === i);
if (!players.length) {
str += `<tr><td>${questionNum}</td><td>None</td>`;
} else {
str += Chat.html`<tr><td>${questionNum}</td><td>${players.map(pl => pl.name).join(", ")}`;
}
}
str += Chat.html`<tr><td>Completed</td><td>${game.completed.length ? game.completed.map(pl => pl.name).join(", ") : 'None'}`;
this.sendReply(`|raw|${str}</table></div>`);
} else {
const elapsedMsg = Chat.toDurationString(Date.now() - game.startTime, {hhmmss: true});
const gameTypeMsg = game.gameType ? `<em>${game.gameType}</em> ` : '';
const hostersMsg = Chat.toListString(game.hosts.map(h => h.name));
const hostMsg = game.hosts.some(h => h.userid === game.staffHostId) ? '' : Chat.html` (started by - ${game.staffHostName})`;
const finishers = Chat.html`${game.completed.map(u => u.name).join(', ')}`;
this.sendReplyBox(`The current ${gameTypeMsg}scavenger hunt by <em>${hostersMsg}${hostMsg}</em> has been up for: ${elapsedMsg}<br />Completed (${game.completed.length}): ${finishers}<br />`);
}
},
hint: function (target, room, user) {