|
|
|
@ -4,7 +4,7 @@ class Deck{
|
|
|
|
|
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();
|
|
|
|
|
//this.createDeck();
|
|
|
|
|
}
|
|
|
|
|
createDeck(){
|
|
|
|
|
for (let i=0; i<12; i++){
|
|
|
|
@ -24,9 +24,9 @@ class Deck{
|
|
|
|
|
*/
|
|
|
|
|
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 tabShape = ['diamond','oval','wave','star','circle'];
|
|
|
|
|
const tabFilling = ['empty','stripped','full','pointed','squared'];
|
|
|
|
|
const tabOutline = ['full','dotted ','aa','bb','cc'];
|
|
|
|
|
let tabOfAllCards=[];
|
|
|
|
|
for (let c=0; c<nbAttributes-1; c++){
|
|
|
|
@ -54,19 +54,21 @@ class Deck{
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
removeFromRemainingCards(selectedCards){
|
|
|
|
|
removeFromRemainingCards(selectedCards){//better check of card type more opti
|
|
|
|
|
let set=[];
|
|
|
|
|
if (selectedCards instanceof Card) {
|
|
|
|
|
for(let i=0; i<this.remainingCards.length;i++){
|
|
|
|
|
let e = this.remainingCards[i]
|
|
|
|
|
if(e.color==selectedCards.color||e.number==selectedCards.number||e.shape==selectedCards.shape||e.filling==selectedCards.filling){
|
|
|
|
|
set.push[e];
|
|
|
|
|
this.remainingCards.splice(i,1);
|
|
|
|
|
for(let i=0; i<this.allCards.length;i++){
|
|
|
|
|
let e = this.allCards[i]
|
|
|
|
|
if(e.equals(selectedCards)){
|
|
|
|
|
set.push(e);
|
|
|
|
|
this.allCards.splice(i,1);
|
|
|
|
|
console.log("card remove : "+e.color,e.number,e.filling,e.shape);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
throw new UnFoundCard(e);
|
|
|
|
|
}
|
|
|
|
|
if(set.length!=1){
|
|
|
|
|
throw new UnFoundCardException(selectedCards);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.setMade.push(set);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|