85 lines
2.3 KiB
Vue
85 lines
2.3 KiB
Vue
<script setup lang="ts">
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex-container gap-1.5">
|
|
<div v-for="i in length" class="border border-default wr-div" :class="{'correct' : getCorrectness[i-1]==2, 'wrong-place' : getCorrectness[i-1]==1, 'incorrect' : getCorrectness[i-1]==0}" >
|
|
{{ guess[i-1] }}
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
export default {
|
|
data() {
|
|
return {
|
|
}
|
|
},
|
|
props: {
|
|
correct: {
|
|
type: String,
|
|
default: 'testword',
|
|
},
|
|
guess: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
index: Number,
|
|
empty: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
length: Number,
|
|
},
|
|
|
|
computed: {
|
|
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;
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.wr-div {
|
|
justify-content: center;
|
|
border-radius: 6px;
|
|
width: 36px;
|
|
height: 36px;
|
|
line-height: 22px;
|
|
background-color: transparent;
|
|
text-transform: uppercase;
|
|
font-weight: bold;
|
|
}
|
|
.correct {
|
|
background-color: rgb(0, 126, 2);
|
|
}
|
|
.incorrect {
|
|
background-color: var(--incorrect-guess);
|
|
}
|
|
.wrong-place {
|
|
background-color: var(--partial-correct-guess);
|
|
}
|
|
.empty {
|
|
background-color: var(--incorrect-guess);
|
|
}
|
|
</style> |