connecer la partie score a l'api

front
Gwenael PLANCHON 1 year ago
parent 2462abfee9
commit d41221bd7d

@ -32,8 +32,6 @@ export default {
},
//variables pour les scores
score:{
leaderboard:{},
score:0,
pointsGagne:0,
},
pointsAnimation:0
@ -63,14 +61,13 @@ export default {
return this.obtenirQuestion
},
obtenirQuestion(){
this.resetEtats() //cacher l'etat precedent
this.kahootAPI.obtenirQuestion().then(response=>{
this.resetEtats() //cacher l'etat precedent
this.tempsLimite=response.tempsLimite
//afficher cet etat
this.etats.question=true
this.question=response.questionActuel
console.log(this.question)
if(this.tempsLimite!=-1){
//executer la fonction en boucle jusqu'a ce que la partie se termine
@ -82,7 +79,6 @@ export default {
)
},
obtenirScores(){
/*
this.resetEtats() //cacher l'etat precedent
this.kahootAPI.obtenirScore().then(response=>{
this.tempsLimite=response.tempsLimite
@ -101,7 +97,7 @@ export default {
this.compteAReboursId=window.setInterval(this.calculerCompteARebours,22)
}
}
)*/
)
},
obtenirSalleAttente(){
this.resetEtats() //cacher l'etat precedent
@ -180,8 +176,8 @@ export default {
<div v-show="etats.score">
<h2>Votre score : {{ pointsAnimation }} (+{{ score.pointsGagne }})</h2>
<ol class="leaderboard">
<li v-for="joueur in Object.keys(score.leaderboard)">
{{ joueur }} : {{score.leaderboard[joueur]}}
<li v-for="scorejoueur in score.scores">
{{ scorejoueur.joueur.pseudo }} : {{scorejoueur.score}}
</li>
</ol>
</div>

@ -15,6 +15,10 @@ export class Kahoot{
const response=await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}/question`)
return new KahootQuestion(await response.json())
}
async obtenirScore(){
const response=await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}/status`)
return new KahootScore(await response.json())
}
async repondreQuestion(id){
const user = await Utilisateur.utilisateurConnecteOuCreerInvite()
const response = await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}/reponse`,{
@ -106,9 +110,17 @@ export class KahootQuestion extends DataObject{
/* JSON de reference (score)
{
"score":1337,
"pointsGagne":100,
"leaderboard":{"Moi":1337, "Titouan":320},
"status": "Pending|Started|Ended",
"scores": [
{"joueur": {"id": 0, "pseudo": 0},
"score": 0},
],
"tempsLimite":${Date.now()+this.DEBUG_temps maintenant + 10 secondes le temps de regarder les scores}
}
*/
*/
export class KahootScore extends DataObject{
constructor(parsedJSON){
super(parsedJSON)
this.tempsLimite=Date.now()+10000
}
}
Loading…
Cancel
Save