This commit is contained in:
Gnieark 2016-05-10 17:05:09 +02:00
parent e036bd55da
commit 910142f0d2
3 changed files with 41 additions and 6 deletions

View File

@ -3,12 +3,23 @@
require_once(__DIR__."/functions.php"); require_once(__DIR__."/functions.php");
switch ($_POST['act']){ switch ($_POST['act']){
case "newfight":
//initialiser la map
$_SESSION['map']=array(
array("","","","","","",""),
array("","","","","","",""),
array("","","","","","",""),
array("","","","","","",""),
array("","","","","","",""),
array("","","","","","",""),
);
echo json_encode($_SESSION['map']);
case "fight": case "fight":
die;
break; break;
default: default:
break; break;
} }

View File

@ -1,4 +1,5 @@
<?php <?php
function get_Post_Params($botsCount){ function get_Post_Params($botsCount){
$keysBots=array('bot1','bot2'); $keysBots=array('bot1','bot2');
foreach($keysBots as $botKey){ foreach($keysBots as $botKey){

View File

@ -1,3 +1,26 @@
function connectFour(bot1,bot2,xd_check){ function Ajx(){
var request = false;
try {request = new ActiveXObject('Msxml2.XMLHTTP');}
catch (err2) {
try {request = new ActiveXObject('Microsoft.XMLHTTP');}
catch (err3) {
try { request = new XMLHttpRequest();}
catch (err1) {
request = false;
}
}
}
return request;
}
function connectFour(bot1,bot2,xd_check){
document.getElementById('fightResult').innerHTML = '<p>Please wait...</p>';
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);
} }