mirror of
https://github.com/aquatix/alfagok.git
synced 2025-12-06 22:15:11 +01:00
Compare commits
8 Commits
cc20e80bf5
...
savegames
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ae7b8618f | |||
| f52ae3cb8f | |||
| bbfa172e7a | |||
| 795ee7aa16 | |||
| 48ccb99492 | |||
| 4058dc3a7a | |||
| e7a39becfc | |||
| f8a3561d9a |
@@ -50,11 +50,11 @@ mdurl==0.1.2
|
|||||||
# via markdown-it-py
|
# via markdown-it-py
|
||||||
packaging==24.2
|
packaging==24.2
|
||||||
# via gunicorn
|
# via gunicorn
|
||||||
pydantic==2.9.2
|
pydantic==2.10.1
|
||||||
# via
|
# via
|
||||||
# fastapi
|
# fastapi
|
||||||
# pydantic-settings
|
# pydantic-settings
|
||||||
pydantic-core==2.23.4
|
pydantic-core==2.27.1
|
||||||
# via pydantic
|
# via pydantic
|
||||||
pydantic-settings==2.6.1
|
pydantic-settings==2.6.1
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
@@ -86,7 +86,7 @@ typing-extensions==4.12.2
|
|||||||
# pydantic
|
# pydantic
|
||||||
# pydantic-core
|
# pydantic-core
|
||||||
# typer
|
# typer
|
||||||
uvicorn==0.32.0
|
uvicorn==0.32.1
|
||||||
# via
|
# via
|
||||||
# fastapi
|
# fastapi
|
||||||
# fastapi-cli
|
# fastapi-cli
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ markupsafe==3.0.2
|
|||||||
# via jinja2
|
# via jinja2
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
# via markdown-it-py
|
# via markdown-it-py
|
||||||
pydantic==2.9.2
|
pydantic==2.10.1
|
||||||
# via
|
# via
|
||||||
# fastapi
|
# fastapi
|
||||||
# pydantic-settings
|
# pydantic-settings
|
||||||
pydantic-core==2.23.4
|
pydantic-core==2.27.1
|
||||||
# via pydantic
|
# via pydantic
|
||||||
pydantic-settings==2.6.1
|
pydantic-settings==2.6.1
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
@@ -82,7 +82,7 @@ typing-extensions==4.12.2
|
|||||||
# pydantic
|
# pydantic
|
||||||
# pydantic-core
|
# pydantic-core
|
||||||
# typer
|
# typer
|
||||||
uvicorn==0.32.0
|
uvicorn==0.32.1
|
||||||
# via
|
# via
|
||||||
# fastapi
|
# fastapi
|
||||||
# fastapi-cli
|
# fastapi-cli
|
||||||
|
|||||||
@@ -1,25 +1,30 @@
|
|||||||
document.addEventListener('alpine:init', () => {
|
document.addEventListener('alpine:init', () => {
|
||||||
Alpine.store('alfagok', {
|
Alpine.store('alfagok', {
|
||||||
|
// isLocalStorageAvailable: this.testLocalStorage(),
|
||||||
|
isLocalStorageAvailable: false,
|
||||||
|
savedGameKey: 'saveGame',
|
||||||
|
|
||||||
/* Main alfagok application, state etc */
|
/* Main alfagok application, state etc */
|
||||||
gameID: 0,
|
gameID: Alpine.$persist(0).as('gameID'),
|
||||||
countingDown: '',
|
countingDown: '',
|
||||||
|
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
||||||
winTime: null,
|
winTime: Alpine.$persist(null).as('winTime'),
|
||||||
startTime: null,
|
startTime: Alpine.$persist(null).as('startTime'),
|
||||||
|
gaveUpTime: Alpine.$persist(null).as('gaveUpTime'), // not implemented yet
|
||||||
|
|
||||||
nrGuesses: 0,
|
nrGuesses: Alpine.$persist(0).as('nrGuesses'),
|
||||||
guessesBefore: [],
|
guessesBefore: Alpine.$persist([]).as('guessesBefore'),
|
||||||
guessesAfter: [],
|
guessesAfter: Alpine.$persist([]).as('guessesAfter'),
|
||||||
|
|
||||||
guessValue: '',
|
guessValue: Alpine.$persist('').as('guessValue'),
|
||||||
|
|
||||||
guessError: '',
|
guessError: '',
|
||||||
|
|
||||||
resultGameID: '',
|
resultGameID: Alpine.$persist('').as('resultGameID'),
|
||||||
resultGuesses: '',
|
resultGuesses: Alpine.$persist('').as('resultGuesses'),
|
||||||
resultTimeTaken: '',
|
resultTimeTaken: Alpine.$persist('').as('resultTimeTaken'),
|
||||||
|
|
||||||
async getGameID() {
|
async getGameID() {
|
||||||
/* Get the game number from the backend */
|
/* Get the game number from the backend */
|
||||||
@@ -30,6 +35,9 @@ document.addEventListener('alpine:init', () => {
|
|||||||
console.log(result);
|
console.log(result);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
if (result.game) {
|
if (result.game) {
|
||||||
|
if (this.gameID !== result.game) {
|
||||||
|
this.setEmptyGameState();
|
||||||
|
}
|
||||||
return this.gameID = result.game;
|
return this.gameID = result.game;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -87,11 +95,31 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.winTime = new Date();
|
this.winTime = new Date();
|
||||||
this.resultGameID = '🧩 Puzzel #' + this.gameID;
|
this.resultGameID = '🧩 Puzzel #' + this.gameID;
|
||||||
this.resultGuesses = '🤔 '+ this.nrGuesses + ' gokken';
|
this.resultGuesses = '🤔 '+ this.nrGuesses + ' gokken';
|
||||||
this.resultTimeTaken = '⏱️ ' + getFormattedTime(this.winTime - this.startTime);
|
let winTimeDate = new Date(this.winTime);
|
||||||
|
let startTimeDate = new Date(this.startTime);
|
||||||
|
// this.resultTimeTaken = '⏱️ ' + getFormattedTime(this.winTime - this.startTime);
|
||||||
|
this.resultTimeTaken = '⏱️ ' + getFormattedTime(winTimeDate - startTimeDate);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setEmptyGameState() {
|
||||||
|
this.winTime = null;
|
||||||
|
this.startTime = null;
|
||||||
|
|
||||||
|
this.nrGuesses = 0;
|
||||||
|
this.guessesBefore = [];
|
||||||
|
this.guessesAfter = [];
|
||||||
|
|
||||||
|
this.guessValue = '';
|
||||||
|
|
||||||
|
this.guessError = '';
|
||||||
|
|
||||||
|
this.resultGameID = '';
|
||||||
|
this.resultGuesses = '';
|
||||||
|
this.resultTimeTaken = '';
|
||||||
|
|
||||||
|
this.getGameID();
|
||||||
|
},
|
||||||
|
// # Countdown timer
|
||||||
getFormattedTime(milliseconds) {
|
getFormattedTime(milliseconds) {
|
||||||
if (!Number.isInteger(milliseconds)) {
|
if (!Number.isInteger(milliseconds)) {
|
||||||
return '';
|
return '';
|
||||||
@@ -129,8 +157,7 @@ document.addEventListener('alpine:init', () => {
|
|||||||
let secondsRemain = Math.floor(diff%60);
|
let secondsRemain = Math.floor(diff%60);
|
||||||
nextgame.innerHTML = '<span class="nextgame">'+addZero(hoursRemain)+':'+addZero(minutesRemain)+':'+addZero(secondsRemain)+' over</span>';
|
nextgame.innerHTML = '<span class="nextgame">'+addZero(hoursRemain)+':'+addZero(minutesRemain)+':'+addZero(secondsRemain)+' over</span>';
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}),
|
|
||||||
|
|
||||||
Alpine.store('darkMode', {
|
Alpine.store('darkMode', {
|
||||||
/* Different Alpine app, dark mode settings for the game */
|
/* Different Alpine app, dark mode settings for the game */
|
||||||
|
|||||||
@@ -11,13 +11,14 @@
|
|||||||
<link rel="icon" type="image/png" sizes="32x32" href="static/images/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="static/images/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="static/images/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="static/images/favicon-16x16.png">
|
||||||
<link rel="manifest" href="static/images/site.webmanifest">
|
<link rel="manifest" href="static/images/site.webmanifest">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@alpinejs/persist@3.x.x/dist/cdn.min.js"></script>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="container" x-data="">
|
<div id="container" x-data="">
|
||||||
|
|
||||||
<a href="/" x-cloak class="title">alfagok</a> <span class="puzzleno">puzzel #<span x-text="$store.alfagok.gameID"></span> • <span id="nextgame"></span> | <span x-text="$store.alfagok.countingDown" • <span x-text="$store.alfagok.nrGuesses"></span> gokken</span>
|
<a href="/" x-cloak class="title">alfagok</a> <span class="puzzleno">puzzel #<span x-text="$store.alfagok.gameID"></span> • <span id="nextgame"></span> | <span x-text="$store.alfagok.countingDown"></span> • <span x-text="$store.alfagok.nrGuesses"></span> gokken</span>
|
||||||
|
|
||||||
<div x-cloak class="instructions" x-show="$store.alfagok.guessesBefore.length === 0 && $store.alfagok.guessesAfter.length === 0">
|
<div x-cloak class="instructions" x-show="$store.alfagok.guessesBefore.length === 0 && $store.alfagok.guessesAfter.length === 0">
|
||||||
<p>Raad het woord van de dag. Elke gok geeft een hint over waar het woord zich in het alfabet bevindt.</p>
|
<p>Raad het woord van de dag. Elke gok geeft een hint over waar het woord zich in het alfabet bevindt.</p>
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
<p><b x-text="$store.alfagok.resultGameID"></b></p>
|
<p><b x-text="$store.alfagok.resultGameID"></b></p>
|
||||||
<p x-text="$store.alfagok.resultGuesses"></p>
|
<p x-text="$store.alfagok.resultGuesses"></p>
|
||||||
<p x-text="$store.alfagok.resultTimeTaken"></p>
|
<p x-text="$store.alfagok.resultTimeTaken"></p>
|
||||||
<p>🔗 <span style="color:var(--blue)">alfagok.diginaut.net</span></p>
|
<p>🔗 <span class="link">alfagok.diginaut.net</span></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="copyresults"></div>
|
<div id="copyresults"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user