some fixes
This commit is contained in:
parent
b6060449e7
commit
8f093f6966
|
@ -1 +1 @@
|
|||
1549
|
||||
1559
|
|
@ -75,6 +75,7 @@ class TronGame
|
|||
foreach($this->bots as $bot){
|
||||
$trailsArr[] = $bot->trail;
|
||||
}
|
||||
//echo json_encode($trailsArr);
|
||||
return json_encode($trailsArr);
|
||||
}
|
||||
public function new_lap(){
|
||||
|
@ -83,14 +84,14 @@ class TronGame
|
|||
$nbeBots = count($this->bots);
|
||||
$urls = array();
|
||||
$paramToSend = array();
|
||||
$board = $this->getBoard();
|
||||
$board = $this->get_trails();
|
||||
$loosers = array();
|
||||
$lastsCells = array();
|
||||
|
||||
for ($botCount = 0; $botCount < $nbeBots; $botCount++){
|
||||
if ($this->bots[$botCount]->getStatus()){
|
||||
if ($this->bots[$botCount]->isAlive){
|
||||
|
||||
$urls[$botCount] = $this->bots[$botCount]->getURL();
|
||||
$urls[$botCount] = $this->bots[$botCount]->url;
|
||||
|
||||
$paramsToSend[$botCount] = array(
|
||||
'game-id' => "".$this->gameId,
|
||||
|
@ -105,16 +106,20 @@ class TronGame
|
|||
|
||||
$responses = $this->get_multi_IAS_Responses($urls,$paramsToSend);
|
||||
|
||||
print_r($responses);
|
||||
|
||||
//grow bots'tails
|
||||
for ($botCount = 0; $botCount < $nbeBots; $botCount++){
|
||||
if ($this->bots[$botCount]->getStatus()){
|
||||
$lastsCells[$botCount] = $this->bots[$botCount]->grow($responses[$botCount]['responseArr']['play']);
|
||||
if ($this->bots[$botCount]->isAlive){
|
||||
$dir = Direction::make($responses[$botCount]['responseArr']['play']);
|
||||
$lastsCells[$botCount] = $this->bots[$botCount]->grow($dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//test if loose
|
||||
for ($botCount = 0; $botCount < $nbeBots; $botCount++){
|
||||
if ($this->bots[$botCount]->getStatus()){
|
||||
if ($this->bots[$botCount]->isAlive){
|
||||
foreach($this->bots as $otherBot){
|
||||
if($otherBot->trail->contains($lastsCells($botCount)))
|
||||
$loosers[] = $botCount;
|
||||
|
@ -248,5 +253,4 @@ class TronGame
|
|||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
}
|
|
@ -61,7 +61,7 @@ switch ($_POST['act']){
|
|||
|
||||
$game = unserialize($_SESSION['game']);
|
||||
|
||||
if($game->getGameId() <> $_POST['gameId']){
|
||||
if($game->gameId <> $_POST['gameId']){
|
||||
//sometimes if an ajax callback is applied after init an other game
|
||||
echo '{"status":"error"}';
|
||||
die;
|
||||
|
@ -73,7 +73,7 @@ switch ($_POST['act']){
|
|||
$continue = 0;
|
||||
}
|
||||
echo json_encode(array(
|
||||
'gameId' => $game->getGameId(),
|
||||
'gameId' => $game->gameId,
|
||||
'continue' => $continue,
|
||||
'lap' => $lap
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue
Block a user