diff --git a/common.php b/common.php index 4ec2c27..b2c5c92 100644 --- a/common.php +++ b/common.php @@ -62,6 +62,12 @@ if (0 === filesize(ROOT_PATH . 'config.php')) { die(); } +foreach (include ROOT_PATH . 'includes/data/events.php' as $event => $listenerList) { + foreach ($listenerList as $listener) { + Legacies::registerListener($event, $listener); + } +} + $lang = array(); define('DEFAULT_SKINPATH', 'skins/xnova/'); @@ -99,42 +105,23 @@ if (!defined('DISABLE_IDENTITY_CHECK')) { includeLang('system'); includeLang('tech'); -$now = time(); -$sql =<<getId())) { + $dpath = $user->getSkinPath(); + if (empty($dpath)) { + $dpath = DEFAULT_SKINPATH; + } + if (defined('IN_ADMIN')) { + $dpath = '../' . $dpath; + } SetSelectedPlanet($user); // FIXME + foreach ($user->getVisibleFleets() as $fleet) { + FlyingFleetHandler($fleet); // FIXME + } + $planetrow = $user->getCurrentPlanet(); $galaxyrow = doquery("SELECT * FROM {{table}} WHERE `id_planet` = '".$planetrow['id']."';", 'galaxy', true); diff --git a/includes/application/code/community/Legacies.php b/includes/application/code/community/Legacies.php index 1c8472a..473b39f 100644 --- a/includes/application/code/community/Legacies.php +++ b/includes/application/code/community/Legacies.php @@ -35,8 +35,9 @@ class Legacies return; } + $eventObject = new Legacies_Core_Event($params); foreach (self::$_listeners[$event] as $listener) { - call_user_func($listener, $params); + call_user_func($listener, $eventObject); } } diff --git a/includes/application/code/community/Legacies/Core/Entity/SubTable.php b/includes/application/code/community/Legacies/Core/Entity/SubTable.php new file mode 100644 index 0000000..c734a8c --- /dev/null +++ b/includes/application/code/community/Legacies/Core/Entity/SubTable.php @@ -0,0 +1,129 @@ +_isLoaded !== false) { + $fields = array(); + $values = array(); + $idFields = array(); + foreach ($this->getAllDatas() as $field => $value) { + if (in_array($field, $this->_idFieldNames)) { + $idFields[] = "{$field}=:{$field}"; + } else { + $fields[] = "{$field}=:{$field}"; + } + $values[$field] = $value; + } + $idFields = '(' . implode(') AND (', $idFields) . ')'; + $fields = implode(', ', $fields); + + $database = Legacies_Database::getSingleton(); + $sql =<<getTable(self::getTableName())} + SET {$fields} + WHERE {$idFields} +SQL_EOF; + $statement = $database->prepare($sql); + + $statement->execute($values); + } else { + $datas = $this->getAllDatas(); + $fields = implode(', ', array_keys($datas)); + + $tokens = array(); + foreach ($datas as $field => $value) { + $tokens[] = ":{$field}"; + } + $tokens = implode(', ', $tokens); + + $database = Legacies_Database::getSingleton(); + $sql =<<getTable(self::getTableName())} ($fields) + VALUES ({$tokens}) +SQL_EOF; + $statement = $database->prepare($sql); + $statement->execute($datas); + } + + return $this; + } + + protected function _load() + { + $idValues = func_get_arg(0); + $database = Legacies_Database::getSingleton(); + + $idFields = array(); + foreach ($this->_idFieldNames as $field) { + $idFields[] = "{$field}=:{$field}"; + } + $idFields = '(' . implode(') AND (', $idFields) . ')'; + + $sql =<<getTable(self::getTableName())} + WHERE $idFields + LIMIT 1 +SQL_EOF; + $statement = $database->prepare($sql); + $statement->execute($idValues); + + $datas = $statement->fetch(PDO::FETCH_ASSOC); + if (!is_array($datas) || empty($datas)) { + throw new Legacies_Core_Model_Exception('Could not load data: this id combination could not be found.'); + } + + $this->_data = $datas; + $this->_isLoaded = true; + + return $this; + } + + protected function _delete() + { + $database = Legacies_Database::getSingleton(); + + $idFields = array(); + foreach ($this->_idFieldNames as $field) { + $idFields[] = "{$field}=:{$field}"; + } + $idFields = '(' . implode(') AND (', $idFields) . ')'; + + $sql =<<getTable(self::getTableName())} + WHERE $idFields + LIMIT 1 +SQL_EOF; + $statement = $database->prepare($sql); + $statement->execute($idValues); + + $this->_data = array(); + $this->_isLoaded = false; + + return $this; + } + + public function setTableName($tableName) + { + $this->_tableName = $tableName; + + return $this; + } + + public function getTableName() + { + return $this->_tableName; + } +} \ No newline at end of file diff --git a/includes/application/code/community/Legacies/Core/Event.php b/includes/application/code/community/Legacies/Core/Event.php new file mode 100644 index 0000000..3031032 --- /dev/null +++ b/includes/application/code/community/Legacies/Core/Event.php @@ -0,0 +1,6 @@ +_index; + } + + public function setIndex($index) + { + $this->_index = $index; + + return $this; + } +} \ No newline at end of file diff --git a/includes/application/code/community/Legacies/Empire/Model/BuilderAbstract.php b/includes/application/code/community/Legacies/Empire/Model/BuilderAbstract.php new file mode 100644 index 0000000..4f1214c --- /dev/null +++ b/includes/application/code/community/Legacies/Empire/Model/BuilderAbstract.php @@ -0,0 +1,161 @@ +_currentPlanet = $currentPlanet; + $this->_currentUser = $currentUser; + } + + abstract protected function _initItem(); + + public function enqueue() + { + $params = func_get_args(); + $item = call_user_func_array(array($this, '_initItem'), $params); + $item->setIndex($this->_index); + $queue[$this->_index++] = $item; + + return $this; + } + + public function dequeue($itemIndex) + { + unset($itemIndex); + + return $this; + } + + protected function getItem($itemIndex) + { + if (isset($this->_queue[$itemIndex])) { + return $this->_queue[$itemIndex]; + } + + return null; + } + + protected function _serializeQueue() + { + $serialize = array(); + foreach ($this->_queue as $item) { + $serialize[] = $item->getAllDatas(); + } + return serialize($serialize); + } + + protected function _unserializeQueue($serialized) + { + $this->clearQueue(); + $reflection = new ReflectionClass($this->_itemClass); + + $unserialized = unserialize($serialized); + foreach ($unserialized as $itemData) { + $this->_enqueue($reflection->newInstance($itemData)); + } + return $this; + } + + public function __toString() + { + return $this->_serializeQueue(); + } + + public function getQueue() + { + return $this->_queue; + } + + abstract public function enqueue($item); + abstract public function dequeue($item); + + public function clearQueue() + { + $this->_queue = array(); + } + + + /** + * Check if an item type is actually buildable on the current + * planet, depending on the technology and buildings requirements. + * + * @param int $typeId + * @return bool + */ + public function checkAvailability($typeId) + { + $types = Legacies_Empire_Model_Game_Types::getSingleton(); + $requirements = Legacies_Empire_Model_Game_Requirements::getSingleton(); + + if (!isset($requirements[$typeId]) || empty($requirements[$typeId])) { + return true; + } + + foreach ($requirements[$typeId] as $requirement => $level) { + if ($types->is($requirement, Legacies_Empire::TYPE_BUILDING) && $this->_currentPlanet->hasElement($requirement, $level)) { + continue; + } else if ($types->is($requirement, Legacies_Empire::TYPE_RESEARCH) && $this->_currentUser->hasElement($requirement, $level)) { + continue; + } else if ($types->is($requirement, Legacies_Empire::TYPE_DEFENSE) && $this->_currentPlanet->hasElement($requirement, $level)) { + continue; + } else if ($types->is($requirement, Legacies_Empire::TYPE_SHIP) && $this->_currentPlanet->hasElement($requirement, $level)) { + continue; + } + return false; + } + + try { + // Dispatch event. Throw an exception to break the avaliability. + Legacies::dispatchEvent('builder.check-availability', array( + 'type_id' => $typeId, + 'builder' => $this, + 'planet' => $this->_currentPlanet, + 'user' => $this->_currentUser + )); + } catch (Legacies_Empire_Model_Builder_Break $e) { + return false; + } + + return true; + } + + abstract public function getResourcesNeeded($typeId, $level); + abstract public function getBuildingTime($typeId, $level); +} \ No newline at end of file diff --git a/includes/application/code/community/Legacies/Empire/Model/Planet.php b/includes/application/code/community/Legacies/Empire/Model/Planet.php index 2a24d5a..980534c 100644 --- a/includes/application/code/community/Legacies/Empire/Model/Planet.php +++ b/includes/application/code/community/Legacies/Empire/Model/Planet.php @@ -19,48 +19,13 @@ class Legacies_Empire_Model_Planet protected static $_instances = array(); - protected static $_productionConfig = array( - Legacies_Empire::RESOURCE_METAL => array( - 'field' => Legacies_Empire::RESOURCE_METAL, - 'production_field' => 'metal_perhour', - 'ratio_field' => 'metal_porcent', - 'storage_field' => 'metal_max', - 'production' => array( - Legacies_Empire::ID_BUILDING_METAL_MINE => 'metal_mine_porcent' - ), - 'storage' => Legacies_Empire::ID_BUILDING_METAL_STORAGE - ), - Legacies_Empire::RESOURCE_CRISTAL => array( - 'field' => Legacies_Empire::RESOURCE_CRISTAL, - 'production_field' => 'crystal_perhour', - 'ratio_field' => 'crystal_porcent', - 'storage_field' => 'crystal_max', - 'production' => array( - Legacies_Empire::ID_BUILDING_CRISTAL_MINE => 'crystal_mine_porcent' - ), - 'storage' => Legacies_Empire::ID_BUILDING_CRISTAL_STORAGE - ), - Legacies_Empire::RESOURCE_DEUTERIUM => array( - 'field' => Legacies_Empire::RESOURCE_DEUTERIUM, - 'production_field' => 'deuterium_perhour', - 'ratio_field' => 'deuterium_porcent', - 'storage_field' => 'deuterium_max', - 'production' => array( - Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER => 'deuterium_sintetizer_porcent' - ), - 'storage' => Legacies_Empire::ID_BUILDING_DEUTERIUM_TANK - ), - Legacies_Empire::RESOURCE_ENERGY => array( - 'field' => 'energy_used', - 'production_field' => 'energy_max', - 'storage_field' => null, - 'production' => array( - Legacies_Empire::ID_BUILDING_SOLAR_PLANT => 'solar_plant_porcent', - Legacies_Empire::ID_BUILDING_FUSION_REACTOR => 'fusion_plant_porcent', - Legacies_Empire::ID_SHIP_SOLAR_SATELLITE => 'solar_satelit_porcent' - ), - 'storage' => null - ) + protected static $_productionCodes = array( + Legacies_Empire::ID_BUILDING_METAL_MINE => 'metal_mine', + Legacies_Empire::ID_BUILDING_CRISTAL_MINE => 'cristal_mine', + Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER => 'deuterium_synthetiser', + Legacies_Empire::ID_BUILDING_SOLAR_PLANT => 'solar_plant', + Legacies_Empire::ID_BUILDING_FUSION_REACTOR => 'fusion_reactor', + Legacies_Empire::ID_SHIP_SOLAR_SATELLITE => 'solar_satelite' ); protected static $_productionInstances = array(); @@ -111,14 +76,14 @@ class Legacies_Empire_Model_Planet $resourcesProductions = array(); foreach (self::$_productionConfig as $resource => $resourceData) { if ($resourceData['storage_field'] !== null && $resourceData['storage_field'] !== null) { - $officerEnhancement = Math::add(Math::mul(.5, $this->getUser('rpg_stockeur')), 1); + $officerEnhancement = Math::add(Math::mul(.5, $this->getData('rpg_stockeur')), 1); $storageCapacity = Math::pow(1.5, $this->getData(Legacies_Empire::getFieldName($resourceData['storage']))); $value = Math::mul(MAX_OVERFLOW, Math::mul($officerEnhancement, Math::add(BASE_STORAGE_SIZE, $storageCapacity))); $this->setData($resourceData['storage_field'], $value); } - foreach ($resourceData[production] as $productionUnit => $ratioField) { + foreach ($resourceData['production'] as $productionUnit => $ratioField) { if (!in_array($productionUnit, $types['prod'])) { continue; } @@ -127,7 +92,7 @@ class Legacies_Empire_Model_Planet $ratio = $this->getData($ratioField); $element = self::getProducitonElementInstance($productionUnit); - foreach ($element->getRatios($level, $ratio, $this, $this->getUser()) as $resourceId => $resourceProduction) { + foreach ($element->getProductionRatios($level, $ratio, $this, $this->getUser()) as $resourceId => $resourceProduction) { if (!isset($resourcesProductions[$resourceId])) { $resourcesProductions[$resourceId] = $resourceProduction; } else { @@ -138,14 +103,15 @@ class Legacies_Empire_Model_Planet } $timeDiff = ($time - $this->getData('last_update')) / 3600; - foreach ($resourcesProductions as $resourceId => $productionPerHour) { + foreach ($resourcesProductions as $resource => $productionPerHour) { if (!isset(self::$_productionConfig[$resource])) { continue; } $this->setData(self::$_productionConfig[$resource]['production_field'], $productionPerHour); $production = Math::add($this->getData(self::$_productionConfig[$resource]['field']), Math::mul($timeDiff, $productionPerHour)); - if (Math::diff($production, $this->getData(self::$_productionConfig[$resource]['storage_field'])) > 0) { + + if (Math::comp($production, $this->getData(self::$_productionConfig[$resource]['storage_field'])) > 0) { $production = $this->getData(self::$_productionConfig[$resource]['storage_field']); } $this->setData(self::$_productionConfig[$resource]['field'], $production); @@ -156,14 +122,15 @@ class Legacies_Empire_Model_Planet public static function getProducitonElementInstance($buildingId) { - global $ProdGrid; // FIXME + $production = Legacies_Empire_Model_Game_Production::getSingleton(); if (!isset(self::$_productionInstances[$buildingId])) { - if (!isset($ProdGrid[$buildingId])) { + if (!isset($production[$buildingId])) { return null; } - $class = $ProdGrid[$buildingId][Legacies_Empire::RESOURCE_FORMULA]; - self::$_productionInstances[$buildingId] = new $class; + $class = $production[$buildingId][Legacies_Empire::RESOURCE_CLASS]; + $reflection = new ReflectionClass($class); + self::$_productionInstances[$buildingId] = $reflection->newInstance(); } return self::$_productionInstances[$buildingId]; @@ -290,6 +257,87 @@ class Legacies_Empire_Model_Planet return $this->hasData($fields[$elementId]) && Math::comp($this->getElement($elementId), $levelRequired) > 0; } + public function appendQueue($buildingId) + { + $types = Legacies_Empire_Model_Game_Types::getSingleton(); + + if (!$types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { + return $this; + } + + if (!$this->checkAvailability($buildingId)) { + return $this; + } + + // Dispatch event + Legacies::dispatchEvent('planet.building.append-queue.before', array( + 'ship_id' => $shipId, + 'qty' => $qty, + 'shipyard' => $this, + 'planet' => $this->_currentPlanet, + 'user' => $this->_currentUser + )); + + foreach ($this->_resourcesTypes as $resourceType) { + $this->setData($resourceType, Math::sub($this->getData($resourceType), $resourcesNeeded[$resourceType])); + } + + // Dispatch event + Legacies::dispatchEvent('planet.shipyard.append-queue.after', array( + 'ship_id' => $shipId, + 'qty' => $qty, + 'shipyard' => $this, + 'planet' => $this->_currentPlanet, + 'user' => $this->_currentUser + )); + + return $this; + } + + /** + * Check if a building is actually buildable on the current planet, + * depending on the technology and buildings requirements. + * + * @param int $buildingId + * @return bool + */ + public function checkAvailability($buildingId) + { + $types = Legacies_Empire_Model_Game_Types::getSingleton(); + $requirements = Legacies_Empire_Model_Game_Requirements::getSingleton(); + + if (!isset($requirements[$buildingId]) || empty($requirements[$buildingId])) { + return true; + } + + foreach ($requirements[$buildingId] as $requirement => $level) { + if ($types->is($requirement, Legacies_Empire::TYPE_BUILDING) && $this->_currentPlanet->hasElement($requirement, $level)) { + continue; + } else if ($types->is($requirement, Legacies_Empire::TYPE_RESEARCH) && $this->_currentUser->hasElement($requirement, $level)) { + continue; + } else if ($types->is($requirement, Legacies_Empire::TYPE_DEFENSE) && $this->_currentPlanet->hasElement($requirement, $level)) { + continue; + } else if ($types->is($requirement, Legacies_Empire::TYPE_SHIP) && $this->_currentPlanet->hasElement($requirement, $level)) { + continue; + } + return false; + } + + try { + // Dispatch event. Throw an exception to break the avaliability. + Legacies::dispatchEvent('planet.shipyard.check-availability', array( + 'ship_id' => $buildingId, + 'shipyard' => $this, + 'planet' => $this->_currentPlanet, + 'user' => $this->_currentUser + )); + } catch (Exception $e) { + return false; + } + + return true; + } + public static function registrationListener($eventData) { if (isset($eventData['user'])) { @@ -392,9 +440,10 @@ class Legacies_Empire_Model_Planet if (isset($eventData['planet'])) { $planet = $eventData['planet']; - $time = null; if (isset($eventData['time'])) { $time = $eventData['time']; + } else { + $time = time(); } if ($planet === null || !$planet instanceof Legacies_Empire_Model_Planet || !$planet->getId()) { @@ -402,10 +451,10 @@ class Legacies_Empire_Model_Planet } $user = $planet->getUser(); - if (($queue = $this->getData('b_building_id')) != '') { + if (($queue = $planet->getData('b_building_id')) != '0') { //FIXME: refactor buildings construciton list $explodedQueue = explode(';', $queue); foreach ($explodedQueue as $item) { - $partialTime = $this->getData('b_building'); + $partialTime = $planet->getData('b_building'); if ($partialTime < $time) { $planet->updateResources($partialTime); @@ -420,6 +469,7 @@ class Legacies_Empire_Model_Planet } else { $planet->updateResources($time); } + $planet->setData('last_update', $time); } } } \ No newline at end of file diff --git a/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard.php b/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard.php index 46c3ceb..9438f0f 100644 --- a/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard.php +++ b/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard.php @@ -75,7 +75,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard Legacies_Empire::RESOURCE_METAL, Legacies_Empire::RESOURCE_CRISTAL, Legacies_Empire::RESOURCE_DEUTERIUM, - //Legacies_Empire::RESOURCE_ENERGY + Legacies_Empire::RESOURCE_ENERGY ); /** @@ -95,7 +95,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard public static function factory($currentPlanet, $currentUser) { if ($currentPlanet->getId()) { - return false; + return null; } if (!isset(self::$_instances[$currentPlanet->getId()])) { @@ -117,10 +117,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard $this->_currentPlanet = $currentPlanet; $this->_currentUser = $currentUser; - $this->_queue = unserialize($this->_currentPlanet->getData('b_hangar_id')); - if (!is_array($this->_queue)) { - $this->_queue = array(); - } + $this->_queue = new Legacies_Empire_Model_Planet_Building_Shipyard_Builder($currentPlanet, $currentUser); $this->_now = time(); } @@ -187,12 +184,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard $resourcesNeeded = $this->_getResourcesNeeded($shipId, $qty); $buildTime = $this->getBuildTime($shipId, $qty); - $this->_queue[] = new Legacies_Empire_Model_Planet_Building_Shipyard_Item(array( - 'ship_id' => $shipId, - 'qty' => $qty, - 'created_at' => $this->_now(), - 'updated_at' => $this->_now() - )); + $this->_queue->enqueue($shipId, $qty); foreach ($this->_resourcesTypes as $resourceType) { $this->_currentPlanet[$resourceType] = Math::sub($this->_currentPlanet[$resourceType], $resourcesNeeded[$resourceType]); diff --git a/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php b/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php new file mode 100644 index 0000000..ab36ce5 --- /dev/null +++ b/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php @@ -0,0 +1,22 @@ +_unserializeQueue($currentPlanet->getData('b_hangar_id')); + } + + public function _initItem($shipId, $qty) + { + return new Legacies_Empire_Model_Planet_Building_Shipyard_Item(array( + 'ship_id' => $shipId, + 'qty' => $qty, + 'created_at' => time(), + 'updated_at' => time() + )); + } +} \ No newline at end of file diff --git a/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php b/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php index cf7f176..83ad74a 100644 --- a/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php +++ b/includes/application/code/community/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php @@ -1,6 +1,6 @@ _tableName = 'planet_production'; + $this->_idFieldNames = array( + 'production_code', + 'planet_id' + ); + } +} \ No newline at end of file diff --git a/includes/application/code/community/Legacies/Empire/Model/Planet/Resource.php b/includes/application/code/community/Legacies/Empire/Model/Planet/Resource.php new file mode 100644 index 0000000..5b1195d --- /dev/null +++ b/includes/application/code/community/Legacies/Empire/Model/Planet/Resource.php @@ -0,0 +1,20 @@ +_tableName = 'planet_resource'; + $this->_idFieldNames = array( + 'resource_code', + 'planet_id' + ); + } +} \ No newline at end of file diff --git a/includes/application/code/community/Legacies/Empire/Model/User.php b/includes/application/code/community/Legacies/Empire/Model/User.php index 8833f6f..04fb695 100644 --- a/includes/application/code/community/Legacies/Empire/Model/User.php +++ b/includes/application/code/community/Legacies/Empire/Model/User.php @@ -205,7 +205,7 @@ class Legacies_Empire_Model_User $planetCollection = new Legacies_Core_Collection(array('planet' => 'planets'), 'Legacies_Empire_Model_Planet'); $planetCollection->where('id_owner=:user'); - $order = ($user['planet_sort_order'] == 1) ? 'DESC' : 'ASC'; + $order = ($this->getData('planet_sort_order') == 1) ? 'DESC' : 'ASC'; switch ($this->getData('planet_sort')) { case self::PLANET_SORT_POSITION: @@ -298,4 +298,19 @@ class Legacies_Empire_Model_User return $this->hasData($fields[$elementId]) && Math::comp($this->getElement($elementId), $levelRequired) > 0; } + + public function getSkinPath($default = null) + { + if ($path = $this->getData('dpath')) { + return $path; + } + return $default; + } + + public function setSkinPath($path) + { + $this->setData('dpath', $path); + + return $this; + } } \ No newline at end of file diff --git a/includes/application/test/UpdatePlanet.php b/includes/application/test/UpdatePlanet.php new file mode 100644 index 0000000..76769f8 --- /dev/null +++ b/includes/application/test/UpdatePlanet.php @@ -0,0 +1,28 @@ +getAllDatas(), $production->getAllDatas(), array( + 'last_update' => $planet->getData('last_update'), + 'metal' => $planet->getData('metal'), + 'cristal' => $planet->getData('crystal'), + 'deuterium' => $planet->getData('deuterium'), + 'energy_max' => $planet->getData('energy_max'), + 'energy_used' => $planet->getData('energy_used') + )); + +Legacies::dispatchEvent('planet.update', array( + 'planet' => $planet + )); + +header('Content-Type: text/plain'); +var_dump(array( + 'last_update' => $planet->getData('last_update'), + 'metal' => $planet->getData('metal'), + 'cristal' => $planet->getData('crystal'), + 'deuterium' => $planet->getData('deuterium'), + 'energy_max' => $planet->getData('energy_max'), + 'energy_used' => $planet->getData('energy_used') + )); \ No newline at end of file diff --git a/includes/data/production.php b/includes/data/production.php index b09634d..291f492 100644 --- a/includes/data/production.php +++ b/includes/data/production.php @@ -13,7 +13,8 @@ Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', Legacies_Empire::RESOURCE_ENERGY => 'return -(10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ) + ), + Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_MetalMine' ), Legacies_Empire::ID_BUILDING_CRISTAL_MINE => array( @@ -27,7 +28,8 @@ Legacies_Empire::RESOURCE_CRISTAL => 'return (20 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);', Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', Legacies_Empire::RESOURCE_ENERGY => 'return -(10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ) + ), + Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_CristalMine' ), Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER => array( @@ -41,7 +43,8 @@ Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', Legacies_Empire::RESOURCE_DEUTERIUM => 'return ((10 * $BuildLevel * pow((1.1), $BuildLevel)) * (-0.002 * $BuildTemp + 1.28)) * (0.1 * $BuildLevelFactor);', Legacies_Empire::RESOURCE_ENERGY => 'return -(30 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ) + ), + Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser' ), Legacies_Empire::ID_BUILDING_SOLAR_PLANT => array( @@ -55,7 +58,8 @@ Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', Legacies_Empire::RESOURCE_ENERGY => 'return (20 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ) + ), + Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_SolarPlant' ), Legacies_Empire::ID_BUILDING_FUSION_REACTOR => array( @@ -69,7 +73,8 @@ Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', Legacies_Empire::RESOURCE_DEUTERIUM => 'return -(10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);', Legacies_Empire::RESOURCE_ENERGY => 'return (50 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ) + ), + Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_FusionReactor' ), // }}} @@ -87,7 +92,8 @@ Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', Legacies_Empire::RESOURCE_ENERGY => 'return (($BuildTemp / 4) + 20) * $BuildLevel * (0.1 * $BuildLevelFactor);' - ) + ), + Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Ship_SolarSatellite' ), Legacies_Empire::ID_SHIP_SUPERNOVA => array( Legacies_Empire::RESOURCE_METAL => 0, @@ -100,7 +106,8 @@ Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', Legacies_Empire::RESOURCE_ENERGY => 'return -(12500 * ($BuildTemp / 4) + 20) * $BuildLevel * (0.1 * $BuildLevelFactor);' - ) + ), + Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Ship_Supernova' ) // }}} ); diff --git a/includes/functions/GetElementPrice.php b/includes/functions/GetElementPrice.php index 6c97d14..33ba4af 100644 --- a/includes/functions/GetElementPrice.php +++ b/includes/functions/GetElementPrice.php @@ -36,7 +36,7 @@ * @param unknown_type $Element * @param unknown_type $userfactor */ -function GetElementPrice ($user, $planet, $Element, $userfactor = true) { +function GetElementPrice($user, $planet, $Element, $userfactor = true) { global $pricelist, $resource, $lang; if ($userfactor) {