Merge pull request #65 from gnieark/dev

Dev
This commit is contained in:
Gnieark 2016-06-08 15:55:24 +02:00
commit 665826f7da
2 changed files with 49 additions and 9 deletions

View File

@ -83,6 +83,11 @@ function playingAT(col){
var symbol="O";
}
if(board[5][col]!== ""){
addLog('Player ' + currentPlayer + ', symbol ' + symbol + ' wants to play on column ' + col + ' but that column is already full. He loses.');
return;
}
//find the first line empty
var i=0;
for(i = 0; i < 6 , board[i][col] !== ""; i++){
@ -185,7 +190,18 @@ function playingAT(col){
wins(currentPlayer);
return;
}
//if it was the last cell
var full=true;
for (var i = 0; i < 7; i ++){
if( board[5][i] == "" ){
full = false;
}
}
if (full){
addLog('match nul');
return;
}
//change player
if(currentPlayer == 1){
@ -249,7 +265,7 @@ function startGame(){
}
//create board
var table=createElem('table',{'class':'battleGrid', 'id': 'board'});
for (var i=6; i > -1; i--){
for (var i=5; i > -1; i--){
var tr=createElem('tr');
for (var j=0;j<7; j++){
var td=createElem('td',{'id': 'td' + j + '_' + i});

View File

@ -254,14 +254,38 @@ switch ($_POST['act']){
}
}else{
$anwserToJS=array(
'continue' => 1,
'strikeX' => $strikeX,
'strikeY' => $strikeY,
'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer
);
//Was it the last cell?
$full=true;
foreach ($_SESSION['map'][5] as $cell) {
if ($cell == ""){
$full=false;
break;
}
}
if($full){
save_battle('connectFou',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],0);
$anwserToJS=array(
'continue' => 0,
'strikeX' => $strikeX,
'strikeY' => $strikeY,
'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer." match nul"
);
}else{
$anwserToJS=array(
'continue' => 1,
'strikeX' => $strikeX,
'strikeY' => $strikeY,
'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer
);
}
}
}else{