wordle backend and some frontend changes
Build / Build-image (push) Successful in 1m13s

This commit is contained in:
2026-08-27 22:33:19 +02:00
parent 865ac153b2
commit 5d5250287d
6 changed files with 92 additions and 47 deletions
+14
View File
@@ -17,6 +17,7 @@ class TlaController extends Controller
$session->forget('tla-'.$language); $session->forget('tla-'.$language);
$session->forget('correct-'.$language); $session->forget('correct-'.$language);
$session->forget('review-'.$language); $session->forget('review-'.$language);
$session->put('tla-array-'.$language, ['', '', '']);
$session->put('date-'.$language, date('Y-m-d')); $session->put('date-'.$language, date('Y-m-d'));
} }
} }
@@ -27,6 +28,9 @@ class TlaController extends Controller
if ( !in_array($language, $allowedLanguages) ) $language = 'en'; if ( !in_array($language, $allowedLanguages) ) $language = 'en';
$tla = Tla::GetCurrentTla($language); $tla = Tla::GetCurrentTla($language);
if ($tla == NULL) return response()->json([ 'no_tla' => true ]);
$this->session_flush($request, $language); $this->session_flush($request, $language);
$session = $request->session(); $session = $request->session();
@@ -39,6 +43,7 @@ class TlaController extends Controller
'context' => $session->get('tla-'.$language) == $tla->acronym ? $tla->context : NULL, 'context' => $session->get('tla-'.$language) == $tla->acronym ? $tla->context : NULL,
'submitter' => $tla->submitter, 'submitter' => $tla->submitter,
'correct' => $session->get('correct-'.$language), 'correct' => $session->get('correct-'.$language),
'tla_array' => ['','',''],
]); ]);
} }
@@ -96,6 +101,14 @@ class TlaController extends Controller
if ($score == 12) $session->put('correct-'.$language, true); if ($score == 12) $session->put('correct-'.$language, true);
} }
$tla_array = $session->get('tla-array-'.$language);
for ($i = 0; $i < 3; $i++) {
if ($tla_array[$i] == "" && $guess_array[$i + 3] == 2) $tla_array[$i] = $tla[$i];
}
$session->put('tla-array-'.$language, $tla_array);
return response()->json([ return response()->json([
'guesses' => $guesses, 'guesses' => $guesses,
'date' => $session->get('date'), 'date' => $session->get('date'),
@@ -103,6 +116,7 @@ class TlaController extends Controller
'context' => $session->get('tla-'.$language) == $tla_object->acronym ? $tla_object->context : NULL, 'context' => $session->get('tla-'.$language) == $tla_object->acronym ? $tla_object->context : NULL,
'score' => $score, 'score' => $score,
'correct' => $session->get('correct-'.$language), 'correct' => $session->get('correct-'.$language),
'tla_array' => $tla_array,
]); ]);
} }
+3 -1
View File
@@ -13,7 +13,7 @@ class Tla extends Model
protected $fillable = ['acronym', 'hint', 'language', 'used', 'context', 'submitter', 'likes', 'dislikes']; protected $fillable = ['acronym', 'hint', 'language', 'used', 'context', 'submitter', 'likes', 'dislikes'];
public static function GetCurrentTla( string $language ) : Tla { public static function GetCurrentTla( string $language ) {
$tla = Tla::where('used', date("Y-m-d")) $tla = Tla::where('used', date("Y-m-d"))
->where('language', $language) ->where('language', $language)
->first(); ->first();
@@ -24,6 +24,8 @@ class Tla extends Model
->inRandomOrder() ->inRandomOrder()
->first(); ->first();
if ($tla == NULL) return NULL;
$tla->used = date("Y-m-d"); $tla->used = date("Y-m-d");
$tla->save(); $tla->save();
} }
+29 -6
View File
@@ -1,20 +1,43 @@
<template> <template>
<Transition appear> <button v-if="true"
<div v-if="true" class="gw-div" :class="{ 'less': correctness==-3, 'more': correctness==-2, 'default': correctness==0, 'cw-cp': correctness==4, 'cw-ip': correctness==3, 'cf-cp': correctness==2, 'cf-ip': correctness==1 }"> @click="onclick"
class="gw-div"
:class="{
'less': correctness==-3,
'more': correctness==-2,
'default': correctness==0,
'cw-cp': correctness==4,
'cw-ip': correctness==3,
'cf-cp': correctness==2,
'cf-ip': correctness==1
}">
<slot></slot> <slot></slot>
</div> </button>
</Transition>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Transition } from 'vue';
export default { export default {
data() {
return {
modal_open: false,
}
},
props: { props: {
correctness: { correctness: {
type: Number, type: Number,
default: 0, default: 0,
}, correct: {
type: String,
default: ''
} }
},
},
methods: {
onclick () {
if (this.correctness == 2) this.modal_open = true;
}
},
} }
</script> </script>
+8 -8
View File
@@ -5,19 +5,19 @@
<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]" :length="length" :correct="correct"/> <WordleRow v-if="guesses.length > i" :guess="guesses[i]" :length="correct.length" :correct="correct"/>
<UForm @submit="onsubmit" v-if="guesses.length == i"> <UForm @submit="onsubmit" v-if="guesses.length == i">
<UPinInput v-if="guesses[guesses.length-1].toString().replace(/\,/gi, '') != correct" default class="mb-2" autofocus v-model="guess" color="neutral" :length="correct.length" size="lg" :correct="correct" />
<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="correct.length"/>
<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" :length="length"/>
<WordleRow v-if="guesses.length < i" :length="correct.length"/>
</template> </template>
</div> </div>
</Modal> </Modal>
@@ -35,7 +35,6 @@
max_guesses: 10, max_guesses: 10,
open: true, open: true,
guess: '', guess: '',
length: 8,
guesses: [''], guesses: [''],
} }
}, },
@@ -43,11 +42,12 @@
correct: { correct: {
type: String, type: String,
default: 'nagyonhosszezugyselesz' default: 'nagyonhosszezugyselesz'
} },
}, },
methods: { methods: {
onsubmit () { onsubmit () {
if (this.guess.length == this.length) { if (this.guess.length == this.correct.length) {
this.guesses.push(this.guess); this.guesses.push(this.guess);
this.guess = ''; this.guess = '';
} }
+14 -8
View File
@@ -13,6 +13,7 @@ import Wordle from '../components/Wordle.vue';
hint: ' ', hint: ' ',
guesses: [''], guesses: [''],
words: [''], words: [''],
correct_words: [''],
guess: '', guess: '',
tla: '', tla: '',
context: '', context: '',
@@ -21,6 +22,7 @@ import Wordle from '../components/Wordle.vue';
loss: false, loss: false,
maxGuesses: 10, maxGuesses: 10,
correct: false, correct: false,
no_tla: false,
}; };
}, },
@@ -28,12 +30,15 @@ import Wordle from '../components/Wordle.vue';
axios axios
.get('/api/fetch_tla/en') .get('/api/fetch_tla/en')
.then(response => { .then(response => {
if (response.data.no_tla) this.no_tla = true;
else {
this.hint = response.data.hint; this.hint = response.data.hint;
this.submitter = response.data.submitter; this.submitter = response.data.submitter;
this.guesses = response.data.guesses; this.guesses = response.data.guesses;
this.tla = response.data.tla; this.tla = response.data.tla;
this.context = response.data.context; this.context = response.data.context;
this.correct = response.data.correct; this.correct = response.data.correct;
}
}); });
}, },
@@ -85,10 +90,10 @@ import Wordle from '../components/Wordle.vue';
</template> </template>
<template v-for="guess in guesses"> <template v-for="guess in guesses" v-if="guesses.length>1">
<div class="flex-container"> <div class="flex-container">
<template v-for="i in 3"> <template v-for="i in 3">
<GuessWord :correctness="Number(guess[i+2])"> <GuessWord :correctness="Number(guess[i+2])" :correct="correct_words[i-1]">
{{ guess[i-1] }} {{ guess[i-1] }}
</GuessWord> </GuessWord>
</template> </template>
@@ -96,8 +101,7 @@ import Wordle from '../components/Wordle.vue';
</template> </template>
<template v-if="guesses.length < maxGuesses && !correct && !no_tla">
<template v-if="guesses.length < maxGuesses && !correct">
<div class="flex-container" v-if="guess.length > 0"> <div class="flex-container" v-if="guess.length > 0">
<template v-for="word in words"> <template v-for="word in words">
<GuessWord :correctness="words.length == 3 ? -1 : (words.length > 3 ? -2 : -3)"> <GuessWord :correctness="words.length == 3 ? -1 : (words.length > 3 ? -2 : -3)">
@@ -115,6 +119,10 @@ import Wordle from '../components/Wordle.vue';
</UButton> </UButton>
</UForm> </UForm>
</template> </template>
<template v-else>
<h2>No TLA for today, please shoot me an email to <a style="text-decoration: underline;" href="mailto:peter@sc0tt.org">
peter@sc0tt.org</a></h2>
</template>
<template v-if="!correct && guesses.length >= maxGuesses"> <template v-if="!correct && guesses.length >= maxGuesses">
You ran out of guesses. Todays TLA was <b>{{ tla }}</b> You ran out of guesses. Todays TLA was <b>{{ tla }}</b>
<Review/> <Review/>
@@ -123,7 +131,7 @@ import Wordle from '../components/Wordle.vue';
You completed todays TLAdle! Todays TLA was <b>{{ tla }}</b> You completed todays TLAdle! Todays TLA was <b>{{ tla }}</b>
<Review/> <Review/>
</template> </template>
<h3>Guesses left: {{ maxGuesses - guesses.length }}</h3> <h3 v-if="!no_tla">Guesses left: {{ maxGuesses - guesses.length }}</h3>
</UCard> </UCard>
<br> <br>
<template v-if="submitter != null"> <template v-if="submitter != null">
@@ -146,9 +154,7 @@ import Wordle from '../components/Wordle.vue';
<h3>The context of todays TLA:</h3> <h3>The context of todays TLA:</h3>
{{ context }} {{ context }}
</Modal> </Modal>
<Wordle correct="sadf"/>
<Wordle correct="testword"/>
</template> </template>