Compare commits
No commits in common. "be30882ed701829be63804e1adb5b3a335afe42f" and "0deea0e016be3cbaf4abeff8397f25bf65befec2" have entirely different histories.
be30882ed7
...
0deea0e016
|
@ -44,7 +44,6 @@ module.exports = {
|
||||||
duck: {
|
duck: {
|
||||||
interval: [10, 3600], // seconds
|
interval: [10, 3600], // seconds
|
||||||
duck: ':duck:',
|
duck: ':duck:',
|
||||||
missRatio: 0.25,
|
|
||||||
},
|
},
|
||||||
letters: {
|
letters: {
|
||||||
length: 9,
|
length: 9,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.11.1",
|
"version": "1.11.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.11.1",
|
"version": "1.11.0",
|
||||||
"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.11.1",
|
"version": "1.11.0",
|
||||||
"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": {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
const config = require('config');
|
const config = require('config');
|
||||||
|
|
||||||
const style = require('../utils/style');
|
const style = require('../utils/style');
|
||||||
const pickRandom = require('../utils/pick-random');
|
|
||||||
|
|
||||||
const ducks = new Map();
|
const ducks = new Map();
|
||||||
let shots = new Map();
|
let shots = new Map();
|
||||||
|
@ -32,35 +31,17 @@ function launchDuck(context) {
|
||||||
function onCommand(args, context) {
|
function onCommand(args, context) {
|
||||||
const duck = ducks.get(context.room.id);
|
const duck = ducks.get(context.room.id);
|
||||||
|
|
||||||
if (!duck && context.command === 'bang') {
|
if (!duck) {
|
||||||
const message = pickRandom([
|
context.sendMessage(`There is no duck, what are you shooting at, ${config.usernamePrefix}${context.user.username}?!`, context.room.id);
|
||||||
`There is no duck, what are you shooting at, ${context.user.prefixedUsername}?!`,
|
|
||||||
`You're wasting bullets, ${context.user.prefixedUsername}, there is no duck!`,
|
|
||||||
`The only quack is you, ${context.user.prefixedUsername}...`,
|
|
||||||
]);
|
|
||||||
|
|
||||||
context.sendMessage(message, context.room.id);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!duck && ['befriend', 'bef'].includes(context.command)) {
|
const hit = Math.random() > 0.3;
|
||||||
const message = pickRandom([
|
|
||||||
`You're trying to befriend a non-existent duck, ${context.user.prefixedUsername}...`,
|
|
||||||
`There aren't any ducks to befriend, ${context.user.prefixedUsername}...`,
|
|
||||||
`That's no duck, ${context.user.prefixedUsername} ✈️`,
|
|
||||||
]);
|
|
||||||
|
|
||||||
context.sendMessage(message, context.room.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hit = Math.random() > config.duck.missRatio;
|
|
||||||
const time = ((new Date().getTime() - duck.getTime()) / 1000).toFixed(3);
|
const time = ((new Date().getTime() - duck.getTime()) / 1000).toFixed(3);
|
||||||
|
|
||||||
if (context.command === 'bang') {
|
if (context.command === 'bang') {
|
||||||
if (hit) {
|
if (hit) {
|
||||||
context.sendMessage(`You shot a duck in ${style.bold(`${time} seconds`)}, ${context.user.prefixedUsername}`, context.room.id);
|
context.sendMessage(`You shot a duck in ${style.bold(`${time} seconds`)}, ${config.usernamePrefix}${context.user.username}`, context.room.id);
|
||||||
launchDuck(context);
|
launchDuck(context);
|
||||||
|
|
||||||
context.setPoints(context.user, 1, { key: 'bang' });
|
context.setPoints(context.user, 1, { key: 'bang' });
|
||||||
|
@ -68,22 +49,22 @@ function onCommand(args, context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = pickRandom([
|
const messages = [
|
||||||
`How could you miss ${style.italic('that')}, ${context.user.prefixedUsername}...?!`,
|
`How could you miss ${style.italic('that')}, ${config.usernamePrefix}${context.user.username}...?!`,
|
||||||
`That's a miss! Better luck next time, ${context.user.prefixedUsername}.`,
|
`That's a miss! Better luck next time, ${config.usernamePrefix}${context.user.username}.`,
|
||||||
`The duck outsmarted you, ${context.user.prefixedUsername}`,
|
`The duck outsmarted you, ${config.usernamePrefix}${context.user.username}`,
|
||||||
`Channeling Gareth Southgate, ${context.user.prefixedUsername}? You missed!`,
|
`Channeling Gareth Southgate, ${config.usernamePrefix}${context.user.username}? You missed!`,
|
||||||
]);
|
];
|
||||||
|
|
||||||
shots.set(context.user.id, new Date());
|
shots.set(context.user.id, new Date());
|
||||||
context.sendMessage(message, context.room.id);
|
context.sendMessage(messages[Math.floor(Math.random() * messages.length)], context.room.id);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['bef', 'befriend'].includes(context.command)) {
|
if (['bef', 'befriend'].includes(context.command)) {
|
||||||
if (hit) {
|
if (hit) {
|
||||||
context.sendMessage(`You befriended a duck in ${style.bold(`${time} seconds`)}, ${context.user.prefixedUsername}`, context.room.id);
|
context.sendMessage(`You befriended a duck in ${style.bold(`${time} seconds`)}, ${config.usernamePrefix}${context.user.username}`, context.room.id);
|
||||||
launchDuck(context);
|
launchDuck(context);
|
||||||
|
|
||||||
context.setPoints(context.user, 1, { key: 'befriend' });
|
context.setPoints(context.user, 1, { key: 'befriend' });
|
||||||
|
@ -91,14 +72,14 @@ function onCommand(args, context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = pickRandom([
|
const messages = [
|
||||||
`The duck does not want to be your friend right now, ${context.user.prefixedUsername}`,
|
`The duck does not want to be your friend right now, ${config.usernamePrefix}${context.user.username}`,
|
||||||
`The duck would like some time for itself, ${context.user.prefixedUsername}`,
|
`The duck would like some time for itself, ${config.usernamePrefix}${context.user.username}`,
|
||||||
`The duck isn't in the mood right now, ${context.user.prefixedUsername}`,
|
`The duck isn't in the mood right now, ${config.usernamePrefix}${context.user.username}`,
|
||||||
]);
|
];
|
||||||
|
|
||||||
shots.set(context.user.id, new Date());
|
shots.set(context.user.id, new Date());
|
||||||
context.sendMessage(message, context.room.id);
|
context.sendMessage(messages[Math.floor(Math.random() * messages.length)], context.room.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
const config = require('config');
|
const config = require('config');
|
||||||
const timers = require('timers/promises');
|
const timers = require('timers/promises');
|
||||||
|
|
||||||
|
const crypto = require('crypto');
|
||||||
const style = require('../utils/style');
|
const style = require('../utils/style');
|
||||||
const getLeaders = require('../utils/get-leaders');
|
const getLeaders = require('../utils/get-leaders');
|
||||||
const getWordKey = require('../utils/get-word-key');
|
const getWordKey = require('../utils/get-word-key');
|
||||||
const pickRandom = require('../utils/pick-random');
|
|
||||||
const words = require('../../assets/mash-words.json');
|
const words = require('../../assets/mash-words.json');
|
||||||
|
|
||||||
const availableLetters = {
|
const availableLetters = {
|
||||||
|
@ -106,10 +106,10 @@ function pickLetters(type, context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'consonant' || type === 'vowel') {
|
if (type === 'consonant' || type === 'vowel') {
|
||||||
game.word = `${game.word}${pickRandom(availableLetters[type])}`;
|
game.word = `${game.word}${availableLetters[type][crypto.randomInt(0, availableLetters[type].length)]}`;
|
||||||
} else {
|
} else {
|
||||||
type.toLowerCase().slice(0, config.letters.length - game.word.length).split('').forEach((typeKey) => {
|
type.toLowerCase().slice(0, config.letters.length - game.word.length).split('').forEach((typeKey) => {
|
||||||
game.word = `${game.word}${pickRandom(availableLetters[types[typeKey]])}`;
|
game.word = `${game.word}${availableLetters[types[typeKey]][crypto.randomInt(0, availableLetters[types[typeKey]].length)]}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/play.js
10
src/play.js
|
@ -138,19 +138,11 @@ function getMessageUser(message, bot) {
|
||||||
return {
|
return {
|
||||||
username: message.from,
|
username: message.from,
|
||||||
id: message.from,
|
id: message.from,
|
||||||
prefixedUsername: `${config.usernamePrefix}${message.from}`,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.platform === 'schat') {
|
if (config.platform === 'schat') {
|
||||||
const user = bot.users[message.userId] || message.user;
|
return bot.users[message.userId] || message.user;
|
||||||
|
|
||||||
if (user) {
|
|
||||||
return {
|
|
||||||
...user,
|
|
||||||
prefixedUsername: `${config.usernamePrefix}${user.username}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue