From 5935b750d0334817b38d0370bbb3df1154bee331 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Mon, 25 Jul 2016 22:01:58 +0200 Subject: [PATCH] . --- countBattles.txt | 2 +- src/arenas/tron/TronGame.php | 9 +++++++-- src/arenas/tron/TronPlayer.php | 3 --- src/arenas/tron/js.js | 4 ++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/countBattles.txt b/countBattles.txt index 46547e5..30ab544 100644 --- a/countBattles.txt +++ b/countBattles.txt @@ -1 +1 @@ -1591 \ No newline at end of file +1593 \ No newline at end of file diff --git a/src/arenas/tron/TronGame.php b/src/arenas/tron/TronGame.php index d484315..86c210d 100644 --- a/src/arenas/tron/TronGame.php +++ b/src/arenas/tron/TronGame.php @@ -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; } + + } } } diff --git a/src/arenas/tron/TronPlayer.php b/src/arenas/tron/TronPlayer.php index ba8c357..60115f8 100644 --- a/src/arenas/tron/TronPlayer.php +++ b/src/arenas/tron/TronPlayer.php @@ -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; } - } \ No newline at end of file diff --git a/src/arenas/tron/js.js b/src/arenas/tron/js.js index 9f01129..c189820 100644 --- a/src/arenas/tron/js.js +++ b/src/arenas/tron/js.js @@ -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{ }