dont send full map

This commit is contained in:
Gnieark 2016-05-13 19:48:41 +02:00
parent fe7905d82c
commit 8caa44abab
2 changed files with 16 additions and 8 deletions

View File

@ -99,6 +99,8 @@ switch ($_POST['act']){
for($y = 0; $_SESSION['map'][$y][$anwserPlayer] <> ""; $y++){ for($y = 0; $_SESSION['map'][$y][$anwserPlayer] <> ""; $y++){
} }
$_SESSION['map'][$y][$anwserPlayer]=$you; $_SESSION['map'][$y][$anwserPlayer]=$you;
$strikeX=$anwserPlayer;
$strikeY=$y;
//does he win? //does he win?
for($i=0;$i < 7;$i++){ for($i=0;$i < 7;$i++){
@ -145,24 +147,28 @@ switch ($_POST['act']){
if($wins){ if($wins){
$anwserToJS=array( $anwserToJS=array(
'continue' => 0, 'continue' => 0,
'grid' => $_SESSION['map'], 'strikeX' => $strikeX,
'strikeY' => $strikeY,
'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." a gagné" 'log' => $you." ".$currentBotName." a gagné"
); );
}else{ }else{
$anwserToJS=array( $anwserToJS=array(
'continue' => 1, 'continue' => 1,
'grid' => $_SESSION['map'], 'strikeX' => $strikeX,
'strikeY' => $strikeY,
'strikeSymbol'=> $you,
'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer 'log' => $you." ".$currentBotName." joue colonne ". $anwserPlayer
); );
} }
}else{ }else{
//reponse non conforme //reponse non conforme
$anwserToJS=array( $anwserToJS=array(
'continue' =>0, 'continue' =>0,
'grid' => $_SESSION['map'], 'strikeX' => -1,
'strikeY' => -1,
'log' => $you." ".$currentBotName." a fait une réponse non conforme, il perd" 'log' => $you." ".$currentBotName." a fait une réponse non conforme, il perd"
); );
} }

View File

@ -26,7 +26,7 @@ function connectFour(bot1,bot2,xd_check){
for (var i=0; i<6; i++){ for (var i=0; i<6; i++){
var tr=createElem('tr'); var tr=createElem('tr');
for (var j=0;j<7; j++){ for (var j=0;j<7; j++){
var td=createElem('td',{'id': 'td' + i + '-' + j}); var td=createElem('td',{'id': 'td' + j + '-' + i});
tr.appendChild (td); tr.appendChild (td);
} }
@ -43,9 +43,11 @@ function connectFour(bot1,bot2,xd_check){
document.getElementById('logs').innerHTML += 'erreur' +xhr.responseText; document.getElementById('logs').innerHTML += 'erreur' +xhr.responseText;
return; return;
} }
//alert (reponse['continue']);
//fill the grid
if( reponse['strikeX'] > -1){
document.getElementById('td' + reponse['strikeX'] + '-' + reponse['strikeY']).innerHTML=reponse['strikeSymbol'];
}
}else{ }else{