Compare commits
No commits in common. "d257f93f3ea93a2c93b36d8ca25773d14bdf89fd" and "cb2fa362d610a13f9528eae741f8c7c30cc0b6ad" have entirely different histories.
d257f93f3e
...
cb2fa362d6
File diff suppressed because it is too large
Load Diff
|
@ -21,23 +21,7 @@ module.exports = {
|
||||||
greeting: 'Hi, I am aisha, your game host!',
|
greeting: 'Hi, I am aisha, your game host!',
|
||||||
usernamePrefix: '@',
|
usernamePrefix: '@',
|
||||||
channels: ['GamesNight'],
|
channels: ['GamesNight'],
|
||||||
games: [
|
games: ['mash', 'trivia', 'letters', 'duck', '8ball', 'riddle', 'dice', 'rock-paper-scissors', 'ping', 'say', 'kill', 'uptime', 'help'],
|
||||||
'mash',
|
|
||||||
'trivia',
|
|
||||||
'letters',
|
|
||||||
'hunt',
|
|
||||||
'8ball',
|
|
||||||
'riddle',
|
|
||||||
'dice',
|
|
||||||
'parrot',
|
|
||||||
'rock-paper-scissors',
|
|
||||||
'duck',
|
|
||||||
'ping',
|
|
||||||
'say',
|
|
||||||
'kill',
|
|
||||||
'uptime',
|
|
||||||
'help',
|
|
||||||
],
|
|
||||||
schatColors: {
|
schatColors: {
|
||||||
white: 'white',
|
white: 'white',
|
||||||
blue: 'var(--message-40)',
|
blue: 'var(--message-40)',
|
||||||
|
@ -81,10 +65,4 @@ module.exports = {
|
||||||
maxRolls: 10,
|
maxRolls: 10,
|
||||||
maxFaces: 1000,
|
maxFaces: 1000,
|
||||||
},
|
},
|
||||||
hangman: {
|
|
||||||
minLength: 5,
|
|
||||||
maxLength: 9,
|
|
||||||
guesses: [2, 3, 4, 5, 6, 7], // by word length, last number repeats for longer words
|
|
||||||
// guesses: 6, // fixed
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.19.0",
|
"version": "1.18.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.19.0",
|
"version": "1.18.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bhttp": "^1.2.8",
|
"bhttp": "^1.2.8",
|
||||||
|
@ -20,7 +20,6 @@
|
||||||
"irc-upd": "^0.11.0",
|
"irc-upd": "^0.11.0",
|
||||||
"jsdom": "^18.1.0",
|
"jsdom": "^18.1.0",
|
||||||
"linkify-it": "^3.0.3",
|
"linkify-it": "^3.0.3",
|
||||||
"markov-strings": "^3.0.1",
|
|
||||||
"simple-node-logger": "^21.8.12",
|
"simple-node-logger": "^21.8.12",
|
||||||
"string-similarity": "^4.0.4",
|
"string-similarity": "^4.0.4",
|
||||||
"tensify": "^0.0.4",
|
"tensify": "^0.0.4",
|
||||||
|
@ -2582,17 +2581,6 @@
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/markov-strings": {
|
|
||||||
"version": "3.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/markov-strings/-/markov-strings-3.0.1.tgz",
|
|
||||||
"integrity": "sha512-/Cf6m7iIK1JWtvOemZ9eRUpKvebm+m6uXMTzszOJrRO3rkmdCqoS/EO9d4/3aFPnYEIHkopcF4C7W+k1zTDjnw==",
|
|
||||||
"dependencies": {
|
|
||||||
"lodash": "^4.17.20"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mime": {
|
"node_modules/mime": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||||
|
@ -5834,14 +5822,6 @@
|
||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"markov-strings": {
|
|
||||||
"version": "3.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/markov-strings/-/markov-strings-3.0.1.tgz",
|
|
||||||
"integrity": "sha512-/Cf6m7iIK1JWtvOemZ9eRUpKvebm+m6uXMTzszOJrRO3rkmdCqoS/EO9d4/3aFPnYEIHkopcF4C7W+k1zTDjnw==",
|
|
||||||
"requires": {
|
|
||||||
"lodash": "^4.17.20"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mime": {
|
"mime": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.19.0",
|
"version": "1.18.2",
|
||||||
"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": {
|
||||||
|
@ -29,7 +29,6 @@
|
||||||
"irc-upd": "^0.11.0",
|
"irc-upd": "^0.11.0",
|
||||||
"jsdom": "^18.1.0",
|
"jsdom": "^18.1.0",
|
||||||
"linkify-it": "^3.0.3",
|
"linkify-it": "^3.0.3",
|
||||||
"markov-strings": "^3.0.1",
|
|
||||||
"simple-node-logger": "^21.8.12",
|
"simple-node-logger": "^21.8.12",
|
||||||
"string-similarity": "^4.0.4",
|
"string-similarity": "^4.0.4",
|
||||||
"tensify": "^0.0.4",
|
"tensify": "^0.0.4",
|
||||||
|
|
|
@ -1,163 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const config = require('config');
|
|
||||||
|
|
||||||
const words = require('../../assets/mash-words.json');
|
|
||||||
const pickRandom = require('../utils/pick-random');
|
|
||||||
const style = require('../utils/style');
|
|
||||||
|
|
||||||
const games = new Map();
|
|
||||||
|
|
||||||
const targets = ['🐣', '🐕', '🐈', '🐢', '🐇', '🐁', '🦔'];
|
|
||||||
const predators = ['🦅', '🐍', '🦖', '🐅', '🐆', '🐊', '🐉'];
|
|
||||||
const trees = ['🌴', '🌳', '🌲', '🌵'];
|
|
||||||
const flowers = ['🌹', '🌻', '🌷', '🌱', '🍄', '🪨'];
|
|
||||||
|
|
||||||
function getGuesses(word) {
|
|
||||||
if (Array.isArray(config.hangman.guesses)) {
|
|
||||||
return config.hangman.guesses[word.length - 1] || config.hangman.guesses.at(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return config.hangman.guesses;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderBoard(context) {
|
|
||||||
const game = games.get(context.room.id);
|
|
||||||
const word = game.partial.map((letter) => letter || '_').join(' ').toUpperCase();
|
|
||||||
const track = `${game.flower}${game.target}${game.track.slice(0, getGuesses(game.word) - game.progress).join('')}${game.predator}`;
|
|
||||||
|
|
||||||
context.sendMessage(`${style.bold(style.code(word))} ${track}`, context.room.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOutcome(target, predator) {
|
|
||||||
return pickRandom([
|
|
||||||
`${target} and ${predator} will now have to spend time together`,
|
|
||||||
`${target} will now have to listen to boring stories from ${predator}`,
|
|
||||||
`${target} must now endure a horrible tickle attack from ${predator}`,
|
|
||||||
`${target} and ${predator} are now going to waste an entire day arguing which one of them has more legs`,
|
|
||||||
`${predator} is out of breath now`,
|
|
||||||
`${target} will now have to explain why they never answer any texts from ${predator}`,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function progress(context) {
|
|
||||||
const game = games.get(context.room.id);
|
|
||||||
|
|
||||||
game.progress += 1;
|
|
||||||
|
|
||||||
if (game.progress > getGuesses(game.word)) {
|
|
||||||
context.sendMessage(`The word ${style.bold(game.word)} was not guessed. ${getOutcome(game.target, game.predator)}.`, context.room.id);
|
|
||||||
games.delete(context.room.id);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBoard(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
function playLetter(playedLetter, context) {
|
|
||||||
const game = games.get(context.room.id);
|
|
||||||
|
|
||||||
if (game.partial.includes(playedLetter)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!game.word.includes(playedLetter)) {
|
|
||||||
progress(context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
game.partial = game.partial.map((letter, index) => letter
|
|
||||||
|| (game.word[index] === playedLetter && game.word[index])
|
|
||||||
|| null);
|
|
||||||
|
|
||||||
renderBoard(context);
|
|
||||||
|
|
||||||
if (game.partial.every((letter) => letter !== null)) {
|
|
||||||
context.sendMessage(style.bold('The word was completed!'), context.room.id);
|
|
||||||
games.delete(context.room.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function playWord(word, context) {
|
|
||||||
const game = games.get(context.room.id);
|
|
||||||
|
|
||||||
if (word === game.word) {
|
|
||||||
context.sendMessage(`The word ${style.answer(word)} was guessed, ${style.username(context.user.prefixedUsername)}, who gets a point!`, context.room.id);
|
|
||||||
context.setPoints(context.user);
|
|
||||||
|
|
||||||
games.delete(context.room.id);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.sendMessage('That\'s not it', context.room.id);
|
|
||||||
progress(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stop(context) {
|
|
||||||
const game = games.get(context.room.id);
|
|
||||||
|
|
||||||
if (!game) {
|
|
||||||
context.sendMessage(`There is no game going on, ${style.username(context.user.prefixedUsername)}. You can start one with ${config.prefix}hunt!`, context.room.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
games.delete(context.room.id);
|
|
||||||
context.sendMessage(`The game was stopped by ${style.username(context.user.prefixedUsername)}. The word was ${style.bold(game.word)} with ${getGuesses(game.word) - game.progress} guesses remaining.`, context.room.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCommand(args, context) {
|
|
||||||
if (context.subcommand === 'stop') {
|
|
||||||
stop(context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const minLength = Number(args[0]) || config.hangman.minLength;
|
|
||||||
const maxLength = Number(args[0]) || config.hangman.maxLength;
|
|
||||||
|
|
||||||
const playableWords = Array.from({ length: (maxLength - minLength) + 1 }, (value, index) => Object.values(words[index + minLength] || {})).flat(2);
|
|
||||||
const word = pickRandom(playableWords);
|
|
||||||
|
|
||||||
if (!word) {
|
|
||||||
context.sendMessage('Sorry, I was not able to find a word to play.', context.room.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.logger.info(`Hangman played ${word.word} with ${getGuesses(word)} guesses`);
|
|
||||||
|
|
||||||
games.set(context.room.id, {
|
|
||||||
word: word.word,
|
|
||||||
progress: 0,
|
|
||||||
defintiions: word.definitions,
|
|
||||||
partial: word.word.split('').map(() => null),
|
|
||||||
flower: pickRandom(flowers),
|
|
||||||
target: pickRandom(targets),
|
|
||||||
predator: pickRandom(predators),
|
|
||||||
track: Array.from({ length: getGuesses(word) }, (value, index) => (index % 2 ? pickRandom(trees) : ' ')), // Em Space to ensure proper spacing in SChat
|
|
||||||
});
|
|
||||||
|
|
||||||
renderBoard(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMessage(message, context) {
|
|
||||||
if (games.has(context.room.id)) {
|
|
||||||
const letter = message.body.match(/^\s*\w\s*$/)?.[0];
|
|
||||||
const word = message.body.match(/^\s*\w{2,}\s*$/)?.[0];
|
|
||||||
|
|
||||||
if (letter) {
|
|
||||||
playLetter(letter.toLowerCase().trim(), context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (word) {
|
|
||||||
playWord(word.toLowerCase().trim(), context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
onCommand,
|
|
||||||
onMessage,
|
|
||||||
commands: ['hangman'],
|
|
||||||
};
|
|
|
@ -1,20 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const Markov = require('markov-strings').default;
|
|
||||||
const sentences = require('../../assets/markov-data.json');
|
|
||||||
|
|
||||||
const markov = new Markov();
|
|
||||||
|
|
||||||
markov.addData(sentences);
|
|
||||||
|
|
||||||
function onCommand(args, context) {
|
|
||||||
const result = markov.generate({ maxTries: 100 });
|
|
||||||
|
|
||||||
console.log(result);
|
|
||||||
|
|
||||||
context.sendMessage(result.string, context.room.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
onCommand,
|
|
||||||
};
|
|
|
@ -124,7 +124,7 @@ async function getGames(bot, identifier) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setGamePoints = (userId, score = 1, options) => setPoints(identifier, key, userId, score, options);
|
const setGamePoints = (userId, score, options) => setPoints(identifier, key, userId, score, options);
|
||||||
|
|
||||||
const curatedGame = {
|
const curatedGame = {
|
||||||
...game,
|
...game,
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
function pickRandom(array) {
|
function pickRandom(array) {
|
||||||
if (array.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array[crypto.randomInt(0, array.length)];
|
return array[crypto.randomInt(0, array.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ function shieldMethods(methods) {
|
||||||
return Object.fromEntries(Object.entries(methods).map(([key, method]) => [key, curate(method)]));
|
return Object.fromEntries(Object.entries(methods).map(([key, method]) => [key, curate(method)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
const styleMethods = (() => {
|
module.exports = (() => {
|
||||||
if (config.platform === 'irc') {
|
if (config.platform === 'irc') {
|
||||||
return shieldMethods({
|
return shieldMethods({
|
||||||
...styles,
|
...styles,
|
||||||
|
@ -66,12 +66,3 @@ const styleMethods = (() => {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const expandedMethods = {
|
|
||||||
...styleMethods,
|
|
||||||
username: (value) => styleMethods.bold(styleMethods.cyan(value)),
|
|
||||||
time: (value) => styleMethods.bold(styleMethods.green(value)),
|
|
||||||
answer: (value) => styleMethods.bold(styleMethods.yellow(value)),
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = expandedMethods;
|
|
||||||
|
|
Loading…
Reference in New Issue