Centralized array random pick. Made duck miss ratio configurable. Different response for missing Duck befriend and bang.
This commit is contained in:
@@ -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]])}`;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user