Centralized array random pick. Made duck miss ratio configurable. Different response for missing Duck befriend and bang.

This commit is contained in:
2022-10-21 22:44:31 +02:00
parent 0deea0e016
commit 741f770d27
4 changed files with 50 additions and 22 deletions

View File

@@ -3,10 +3,10 @@
const config = require('config');
const timers = require('timers/promises');
const crypto = require('crypto');
const style = require('../utils/style');
const getLeaders = require('../utils/get-leaders');
const getWordKey = require('../utils/get-word-key');
const pickRandom = require('../utils/pick-random');
const words = require('../../assets/mash-words.json');
const availableLetters = {
@@ -106,10 +106,10 @@ function pickLetters(type, context) {
}
if (type === 'consonant' || type === 'vowel') {
game.word = `${game.word}${availableLetters[type][crypto.randomInt(0, availableLetters[type].length)]}`;
game.word = `${game.word}${pickRandom(availableLetters[type])}`;
} else {
type.toLowerCase().slice(0, config.letters.length - game.word.length).split('').forEach((typeKey) => {
game.word = `${game.word}${availableLetters[types[typeKey]][crypto.randomInt(0, availableLetters[types[typeKey]].length)]}`;
game.word = `${game.word}${pickRandom(availableLetters[types[typeKey]])}`;
});
}