|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
import('./Model/Card.js')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isSet(cards)
|
|
|
|
|
{
|
|
|
|
|
let attributesMatrix = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cards.forEach(element => {
|
|
|
|
|
attributesMatrix.push(element.getAttributes());
|
|
|
|
|
});
|
|
|
|
@ -61,38 +64,51 @@ function nbrSets(deck, setSize){
|
|
|
|
|
matrix = []
|
|
|
|
|
// Remplie la matrice des valeurs du deck
|
|
|
|
|
for (i=0;i<setSize;i++){
|
|
|
|
|
for (j=0;j<(deck.length - i +1);j++){
|
|
|
|
|
matrix[i] = []
|
|
|
|
|
for (j=i;j<(deck.length - setSize + i + 1);j++){
|
|
|
|
|
// Check si ca marche bien
|
|
|
|
|
matrix[i] = []
|
|
|
|
|
matrix[i].push(deck[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = 0
|
|
|
|
|
currentSet = []
|
|
|
|
|
let res = 0
|
|
|
|
|
console.log(matrix)
|
|
|
|
|
for (p =0 ;p < matrix[0].length;p++){
|
|
|
|
|
console.log("JE SUIS P")
|
|
|
|
|
console.log(p)
|
|
|
|
|
let currentSet = []
|
|
|
|
|
res += forEachMember(0,p,matrix,currentSet,res)
|
|
|
|
|
}
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function forEachMember(x,y,matrix,currentSet,res){
|
|
|
|
|
currentSet.push(matrix[x][y])
|
|
|
|
|
if(matrix.length == x+1){
|
|
|
|
|
function forEachMember(x,y,matrix,tmp,counter){
|
|
|
|
|
console.log('X :',x)
|
|
|
|
|
console.log('Y : ',y)
|
|
|
|
|
currentSet = tmp
|
|
|
|
|
res = counter
|
|
|
|
|
currentSet[x] = (matrix[x][y])
|
|
|
|
|
console.log(currentSet)
|
|
|
|
|
if(matrix.length === currentSet.length){
|
|
|
|
|
console.log("JE SUIS DEDANS")
|
|
|
|
|
if(isSet(currentSet)){
|
|
|
|
|
currentSet.pop()
|
|
|
|
|
return res + 1
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
currentSet.pop()
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
for(i=y; i< matrix[x].length; i++){
|
|
|
|
|
console.log("JE SUIS PQS DANS LE IF")
|
|
|
|
|
console.log(y)
|
|
|
|
|
console.log(matrix[x+1].length)
|
|
|
|
|
for(let i=y; i< matrix[x+1].length; i++){
|
|
|
|
|
console.log("JAPPELLE LE FONC")
|
|
|
|
|
res += forEachMember(x+1,i,matrix, currentSet,res)
|
|
|
|
|
}
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// "Stub de test"
|
|
|
|
@ -112,4 +128,5 @@ let card6 = new Card("Purple","1","Triangle","Full");
|
|
|
|
|
let deck = [card1,card2,card3,card8,card9,card0,card10]
|
|
|
|
|
|
|
|
|
|
let nbrSet = nbrSets(deck,3)
|
|
|
|
|
|
|
|
|
|
console.log("JE SUIS LE RESULTAT")
|
|
|
|
|
console.log(nbrSet)
|
|
|
|
|