Improved wordle readability for IRC.

This commit is contained in:
ThePendulum 2024-06-03 22:46:17 +02:00
parent 402dbc3923
commit f85cac7f2f
1 changed files with 25 additions and 11 deletions

View File

@ -13,40 +13,54 @@ const alphabet = Array.from({ length: 26 }, (value, index) => String.fromCharCod
function getBoard(letters, showLetters, context) { function getBoard(letters, showLetters, context) {
const wordle = wordles.get(context.room.id); const wordle = wordles.get(context.room.id);
const prefix = style.grey(style.code('[')); const prefix = config.platform === 'irc' ? '' : style.grey(style.code('['));
const middle = letters.map((letter) => { const middle = letters.map((letter) => {
if (letter === null) { if (letter === null) {
return style.code(''); // em space, U+2003, charcode 8195 return config.platform === 'irc'
? style.bgsilver('?')
: style.code(''); // em space, U+2003, charcode 8195
} }
if (letter[1] === true) { if (letter[1] === true) {
return style.green(style.bold(style.code(letter[0].toUpperCase()))); return config.platform === 'irc'
? style.bggreen(` ${letter[0].toUpperCase()}${style.green('*')}`)
: style.green(style.bold(style.code(letter[0].toUpperCase())));
} }
if (letter[1] === false) { if (letter[1] === false) {
return style.orange(style.bold(style.code(letter[0].toUpperCase()))); return config.platform === 'irc'
? style.bgyellow(` ${letter[0].toUpperCase()}${style.yellow('?')}`)
: style.orange(style.bold(style.code(letter[0].toUpperCase())));
} }
return style.grey(style.bold(style.code(letter[0].toUpperCase()))); return config.platform === 'irc'
}).join(style.grey(style.code('|'))); ? style.bgsilver(` ${letter[0].toUpperCase()} `)
: style.grey(style.bold(style.code(letter[0].toUpperCase())));
}).join(config.platform === 'irc' ? '' : style.grey(style.code('|')));
const suffix = `${style.grey(style.code(']'))}`; const suffix = config.platform === 'irc' ? '' : `${style.grey(style.code(']'))}`;
if (showLetters) { if (showLetters) {
const letterBoard = Array.from(wordle.letters).map(([letter, state]) => { const letterBoard = Array.from(wordle.letters).map(([letter, state]) => {
if (state === true) { if (state === true) {
return style.green(style.bold(letter)); return config.platform === 'irc'
? style.bggreen(`${letter}${style.green('*')}`)
: style.green(style.bold(letter));
} }
if (state === false) { if (state === false) {
return style.orange(style.bold(letter)); return config.platform === 'irc'
? style.bgyellow(`${letter}${style.yellow('?')}`)
: style.orange(style.bold(letter));
} }
return style.grey(letter); return config.platform === 'irc'
? letter
: style.grey(letter);
}).join(''); }).join('');
return `${prefix}${middle}${suffix}${letterBoard}`; // eslint-disable-line no-irregular-whitespace return `${prefix}${middle}${suffix}Letters: ${letterBoard}`; // eslint-disable-line no-irregular-whitespace
} }
return `${prefix}${middle}${suffix}`; return `${prefix}${middle}${suffix}`;