refreshchips

This commit is contained in:
Michael Wain 2024-03-15 19:52:09 +03:00
parent 578344f784
commit a8ae3f6a9a

View File

@ -191,11 +191,9 @@ function moveChips() {
}
}
function refreshChips() {
let positions = distinct(board.chips.filter((c) => c.uid != 0).map(({ x, y }) => ({ x, y })));
for( let i = 0; i < positions.length; i++ ) {
let a = board.chips.filter((c) => c.x == positions[i].x && c.y == positions[i].y && c.uid != 0);
if( includes(positions[i]) ) {
function refreshChip(position) {
let a = board.chips.filter((c) => c.x == position.x && c.y == position.y && c.uid != 0);
if( includes(position) ) {
switch(a.length) {
case 1:
$(a[0].dom).animate({marginTop: "+=40", marginLeft: "+=40"}, 500);
@ -224,7 +222,7 @@ function refreshChips() {
break;
}
} else {
if( positions[i].x > 0 && positions[i].x < 10 ) {
if( position.x > 0 && position.x < 10 ) {
for(let u = 0; u < a.length; u++) {
$(a[u].dom).animate({marginTop: "+=" + chips_margins[a.length][u].top, marginLeft: "+=" + chips_margins[a.length][u].left}, 500);
}
@ -235,6 +233,12 @@ function refreshChips() {
}
}
}
function refreshChips() {
let positions = distinct(board.chips.filter((c) => c.uid != 0).map(({ x, y }) => ({ x, y })));
for( let i = 0; i < positions.length; i++ ) {
refreshChip(positions[i]);
}
}
function assignChip(body) {