Added hard mode to wordle.
This commit is contained in:
parent
234bbb2bbc
commit
990e18d3da
|
@ -71572,6 +71572,7 @@
|
||||||
"shirtwaists",
|
"shirtwaists",
|
||||||
"shirty",
|
"shirty",
|
||||||
"shit",
|
"shit",
|
||||||
|
"shite",
|
||||||
"shitfaced",
|
"shitfaced",
|
||||||
"shithead",
|
"shithead",
|
||||||
"shitheads",
|
"shitheads",
|
||||||
|
|
|
@ -136,7 +136,8 @@ module.exports = {
|
||||||
},
|
},
|
||||||
wordle: {
|
wordle: {
|
||||||
minLength: 3,
|
minLength: 3,
|
||||||
defaultLength: 5,
|
length: 5,
|
||||||
|
mode: 'easy',
|
||||||
},
|
},
|
||||||
numbers: {
|
numbers: {
|
||||||
length: 6,
|
length: 6,
|
||||||
|
|
|
@ -60,13 +60,13 @@ function getBoard(letters, showLetters, context) {
|
||||||
: style.grey(letter);
|
: style.grey(letter);
|
||||||
}).join(config.platform === 'irc' ? ' ' : ' '); // regular space vs em space
|
}).join(config.platform === 'irc' ? ' ' : ' '); // regular space vs em space
|
||||||
|
|
||||||
return `${prefix}${middle}${suffix} Letters: ${letterBoard}`; // eslint-disable-line no-irregular-whitespace
|
return `${prefix}${middle}${suffix}${wordle.mode === 'hard' ? ' (Hard)' : ''} Letters: ${letterBoard}`; // eslint-disable-line no-irregular-whitespace
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${prefix}${middle}${suffix}`;
|
return `${prefix}${middle}${suffix}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function start(length = settings.defaultLength, context) {
|
function start(length = settings.length, mode = settings.mode, context) {
|
||||||
const wordPool = words[length];
|
const wordPool = words[length];
|
||||||
|
|
||||||
if (length < settings.minLength) {
|
if (length < settings.minLength) {
|
||||||
|
@ -85,15 +85,16 @@ function start(length = settings.defaultLength, context) {
|
||||||
wordles.set(context.room.id, {
|
wordles.set(context.room.id, {
|
||||||
word: word.word.toUpperCase(),
|
word: word.word.toUpperCase(),
|
||||||
wordList,
|
wordList,
|
||||||
|
mode,
|
||||||
definitions: word.definitions,
|
definitions: word.definitions,
|
||||||
letters: new Map(alphabet.map((letter) => [letter, null])),
|
letters: new Map(alphabet.map((letter) => [letter, null])),
|
||||||
guesses: [],
|
guesses: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config.platform === 'irc') {
|
if (config.platform === 'irc') {
|
||||||
context.sendMessage(`${getBoard(Array.from({ length }, () => null), false, context)} guess the word with ${config.prefix}w [word]! ${style.bgsilver(' X ')} not in word; ${style.bgyellow(` X${style.yellow('?')}`)} wrong position; ${style.bggreen(` X${style.green('*')}`)} correct position.`, context.room.id); // eslint-disable-line no-irregular-whitespace
|
context.sendMessage(`${getBoard(Array.from({ length }, () => null), false, context)}${mode === 'hard' ? ' (Hard)' : ''} guess the word with ${config.prefix}w [word]! ${style.bgsilver(' X ')} not in word; ${style.bgyellow(` X${style.yellow('?')}`)} wrong position; ${style.bggreen(` X${style.green('*')}`)} correct position.`, context.room.id); // eslint-disable-line no-irregular-whitespace
|
||||||
} else {
|
} else {
|
||||||
context.sendMessage(`${getBoard(Array.from({ length }, () => null), false, context)} guess the word with ${config.prefix}w [word]! ${style.grey(style.bold('X'))} not in word; ${style.orange(style.bold('X'))} wrong position; ${style.green(style.bold('X'))} correct position.`, context.room.id);
|
context.sendMessage(`${getBoard(Array.from({ length }, () => null), false, context)}${mode === 'hard' ? ' (Hard)' : ''} guess the word with ${config.prefix}w [word]! ${style.grey(style.bold('X'))} not in word; ${style.orange(style.bold('X'))} wrong position; ${style.green(style.bold('X'))} correct position.`, context.room.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.logger.info(`Wordle started: ${word.word.toUpperCase()}`);
|
context.logger.info(`Wordle started: ${word.word.toUpperCase()}`);
|
||||||
|
@ -122,6 +123,37 @@ function play(guess, context) {
|
||||||
|
|
||||||
const guessLetters = upperGuess.split('');
|
const guessLetters = upperGuess.split('');
|
||||||
const check = guessLetters.map((letter) => [letter, null]);
|
const check = guessLetters.map((letter) => [letter, null]);
|
||||||
|
const prevGuess = wordle.guesses.at(-1)?.[1];
|
||||||
|
|
||||||
|
if (wordle.mode === 'hard' && prevGuess) {
|
||||||
|
const prevLetters = prevGuess.split('');
|
||||||
|
|
||||||
|
const valid = prevLetters.every((letter, index) => {
|
||||||
|
if (wordle.letters.get(letter) === false && !guessLetters.includes(letter)) {
|
||||||
|
context.sendMessage(`(Hard) Your guess must include the letter ${config.platform === 'irc'
|
||||||
|
? style.bggreen(` ${letter} `)
|
||||||
|
: `${style.grey(style.code('['))}${style.orange(style.bold(style.code(letter)))}${style.grey(style.code(']'))}`
|
||||||
|
}.`, context.room.id);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wordle.letters.get(letter) === true && letter === wordle.word[index] && letter !== guessLetters[index]) {
|
||||||
|
context.sendMessage(`(Hard) Your guess must include the letter ${config.platform === 'irc'
|
||||||
|
? style.bgyellow(` ${letter} `)
|
||||||
|
: `${style.grey(style.code('['))}${style.green(style.bold(style.code(letter)))}${style.grey(style.code(']'))}`
|
||||||
|
} in the correct position.`, context.room.id);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// correct
|
// correct
|
||||||
guessLetters.forEach((letter, index) => {
|
guessLetters.forEach((letter, index) => {
|
||||||
|
@ -169,7 +201,10 @@ function play(guess, context) {
|
||||||
|
|
||||||
function onCommand(args, context) {
|
function onCommand(args, context) {
|
||||||
const wordle = wordles.get(context.room.id);
|
const wordle = wordles.get(context.room.id);
|
||||||
const length = Number(args[0]) || settings.defaultLength;
|
const length = args.map((arg) => Number(arg)).find(Boolean) || settings.length;
|
||||||
|
const mode = args.find((arg) => arg === 'easy' || arg === 'hard')
|
||||||
|
|| (context.command === 'hardle' && 'hard')
|
||||||
|
|| settings.mode;
|
||||||
|
|
||||||
if (['guess', 'w'].includes(context.command)) {
|
if (['guess', 'w'].includes(context.command)) {
|
||||||
play(args[0], context);
|
play(args[0], context);
|
||||||
|
@ -189,7 +224,7 @@ function onCommand(args, context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wordle && context.room.id) {
|
if (!wordle && context.room.id) {
|
||||||
start(length, context);
|
start(length, mode, context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +233,8 @@ function onCommand(args, context) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'Wordle',
|
name: 'Wordle',
|
||||||
commands: ['wordle', 'guess', 'w'],
|
commands: ['wordle', 'hardle', 'lingo', 'guess', 'w'],
|
||||||
help: `Guess the ${settings.defaultLength}-letter word on the board. Submit a guess with ${config.prefix}w [word]. If the letter is green, it is in the correct place. If it is yellow, it is part of the word, but not in the correct place. The number of letters in the word is the highest score you can get. You lose 1 point per guess, down to 1 point.`,
|
help: `Guess the ${settings.length}-letter word on the board. Submit a guess with ${config.prefix}w [word]. If the letter is green, it is in the correct place. If it is yellow, it is part of the word, but not in the correct place. The number of letters in the word is the highest score you can get. You lose 1 point per guess, down to 1 point.`,
|
||||||
onCommand,
|
onCommand,
|
||||||
// onMessage,
|
// onMessage,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue