This commit is contained in:
@@ -1,16 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<Modal v-model:open="open">
|
<Modal v-model:open="open">
|
||||||
|
<h1>Wordle for the tired</h1>
|
||||||
|
<br>
|
||||||
<div class="flex-container-a gap-1.5">
|
<div class="flex-container-a gap-1.5">
|
||||||
<template v-for="i in max_guesses">
|
<template v-for="i in max_guesses">
|
||||||
<WordleRow v-if="guesses.length >= i" :guess="guesses[i-1]"/>
|
|
||||||
|
<WordleRow v-if="guesses.length > i" :guess="guesses[i]" :length="length" :correct="correct"/>
|
||||||
|
|
||||||
<UForm @submit="onsubmit" v-if="guesses.length == i">
|
<UForm @submit="onsubmit" v-if="guesses.length == i">
|
||||||
<UPinInput default class="mb-2" autofocus v-model="guess" color="neutral" size="lg" :length="length"/>
|
|
||||||
|
<UPinInput v-if="guesses[guesses.length-1].toString().replace(/\,/gi, '') != correct" default class="mb-2" autofocus v-model="guess" color="neutral" :length="length" size="lg" :correct="correct" />
|
||||||
|
|
||||||
|
<WordleRow v-else :length="length"/>
|
||||||
|
|
||||||
<UButton type="submit" style="display: none;">
|
<UButton type="submit" style="display: none;">
|
||||||
Submit
|
Submit
|
||||||
</UButton>
|
</UButton>
|
||||||
</UForm>
|
</UForm>
|
||||||
<WordleRow v-if="guesses.length < i"/>
|
<WordleRow v-if="guesses.length < i" :length="length"/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -25,18 +32,26 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
max_guesses: 5,
|
max_guesses: 10,
|
||||||
open: true,
|
open: true,
|
||||||
guess: '',
|
guess: '',
|
||||||
length: 8,
|
length: 8,
|
||||||
guesses: [''],
|
guesses: [''],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
correct: {
|
||||||
|
type: String,
|
||||||
|
default: 'nagyonhosszezugyselesz'
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onsubmit () {
|
onsubmit () {
|
||||||
|
if (this.guess.length == this.length) {
|
||||||
this.guesses.push(this.guess);
|
this.guesses.push(this.guess);
|
||||||
this.guess = '';
|
this.guess = '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { empty } from 'valibot';
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex-container gap-1.5">
|
<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}">
|
<div v-for="i in length" class="border border-default wr-div" :class="{'correct' : getCorrectness[i-1]==2, 'wrong-place' : getCorrectness[i-1]==1}">
|
||||||
{{ getGuess[i-1] }}
|
{{ guess[i-1] }}
|
||||||
{{ correct[i-1] }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -17,7 +14,6 @@ import { empty } from 'valibot';
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -30,26 +26,33 @@ import { empty } from 'valibot';
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
index: Number,
|
index: Number,
|
||||||
|
empty: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
length: Number,
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
getGuess() {
|
|
||||||
let guess = '';
|
|
||||||
if (this.guess.length == 0)
|
|
||||||
{
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
guess += ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return guess;
|
|
||||||
},
|
|
||||||
getCorrectness() : number[] {
|
getCorrectness() : number[] {
|
||||||
|
let correctness_alt = [];
|
||||||
let correctness = [];
|
let correctness = [];
|
||||||
for (let i = 0; i < this.guess.length; i++) {
|
for (let i = 0; i < this.guess.length; i++) {
|
||||||
if (this.guess[i] == this.correct[i]) {
|
if (this.guess[i] == this.correct[i]) {
|
||||||
correctness.push(2);
|
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;
|
return correctness;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -73,4 +76,7 @@ import { empty } from 'valibot';
|
|||||||
.wrong-place {
|
.wrong-place {
|
||||||
background-color: rgb(37, 43, 154);
|
background-color: rgb(37, 43, 154);
|
||||||
}
|
}
|
||||||
|
.empty {
|
||||||
|
background-color: rgb(93, 93, 93);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -147,7 +147,7 @@ import Wordle from '../components/Wordle.vue';
|
|||||||
{{ context }}
|
{{ context }}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Wordle/>
|
<Wordle correct="testword"/>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user