This commit is contained in:
Gnieark 2016-06-08 15:41:04 +02:00
parent 92c0461152
commit c0530819cd
2 changed files with 48 additions and 8 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 = true;
}
}
if (full){
addLog('match nul');
return;
}
//change player
if(currentPlayer == 1){

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{