some fixes

pull/96/head
Gnieark 8 years ago
parent 8f093f6966
commit aced31b12c

@ -1 +1 @@
1559
1579

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

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

Loading…
Cancel
Save