randomize word by day + more logic fix

This commit is contained in:
Evan You 2022-01-23 23:17:36 +08:00
parent f28c5585f2
commit 93c2322834
3 changed files with 15 additions and 6 deletions

View File

@ -1,11 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { onUnmounted } from 'vue' import { onUnmounted } from 'vue'
import { allWords } from './words' import { answers, allWords } from './words'
import Keyboard from './Keyboard.vue' import Keyboard from './Keyboard.vue'
import { LetterState } from './types' import { LetterState } from './types'
// try to guess this by actually playing the game :) const now = new Date()
const answer = atob('aGVsbG8=') const start = new Date(2022, 0, 0)
const diff = Number(now) - Number(start)
let day = Math.floor(diff / (1000 * 60 * 60 * 24))
while (day > answers.length) {
day -= answers.length
}
const answer = answers[day]
class Tile { class Tile {
letter = '' letter = ''
@ -95,7 +101,10 @@ function completeRow() {
// 3rd pass: mark absent // 3rd pass: mark absent
currentRow.forEach((tile) => { currentRow.forEach((tile) => {
if (!tile.state) { if (!tile.state) {
tile.state = letterStates[tile.letter] = LetterState.ABSENT tile.state = LetterState.ABSENT
if (!letterStates[tile.letter]) {
letterStates[tile.letter] = LetterState.ABSENT
}
} }
}) })

View File

@ -17,7 +17,7 @@ header {
#source-link { #source-link {
position: absolute; position: absolute;
right: 0; right: 1em;
top: 0.5em; top: 0.5em;
} }

View File

@ -1,5 +1,5 @@
// copied from Wordle source // copied from Wordle source
const answers = [ export const answers = [
'cigar', 'cigar',
'rebut', 'rebut',
'sissy', 'sissy',