From 0d2ff7d5637da6013073a0165b26d30997982c97 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Mon, 11 Jul 2016 19:06:02 +0200 Subject: [PATCH] return lap info --- countBattles.txt | 2 +- src/arenas/tron/act.php | 13 ++++++++++++- src/arenas/tron/class.TronGame.php | 21 ++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/countBattles.txt b/countBattles.txt index ae6f116..9bf7b0b 100644 --- a/countBattles.txt +++ b/countBattles.txt @@ -1 +1 @@ -1507 \ No newline at end of file +1512 \ No newline at end of file diff --git a/src/arenas/tron/act.php b/src/arenas/tron/act.php index 82c1037..7cc5a3f 100644 --- a/src/arenas/tron/act.php +++ b/src/arenas/tron/act.php @@ -54,7 +54,18 @@ switch ($_POST['act']){ echo '{"status":"error"}'; die; } - $game->new_lap(); + $lap = $game->new_lap(); + if($game->get_continue()){ + $continue = 1; + }else{ + $continue = 0; + } + echo json_encode(array( + 'gameId' => $game->getGameId(), + 'continue' => $continue, + 'lap' => $lap + )); + die; /* //make the board array for ($botCount = 0; $botCount < count($bots); $botCount ++){ diff --git a/src/arenas/tron/class.TronGame.php b/src/arenas/tron/class.TronGame.php index 46657db..f14dca8 100644 --- a/src/arenas/tron/class.TronGame.php +++ b/src/arenas/tron/class.TronGame.php @@ -169,6 +169,7 @@ class TronGame if ($this->bots[$botCount]->getStatus()){ //tester si sa réponse n'est pas sur une case déjà occupée. $target = $this->bots[$botCount]->grow($responses[$botCount]['responseArr']['play']); + $targetByBot[$botCount] = $target; $x = $target[0]; $y = $target[1]; $hashTargetsList[$botCount] = $x * 1000 + $y; //wil be easyest to compare than if it was arrays @@ -202,20 +203,30 @@ class TronGame if(count($loosers > 0)){ - //save_draw_bots - save_draw_bots($loosers); + $this->save_draw_bots($loosers); $winners = array(); for ($botCount = 0; $botCount < $nbeBots; $botCount++){ if ($this->bots[$botCount]->getStatus()){ $winners[] = $this->bots[$botCount]->getId(); } } + //sauver les relations winers loosers + $this->save_losers_winers($loosers,$winners); } - - //sauver les relations winers loosers - + // generer un array en retour qui permettra de dessiner les modifications + // sur la map + $arrRapport = array(); + for ($botCount = 0; $botCount < $nbeBots; $botCount++){ + if ($this->bots[$botCount]->getStatus()){ + $arrRapport[$botCount] = $targetByBot[$botCount]; + }else{ + $arrRapport[$botCount] = "die"; + } + } + + return $arrRapport; }