|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
class Factory{
|
|
|
|
|
constructor(arrayOfAttributes){
|
|
|
|
|
constructor(arrayOfAttributes, nbAttributes){
|
|
|
|
|
this.nbAttr=nbAttributes;
|
|
|
|
|
this.dicoAttributes=this.attributesDictionnary(arrayOfAttributes,this.funArrayOfAttributes(arrayOfAttributes));
|
|
|
|
|
this.product=this.concreteCardCreation(arrayOfAttributes);
|
|
|
|
|
// console.log("arrayOfAttributes",this.funArrayOfAttributes(arrayOfAttributes));
|
|
|
|
@ -15,7 +16,7 @@ class Factory{
|
|
|
|
|
*/
|
|
|
|
|
funArrayOfAttributes(arrayOfIdxAttributes){//working✅
|
|
|
|
|
let attr=[];
|
|
|
|
|
let l=arrayOfIdxAttributes.length;
|
|
|
|
|
let l=this.nbAttr;
|
|
|
|
|
arrayOfIdxAttributes.forEach(e => {
|
|
|
|
|
for (let i=0;i<l;i++){
|
|
|
|
|
attr.push(ATTRIBUTES[e][i]);
|
|
|
|
@ -34,8 +35,8 @@ class Factory{
|
|
|
|
|
let dico={};
|
|
|
|
|
for (let i=0;i<l;i++){
|
|
|
|
|
let tmp=[]
|
|
|
|
|
for(let j=0;j<l;j++){
|
|
|
|
|
tmp.push(arrayOfAllAttributes[(i*l)+j]);
|
|
|
|
|
for(let j=0;j<this.nbAttr;j++){
|
|
|
|
|
tmp.push(arrayOfAllAttributes[(i*this.nbAttr)+j]);
|
|
|
|
|
}
|
|
|
|
|
dico[IDX_ATTRIBUTES[arrayOfIdxAttributes[i]]]=tmp;
|
|
|
|
|
}
|
|
|
|
@ -78,9 +79,8 @@ class Factory{
|
|
|
|
|
let tabOfAllCards=[];
|
|
|
|
|
let dicoAttributes=this.dicoAttributes
|
|
|
|
|
let attributes=this.attributesName(dicoAttributes);
|
|
|
|
|
let nbAttributes=attributes.length;
|
|
|
|
|
console.log('nbAttributes',nbAttributes)
|
|
|
|
|
if(nbAttributes==3){
|
|
|
|
|
let nbAttributes=this.nbAttr;
|
|
|
|
|
if(attributes.length==3){
|
|
|
|
|
for (let c=0; c<nbAttributes; c++){
|
|
|
|
|
for (let n=0; n<nbAttributes; n++){
|
|
|
|
|
for (let s=0; s<nbAttributes; s++){
|
|
|
|
@ -92,7 +92,7 @@ class Factory{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nbAttributes==4){
|
|
|
|
|
else if(attributes.length==4){
|
|
|
|
|
for (let a=0; a<nbAttributes; a++){
|
|
|
|
|
for (let b=0; b<nbAttributes; b++){
|
|
|
|
|
for (let c=0; c<nbAttributes; c++){
|
|
|
|
@ -107,7 +107,7 @@ class Factory{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nbAttributes==5){
|
|
|
|
|
else if(attributes.length==5){
|
|
|
|
|
for (let a=0; a<nbAttributes; a++){
|
|
|
|
|
for (let b=0; b<nbAttributes; b++){
|
|
|
|
|
for (let c=0; c<nbAttributes; c++){
|
|
|
|
@ -130,61 +130,4 @@ class Factory{
|
|
|
|
|
}
|
|
|
|
|
return tabOfAllCards
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
concreteCardCreation(attributesDico){//progress
|
|
|
|
|
let tabOfAllCards=[];
|
|
|
|
|
let attributes=this.attributesRequiredFun(arrayOfAttributes);
|
|
|
|
|
let nbAttributes=length
|
|
|
|
|
if(nbAttributes==3){
|
|
|
|
|
for (let c=0; c<nbAttributes-1; c++){
|
|
|
|
|
for (let n=0; n<nbAttributes-1; n++){
|
|
|
|
|
for (let s=0; s<nbAttributes-1; s++){
|
|
|
|
|
tabOfAllCards.push(new Card3(ATTRIBUTES[0][c],ATTRIBUTES[1][n],ATTRIBUTES[2][s]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nbAttributes==4){
|
|
|
|
|
for (let n=0; n<nbAttributes-1; n++){
|
|
|
|
|
for (let s=0; s<nbAttributes-1; s++){
|
|
|
|
|
for (let f=0; f<nbAttributes-1; f++){
|
|
|
|
|
for (let o=0; o<nbAttributes-1; o++){
|
|
|
|
|
if(attributes[0][0]===0){
|
|
|
|
|
tabOfAllCards.push(new Card4WithoutColor(attributes[1][n],attributes[2][s],attributes[3][f],attributes[4][o]));
|
|
|
|
|
}
|
|
|
|
|
else if(attributes[1][0]===0){
|
|
|
|
|
tabOfAllCards.push(new Card4WithoutNumber(attributes[0][n],attributes[2][s],attributes[3][f],attributes[4][o]));
|
|
|
|
|
}
|
|
|
|
|
else if(attributes[2][0]===0){
|
|
|
|
|
tabOfAllCards.push(new Card4WithoutShape(attributes[0][n],attributes[1][s],attributes[3][f],attributes[4][o]));
|
|
|
|
|
}
|
|
|
|
|
else if(attributes[3][0]===0){
|
|
|
|
|
tabOfAllCards.push(new Card4WithoutFilling(attributes[0][n],attributes[1][s],attributes[2][f],attributes[4][o]));
|
|
|
|
|
}
|
|
|
|
|
else if(attributes[4][0]===0){
|
|
|
|
|
tabOfAllCards.push(new Card4WithoutOutline(attributes[0][n],attributes[1][s],attributes[2][f],attributes[3][o]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(nbAttributes==5){
|
|
|
|
|
for (let c=0; c<nbAttributes-1; c++){
|
|
|
|
|
for (let n=0; n<nbAttributes-1; n++){
|
|
|
|
|
for (let s=0; s<nbAttributes-1; s++){
|
|
|
|
|
for (let f=0; f<nbAttributes-1; f++){
|
|
|
|
|
for (let o=0; o<nbAttributes-1; o++){
|
|
|
|
|
tabOfAllCards.push(new Card5(attributes[0][c],attributes[1][n],attributes[2][s],attributes[3][f],attributes[4][o]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
throw new EmptyParamaterException("ilegal number of attributes");
|
|
|
|
|
}
|
|
|
|
|
return tabOfAllCards
|
|
|
|
|
}*/
|
|
|
|
|
}
|