From 76d2378146c7918b0a0864ea0e32e7c0e1a39730 Mon Sep 17 00:00:00 2001 From: bajacqueli Date: Sun, 2 Apr 2023 13:12:30 +0200 Subject: [PATCH] fix bug, now remove the element key + value in the selectedCard array --- views/deck-module.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/views/deck-module.js b/views/deck-module.js index b40dc39..8f11c18 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -22,11 +22,11 @@ export default{ if(this.nbCardsSelected>=this.deck.nbCards){ this.set(); } - else{ - if(this.selectedCards[id]!=null){ + else{// pas suffisament de cartes pour un set + if(this.selectedCards[id]!=null){// carte déja selectionnée document.querySelector(`#id${id}`).setAttribute("style","border: none;cursor: pointer;"); this.nbCardsSelected-=1 - this.selectedCards[id]=null + delete this.selectedCards[id]//pb this.selectedCardsindex.splice(this.selectedCardsindex.indexOf(id),1) } else{ @@ -41,6 +41,7 @@ export default{ } }, set(){ + console.log("this.selectedCards",this.selectedCards) let checkSet=this.deck.checkSet(this.selectedCards); if(checkSet){//is set @@ -51,8 +52,8 @@ export default{ }) // flush array this.nbCardsSelected=0; - this.selectedCards.splice(0,this.selectedCards.length+1) - this.selectedCardsindex.splice(0,this.selectedCardsindex.length+1) + this.selectedCards=[] + this.selectedCardsindex=[] }, }, template:`