Fonction empiler ne garde que les points visibles

pile_4_cartes
adplantade 5 years ago
parent 1b0f9727a2
commit 078f2b6b6b

@ -37,6 +37,7 @@
tab4=[]; tab4=[];
tabTotal=[]; tabTotal=[];
mousePos=[]; mousePos=[];
colors=["red","blue","green","brown"];
width=300; // 6 lignes de 50px width=300; // 6 lignes de 50px
height=300; // 6 colonnes de 50px height=300; // 6 colonnes de 50px
@ -116,17 +117,41 @@
function empiler() function empiler()
{ {
tabTotal=[]; tabTotal=[];
tab4.forEach(element => { const unique = (val) => val.toString() != test.toString();
exists=false;
tab1.forEach(element => {
tabTotal.push(element); tabTotal.push(element);
}) })
tab3.forEach(element => { tab2.forEach(element => {
colors.forEach(col => {
test=[element[0],element[1],col];
if(!exists)
exists=!tabTotal.every(unique);
})
if(!exists)
tabTotal.push(element); tabTotal.push(element);
exists=false;
}) })
tab2.forEach(element => { tab3.forEach(element => {
colors.forEach(col => {
test=[element[0],element[1],col];
if(!exists)
exists=!tabTotal.every(unique);
})
if(!exists)
tabTotal.push(element); tabTotal.push(element);
exists=false;
}) })
tab1.forEach(element => { tab4.forEach(element => {
colors.forEach(col => {
test=[element[0],element[1],col];
if(!exists)
exists=!tabTotal.every(unique);
})
if(!exists)
tabTotal.push(element); tabTotal.push(element);
exists=false;
}) })
toutDessiner(tabTotal,canvasT,ctxT); toutDessiner(tabTotal,canvasT,ctxT);

Loading…
Cancel
Save