File size: 976 Bytes
47cfe3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f7a4650
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// original code inspired by Evan You https://github.com/yyx990803/vue-wordle/
import { LetterState } from '../types';
import type { Board } from '../types';

export function clearTile(board: Board, currentRowIndex: number) {
	const newBoard = [...board];
	const currentRow = newBoard[currentRowIndex];
	for (const tile of [...currentRow].reverse()) {
		if (tile.letter) {
			tile.letter = '';
			break;
		}
	}
	return newBoard;
}

export function fillTile(board: Board, currentRowIndex: number, letter: string) {
	const newBoard = [...board];
	const currentRow = newBoard[currentRowIndex];
	for (const tile of currentRow) {
		if (!tile.letter) {
			tile.letter = letter;
			break;
		}
	}
	return newBoard;
}

export const colors = {
	[LetterState.CORRECT]: '#00b81a',
	[LetterState.PRESENT]: '#ffc80a',
	[LetterState.ABSENT]: '#d9d9d9',
	[LetterState.INITIAL]: '#5d5d5d'
};

export const cheersMessages = ['Genius', 'Magnificent', 'Impressive', 'Splendid', 'Great', 'Phew'];