File size: 1,288 Bytes
1bc8781
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// original code inspired by Evan You https://github.com/yyx990803/vue-wordle/
import { LetterState } from '../types';
import type { Board, BadgeComponent } 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.correct === ' ') {
			tile.letter = ' ';
		}
		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 badgesComponents: BadgeComponent = {
	2: 'two',
	5: 'five',
	10: 'ten',
	15: 'fifteen',
	20: 'twenty',
	35: 'thirtyfive',
	50: 'fifty'
};

export const cheersMessages = [
	'πŸ€— Hugging πŸ€—',
	'🧞 Genius 🧞',
	'🀩 Magnificent 🀩',
	'😲 Impressive 😲',
	'🧚 Splendid 🧚',
	'✳ Great ✳',
	'🍑 Phew 🍑'
];