pull/96/head
Gnieark 8 years ago
parent 60c95835a4
commit 5935b750d0

@ -1 +1 @@
1591
1593

@ -119,12 +119,17 @@ class TronGame
//test if loose
for ($botCount = 0; $botCount < $nbeBots; $botCount++){
if ($this->bots[$botCount]->isAlive){
foreach($this->bots as $otherBot){
if($otherBot->trail->contains($lastsCells[$botCount]))
for( $botCount2 = 0; $botCount2 < $nbeBots; $botCount2++){
if(($botCount <> $botCount2)
&& ($this->bots[$botCount2]->trail->contains($lastsCells[$botCount]))
){
$loosers[] = $botCount;
$this->bots[$botCount]->loose();
break;
}
}
}
}

@ -5,14 +5,12 @@ class TronPlayer{
public $name;
public $trail;
private $direction;
public $isAlive = true;
public function grow(Direction $dir){
$this->trail->add($this->trail->last()->addDirection($dir));
return $this->trail->last();
}
public function loose(){
$this->isAlive = false;
$this->trail->emptyTrail();
@ -29,5 +27,4 @@ class TronPlayer{
public function __construct(){
$this->state = false;
}
}

@ -104,6 +104,10 @@ function play(gameId,xd_check){
if(req.status == 200) {
addLog(req.responseText);
var reponse = JSON.parse(req.responseText);
growTails(reponse['lap']);
play(gameId,xd_check);
}else{
}

Loading…
Cancel
Save