From e48f3d3caf5e732e63533532e1420cce84d92451 Mon Sep 17 00:00:00 2001 From: Ota Prokopec Date: Sun, 19 Mar 2023 15:19:43 +0100 Subject: [PATCH] finish fix --- src/routes/game/Forms/Finish.svelte | 28 +++++++++++++++---- src/routes/game/Forms/Renderer.svelte | 40 +++++++++++++-------------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/routes/game/Forms/Finish.svelte b/src/routes/game/Forms/Finish.svelte index f068716..0d4b965 100644 --- a/src/routes/game/Forms/Finish.svelte +++ b/src/routes/game/Forms/Finish.svelte @@ -1,12 +1,28 @@ - - -
-
- + +
+
+ Získali jste {client.points} / {client.possiblePointsToSeize} bodů + + {#if score > 90} + {@html gameData.ExpEnd100} + {:else if score > 50} + {@html gameData.ExpEnd60} + {:else} + {@html gameData.ExpEnd0} + {/if} + +
+
diff --git a/src/routes/game/Forms/Renderer.svelte b/src/routes/game/Forms/Renderer.svelte index f9989c0..c8b6abf 100644 --- a/src/routes/game/Forms/Renderer.svelte +++ b/src/routes/game/Forms/Renderer.svelte @@ -11,6 +11,7 @@ import { data } from '$lib/stores/game' import Erantmap from '$lib/components/Map/Erantmap.svelte' import Info from './Info.svelte' + import { Experience } from '$lib/TStypes/experiences' const components = { TEXT: TextForm, @@ -25,47 +26,43 @@ export let control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null = null let view: 'question' | 'map' | 'end' = 'map' - export let gameData: any = {} //data - $: console.log(gameData) + export let gameData: Experience //data + $: console.log(client) - let clientAnswers = { + let client = { //user data about game pos: 0, end: gameData.checkPoints.length - 1, //kolik otázek points: 0, //body + possiblePointsToSeize: gameData.checkPoints.length * 2, } - $: console.log(clientAnswers.pos === clientAnswers.end + 1) - - $: if (control === 'correct') clientAnswers.points += 2 //body bodování + $: if (control === 'correct' && gameData.checkPoints[client.pos].CPType !== 'INFO') client.points += 2 //only for now const nextQuestion = () => { //další otázka - - console.log({ control }) - control = null - if (clientAnswers.pos === clientAnswers.end) view = 'end' + if (client.pos === client.end) view = 'end' else { - clientAnswers.pos++ + client.pos++ view = 'map' } } //let answers - //$: if (clientAnswers.pos < clientAnswers.end) answers = parseQuestion(gameData.questions[clientAnswers.pos].answer, gameData.questions[clientAnswers.pos].type) //delete + //$: if (client.pos < client.end) answers = parseQuestion(gameData.questions[client.pos].answer, gameData.questions[client.pos].type) //delete let page = null - $: page = view === 'question' ? components[gameData.checkPoints[clientAnswers.pos].CPType] : null + $: page = view === 'question' ? components[gameData.checkPoints[client.pos].CPType] : null let [lat, lng] = [null, null] - $: if (clientAnswers.pos < clientAnswers.end) [lat, lng] = $data.checkPoints[clientAnswers.pos].CPLocation + $: if (client.pos < client.end) [lat, lng] = $data.checkPoints[client.pos].CPLocation let user = { lat: 0, lng: 0 } /* //set user to localstorage - $: if (clientAnswers.pos !== clientAnswers.end && clientAnswers.pos !== 0) { + $: if (client.pos !== client.end && client.pos !== 0) { //nastaví - localStorage.setItem(`/${gameData.url}`, JSON.stringify(clientAnswers.pos)) + localStorage.setItem(`/${gameData.url}`, JSON.stringify(client.pos)) localStorage.setItem('lastGame', `/${gameData.url}`) } else { //vymaže když jsi dohrál @@ -76,11 +73,11 @@ //is user already in game const userInGame = JSON.parse(localStorage.getItem(location.pathname)) if (userInGame) { - clientAnswers.pos = userInGame + client.pos = userInGame }*/ - + {#if view === 'map'} @@ -90,10 +87,11 @@ {/if} {#if view === 'question'} - + {/if} {#if view === 'end'} - - Získali jste {clientAnswers.points} / {clientAnswers.end * 2} bodů + + Získali jste {client.points} / {client.possiblePointsToSeize} bodů + {/if}