This commit is contained in:
Gnieark 2016-09-30 19:25:25 +02:00
parent 759230082c
commit 9a2224f019
4 changed files with 18 additions and 12 deletions

View File

@ -1 +1 @@
1662 1671

View File

@ -66,9 +66,7 @@ class TronGame
save_battle('tron',$winer,$loser,1,'id'); save_battle('tron',$winer,$loser,1,'id');
} }
} }
} }
public function get_trails(){ public function get_trails(){
//return all trails for draw svg //return all trails for draw svg
$trailsArr = array(); $trailsArr = array();
@ -109,8 +107,6 @@ class TronGame
'player-index' => $botCount, // To do: verifier que ça restera le même à chaque tour 'player-index' => $botCount, // To do: verifier que ça restera le même à chaque tour
'players' => $nbeBots 'players' => $nbeBots
); );
//!!!!!!!!!!!!! To debug
//error_log(json_encode($paramsToSend[$botCount]));
} }
} }
@ -156,11 +152,21 @@ class TronGame
} }
} }
return $this->get_lasts_trails();
//loosers list (in order to pass their id)
$loosersList = array();
foreach($loosers as $looser){
$loosersList[] = array(
'order' => $looser,
'id' => $this->bots[$looser]->id
);
} }
return array(
'last_points' => $this->get_lasts_trails(),
'loosers' => $loosersList
);
}
private function get_multi_IAS_Responses($iasUrls, $postParams){ private function get_multi_IAS_Responses($iasUrls, $postParams){
//same as the get_IAS_Responses function //same as the get_IAS_Responses function
// but more than one bot requested parallely // but more than one bot requested parallely

View File

@ -36,7 +36,7 @@ switch ($_POST['act']){
$botsInfos[] = $botsFullArr[$id]; $botsInfos[] = $botsFullArr[$id];
} }
} }
//************
$game = new TronGame($botsInfos); $game = new TronGame($botsInfos);

View File

@ -100,9 +100,9 @@ function play(gameId,xd_check){
req.onreadystatechange = function(){ req.onreadystatechange = function(){
if(req.readyState == 4){ if(req.readyState == 4){
if(req.status == 200) { if(req.status == 200) {
addLog(req.responseText); //addLog(req.responseText);
var reponse = JSON.parse(req.responseText); var reponse = JSON.parse(req.responseText);
drawMap(reponse['lap']); drawMap(reponse['lap']['last_points']);
if(reponse['continue'] == '1'){ if(reponse['continue'] == '1'){
//setTimeout(function(){ //setTimeout(function(){