diff --git a/index.html b/index.html index 4f3d442..cc59ea0 100755 --- a/index.html +++ b/index.html @@ -7,6 +7,7 @@ +
diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 3d17b4b..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,20 +72,31 @@ 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) { + if (this.outputCards.length == 0) {//plus de deck console.log("C'est win") return 2; } - else { - return this.removeFromoutputCards(selectedCards); + else {//encore des cartes sur le deck + if(this.remainingCards.length < this.nbCards){// plus de pile + if(setsCounter(this.outputCards, this.nbCards) == 0){//plus de set mais encore des cartes dans le deck + return 2; + } + else{//encore des set + console.log("plus la pile") + return this.removeFromoutputCards(selectedCards); + } + } + else{// encore de la pile + console.log("encore de la pile") + return this.removeFromoutputCards(selectedCards); + } } } - else if (this.remainingCards.length < this.nbCards) { - console.log("C'est win") - return 2; + else{// pas un set + return -1; } - return 0; } /** diff --git a/src/algo.js b/src/algo.js index 64881a4..7792ee3 100755 --- a/src/algo.js +++ b/src/algo.js @@ -14,7 +14,9 @@ function isSet(cards) for(let j = 0; j < attributesMatrix.length; j++) { listAttributes.push(attributesMatrix[j][i]); } - if(!checkAttributes(listAttributes)){ + console.log("JE SUIS LES ATTRIBUTS") + console.log(listAttributes) + if(!checkAttributes2(listAttributes,attributesMatrix.length)){ return false; } } @@ -23,6 +25,17 @@ function isSet(cards) } +function checkAttributes2(params,length) { + var tab = [] + params.forEach(element => { + if (!tab.includes(element)) { + tab.push(element) + } + }); + console.log(tab.length === 1 || tab.length === length) + return tab.length === 1 || tab.length === length; +} + function checkAttributes(attributes){ let orderingMethod = "null"; // Can only take ["null", "same", "different"] let boolLoop = true; diff --git a/views/deck-module.js b/views/deck-module.js index fabe6bb..25ade03 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -3,13 +3,13 @@ export default{ props:{ deck:Deck, idRoom:String, - mode:Boolean//true for chrono + mode:Boolean,//true for chrono + hyperSet:Boolean, }, data: function(){ return{ card:new Card({"filling":"empty"}), id:0, - //deck : new Deck([0,1,2],3), selectedCards:[], selectedCardsindex:[], nbCardsSelected:0, diff --git a/views/room.html b/views/room.html new file mode 100644 index 0000000..1754092 --- /dev/null +++ b/views/room.html @@ -0,0 +1,77 @@ + + + + +