some fixes

This commit is contained in:
Gnieark 2016-07-25 18:38:48 +02:00
parent 8f093f6966
commit aced31b12c
3 changed files with 13 additions and 13 deletions

View File

@ -1 +1 @@
1559
1579

View File

@ -34,20 +34,21 @@ class Trail {
$this->trail->push($value);
}
public function __toString(){
$arr = "";
foreach($this->trail as $value) {
$arr[] = $value;
return json_encode($this->getTrailAsArray());
}
public function getTrailAsArray(){
$arr = array();
foreach($this->trail as $coord) {
$arr[] = array($coord->x,$coord->y);
}
return json_encode($arr);
return $arr;
}
public function contains($searchedValue) {
foreach($this->trail as $value) {
if($value == $searchedValue) return TRUE;
if($value == $searchedValue) return true;
}
return FALSE;
return false;
}
public static function kind($var) {

View File

@ -73,9 +73,8 @@ class TronGame
//return all trails for draw svg
$trailsArr = array();
foreach($this->bots as $bot){
$trailsArr[] = $bot->trail;
$trailsArr[] = $bot->trail->getTrailAsArray();
}
//echo json_encode($trailsArr);
return json_encode($trailsArr);
}
public function new_lap(){
@ -105,13 +104,13 @@ 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]->isAlive){
$dir = Direction::make($responses[$botCount]['responseArr']['play']);
$lastsCells[$botCount] = $this->bots[$botCount]->grow($dir);
}
}