fix end of game bug
continuous-integration/drone/push Build is passing Details

master
Bastien JACQUELIN 2 years ago
parent e54a8e652f
commit ec42198642

@ -29,9 +29,13 @@ class Deck {
*/ */
createDeck(nbCards) {//toTest⌛when more than 12c to d't add other cards createDeck(nbCards) {//toTest⌛when more than 12c to d't add other cards
if (this.remainingCards.length < this.nbCards) {// no more cards if (this.remainingCards.length < this.nbCards) {// no more cards
console.log("PLUS DE CARTES"); if(setsCounter(this.outputCards, this.nbCards)==0){
return 2; return 2;
} }
else{
return 1;
}
}
else { else {
let nbSets = setsCounter(this.outputCards, this.nbCards); let nbSets = setsCounter(this.outputCards, this.nbCards);
if(this.outputCards.length>=12 && nbSets!=0){ if(this.outputCards.length>=12 && nbSets!=0){
@ -45,8 +49,6 @@ class Deck {
} }
nbSets = setsCounter(this.outputCards, this.nbCards); nbSets = setsCounter(this.outputCards, this.nbCards);
console.log("nbSets", nbSets); console.log("nbSets", nbSets);
// console.log("outputCards.length", this.outputCards.length);
// console.log("remainingCards.length", this.remainingCards.length);
if (nbSets == 0) { if (nbSets == 0) {
this.createDeck(this.nbCards) this.createDeck(this.nbCards)
} }
@ -70,6 +72,7 @@ class Deck {
* @author Bastien Jacquelin * @author Bastien Jacquelin
*/ */
checkSet(selectedCards) {//toTest⌛ checkSet(selectedCards) {//toTest⌛
console.log("nb set",setsCounter(this.outputCards, this.nbCards))
if (isSet(selectedCards)){// is a set if (isSet(selectedCards)){// is a set
if (this.outputCards.length == 0) {//plus de deck if (this.outputCards.length == 0) {//plus de deck
console.log("C'est win") console.log("C'est win")
@ -81,13 +84,13 @@ class Deck {
return 2; return 2;
} }
else{//encore des set else{//encore des set
this.removeFromoutputCards(selectedCards); console.log("plus la pile")
return 1; return this.removeFromoutputCards(selectedCards);
} }
} }
else{// encore de la pile else{// encore de la pile
this.removeFromoutputCards(selectedCards); console.log("encore de la pile")
return 1; return this.removeFromoutputCards(selectedCards);
} }
} }
} }

Loading…
Cancel
Save