full JSON

This commit is contained in:
gnieark 2016-05-29 21:22:41 +02:00
parent 0bd456f454
commit 612265d8c6
3 changed files with 5 additions and 9 deletions

View File

@ -3,12 +3,9 @@
* stupid IA for battle ship * stupid IA for battle ship
* choose by random a free column * choose by random a free column
*/ */
$in=file_get_contents('php://input');
print_r($_POST); $params=json_decode($in, TRUE);
$grid=$params['grid'];
/*
$grid=json_decode($_POST['grid']);
$colAvailable=array(); $colAvailable=array();
for($i=0;$i<7;$i++){ for($i=0;$i<7;$i++){
@ -19,4 +16,3 @@ for($i=0;$i<7;$i++){
shuffle($colAvailable); shuffle($colAvailable);
echo $colAvailable[0]; echo $colAvailable[0];
die; die;
*/

View File

@ -90,7 +90,7 @@ switch ($_POST['act']){
//send query //send query
$anwserPlayer=get_IA_Response($botUrl,$postDatas); $anwserPlayer=get_IA_Response($botUrl,$postDatas);
//for test *************************** //for test ***************************
echo $anwserPlayer; die; //echo $anwserPlayer; die;
//vérifier la validité de la réponse //vérifier la validité de la réponse
if((isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == "")){ if((isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == "")){
//reponse conforme //reponse conforme

View File

@ -48,7 +48,7 @@ function connectFour(bot1,bot2,xd_check, newGame){
xhr.onreadystatechange = function(){if(xhr.readyState == 4){ xhr.onreadystatechange = function(){if(xhr.readyState == 4){
if(xhr.status == 200) { if(xhr.status == 200) {
//for test //for test
alert(xhr.responseText); // alert(xhr.responseText);
try{ try{
var reponse = JSON.parse(xhr.responseText); var reponse = JSON.parse(xhr.responseText);