From ec4219864291195b18aaa90b69cbed50fa48e0da Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Mon, 3 Apr 2023 10:39:49 +0200 Subject: [PATCH] fix end of game bug --- src/Model/Deck.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Model/Deck.js b/src/Model/Deck.js index d0e6d96..adb7327 100755 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -29,8 +29,12 @@ class Deck { */ createDeck(nbCards) {//toTest⌛when more than 12c to d't add other cards if (this.remainingCards.length < this.nbCards) {// no more cards - console.log("PLUS DE CARTES"); - return 2; + if(setsCounter(this.outputCards, this.nbCards)==0){ + return 2; + } + else{ + return 1; + } } else { let nbSets = setsCounter(this.outputCards, this.nbCards); @@ -45,8 +49,6 @@ class Deck { } nbSets = setsCounter(this.outputCards, this.nbCards); console.log("nbSets", nbSets); - // console.log("outputCards.length", this.outputCards.length); - // console.log("remainingCards.length", this.remainingCards.length); if (nbSets == 0) { this.createDeck(this.nbCards) } @@ -70,6 +72,7 @@ class Deck { * @author Bastien Jacquelin */ checkSet(selectedCards) {//toTest⌛ + console.log("nb set",setsCounter(this.outputCards, this.nbCards)) if (isSet(selectedCards)){// is a set if (this.outputCards.length == 0) {//plus de deck console.log("C'est win") @@ -81,13 +84,13 @@ class Deck { return 2; } else{//encore des set - this.removeFromoutputCards(selectedCards); - return 1; + console.log("plus la pile") + return this.removeFromoutputCards(selectedCards); } } else{// encore de la pile - this.removeFromoutputCards(selectedCards); - return 1; + console.log("encore de la pile") + return this.removeFromoutputCards(selectedCards); } } }