|
|
@ -1,4 +1,4 @@
|
|
|
|
import('./Model/Card.js')
|
|
|
|
//import('./Model/Card.js')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isSet(cards)
|
|
|
|
function isSet(cards)
|
|
|
@ -131,77 +131,113 @@ function setsCounter(deck, numberForSet){
|
|
|
|
console.error('The number of cards in a Set is not existing', numberForSet)
|
|
|
|
console.error('The number of cards in a Set is not existing', numberForSet)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createElements(attributs1, attributs2) {
|
|
|
|
function createElements(attributsCartes, listeAttributs) {
|
|
|
|
if (attributs1 in tabColor) {
|
|
|
|
let l = []
|
|
|
|
tabColor.forEach(element => {
|
|
|
|
let verif;
|
|
|
|
if (element != attributs1) {
|
|
|
|
listeAttributs.forEach(element => {
|
|
|
|
if (element != attributs2) {
|
|
|
|
verif = false;
|
|
|
|
return element;
|
|
|
|
attributsCartes.forEach(attribCartes => {
|
|
|
|
}
|
|
|
|
if (element == attribCartes) {
|
|
|
|
}
|
|
|
|
verif = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attributs1 in tabNumber) {
|
|
|
|
|
|
|
|
tabNumber.forEach(element => {
|
|
|
|
|
|
|
|
if (element != attributs1) {
|
|
|
|
|
|
|
|
if (element != attributs2) {
|
|
|
|
|
|
|
|
return element;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attributs1 in tabShape) {
|
|
|
|
|
|
|
|
tabShape.forEach(element => {
|
|
|
|
|
|
|
|
if (element != attributs1) {
|
|
|
|
|
|
|
|
if (element != attributs2) {
|
|
|
|
|
|
|
|
return element;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attributs1 in tabFilling) {
|
|
|
|
|
|
|
|
tabFilling.forEach(element => {
|
|
|
|
|
|
|
|
if (element != attributs1) {
|
|
|
|
|
|
|
|
if (element != attributs2) {
|
|
|
|
|
|
|
|
return element;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (verif == false) {
|
|
|
|
if (attributs1 in tabOutline) {
|
|
|
|
l.push(element);
|
|
|
|
tabOutline.forEach(element => {
|
|
|
|
}
|
|
|
|
if (element != attributs1) {
|
|
|
|
});
|
|
|
|
if (element != attributs2) {
|
|
|
|
return l
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
function trouveElements(attributsCartes) {
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
let x;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabColor.forEach(element => {
|
|
|
|
|
|
|
|
if (element == attributsCartes[0]) {
|
|
|
|
|
|
|
|
x = createElements(attributsCartes, tabColor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabNumber.forEach(element => {
|
|
|
|
|
|
|
|
if (element == attributsCartes[0]) {
|
|
|
|
|
|
|
|
x = createElements(attributsCartes, tabNumber);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabShape.forEach(element => {
|
|
|
|
|
|
|
|
if (element == attributsCartes[0]) {
|
|
|
|
|
|
|
|
x = createElements(attributsCartes, tabShape);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabFilling.forEach(element => {
|
|
|
|
|
|
|
|
if (element == attributsCartes[0]) {
|
|
|
|
|
|
|
|
x = createElements(attributsCartes, tabFilling);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabOutline.forEach(element => {
|
|
|
|
|
|
|
|
if (element == attributsCartes[0]) {
|
|
|
|
|
|
|
|
x = createElements(attributsCartes, tabOutline);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createCard(cards) {
|
|
|
|
function createCard(cards) {
|
|
|
|
|
|
|
|
|
|
|
|
let attributesMatrix = [];
|
|
|
|
let attributesMatrix = [];
|
|
|
|
let carteFinale = [];
|
|
|
|
let carteFinale = [];
|
|
|
|
|
|
|
|
let listeInter = [];
|
|
|
|
|
|
|
|
|
|
|
|
cards.forEach(element => {
|
|
|
|
cards.forEach(element => {
|
|
|
|
attributesMatrix.push(element.getAttributes());
|
|
|
|
attributesMatrix.push(element.getAttributes());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < attributesMatrix[0].length; i++) {
|
|
|
|
for (let i = 0; i < attributesMatrix[0].length; i++) {
|
|
|
|
if (attributesMatrix[0][i] == attributesMatrix[1][i]) {
|
|
|
|
listeInter = [];
|
|
|
|
carteFinale.push(attributesMatrix[0][i]);
|
|
|
|
attributesMatrix.forEach(element => {
|
|
|
|
|
|
|
|
listeInter.push(element[i]);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//S'ils sont tous égaux
|
|
|
|
|
|
|
|
if (listeInter.every(element => element === listeInter[0])) {
|
|
|
|
|
|
|
|
carteFinale.push(listeInter[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
carteFinale.push(createElements(attributesMatrix[0][i], attributesMatrix[1][i]))
|
|
|
|
//S'ils sont tous différents
|
|
|
|
|
|
|
|
if ([...new Set(listeInter)].length === listeInter.length) {
|
|
|
|
|
|
|
|
carteFinale.push(trouveElements(listeInter));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Sinon
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
carteFinale.push([]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(carteFinale);
|
|
|
|
return carteFinale;
|
|
|
|
return carteFinale;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isHyperset(cardsLeft, cardsRight) {
|
|
|
|
function isHyperset(cardsLeft, cardsRight) {
|
|
|
|
return createCard(cardsLeft).join() == createCard(cardsRight).join();
|
|
|
|
left = createCard(cardsLeft)
|
|
|
|
|
|
|
|
right = createCard(cardsRight)
|
|
|
|
|
|
|
|
let verif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < left[0].length; i++) {
|
|
|
|
|
|
|
|
verif = false;
|
|
|
|
|
|
|
|
left.forEach(elementG => {
|
|
|
|
|
|
|
|
right.forEach(elementD => {
|
|
|
|
|
|
|
|
if (elementD == elementG) {
|
|
|
|
|
|
|
|
verif=true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
if (verif == false) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|