From 76d2378146c7918b0a0864ea0e32e7c0e1a39730 Mon Sep 17 00:00:00 2001 From: bajacqueli Date: Sun, 2 Apr 2023 13:12:30 +0200 Subject: [PATCH 01/13] 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:` From 128d641657de85cfac8644647241be886dbd870a Mon Sep 17 00:00:00 2001 From: "remi.arnal" Date: Sun, 2 Apr 2023 13:18:19 +0200 Subject: [PATCH 02/13] tweaks + bug --- src/Model/Const.js | 4 ++-- src/Model/card-to-html.js | 15 +++++++-------- views/cards-test.html | 17 ++++++++--------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/Model/Const.js b/src/Model/Const.js index 858eec3..200c05d 100755 --- a/src/Model/Const.js +++ b/src/Model/Const.js @@ -15,8 +15,8 @@ const SHAPE_PATH = { }; const OUTLINE_SPEC = { - full: {}, - dot: { "stroke-dasharray": "1 20", "stroke-linecap": "round" }, + continuous: {}, + dot: { "stroke-dasharray": "1 25", "stroke-linecap": "round" }, rect: { "stroke-dasharray": 70 }, spade: { "stroke-dasharray": "10 15", "stroke-width": 40 }, sharp: {} diff --git a/src/Model/card-to-html.js b/src/Model/card-to-html.js index e5bbb1f..fdf6b76 100755 --- a/src/Model/card-to-html.js +++ b/src/Model/card-to-html.js @@ -10,6 +10,10 @@ class CardToHtml { svg.setAttribute('height','160'); svg.setAttribute('width','80'); svg.setAttribute('viewBox','0 0 200 400'); + + if(card.attributes['number'] == undefined){ + card.attributes['number'] = 1; + } // Create paths + add to svg for(let j = 0; j < 2; j++) { @@ -31,14 +35,9 @@ class CardToHtml { // The way to create svg element (differs from html element) const path = document.createElementNS("http://www.w3.org/2000/svg", "path"); - if(shape === null) shape = 'oval'; - if(color === null) color = '000000'; - if(filling === null) filling = 'fill'; - - // console.log("shape: " + shape); - // console.log("color: " + color); - // console.log("filling: " + filling); - // console.log("outline: " + outline); + if(shape === undefined) shape = 'oval'; + if(color === undefined) color = 'black'; + if(filling === undefined) filling = 'none'; // Add lots of attributes path.setAttribute("d",SHAPE_PATH[shape]); diff --git a/views/cards-test.html b/views/cards-test.html index 57c7f1c..32884c0 100755 --- a/views/cards-test.html +++ b/views/cards-test.html @@ -122,17 +122,16 @@ // const c2 = new Card({shape: 'oval', color: '008000', number: 2, filling: 'full', outline: null}) // const c3 = new Card({shape: 'oval', color: '800080', number: 3, filling: 'full', outline: null}) - const c1 = new Card({shape: 'diamond', color: 'green', number: 3, filling: 'empty', outline: null}) - const c2 = new Card({shape: 'squiggle', color: 'blue', number: 1, filling: 'stripe', outline: null}) - const c3 = new Card({shape: 'squiggle', color: 'blue', number: 2, filling: 'stripe', outline: null}) - const c4 = new Card({shape: 'diamond', color: 'green', number: 2, filling: 'empty', outline: null}) - const c5 = new Card({shape: 'oval', color: 'red', number: 2, filling: 'full', outline: null}) + // const c1 = new Card({shape: 'diamond', color: 'green', number: 3, filling: 'empty', outline: null}) + // const c2 = new Card({shape: 'squiggle', color: 'blue', number: 1, filling: 'stripe', outline: null}) + // const c3 = new Card({shape: 'squiggle', color: 'blue', number: 2, filling: 'stripe', outline: null}) + // const c4 = new Card({shape: 'diamond', color: 'green', number: 2, filling: 'empty', outline: null}) + // const c5 = new Card({shape: 'oval', color: 'red', number: 2, filling: 'full', outline: null}) + // const c6 = new Card({shape: 'oval', color: 'red', number: 1, filling: 'dot', outline: null}) + const c1 = new Card({shape: 'diamond',color: 'orange' ,filling: 'grid', outline: 'dot'}) + CardToHtml.create(c1); - CardToHtml.create(c2); - CardToHtml.create(c3); - CardToHtml.create(c4); - CardToHtml.create(c5); \ No newline at end of file From 83bf3ef83837043ee7b281dcf11f9cc3cff88ba3 Mon Sep 17 00:00:00 2001 From: bajacqueli Date: Sun, 2 Apr 2023 13:20:12 +0200 Subject: [PATCH 03/13] add win message --- views/deck-module.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/views/deck-module.js b/views/deck-module.js index 8f11c18..d93e296 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -15,6 +15,7 @@ export default{ nbCardsSelected:0, connected:'7/8', timer:'10.51', + win:false, } }, methods:{ @@ -43,8 +44,8 @@ export default{ set(){ console.log("this.selectedCards",this.selectedCards) let checkSet=this.deck.checkSet(this.selectedCards); - if(checkSet){//is set - + if(checkSet==2){//is set + this.win=true; } // remove red outline this.selectedCardsindex.forEach((e) => { @@ -64,8 +65,11 @@ export default{

Players: {{connected}}

-
+
+
+

Félicitations, vous venez de gagner la partie +

` } \ No newline at end of file From 430632932b2284d0c7d9e85efde40b7248691db2 Mon Sep 17 00:00:00 2001 From: "remi.arnal" Date: Sun, 2 Apr 2023 14:33:13 +0200 Subject: [PATCH 04/13] =?UTF-8?q?css=20to=20be=20responsive=20(a=20moiti?= =?UTF-8?q?=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/card.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/styles/card.css b/styles/card.css index 546028d..70360c6 100755 --- a/styles/card.css +++ b/styles/card.css @@ -3,8 +3,8 @@ flex-direction: row; justify-content: center; align-items: center; - height: 8rem; - min-width: 18rem; + height: 12vh; + min-width: 14vw; padding: 1.5em; margin: 1.2rem; /* for better display */ border: 0.3em solid black; @@ -14,7 +14,7 @@ svg { height: 12vh; - width: 6vh; + width: 3vw; } .item { From 7fe0e5f7f7cd3572c93370cb9a23603661b2e1dd Mon Sep 17 00:00:00 2001 From: "remi.arnal" Date: Sun, 2 Apr 2023 15:03:28 +0200 Subject: [PATCH 05/13] card horizontal -> vertical --- styles/card.css | 14 +++++++++----- views/deck-module.js | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/styles/card.css b/styles/card.css index 70360c6..0c7a614 100755 --- a/styles/card.css +++ b/styles/card.css @@ -1,10 +1,10 @@ .card { display: flex; - flex-direction: row; + flex-direction: column; justify-content: center; align-items: center; - height: 12vh; - min-width: 14vw; + width: 6vw; + min-height: 26vh; padding: 1.5em; margin: 1.2rem; /* for better display */ border: 0.3em solid black; @@ -12,13 +12,17 @@ background-color: white; } +.card:hover { + cursor: pointer; +} + svg { - height: 12vh; + rotate: 90deg; + height: 7vh; width: 3vw; } .item { - margin: 1rem; } #main { diff --git a/views/deck-module.js b/views/deck-module.js index d93e296..566b44d 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -65,7 +65,7 @@ export default{

Players: {{connected}}

-
+
From 54d319ef6c84d6d3b8e639bbcc79d4d15e4972b4 Mon Sep 17 00:00:00 2001 From: Aurian JAULT Date: Sun, 2 Apr 2023 15:30:17 +0200 Subject: [PATCH 06/13] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/algo.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/algo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algo.js b/src/algo.js index bcc7e7b..dbb853c 100755 --- a/src/algo.js +++ b/src/algo.js @@ -82,7 +82,7 @@ function numberOfSets4(deck){ for(j = i+1 ; j < deck.length - 2; j++){ for(k = j+1 ; k < deck.length - 1 ; k++){ for(l = k + 1 ; l < deck.length;l++){ - if(isSet([deck[i],deck[j],deck[k]])){ + if(isSet([deck[i],deck[j],deck[k],deck[l]])){ //console.log(deck[i],deck[j],deck[k],deck[l]) res += 1 } @@ -100,7 +100,7 @@ function numberOfSets5(deck){ for(k = j+1 ; k < deck.length - 2 ; k++){ for(l = k + 1 ; l < deck.length - 1;l++){ for(m = l + 1; m Date: Sun, 2 Apr 2023 15:30:58 +0200 Subject: [PATCH 07/13] tw --- src/algo.js | 1 + views/deck-module.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algo.js b/src/algo.js index bcc7e7b..5068ccd 100755 --- a/src/algo.js +++ b/src/algo.js @@ -18,6 +18,7 @@ function isSet(cards) return false; } } + console.log(cards) return true; } diff --git a/views/deck-module.js b/views/deck-module.js index 566b44d..5390daa 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -9,7 +9,7 @@ export default{ return{ card:new Card({"filling":"empty"}), id:0, - deck : new Deck([0,1,2,3],3), + deck : new Deck([0,1,2,3],4), selectedCards:[], selectedCardsindex:[], nbCardsSelected:0, From 1868a12a4e45819380d28eaa2a71e2ec885d9d0f Mon Sep 17 00:00:00 2001 From: bajacqueli Date: Sun, 2 Apr 2023 15:35:09 +0200 Subject: [PATCH 08/13] fix --- src/Model/Factory.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Model/Factory.js b/src/Model/Factory.js index d75e7ef..994dca7 100755 --- a/src/Model/Factory.js +++ b/src/Model/Factory.js @@ -114,6 +114,7 @@ class Factory{ for (let c=0; c Date: Sun, 2 Apr 2023 15:38:22 +0200 Subject: [PATCH 09/13] fix --- src/Model/Factory.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Model/Factory.js b/src/Model/Factory.js index 994dca7..b7d2987 100755 --- a/src/Model/Factory.js +++ b/src/Model/Factory.js @@ -84,6 +84,7 @@ class Factory{ for (let c=0; c Date: Sun, 2 Apr 2023 15:40:15 +0200 Subject: [PATCH 10/13] fix --- src/Model/Factory.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Model/Factory.js b/src/Model/Factory.js index b7d2987..914245c 100755 --- a/src/Model/Factory.js +++ b/src/Model/Factory.js @@ -81,9 +81,9 @@ class Factory{ let attributes=this.attributesName(dicoAttributes); let nbAttributes=this.nbAttr; if(attributes.length==3){ - for (let c=0; c Date: Sun, 2 Apr 2023 15:43:03 +0200 Subject: [PATCH 11/13] fix end of game --- src/Model/Deck.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 05f2e30..3d17b4b 100755 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -30,7 +30,7 @@ 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; + return 2; } else { let nbSets = setsCounter(this.outputCards, this.nbCards); @@ -76,8 +76,7 @@ class Deck { return 2; } else { - this.removeFromoutputCards(selectedCards); - return 1; + return this.removeFromoutputCards(selectedCards); } } else if (this.remainingCards.length < this.nbCards) { @@ -109,7 +108,7 @@ class Deck { } else { this.setMade.push(set); - this.createDeck(this.nbCards) + return this.createDeck(this.nbCards) } } } From cc4eebe0ab98d172cc68f6da280bbf0872974bc7 Mon Sep 17 00:00:00 2001 From: "remi.arnal" Date: Sun, 2 Apr 2023 19:40:29 +0200 Subject: [PATCH 12/13] zoomed form in cards and center game div --- styles/card.css | 8 ++++---- views/deck-module.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/styles/card.css b/styles/card.css index 0c7a614..e5f2836 100755 --- a/styles/card.css +++ b/styles/card.css @@ -4,8 +4,8 @@ justify-content: center; align-items: center; width: 6vw; - min-height: 26vh; - padding: 1.5em; + min-height: 30vh; + padding: 0.5em 1em 0.5em 1em; margin: 1.2rem; /* for better display */ border: 0.3em solid black; border-radius: 2em; @@ -18,8 +18,8 @@ svg { rotate: 90deg; - height: 7vh; - width: 3vw; + height: 10vh; + width: 5vw; } .item { diff --git a/views/deck-module.js b/views/deck-module.js index 5390daa..160e02f 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -9,7 +9,7 @@ export default{ return{ card:new Card({"filling":"empty"}), id:0, - deck : new Deck([0,1,2,3],4), + deck : new Deck([0,1,2],3), selectedCards:[], selectedCardsindex:[], nbCardsSelected:0, @@ -65,7 +65,7 @@ export default{

Players: {{connected}}

-
+
From c7ddd44f54fd1fcf81efd09d8438f8b8b7d9ddce Mon Sep 17 00:00:00 2001 From: "remi.arnal" Date: Sun, 2 Apr 2023 21:21:39 +0200 Subject: [PATCH 13/13] just add an emoji --- views/deck-module.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/deck-module.js b/views/deck-module.js index 160e02f..d7b9dcd 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -69,7 +69,7 @@ export default{
-

Félicitations, vous venez de gagner la partie +

Félicitations, vous venez de gagner la partie ! 🎉

` } \ No newline at end of file