fix factory, bug in attributesRequiredFun in facory

pull/32/head
Bastien JACQUELIN 2 years ago
parent 99ed8b1233
commit 77665d9254

@ -31,30 +31,29 @@ console.groupEnd();
console.group('Deck'); console.group('Deck');
let deck = new Deck([0,1,2,3]); let deck = new Deck([0,1,3,4]);
console.log(`All cards with 4 attributes size ${deck.allCards.length}`); console.log(`All cards with 4 attributes size ${deck.allCards.length}`);
console.log(`size output ${deck.outputCards.length}`); console.log(`size output ${deck.outputCards.length}`);
//Display all cards //Display all cards
console.log(`All cards`); console.log(`All cards`);
console.log(deck.allCards)
deck.allCards.forEach(e => { deck.allCards.forEach(e => {
console.log(e.color,e.number,e.shape,e.filling); //console.log(e.color,e.number,e.shape,e.filling);
console.log(e.color,e.number,e.filling,e.outline);
//console.log(e.color,e.number,e.shape,e.outline);
}); });
console.log(`Output cards`); console.log(`Output cards`);
// deck.outputCards.forEach(e => { // deck.outputCards.forEach(e => {
// console.log(e.getAttributes()); // console.log(e.getAttributes());
// }); // });
console.log(`set already made ${deck.setMade}`); console.log(`set already made ${deck.setMade}`);
console.log(`remaining cards:`);
deck.setMade.forEach(e => {
console.log(e.color,e.number,e.shape,e.filling);
});
let customCard=[new Card('red',1,'diamond','stripped')]; let customCard=[new Card('red',1,'diamond','stripped')];
//deck.checkSet(customCard); //deck.checkSet(customCard);
console.log(`deck size :${deck.allCards.length}`);
console.log(`remaining cars:`);
deck.setMade.forEach(e => {
console.log(e.color,e.number,e.shape,e.filling);
});
//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}`);

@ -36,7 +36,7 @@ class Deck{
*/ */
createCards(attributes){ createCards(attributes){
let factory = new Factory(attributes) let factory = new Factory(attributes)
return factory.concreteCardCreation(); return factory.product
} }
checkSet(selectedCards){ checkSet(selectedCards){
if(true){//isSet(selectedCards)){ if(true){//isSet(selectedCards)){

@ -4,6 +4,8 @@ class Factory{
this.product=this.concreteCardCreation(arrayOfAttributes,length); this.product=this.concreteCardCreation(arrayOfAttributes,length);
} }
attributesRequiredFun(arrayOfAttributes,length){ attributesRequiredFun(arrayOfAttributes,length){
console.log("arr attr")
console.log(arrayOfAttributes)
let attributesRequiredTmp=[]; let attributesRequiredTmp=[];
let nullArray=[0,0,0,0,0]; let nullArray=[0,0,0,0,0];
for(let i=0;i<5;i++){ for(let i=0;i<5;i++){
@ -18,6 +20,10 @@ class Factory{
attributesRequiredTmp.push(nullArray); attributesRequiredTmp.push(nullArray);
} }
} }
attributesRequiredTmp.forEach(e=>{
console.log("tab index")
console.log(e);
});
return attributesRequiredTmp; return attributesRequiredTmp;
} }
concreteCardCreation(arrayOfAttributes, length){ concreteCardCreation(arrayOfAttributes, length){
@ -45,15 +51,13 @@ class Factory{
tabOfAllCards.push(new Card4WithoutNumber(attributes[0][n],attributes[2][s],attributes[3][f],attributes[4][o])); tabOfAllCards.push(new Card4WithoutNumber(attributes[0][n],attributes[2][s],attributes[3][f],attributes[4][o]));
} }
else if(attributes[2][0]===0){ else if(attributes[2][0]===0){
console.log("jrentre la frro")
tabOfAllCards.push(new Card4WithoutShape(attributes[0][n],attributes[1][s],attributes[3][f],attributes[4][o])); tabOfAllCards.push(new Card4WithoutShape(attributes[0][n],attributes[1][s],attributes[3][f],attributes[4][o]));
} }
else if(attributes[3][0]===0){ else if(attributes[3][0]===0){
console.log(attributes[0][n],attributes[1][s],attributes[2][f],attributes[4][o]);
tabOfAllCards.push(new Card4WithoutFilling(attributes[0][n],attributes[1][s],attributes[2][f],attributes[4][o])); tabOfAllCards.push(new Card4WithoutFilling(attributes[0][n],attributes[1][s],attributes[2][f],attributes[4][o]));
} }
else if(attributes[4][0]===0){ else if(attributes[4][0]===0){
console.log('rentre la');
console.log(attributes[0][n],attributes[1][s],attributes[2][f],attributes[3][o]);
tabOfAllCards.push(new Card4WithoutOutline(attributes[0][n],attributes[1][s],attributes[2][f],attributes[3][o])); tabOfAllCards.push(new Card4WithoutOutline(attributes[0][n],attributes[1][s],attributes[2][f],attributes[3][o]));
} }
} }

Loading…
Cancel
Save