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

@ -1 +1 @@
1591 1593

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

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

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

Loading…
Cancel
Save