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/Console/main.js b/src/Console/main.js
index 108635f..930cf2c 100644
--- a/src/Console/main.js
+++ b/src/Console/main.js
@@ -27,19 +27,33 @@ try {
}
console.groupEnd();
console.group('Deck');
-let deck = new Deck();
-console.log(`Output cards ${deck.outputCards}`);
+let deck = new Deck(4);
+
+console.log(`All cards with 4 attributes size ${deck.allCards.length}`);
+console.log(`size ${deck.outputCards.length}`);
+
+// deck.allCards.forEach(e => {
+// console.log(e.color,e.number,e.shape,e.filling);
+// });
+console.log(`Output cards`);
+deck.outputCards.forEach(e => {
+ console.log(e.color,e.number,e.shape,e.filling);
+});
console.log(`set already made ${deck.setMade}`);
-console.log(`All cards ${deck.allCards}`);
-console.log(`Remaining cards ${deck.remainingCards}`);
-console.groupEnd();
-console.group('Maths');
-let list=[];
-list.push(1);
-list.push(2);
-let gngn=Math.floor(Math.random() * list.length)
-console.log(gngn);
+
+
+
+let deck5 = new Deck(5)
+console.log(`All cards with 5 attributes size ${deck5.allCards.length}`);
+// deck5.allCards.forEach(e => {
+// console.log(e.color,e.number,e.shape,e.filling,e.outline);
+// });
+//console.log(`Remaining cards ${deck.remainingCards}`);
+//console.log(`random : ${deck.getRandCard()}`);
+
+
+
console.groupEnd();
diff --git a/src/Model/Deck.js b/src/Model/Deck.js
index b38bd49..81ee4e8 100644
--- a/src/Model/Deck.js
+++ b/src/Model/Deck.js
@@ -1,19 +1,72 @@
class Deck{
- constructor(){
- this.outputCards=this.createDeck();
- this.setMade=[];
- this.allCards=this.createCards();
- this.remainingCards=this.allCards;
+ 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
+ this.setMade=[];// array with all the set already mades (array of set)
+ this.createDeck();
}
createDeck(){
for (let i=0; i<12; i++){
-
+ const rand = this.getRandCard();
+ this.outputCards.push(this.remainingCards[rand]);
+ this.remainingCards.splice(rand,1);
}
}
getRandCard(){
- Math.floor(Math.random() * remainingCards.length);
+ const random = Math.floor(Math.random() * this.remainingCards.length);
+ return random;
}
- createCards(){
- return 456;
+ /**
+ *
+ * @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']
+ const tabFilling = ['empty','stripped','full','pointed','squared'];
+ const tabNumber = [1,2,3,4,5];
+ const tabOutline = ['full','dotted ','aa','bb','cc'];
+ let tabOfAllCards=[];
+ for (let c=0; c {
+ this.removeFromRemainingCards(e);
+ });
+ }
+ }
+ removeFromRemainingCards(selectedCards){
+ let set=[];
+ if (selectedCards instanceof Card) {
+ for(let i=0; i