Fix: turn value sometimes cleared or incorect.
--- a/2048.html Sat Sep 20 01:01:53 2014 +0300
+++ b/2048.html Sat Sep 20 01:16:14 2014 +0300
@@ -428,9 +428,8 @@
maxDom.innerHTML = '' + ui.board.val2048(score.max);
turnDom.innerHTML = '' + turn;
}
- ui.score.speed = function(speed, turn) {
+ ui.score.speed = function(speed) {
speedDom.innerHTML = '' + speed;
- turnDom.innerHTML = '' + turn;
}
////////////////////////////////////////////////////////////////
@@ -607,15 +606,17 @@
if (updated) {
board.putRandom(ui.board.position);
} else {
- ui.game.finishStep();
+ ui.board.turn += step;
+ ui.game.refresh();
ui.game.setMessage("Wrong move!");
return;
}
step++;
}
var tsTo = new Date().getTime();
+ ui.board.turn += step;
ui.game.finishStep();
- ui.score.speed(parseFloat((step*1000.0/(tsTo-tsFrom)).toPrecision(3)), step);
+ ui.score.speed(parseFloat((step*1000.0/(tsTo-tsFrom)).toPrecision(3)));
ui.game.setMessage("Game over!");
ui.ai.current.cleanup();
}
@@ -668,8 +669,9 @@
step++;
}
var tsTo = new Date().getTime();
+ ui.board.turn += step;
ui.game.refresh();
- ui.score.speed(parseFloat((step*1000.0/(tsTo-tsFrom)).toPrecision(3)), step);
+ ui.score.speed(parseFloat((step*1000.0/(tsTo-tsFrom)).toPrecision(3)));
ui.ai.current.cleanup();
}
document.getElementById("until").addEventListener("click", ui.action.until, false);