wordle part kind of working
Build / Build-image (push) Successful in 1m8s

This commit is contained in:
2026-08-25 00:56:08 +02:00
parent a79363b4da
commit 865ac153b2
3 changed files with 50 additions and 29 deletions
+23 -17
View File
@@ -1,15 +1,12 @@
<script setup lang="ts">
import { empty } from 'valibot';
</script>
<template>
<div class="flex-container gap-1.5">
<div v-for="i in getGuess.length" class="border border-default wr-div" :class="{'correct' : getCorrectness[i-1]==2, 'wrong-place' : correctness[i-1]==1}">
{{ getGuess[i-1] }}
{{ correct[i-1] }}
</div>
<div v-for="i in length" class="border border-default wr-div" :class="{'correct' : getCorrectness[i-1]==2, 'wrong-place' : getCorrectness[i-1]==1}">
{{ guess[i-1] }}
</div>
</div>
</template>
@@ -17,7 +14,6 @@ import { empty } from 'valibot';
export default {
data() {
return {
}
},
props: {
@@ -30,26 +26,33 @@ import { empty } from 'valibot';
default: '',
},
index: Number,
empty: {
type: Boolean,
default: false,
},
length: Number,
},
computed: {
getGuess() {
let guess = '';
if (this.guess.length == 0)
{
for (let i = 0; i < length; i++) {
guess += ' ';
}
}
return guess;
},
getCorrectness() : number[] {
let correctness_alt = [];
let correctness = [];
for (let i = 0; i < this.guess.length; i++) {
if (this.guess[i] == this.correct[i]) {
correctness.push(2);
} else correctness.push(0);
}
correctness_alt = correctness.slice();
for (let i = 0; i < this.guess.length; i++) {
for (let j = 0; j < this.correct.length; j++) {
if (this.guess[i] == this.correct[j] && correctness[i] == 0 && correctness_alt[j] == 0) {
correctness[i] = 1;
correctness_alt[j] = 1;
}
}
}
return correctness;
}
},
@@ -73,4 +76,7 @@ import { empty } from 'valibot';
.wrong-place {
background-color: rgb(37, 43, 154);
}
.empty {
background-color: rgb(93, 93, 93);
}
</style>