v2.0 #7

Merged
Belupeti merged 13 commits from dev into master 2026-09-05 20:28:29 +02:00
6 changed files with 92 additions and 47 deletions
Showing only changes of commit 5d5250287d - Show all commits
+14
View File
@@ -17,6 +17,7 @@ class TlaController extends Controller
$session->forget('tla-'.$language);
$session->forget('correct-'.$language);
$session->forget('review-'.$language);
$session->put('tla-array-'.$language, ['', '', '']);
$session->put('date-'.$language, date('Y-m-d'));
}
}
@@ -27,6 +28,9 @@ class TlaController extends Controller
if ( !in_array($language, $allowedLanguages) ) $language = 'en';
$tla = Tla::GetCurrentTla($language);
if ($tla == NULL) return response()->json([ 'no_tla' => true ]);
$this->session_flush($request, $language);
$session = $request->session();
@@ -39,6 +43,7 @@ class TlaController extends Controller
'context' => $session->get('tla-'.$language) == $tla->acronym ? $tla->context : NULL,
'submitter' => $tla->submitter,
'correct' => $session->get('correct-'.$language),
'tla_array' => ['','',''],
]);
}
@@ -96,6 +101,14 @@ class TlaController extends Controller
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([
'guesses' => $guesses,
'date' => $session->get('date'),
@@ -103,6 +116,7 @@ class TlaController extends Controller
'context' => $session->get('tla-'.$language) == $tla_object->acronym ? $tla_object->context : NULL,
'score' => $score,
'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'];
public static function GetCurrentTla( string $language ) : Tla {
public static function GetCurrentTla( string $language ) {
$tla = Tla::where('used', date("Y-m-d"))
->where('language', $language)
->first();
@@ -24,6 +24,8 @@ class Tla extends Model
->inRandomOrder()
->first();
if ($tla == NULL) return NULL;
$tla->used = date("Y-m-d");
$tla->save();
}
+29 -6
View File
@@ -1,20 +1,43 @@
<template>
<Transition appear>
<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 }">
<button v-if="true"
@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>
</div>
</Transition>
</button>
</template>
<script lang="ts">
import { Transition } from 'vue';
export default {
data() {
return {
modal_open: false,
}
},
props: {
correctness: {
type: Number,
default: 0,
},
correct: {
type: String,
default: ''
}
},
},
methods: {
onclick () {
if (this.correctness == 2) this.modal_open = true;
}
},
}
</script>
+8 -8
View File
@@ -5,19 +5,19 @@
<div class="flex-container-a gap-1.5">
<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">
<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="length"/>
<WordleRow v-else :length="correct.length"/>
<UButton type="submit" style="display: none;">
Submit
</UButton>
</UForm>
<WordleRow v-if="guesses.length < i" :length="length"/>
<WordleRow v-if="guesses.length < i" :length="correct.length"/>
</template>
</div>
</Modal>
@@ -35,7 +35,6 @@
max_guesses: 10,
open: true,
guess: '',
length: 8,
guesses: [''],
}
},
@@ -43,11 +42,12 @@
correct: {
type: String,
default: 'nagyonhosszezugyselesz'
}
},
},
methods: {
onsubmit () {
if (this.guess.length == this.length) {
if (this.guess.length == this.correct.length) {
this.guesses.push(this.guess);
this.guess = '';
}
+14 -8
View File
@@ -13,6 +13,7 @@ import Wordle from '../components/Wordle.vue';
hint: ' ',
guesses: [''],
words: [''],
correct_words: [''],
guess: '',
tla: '',
context: '',
@@ -21,6 +22,7 @@ import Wordle from '../components/Wordle.vue';
loss: false,
maxGuesses: 10,
correct: false,
no_tla: false,
};
},
@@ -28,12 +30,15 @@ import Wordle from '../components/Wordle.vue';
axios
.get('/api/fetch_tla/en')
.then(response => {
if (response.data.no_tla) this.no_tla = true;
else {
this.hint = response.data.hint;
this.submitter = response.data.submitter;
this.guesses = response.data.guesses;
this.tla = response.data.tla;
this.context = response.data.context;
this.correct = response.data.correct;
}
});
},
@@ -85,10 +90,10 @@ import Wordle from '../components/Wordle.vue';
</template>
<template v-for="guess in guesses">
<template v-for="guess in guesses" v-if="guesses.length>1">
<div class="flex-container">
<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] }}
</GuessWord>
</template>
@@ -96,8 +101,7 @@ import Wordle from '../components/Wordle.vue';
</template>
<template v-if="guesses.length < maxGuesses && !correct">
<template v-if="guesses.length < maxGuesses && !correct && !no_tla">
<div class="flex-container" v-if="guess.length > 0">
<template v-for="word in words">
<GuessWord :correctness="words.length == 3 ? -1 : (words.length > 3 ? -2 : -3)">
@@ -115,6 +119,10 @@ import Wordle from '../components/Wordle.vue';
</UButton>
</UForm>
</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">
You ran out of guesses. Todays TLA was <b>{{ tla }}</b>
<Review/>
@@ -123,7 +131,7 @@ import Wordle from '../components/Wordle.vue';
You completed todays TLAdle! Todays TLA was <b>{{ tla }}</b>
<Review/>
</template>
<h3>Guesses left: {{ maxGuesses - guesses.length }}</h3>
<h3 v-if="!no_tla">Guesses left: {{ maxGuesses - guesses.length }}</h3>
</UCard>
<br>
<template v-if="submitter != null">
@@ -146,9 +154,7 @@ import Wordle from '../components/Wordle.vue';
<h3>The context of todays TLA:</h3>
{{ context }}
</Modal>
<Wordle correct="testword"/>
<Wordle correct="sadf"/>
</template>