fix issue : adding 3 new card to the deck : Working
continuous-integration/drone/push Build is passing Details

pull/47/head
Bastien JACQUELIN 2 years ago
parent 77bb3c0ada
commit 1606be743e

@ -47,14 +47,15 @@ console.log(`remaining cards : ${deck.remainingCards.length}`)
// console.log(e.getAttributes()); // console.log(e.getAttributes());
// }); // });
console.log(`size output ${deck.outputCards.length}`); console.log(`size output ${deck.outputCards.length}`);
console.log(`Output cards`); console.group('Output cards');
deck.outputCards.forEach(e => { deck.outputCards.forEach(e => {
console.log(e.getAttributes()); console.log(e.getAttributes());
}); });
console.groupEnd();
console.log(`set already made ${deck.setMade}`); console.log(`set already made ${deck.setMade}`);
// deck.setMade.forEach(e => { deck.setMade.forEach(e => {
// console.log(e.color,e.number,e.shape,e.filling); console.log(e.color,e.number,e.shape,e.filling);
// }); });
// CHECK SET // CHECK SET
@ -66,7 +67,6 @@ let customCard=[deck.outputCards[0],deck.outputCards[1],deck.outputCards[2]];
deck.checkSet(customCard); deck.checkSet(customCard);
console.log(`remaining cards : ${deck.remainingCards.length}`) console.log(`remaining cards : ${deck.remainingCards.length}`)
console.log(`All cards : ${deck.allCards.length}`) console.log(`All cards : ${deck.allCards.length}`)
console.log(`remaining cards : ${deck.remainingCards.length}`)
// deck.remainingCards.forEach(e => { // deck.remainingCards.forEach(e => {
// console.log(e.getAttributes()); // console.log(e.getAttributes());
// }); // });
@ -75,9 +75,14 @@ console.group('Output cards');
deck.outputCards.forEach(e => { deck.outputCards.forEach(e => {
console.log(e.getAttributes()); console.log(e.getAttributes());
}); });
console.log(`nbCards : ${deck.nbCards}`);
console.groupEnd(); console.groupEnd();
console.group('set made');
console.log(`set already made : ${deck.setMade.length}`);
deck.setMade.forEach(e => {
console.log(e.color,e.number,e.shape,e.filling);
});
console.groupEnd();
//let deck5 = new Deck([0,1,2,3,4]); //let deck5 = new Deck([0,1,2,3,4]);
//console.log(`All cards with 5 attributes size ${deck5.allCards.length}`); //console.log(`All cards with 5 attributes size ${deck5.allCards.length}`);

@ -51,9 +51,7 @@ class Deck{
*/ */
checkSet(selectedCards){ checkSet(selectedCards){
if(true){//isSet(selectedCards)){ if(true){//isSet(selectedCards)){
selectedCards.forEach(e => { this.removeFromoutputCards(selectedCards);
this.removeFromoutputCards(e);
});
} }
} }
/** /**
@ -63,15 +61,17 @@ class Deck{
*/ */
removeFromoutputCards(selectedCards){//better check of card type more opti removeFromoutputCards(selectedCards){//better check of card type more opti
let set=[]; let set=[];
selectedCards.forEach(element => {
for(let i=0; i<this.outputCards.length;i++){ for(let i=0; i<this.outputCards.length;i++){
let e = this.outputCards[i] let e = this.outputCards[i]
if(e.equals(selectedCards)){ if(e.equals(element)){
set.push(e); set.push(e);
this.outputCards.splice(i,1); this.outputCards.splice(i,1);
console.log("card remove : "+e.color,e.number,e.filling,e.shape);
} }
} }
if(set.length!=1){ });
if(set.length<1){
throw new UnFoundCardException(selectedCards); throw new UnFoundCardException(selectedCards);
} }
else{ else{

Loading…
Cancel
Save