From 910142f0d23fb94b02982a3df4385c1f07828261 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Tue, 10 May 2016 17:05:09 +0200 Subject: [PATCH] init map --- src/arenas/connectFour/act.php | 19 +++++++++++++++---- src/arenas/connectFour/functions.php | 1 + src/arenas/connectFour/js.js | 27 +++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/arenas/connectFour/act.php b/src/arenas/connectFour/act.php index 998a7d4..8a4d442 100644 --- a/src/arenas/connectFour/act.php +++ b/src/arenas/connectFour/act.php @@ -3,12 +3,23 @@ require_once(__DIR__."/functions.php"); switch ($_POST['act']){ + case "newfight": + //initialiser la map + $_SESSION['map']=array( + array("","","","","","",""), + array("","","","","","",""), + array("","","","","","",""), + array("","","","","","",""), + array("","","","","","",""), + array("","","","","","",""), + ); + + + echo json_encode($_SESSION['map']); case "fight": - - - break; - + die; + break; default: break; } \ No newline at end of file diff --git a/src/arenas/connectFour/functions.php b/src/arenas/connectFour/functions.php index 09b1f14..1f60e7e 100644 --- a/src/arenas/connectFour/functions.php +++ b/src/arenas/connectFour/functions.php @@ -1,4 +1,5 @@ Please wait...

'; + var xhr = Ajx(); + xhr.onreadystatechange = function(){if(xhr.readyState == 4){ + if(xhr.status == 200) { + document.getElementById('fightResult').innerHTML = xhr.responseText; + } + }}; + xhr.open("POST", '/connectFour', true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send('act=newFight&bot1=' + bot1 + '&bot2=' + bot2 + '&xd_check=' + xd_check); +}