A few gaming features added, e.g. rolling dice, flipping coin, eightball.
This commit is contained in:
@@ -3106,6 +3106,12 @@ function addToChatbox(id, peerId, dest, nick, time, privileged, history, kind, m
|
||||
footer.classList.add('message-footer');
|
||||
if(!peerId)
|
||||
container.classList.add('message-system');
|
||||
if(kind === 'dice' && privileged)
|
||||
container.classList.add('message-dice');
|
||||
if(kind === 'eightball' && privileged)
|
||||
container.classList.add('message-eightball');
|
||||
if(kind === 'coin' && privileged)
|
||||
container.classList.add('message-coin');
|
||||
if(serverConnection && peerId === serverConnection.id)
|
||||
container.classList.add('message-sender');
|
||||
if(dest)
|
||||
@@ -3314,6 +3320,9 @@ function clearChat(id, userId) {
|
||||
*/
|
||||
let commands = {};
|
||||
|
||||
const diceCommandRegexp =
|
||||
/^\/\s*[0-9]+\s*[dD]\s*[0-9]+(?:\s*[+-]\s*[0-9]+)?\s*$/;
|
||||
|
||||
function operatorPredicate() {
|
||||
if(serverConnection && serverConnection.permissions &&
|
||||
serverConnection.permissions.indexOf('op') >= 0)
|
||||
@@ -3348,6 +3357,7 @@ commands.help = {
|
||||
continue;
|
||||
cs.push(`/${cmd}${c.parameters?' ' + c.parameters:''}: ${c.description}`);
|
||||
}
|
||||
cs.push('/NdS [ +|- modifier]: roll dice; spaces and uppercase D are allowed');
|
||||
let shortcuts = '\n\nKeyboard shortcuts:\n' +
|
||||
'Control+Alt+H or Alt+Shift+H: Raise or lower hand\n' +
|
||||
'Control+Alt+C or Alt+Shift+C: Expand or collapse chat\n' +
|
||||
@@ -3356,6 +3366,27 @@ commands.help = {
|
||||
}
|
||||
};
|
||||
|
||||
function eightBallCommand(c, r) {
|
||||
serverConnection.hallAction('eightball', r);
|
||||
}
|
||||
|
||||
commands['8ball'] = {
|
||||
description: 'ask the Eight Ball a question',
|
||||
parameters: 'question',
|
||||
f: eightBallCommand,
|
||||
};
|
||||
|
||||
commands.eightball = {
|
||||
f: eightBallCommand,
|
||||
};
|
||||
|
||||
commands.coin = {
|
||||
description: 'flip a coin',
|
||||
f: (c, r) => {
|
||||
serverConnection.hallAction('coin', r);
|
||||
},
|
||||
};
|
||||
|
||||
commands.me = {
|
||||
f: (c, r) => {
|
||||
// handled as a special case
|
||||
@@ -3968,6 +3999,14 @@ function handleInput() {
|
||||
if(data.length > 1 && data[1] === '/') {
|
||||
message = data.slice(1);
|
||||
me = false;
|
||||
} else if(diceCommandRegexp.test(data)) {
|
||||
try {
|
||||
serverConnection.hallAction('roll', data.slice(1));
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
displayError(e);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
let cmd, rest;
|
||||
let space = data.indexOf(' ');
|
||||
|
||||
Reference in New Issue
Block a user