return lap info

This commit is contained in:
Gnieark 2016-07-11 19:06:02 +02:00
parent a6eae7ce1c
commit 0d2ff7d563
3 changed files with 29 additions and 7 deletions

View File

@ -1 +1 @@
1507
1512

View File

@ -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 ++){

View File

@ -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;
}