removed brackets, and fixed language lack

master
puskin94 2015-04-17 10:25:58 +02:00
parent 6dac7cc024
commit 0f5a699a04
1 changed files with 18 additions and 20 deletions

View File

@ -18,12 +18,11 @@ DDH.game2048.build = function(ops) {
flag = false,
exit;
if (dir === 'a' || dir === 'd') {
if (dir === 'a' || dir === 'd')
area = transpose();
}
if (dir === 's' || dir === 'd') {
if (dir === 's' || dir === 'd')
area = swapRows();
}
for (var col = 0; col < $SIZE; col++) {
for (var row = 0; row < $SIZE; row++) {
@ -58,19 +57,18 @@ DDH.game2048.build = function(ops) {
moves = 0;
}
if (dir === 's' || dir === 'd') {
if (dir === 's' || dir === 'd')
area = swapRows();
}
if (dir === 'a' || dir === 'd') {
if (dir === 'a' || dir === 'd')
area = transpose();
}
printArea();
increasePoints(points);
if (checkWin() || checkLose()) {
if (checkWin() || checkLose())
goOn = false;
}
/* This check is mandatory in order to avoid the appearance of a new
value in the area if no moves has been made */
return flag;
@ -194,9 +192,9 @@ recall the transpose() function (final state)
function swapRows() {
var nArea = [];
for(i = 0;i < $SIZE;i++) {
nArea[$SIZE-1-i]=area[i];
}
for(i = 0;i < $SIZE;i++)
nArea[$SIZE-1 - i]=area[i];
return nArea;
}
@ -214,7 +212,7 @@ recall the transpose() function (final state)
do {
posX=Math.floor(Math.random()*$SIZE);
posY=Math.floor(Math.random()*$SIZE);
} while( area[posX][posY] !== '');
} while(area[posX][posY] !== '');
area[posX][posY] = rand;
printArea();
@ -246,9 +244,9 @@ recall the transpose() function (final state)
for (var row = 0; row < $SIZE; row++) {
for (var col = 0; col < $SIZE; col++) {
// how many cells are not empty??
if (area[row][col] !== '') {
if (area[row][col] !== '')
count++;
}
// check all available movements
if ((row !== 0 && area[row][col] === area[row-1][col]) ||
(row !== $SIZE-1 && area[row][col] === area[row+1][col]) ||
@ -298,16 +296,17 @@ recall the transpose() function (final state)
/* 'started' is a boolean variable used in order to avoid the
duplication of the gaming area. Moving around the DDG tabs the
'onShow' function is executed over and over. This simple solution
solves the problem */
prevents the problem */
if (!started) {
started = true;
$container = $('#2048-area');
$WINNUM = $('#game').html();
$SIZE = parseInt($("#dimension").html(), 10);
$spanPoints = $('.points');
createTable($container);
started = true;
$tempArea = $('#area');
start();
@ -331,9 +330,8 @@ recall the transpose() function (final state)
}
// if move is true, a move has been made
if (move) {
if (move)
getRand();
}
}
});