From 612265d8c644ac456e738882e0ca898b69a9b3e0 Mon Sep 17 00:00:00 2001 From: gnieark Date: Sun, 29 May 2016 21:22:41 +0200 Subject: [PATCH] full JSON --- html/StupidIAconnectFour.php | 10 +++------- src/arenas/connectFour/act.php | 2 +- src/arenas/connectFour/js.js | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/html/StupidIAconnectFour.php b/html/StupidIAconnectFour.php index df357b7..c36cb12 100644 --- a/html/StupidIAconnectFour.php +++ b/html/StupidIAconnectFour.php @@ -3,12 +3,9 @@ * stupid IA for battle ship * choose by random a free column */ - -print_r($_POST); - -/* -$grid=json_decode($_POST['grid']); - +$in=file_get_contents('php://input'); +$params=json_decode($in, TRUE); +$grid=$params['grid']; $colAvailable=array(); for($i=0;$i<7;$i++){ @@ -19,4 +16,3 @@ for($i=0;$i<7;$i++){ shuffle($colAvailable); echo $colAvailable[0]; die; -*/ \ No newline at end of file diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php index c98259a..9fdb909 100644 --- a/src/arenas/connectFour/act.php +++ b/src/arenas/connectFour/act.php @@ -90,7 +90,7 @@ switch ($_POST['act']){ //send query $anwserPlayer=get_IA_Response($botUrl,$postDatas); //for test *************************** - echo $anwserPlayer; die; + //echo $anwserPlayer; die; //vérifier la validité de la réponse if((isset($_SESSION['map'][5][$anwserPlayer])) && ($_SESSION['map'][5][$anwserPlayer] == "")){ //reponse conforme diff --git a/src/arenas/connectFour/js.js b/src/arenas/connectFour/js.js index 9cefe73..0084f52 100644 --- a/src/arenas/connectFour/js.js +++ b/src/arenas/connectFour/js.js @@ -48,7 +48,7 @@ function connectFour(bot1,bot2,xd_check, newGame){ xhr.onreadystatechange = function(){if(xhr.readyState == 4){ if(xhr.status == 200) { //for test - alert(xhr.responseText); + // alert(xhr.responseText); try{ var reponse = JSON.parse(xhr.responseText);