From 4cd4a1138323e9fa61f1187c776618f53fa43b1d Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Mon, 3 Apr 2023 10:27:49 +0200 Subject: [PATCH 1/7] fix bug end of game --- src/Model/Deck.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 05f2e30..8027e35 100755 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -30,7 +30,6 @@ 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; } else { let nbSets = setsCounter(this.outputCards, this.nbCards); @@ -71,20 +70,29 @@ class Deck { */ checkSet(selectedCards) {//toTest⌛ 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 { - this.removeFromoutputCards(selectedCards); - return 1; + 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 + this.removeFromoutputCards(selectedCards); + return 1; + } + } + else{// encore de la pile + this.removeFromoutputCards(selectedCards); + return 1; + } } } - else if (this.remainingCards.length < this.nbCards) { - console.log("C'est win") - return 2; + else{// pas un set + return -1; } - return 0; } /** From e54a8e652fff6f3355f079b9c4a42d812c274230 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Mon, 3 Apr 2023 10:29:58 +0200 Subject: [PATCH 2/7] add { --- src/Model/Deck.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Model/Deck.js b/src/Model/Deck.js index d28a0c0..d0e6d96 100755 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -89,6 +89,7 @@ class Deck { this.removeFromoutputCards(selectedCards); return 1; } + } } else{// pas un set return -1; From 070a72162ce833436316fe8ab56a90cd51525eb2 Mon Sep 17 00:00:00 2001 From: "aurian.jault" Date: Mon, 3 Apr 2023 10:31:39 +0200 Subject: [PATCH 3/7] update Checkqttriutes --- src/algo.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/algo.js b/src/algo.js index 8f0ab21..b5c09d6 100644 --- a/src/algo.js +++ b/src/algo.js @@ -14,7 +14,7 @@ function isSet(cards) for(let j = 0; j < attributesMatrix.length; j++) { listAttributes.push(attributesMatrix[j][i]); } - if(!checkAttributes(listAttributes)){ + if(!checkAttributes2(listAttributes,attributesMatrix.length)){ return false; } } @@ -22,6 +22,16 @@ function isSet(cards) } +function checkAttributes2(params,length) { + var tab = [] + params.forEach(element => { + if (!tab.includes(element)) { + tab.push(element) + } + }); + return tab.length === 1 || tab.length === length; +} + function checkAttributes(attributes){ let orderingMethod = "null"; // Can only take ["null", "same", "different"] let boolLoop = true; From ec4219864291195b18aaa90b69cbed50fa48e0da Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Mon, 3 Apr 2023 10:39:49 +0200 Subject: [PATCH 4/7] 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); } } } From ba3be75ddb68882095b4baebaa8760f071ba8752 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Mon, 3 Apr 2023 10:43:10 +0200 Subject: [PATCH 5/7] add favicon on pages --- index.html | 1 + views/room.html | 2 ++ 2 files changed, 3 insertions(+) diff --git a/index.html b/index.html index 40fb083..36265e9 100755 --- a/index.html +++ b/index.html @@ -7,6 +7,7 @@ + diff --git a/views/room.html b/views/room.html index 7bbdd64..1754092 100644 --- a/views/room.html +++ b/views/room.html @@ -5,6 +5,8 @@ Room - HyperSet + + From 9e4e206b598ad738c38d84f5231f94ec7ef0f41b Mon Sep 17 00:00:00 2001 From: "aurian.jault" Date: Mon, 3 Apr 2023 10:49:12 +0200 Subject: [PATCH 6/7] opti checkattributes --- src/algo.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/algo.js b/src/algo.js index 4ebf3e1..7792ee3 100755 --- a/src/algo.js +++ b/src/algo.js @@ -14,6 +14,8 @@ function isSet(cards) for(let j = 0; j < attributesMatrix.length; j++) { listAttributes.push(attributesMatrix[j][i]); } + console.log("JE SUIS LES ATTRIBUTS") + console.log(listAttributes) if(!checkAttributes2(listAttributes,attributesMatrix.length)){ return false; } @@ -30,6 +32,7 @@ function checkAttributes2(params,length) { tab.push(element) } }); + console.log(tab.length === 1 || tab.length === length) return tab.length === 1 || tab.length === length; } From bd9c12f63c5a8312ab9b2e4ea44e2cbf034e6d16 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Mon, 3 Apr 2023 12:07:13 +0200 Subject: [PATCH 7/7] deck define in the rooom page --- views/deck-module.js | 7 ++++--- views/game.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/views/deck-module.js b/views/deck-module.js index d7b9dcd..86fc37e 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -1,15 +1,16 @@ export default{ emits:[], props:{ - deckR:Deck, + 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), + //deck : new Deck([2,0,1],3), selectedCards:[], selectedCardsindex:[], nbCardsSelected:0, diff --git a/views/game.html b/views/game.html index 8c31318..cd0b0dc 100644 --- a/views/game.html +++ b/views/game.html @@ -86,7 +86,7 @@
- +