From 07e116ed0f6a0074c608391c35f287818e2ff4f6 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Thu, 2 Feb 2023 14:19:54 +0100 Subject: [PATCH] add unfoundCardException, add the set verificatio operations --- src/Console/Console.html | 1 + src/Model/Deck.js | 29 ++++++++++++++++++++++++++++- src/Model/unfoundCardException.js | 5 +++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/Model/unfoundCardException.js diff --git a/src/Console/Console.html b/src/Console/Console.html index bc47ce5..1f6b5c3 100644 --- a/src/Console/Console.html +++ b/src/Console/Console.html @@ -14,6 +14,7 @@ + diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 55d34bd..81ee4e8 100644 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -1,5 +1,5 @@ class Deck{ - constructor(nbAttributes){ + constructor(nbAttributes=4){ this.allCards=this.createCards(nbAttributes);// All the cards in the game this.remainingCards=this.allCards;// cards in the stack this.outputCards=[];// 12 cards lay on the table @@ -17,6 +17,11 @@ class Deck{ const random = Math.floor(Math.random() * this.remainingCards.length); return random; } + /** + * + * @param {*} nbAttributes : attributes of the card, by default = 4 + * @returns all cards: 81 in case of 4 attributes and 1224 + */ createCards(nbAttributes){ const tabColor = ['red','purple','green','blue','orange']; const tabShape = ['diamond','oval','wave','star','circle'] @@ -42,4 +47,26 @@ class Deck{ } return tabOfAllCards; } + checkSet(selectedCards){ + if(true){//isSet(selectedCards)){ + selectedCards.forEach(e => { + this.removeFromRemainingCards(e); + }); + } + } + removeFromRemainingCards(selectedCards){ + let set=[]; + if (selectedCards instanceof Card) { + for(let i=0; i