This commit is contained in:
Gnieark 2016-07-25 22:01:58 +02:00
parent 60c95835a4
commit 5935b750d0
4 changed files with 12 additions and 6 deletions

View File

@ -1 +1 @@
1591
1593

View File

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

View File

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

View File

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