%PDF- %PDF-
Direktori : /www/old2/_music/diplomka/diplomka/src/cluster/ |
Current File : /www/old2/_music/diplomka/diplomka/src/cluster/Portal.php |
<?php class Portal { var $guid; var $latitude = 0; var $longitude = 0; var $resonators = 0; var $side = "ENLIGHTENED"; var $startTime = 0; var $history = array(); var $actions = 0; var $deployCnt = 0; var $deployLevel = 0; var $destroyLevel = 0; var $destroyCnt = 0; var $name = ""; var $cluster = 0; public function __construct($guid, $side, $lat, $lon) { $this->guid = $guid; $this->side = $side; $this->latitude = $lat; $this->longitude = $lon; } public function addResonator($lvl) { $this->resonators += $lvl; $this->actions++; $this->deployCnt++; $this->deployLevel += $lvl; } public function destroyResonator($lvl) { $this->resonators -= $lvl; $this->actions++; $this->destroyCnt++; $this->destroyLevel += $lvl; } public function getLevel() { return floor($this->resonators / 8); } public function getDeployAverage() { return $this->deployLevel / $this->deployLevel; } public function getDestroyAverage() { return $this->destroyLevel / $this->destroyCnt; } public function setSide($side, $timestamp) { $this->side = $side; $this->startTime = $timestamp; $this->resonators = 0; } public function setCompleted($timestamp) { // if($this->startTime == 0 && $this->getLevel() >= 7) // { // $this->startTime = $timestamp; // } } public function destroy($timestamp) { if($this->startTime == 0) return; if($this->getDeployAverage() >= 6 || $this->getDestroyAverage() >= 6) { $o = new stdClass(); $o->start = new DateTime(date("Y-m-d H:i:s", $this->startTime)); $o->end = new DateTime(date("Y-m-d H:i:s", $timestamp)); $o->level = $this->getLevel(); $o->side = $this->side; $this->history[] = $o; $this->startTime = 0; } } }