From d612aea416fc0e113d3ba23c10c6682bc04b5f57 Mon Sep 17 00:00:00 2001
From: Your Name
+
+ `);
+
+
+ document.getElementById('player-list-group').appendChild(playerItem);
+
+ //ban button if the viewer is the owner and the player is not
+ if (iAmOwner && userId !== ownerId) {
+ const banButton = document.createElement('button');
+ banButton.className = 'btn btn-danger btn-sm mt-2';
+ banButton.innerText = 'Ban';
+
+
+ playerItem.appendChild(banButton);
- playerItem.setAttribute('data-bs-title', username);
- playerItem.setAttribute('data-bs-content', `
-
-
- `);
+
+ banButton.addEventListener('click', () => {
+ console.log(`Banning user ${username} (ID: ${userId})`);
+ socket.send(JSON.stringify({ type: 'ban', ownerId: ownerId, target_user: userId, targ_name: username }));
+ });
+ }
- document.getElementById('player-list-group').appendChild(playerItem);
- // bootstrap requires "new" to be called on each popover
- // eslint-disable-next-line no-new
- new bootstrap.Popover(playerItem);
+ // popover
+ new bootstrap.Popover(playerItem);
}
diff --git a/server/multiplayer/ServerTossupRoom.js b/server/multiplayer/ServerTossupRoom.js
index 8ddb7d132..1d2d923ad 100644
--- a/server/multiplayer/ServerTossupRoom.js
+++ b/server/multiplayer/ServerTossupRoom.js
@@ -22,6 +22,7 @@ export default class ServerTossupRoom extends TossupRoom {
this.getRandomTossups = getRandomTossups;
this.getSet = getSet;
this.getSetList = getSetList;
+ this.bannedUserList = [];
this.rateLimiter = new RateLimit(50, 1000);
this.rateLimitExceeded = new Set();
@@ -37,6 +38,7 @@ export default class ServerTossupRoom extends TossupRoom {
async message (userId, message) {
switch (message.type) {
+ case 'ban': return this.banUser(message.ownerId, message.target_user, message.targ_name);
case 'chat': return this.chat(userId, message);
case 'chat-live-update': return this.chatLiveUpdate(userId, message);
case 'give-answer-live-update': return this.giveAnswerLiveUpdate(userId, message);
@@ -49,6 +51,8 @@ export default class ServerTossupRoom extends TossupRoom {
}
connection (socket, userId, username) {
+
+
console.log(`Connection in room ${HEADER}${this.name}${ENDC} - ID of owner: ${OKBLUE}${this.ownerId}${ENDC} - userId: ${OKBLUE}${userId}${ENDC}, username: ${OKBLUE}${username}${ENDC} - with settings ${OKGREEN}${Object.keys(this.settings).map(key => [key, this.settings[key]].join(': ')).join('; ')};${ENDC}`);
const isNew = !(userId in this.players);
@@ -56,6 +60,11 @@ export default class ServerTossupRoom extends TossupRoom {
this.players[userId].online = true;
this.sockets[userId] = socket;
username = this.players[userId].safelySetUsername(username);
+ if (this.bannedUserList.includes(userId)) {
+ console.log("Banned user " + userId + " (" + username + ") tried to join a room");
+ this.sendToSocket(userId, {type: 'enforcing-ban'})
+ return;
+ }
socket.on('message', message => {
if (this.rateLimiter(socket) && !this.rateLimitExceeded.has(username)) {
@@ -74,6 +83,7 @@ export default class ServerTossupRoom extends TossupRoom {
});
socket.on('close', this.close.bind(this, userId));
+
socket.send(JSON.stringify({
type: 'connection-acknowledged',
@@ -109,6 +119,14 @@ export default class ServerTossupRoom extends TossupRoom {
this.emitMessage({ type: 'join', isNew, userId, username, user: this.players[userId] });
}
+ banUser(ownerId, target_user, target_username) {
+ console.log("Ban request recieved. Target " + target_user);
+ if (this.ownerId === ownerId) {
+ console.log("Checked, owner sent ban");
+ this.emitMessage({ type: 'verified-ban', target: target_user, targetUsername: target_username});
+ this.bannedUserList.push(target_user);
+ }
+ }
owner_id (id) {
console.log("Recieved a owner-id request");
From fffe6d11eb588a34ee27c56ffc54cf2124c57731 Mon Sep 17 00:00:00 2001
From: Your Name
`);
-
- document.getElementById('player-list-group').appendChild(playerItem);
+ document.getElementById('player-list-group').appendChild(playerItem);
+
+ // ban button if the viewer is the owner and the player is not
+ if (iAmOwner && userId !== ownerId) {
+ const banButton = document.createElement('button');
+ banButton.className = 'btn btn-danger btn-sm mt-2';
+ banButton.innerText = 'Ban';
- //ban button if the viewer is the owner and the player is not
- if (iAmOwner && userId !== ownerId) {
- const banButton = document.createElement('button');
- banButton.className = 'btn btn-danger btn-sm mt-2';
- banButton.innerText = 'Ban';
-
-
- playerItem.appendChild(banButton);
+ playerItem.appendChild(banButton);
-
- banButton.addEventListener('click', () => {
- socket.send(JSON.stringify({ type: 'ban', ownerId: ownerId, target_user: userId, targ_name: username }));
- });
- }
+ banButton.addEventListener('click', () => {
+ socket.send(JSON.stringify({ type: 'ban', ownerId, target_user: userId, targ_name: username }));
+ });
+ }
- // popover
- new bootstrap.Popover(playerItem);
+ // bootstrap requires "new" to be called on each popover
+ // eslint-disable-next-line no-new
+ new bootstrap.Popover(playerItem);
}
diff --git a/quizbowl/Player.js b/quizbowl/Player.js
index 2b3c26dc0..ffdfab77c 100644
--- a/quizbowl/Player.js
+++ b/quizbowl/Player.js
@@ -22,8 +22,9 @@ class Player {
}
};
}
- assignOwner() {
- this.owner = true
+
+ assignOwner () {
+ this.owner = true;
}
clearStats () {
diff --git a/routes/api/query.js b/routes/api/query.js
index c41de3c33..7b3df20bc 100644
--- a/routes/api/query.js
+++ b/routes/api/query.js
@@ -67,7 +67,7 @@ router.get('/', async (req, res) => {
try {
const queryResult = await getQuery(req.query);
- res.json(queryResult);
+ res.json(queryResult);
} catch (error) {
switch (error.message) {
case 'Invalid question type specified.':
diff --git a/server/multiplayer/ServerTossupRoom.js b/server/multiplayer/ServerTossupRoom.js
index 1d2d923ad..6e4145cb8 100644
--- a/server/multiplayer/ServerTossupRoom.js
+++ b/server/multiplayer/ServerTossupRoom.js
@@ -15,7 +15,7 @@ import checkAnswer from 'qb-answer-checker';
export default class ServerTossupRoom extends TossupRoom {
constructor (name, ownerId, isPermanent = false, categories = [], subcategories = [], alternateSubcategories = []) {
super(name, categories, subcategories, alternateSubcategories);
- this.ownerId = ownerId
+ this.ownerId = ownerId;
this.isPermanent = isPermanent;
this.checkAnswer = checkAnswer;
this.getNumPackets = getNumPackets;
@@ -45,14 +45,12 @@ export default class ServerTossupRoom extends TossupRoom {
case 'toggle-lock': return this.toggleLock(userId, message);
case 'toggle-login-required': return this.toggleLoginRequired(userId, message);
case 'toggle-public': return this.togglePublic(userId, message);
- case 'owner-id': return this.owner_id(this.ownerId)
+ case 'owner-id': return this.owner_id(this.ownerId);
default: super.message(userId, message);
}
}
connection (socket, userId, username) {
-
-
console.log(`Connection in room ${HEADER}${this.name}${ENDC} - ID of owner: ${OKBLUE}${this.ownerId}${ENDC} - userId: ${OKBLUE}${userId}${ENDC}, username: ${OKBLUE}${username}${ENDC} - with settings ${OKGREEN}${Object.keys(this.settings).map(key => [key, this.settings[key]].join(': ')).join('; ')};${ENDC}`);
const isNew = !(userId in this.players);
@@ -61,10 +59,10 @@ export default class ServerTossupRoom extends TossupRoom {
this.sockets[userId] = socket;
username = this.players[userId].safelySetUsername(username);
if (this.bannedUserList.includes(userId)) {
- console.log("Banned user " + userId + " (" + username + ") tried to join a room");
- this.sendToSocket(userId, {type: 'enforcing-ban'})
+ console.log('Banned user ' + userId + ' (' + username + ') tried to join a room');
+ this.sendToSocket(userId, { type: 'enforcing-ban' });
return;
- }
+ }
socket.on('message', message => {
if (this.rateLimiter(socket) && !this.rateLimitExceeded.has(username)) {
@@ -83,7 +81,6 @@ export default class ServerTossupRoom extends TossupRoom {
});
socket.on('close', this.close.bind(this, userId));
-
socket.send(JSON.stringify({
type: 'connection-acknowledged',
@@ -119,20 +116,22 @@ export default class ServerTossupRoom extends TossupRoom {
this.emitMessage({ type: 'join', isNew, userId, username, user: this.players[userId] });
}
- banUser(ownerId, target_user, target_username) {
- console.log("Ban request recieved. Target " + target_user);
+
+ banUser (ownerId, targetUser, targetUsername) {
+ console.log('Ban request recieved. Target ' + targetUser);
if (this.ownerId === ownerId) {
- console.log("Checked, owner sent ban");
- this.emitMessage({ type: 'verified-ban', target: target_user, targetUsername: target_username});
- this.bannedUserList.push(target_user);
+ console.log('Checked, owner sent ban');
+ this.emitMessage({ type: 'verified-ban', target: targetUser, targetUsername });
+ this.bannedUserList.push(targetUser);
}
}
owner_id (id) {
- console.log("Recieved a owner-id request");
+ console.log('Recieved a owner-id request');
this.emitMessage({ type: 'owner-check', id });
- console.log("Owner check sent");
+ console.log('Owner check sent');
}
+
chat (userId, { message }) {
// prevent chat messages if room is public, since they can still be sent with API
if (this.settings.public || typeof message !== 'string') { return false; }
From 83c1e21b6921233e794bb2fc87ac29b78a796caa Mon Sep 17 00:00:00 2001
From: Your Name
`);
- document.getElementById('player-list-group').appendChild(playerItem);
+ document.getElementById('player-list-group').appendChild(playerItem);
+
+ // ban button if the viewer is the owner and the player is not, also room has to be private
+ if (iAmOwner && userId !== ownerId && !isPublic) {
+ const banButton = document.createElement('button');
+ banButton.className = 'btn btn-danger btn-sm mt-2';
+ banButton.title = 'Ban an user. They can no longer join the room.'
+ banButton.innerText = 'Ban';
+
+ playerItem.appendChild(banButton);
+
+ banButton.addEventListener('click', () => {
+ socket.send(JSON.stringify({ type: 'ban', ownerId, target_user: userId, targ_name: username }));
+ });
+ }
+ let conditionalVK;
+ if (!isPublic) {
+ if (ownerId === userId) {
+ conditionalVK = false;
+ } else {
+ conditionalVK = true;
+ }
+
+ } else {
+ conditionalVK = true;
+ }
+
+ if (userId !== USER_ID && conditionalVK) {
+ const vkButton = document.createElement('button');
+ vkButton.className = 'btn btn-warning btn-sm mt-2';
+ vkButton.title = 'Initiate a votekick on an user. 90 second cooldown.'
+ vkButton.innerText = 'VK';
+
+ playerItem.appendChild(vkButton);
+
+ vkButton.addEventListener('click', () => {
+ socket.send(JSON.stringify({ type: 'votekick-vote', target_user: userId, targ_name: username, send_id: USER_ID }));
+ socket.send(JSON.stringify({ type: 'votekick-init', target_user: userId, targ_name: username, send_id: USER_ID }));
- // ban button if the viewer is the owner and the player is not
- if (iAmOwner && userId !== ownerId) {
- const banButton = document.createElement('button');
- banButton.className = 'btn btn-danger btn-sm mt-2';
- banButton.innerText = 'Ban';
+ vkButton.disabled = true;
+ vkButton.innerText = 'Cooldown';
- playerItem.appendChild(banButton);
+ setTimeout(() => {
+ vkButton.disabled = false;
+ vkButton.innerText = 'VK';
+ }, 90000);
+ });
+ }
- banButton.addEventListener('click', () => {
- socket.send(JSON.stringify({ type: 'ban', ownerId, target_user: userId, targ_name: username }));
- });
- }
- // bootstrap requires "new" to be called on each popover
- // eslint-disable-next-line no-new
- new bootstrap.Popover(playerItem);
+ // bootstrap requires "new" to be called on each popover
+ // eslint-disable-next-line no-new
+ new bootstrap.Popover(playerItem);
}
diff --git a/server/multiplayer/ServerTossupRoom.js b/server/multiplayer/ServerTossupRoom.js
index 6e4145cb8..4df7daa5d 100644
--- a/server/multiplayer/ServerTossupRoom.js
+++ b/server/multiplayer/ServerTossupRoom.js
@@ -12,6 +12,34 @@ import getNumPackets from '../../database/qbreader/get-num-packets.js';
import checkAnswer from 'qb-answer-checker';
+class Votekick {
+ constructor(targName, targId, voted = [], threshold) {
+ this.targName = targName;
+ this.targId = targId;
+ this.voted = Array.isArray(voted) ? voted : [];
+ this.threshold = threshold;
+ }
+ exists(givenId) {
+ if (this.targId === givenId) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ vote(votingId) {
+ if (!this.voted.includes(votingId)) {
+ this.voted.push(votingId);
+ }
+ }
+ check() {
+ if (this.voted.length >= this.threshold) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+}
export default class ServerTossupRoom extends TossupRoom {
constructor (name, ownerId, isPermanent = false, categories = [], subcategories = [], alternateSubcategories = []) {
super(name, categories, subcategories, alternateSubcategories);
@@ -23,7 +51,9 @@ export default class ServerTossupRoom extends TossupRoom {
this.getSet = getSet;
this.getSetList = getSetList;
this.bannedUserList = [];
-
+ this.kickedUserList = [];
+ this.votekickList = [];
+
this.rateLimiter = new RateLimit(50, 1000);
this.rateLimitExceeded = new Set();
this.settings = {
@@ -36,7 +66,8 @@ export default class ServerTossupRoom extends TossupRoom {
this.getSetList().then(setList => { this.setList = setList; });
}
- async message (userId, message) {
+ async message(userId, message) {
+
switch (message.type) {
case 'ban': return this.banUser(message.ownerId, message.target_user, message.targ_name);
case 'chat': return this.chat(userId, message);
@@ -46,10 +77,69 @@ export default class ServerTossupRoom extends TossupRoom {
case 'toggle-login-required': return this.toggleLoginRequired(userId, message);
case 'toggle-public': return this.togglePublic(userId, message);
case 'owner-id': return this.owner_id(this.ownerId);
+ case 'votekick-init': return this.votekickInit(message.target_user, message.targ_name, message.send_id);
+ case 'votekick-vote': return this.votekickVote(message.target_user, message.send_id);
default: super.message(userId, message);
}
}
+ votekickInit(targetId, targetName, sendingId) {
+ if (!this.lastVotekickTime) {
+ this.lastVotekickTime = {};
+ }
+
+ const currentTime = Date.now();
+ if (this.lastVotekickTime[sendingId] && (currentTime - this.lastVotekickTime[sendingId] < 90000)) {
+ console.log(`Votekick denied: ${sendingId} 90 second cooldown viol.`);
+ return;
+ }
+
+ this.lastVotekickTime[sendingId] = currentTime;
+
+ let exists = false;
+ this.votekickList.forEach((votekick) => {
+ if (votekick.exists(targetId)) {
+ exists = true;
+ }
+ });
+ if (exists) {
+ return;
+ }
+
+ let threshold = Math.max((Object.keys(this.players).length) - 1, 0);
+ let votekick = new Votekick(targetName, targetId, [], threshold);
+ votekick.vote(sendingId);
+ if (votekick.check()) {
+ this.emitMessage({ type: 'successful-vk', targetName: votekick.targName, targetId: votekick.targId });
+ this.kickedUserList.push(targetId);
+ } else {
+ this.votekickList.push(votekick);
+ this.emitMessage({ type: 'initiated-vk', targetName: votekick.targName, targetId: votekick.targId, threshold });
+ }
+ console.log(this.votekickList);
+ }
+
+ votekickVote(targetUser, votingId) {
+ let exists = false;
+ let thisVotekick;
+ this.votekickList.forEach((votekick) => {
+ if (votekick.exists(targetUser)) {
+ thisVotekick = votekick;
+ exists = true;
+ }
+ })
+ if (!exists) {
+ return;
+ }
+ thisVotekick.vote(votingId);
+ if (thisVotekick.check()) {
+ this.emitMessage({ type: 'successful-vk', targetName: thisVotekick.targName, targetId: thisVotekick.targId })
+ this.kickedUserList.push(targetUser);
+ }
+ console.log(this.votekickList);
+
+ }
+
connection (socket, userId, username) {
console.log(`Connection in room ${HEADER}${this.name}${ENDC} - ID of owner: ${OKBLUE}${this.ownerId}${ENDC} - userId: ${OKBLUE}${userId}${ENDC}, username: ${OKBLUE}${username}${ENDC} - with settings ${OKGREEN}${Object.keys(this.settings).map(key => [key, this.settings[key]].join(': ')).join('; ')};${ENDC}`);
@@ -63,6 +153,11 @@ export default class ServerTossupRoom extends TossupRoom {
this.sendToSocket(userId, { type: 'enforcing-ban' });
return;
}
+ if (this.kickedUserList.includes(userId)) {
+ console.log('Kicked user ' + userId + ' (' + username + ') tried to join a room');
+ this.sendToSocket(userId, { type: 'enforcing-kick' });
+ return;
+ }
socket.on('message', message => {
if (this.rateLimiter(socket) && !this.rateLimitExceeded.has(username)) {
From 25b5ca6dd9ce2f3825a7faeaa2c99bf7658afab8 Mon Sep 17 00:00:00 2001
From: Your Name
`);
- document.getElementById('player-list-group').appendChild(playerItem);
-
- // ban button if the viewer is the owner and the player is not, also room has to be private
- if (iAmOwner && userId !== ownerId && !isPublic) {
- const banButton = document.createElement('button');
- banButton.className = 'btn btn-danger btn-sm mt-2';
- banButton.title = 'Ban an user. They can no longer join the room.'
- banButton.innerText = 'Ban';
-
- playerItem.appendChild(banButton);
-
- banButton.addEventListener('click', () => {
- socket.send(JSON.stringify({ type: 'ban', ownerId, target_user: userId, targ_name: username }));
- });
- }
- let conditionalVK;
- if (!isPublic) {
- if (ownerId === userId) {
- conditionalVK = false;
- } else {
- conditionalVK = true;
- }
-
+ document.getElementById('player-list-group').appendChild(playerItem);
+
+ // ban button if the viewer is the owner and the player is not, also room has to be private
+ if (iAmOwner && userId !== ownerId && !isPublic) {
+ const banButton = document.createElement('button');
+ banButton.className = 'btn btn-danger btn-sm mt-2';
+ banButton.title = 'Ban an user. They can no longer join the room.';
+ banButton.innerText = 'Ban';
+
+ playerItem.appendChild(banButton);
+
+ banButton.addEventListener('click', () => {
+ socket.send(JSON.stringify({ type: 'ban', ownerId, target_user: userId, targ_name: username }));
+ });
+ }
+ let conditionalVK;
+ if (!isPublic) {
+ if (ownerId === userId) {
+ conditionalVK = false;
} else {
- conditionalVK = true;
+ conditionalVK = true;
}
+ } else {
+ conditionalVK = true;
+ }
- if (userId !== USER_ID && conditionalVK) {
- const vkButton = document.createElement('button');
- vkButton.className = 'btn btn-warning btn-sm mt-2';
- vkButton.title = 'Initiate a votekick on an user. 90 second cooldown.'
- vkButton.innerText = 'VK';
-
- playerItem.appendChild(vkButton);
+ if (userId !== USER_ID && conditionalVK) {
+ const vkButton = document.createElement('button');
+ vkButton.className = 'btn btn-warning btn-sm mt-2';
+ vkButton.title = 'Initiate a votekick on an user. 90 second cooldown.';
+ vkButton.innerText = 'VK';
- vkButton.addEventListener('click', () => {
- socket.send(JSON.stringify({ type: 'votekick-vote', target_user: userId, targ_name: username, send_id: USER_ID }));
- socket.send(JSON.stringify({ type: 'votekick-init', target_user: userId, targ_name: username, send_id: USER_ID }));
+ playerItem.appendChild(vkButton);
- vkButton.disabled = true;
- vkButton.innerText = 'Cooldown';
+ vkButton.addEventListener('click', () => {
+ socket.send(JSON.stringify({ type: 'votekick-vote', target_user: userId, targ_name: username, send_id: USER_ID }));
+ socket.send(JSON.stringify({ type: 'votekick-init', target_user: userId, targ_name: username, send_id: USER_ID }));
- setTimeout(() => {
- vkButton.disabled = false;
- vkButton.innerText = 'VK';
- }, 90000);
- });
- }
+ vkButton.disabled = true;
+ vkButton.innerText = 'Cooldown';
+ setTimeout(() => {
+ vkButton.disabled = false;
+ vkButton.innerText = 'VK';
+ }, 90000);
+ });
+ }
- // bootstrap requires "new" to be called on each popover
- // eslint-disable-next-line no-new
- new bootstrap.Popover(playerItem);
+ // bootstrap requires "new" to be called on each popover
+ // eslint-disable-next-line no-new
+ new bootstrap.Popover(playerItem);
}
diff --git a/quizbowl/TossupRoom.js b/quizbowl/TossupRoom.js
index 2887969d7..d3c1029ee 100644
--- a/quizbowl/TossupRoom.js
+++ b/quizbowl/TossupRoom.js
@@ -85,12 +85,9 @@ export default class TossupRoom extends Room {
case 'buzz': return this.buzz(userId, message);
case 'clear-stats': return this.clearStats(userId, message);
case 'give-answer': return this.giveAnswer(userId, message);
-
case 'next':
case 'skip':
- case 'start':
- return this.next(userId, message);
-
+ case 'start': return this.next(userId, message);
case 'pause': return this.pause(userId, message);
case 'set-categories': return this.setCategories(userId, message);
case 'set-difficulties': return this.setDifficulties(userId, message);
@@ -411,7 +408,7 @@ export default class TossupRoom extends Room {
// calculate time needed before reading next word
let time = Math.log(word.length) + 1;
if ((word.endsWith('.') && word.charCodeAt(word.length - 2) > 96 && word.charCodeAt(word.length - 2) < 123) ||
- word.slice(-2) === '.\u201d' || word.slice(-2) === '!\u201d' || word.slice(-2) === '?\u201d') {
+ word.slice(-2) === '.\u201d' || word.slice(-2) === '!\u201d' || word.slice(-2) === '?\u201d') {
time += 2;
} else if (word.endsWith(',') || word.slice(-2) === ',\u201d') {
time += 0.75;
diff --git a/server/multiplayer/ServerTossupRoom.js b/server/multiplayer/ServerTossupRoom.js
index 4df7daa5d..691a49b8b 100644
--- a/server/multiplayer/ServerTossupRoom.js
+++ b/server/multiplayer/ServerTossupRoom.js
@@ -13,32 +13,34 @@ import getNumPackets from '../../database/qbreader/get-num-packets.js';
import checkAnswer from 'qb-answer-checker';
class Votekick {
- constructor(targName, targId, voted = [], threshold) {
+ constructor (targName, targId, voted = [], threshold) {
this.targName = targName;
this.targId = targId;
this.voted = Array.isArray(voted) ? voted : [];
this.threshold = threshold;
}
- exists(givenId) {
+
+ exists (givenId) {
if (this.targId === givenId) {
return true;
} else {
return false;
}
}
- vote(votingId) {
+
+ vote (votingId) {
if (!this.voted.includes(votingId)) {
this.voted.push(votingId);
}
}
- check() {
+
+ check () {
if (this.voted.length >= this.threshold) {
return true;
} else {
return false;
}
}
-
}
export default class ServerTossupRoom extends TossupRoom {
constructor (name, ownerId, isPermanent = false, categories = [], subcategories = [], alternateSubcategories = []) {
@@ -53,7 +55,7 @@ export default class ServerTossupRoom extends TossupRoom {
this.bannedUserList = [];
this.kickedUserList = [];
this.votekickList = [];
-
+
this.rateLimiter = new RateLimit(50, 1000);
this.rateLimitExceeded = new Set();
this.settings = {
@@ -66,8 +68,7 @@ export default class ServerTossupRoom extends TossupRoom {
this.getSetList().then(setList => { this.setList = setList; });
}
- async message(userId, message) {
-
+ async message (userId, message) {
switch (message.type) {
case 'ban': return this.banUser(message.ownerId, message.target_user, message.targ_name);
case 'chat': return this.chat(userId, message);
@@ -83,7 +84,7 @@ export default class ServerTossupRoom extends TossupRoom {
}
}
- votekickInit(targetId, targetName, sendingId) {
+ votekickInit (targetId, targetName, sendingId) {
if (!this.lastVotekickTime) {
this.lastVotekickTime = {};
}
@@ -106,8 +107,8 @@ export default class ServerTossupRoom extends TossupRoom {
return;
}
- let threshold = Math.max((Object.keys(this.players).length) - 1, 0);
- let votekick = new Votekick(targetName, targetId, [], threshold);
+ const threshold = Math.max((Object.keys(this.players).length) - 1, 0);
+ const votekick = new Votekick(targetName, targetId, [], threshold);
votekick.vote(sendingId);
if (votekick.check()) {
this.emitMessage({ type: 'successful-vk', targetName: votekick.targName, targetId: votekick.targId });
@@ -119,7 +120,7 @@ export default class ServerTossupRoom extends TossupRoom {
console.log(this.votekickList);
}
- votekickVote(targetUser, votingId) {
+ votekickVote (targetUser, votingId) {
let exists = false;
let thisVotekick;
this.votekickList.forEach((votekick) => {
@@ -127,17 +128,16 @@ export default class ServerTossupRoom extends TossupRoom {
thisVotekick = votekick;
exists = true;
}
- })
+ });
if (!exists) {
return;
}
thisVotekick.vote(votingId);
if (thisVotekick.check()) {
- this.emitMessage({ type: 'successful-vk', targetName: thisVotekick.targName, targetId: thisVotekick.targId })
+ this.emitMessage({ type: 'successful-vk', targetName: thisVotekick.targName, targetId: thisVotekick.targId });
this.kickedUserList.push(targetUser);
}
console.log(this.votekickList);
-
}
connection (socket, userId, username) {
From b3d1196a1b51b7b1c82fa68d531abfc7dc7b80f2 Mon Sep 17 00:00:00 2001
From: Your Name Does it cost money to create an account?
Geoword is the only feature that costs money.
All of the other features of QB Reader are completely free.
+ If a player in a public room is causing issues, such as spamming, advertising, or being expletive, you have a few options. +
+You can do so @@ -156,4 +170,4 @@