v2.0 #7
@@ -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
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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="length" size="lg" :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" />
|
||||
|
||||
<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"/>
|
||||
<UButton type="submit" style="display: none;">
|
||||
Submit
|
||||
</UButton>
|
||||
</UForm>
|
||||
|
||||
<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 = '';
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
<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}">
|
||||
{{ guess[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>
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ import Wordle from '../components/Wordle.vue';
|
||||
data() {
|
||||
return {
|
||||
hint: ' ',
|
||||
guesses: [' '],
|
||||
words: [' '],
|
||||
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 => {
|
||||
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;
|
||||
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,26 +90,25 @@ 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>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<template v-if="guesses.length < maxGuesses && !correct">
|
||||
<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)">
|
||||
{{ word }}
|
||||
</GuessWord>
|
||||
</template>
|
||||
</div>
|
||||
<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)">
|
||||
{{ word }}
|
||||
</GuessWord>
|
||||
</template>
|
||||
</div>
|
||||
<UForm class="space-y-2" ref="main-form" @submit="onSubmit" onsubmit="return false">
|
||||
<UFormField>
|
||||
<UInput v-model="guess" @keyup="onkeyup()" autofocus/>
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user