Added letter generator to letters game.
This commit is contained in:
@@ -122,7 +122,7 @@ function pickLetters(type, context) {
|
||||
context.sendMessage(`${getBoard(context)} Would you like a consonant or a vowel?`, context.room.id);
|
||||
}
|
||||
|
||||
function start(context) {
|
||||
function start(context, letters) {
|
||||
if (games.has(context.room.id)) {
|
||||
context.sendMessage(`${getBoard(context)} This is the current board. Use ${config.prefix}letters:stop to reset.`, context.room.id);
|
||||
return;
|
||||
@@ -136,6 +136,11 @@ function start(context) {
|
||||
ac: new AbortController(), // eslint-disable-line no-undef
|
||||
});
|
||||
|
||||
if (letters) {
|
||||
pickLetters(letters.toLowerCase(), context);
|
||||
return;
|
||||
}
|
||||
|
||||
context.sendMessage('Let\'s play the letters! Would you like a consonant or a vowel?', context.room.id);
|
||||
}
|
||||
|
||||
@@ -145,6 +150,11 @@ function onCommand(args, context) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (['start', 'go', 'auto', 'random'].includes(context.subcommand)) {
|
||||
start(context, Array.from({ length: config.letters.length }, () => (Math.random() < 0.55 ? 'c' : 'v')).join('')); // a slight bias towards consonants seems to give better boards
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.subcommand) {
|
||||
start(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user