Planet resource produciton calculations and planet resources updates implemented and tested

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-06-19 15:53:50 +02:00
commit 282eb43a31
6 changed files with 207 additions and 22 deletions

View file

@ -9,6 +9,7 @@ if (!extension_loaded('xdebug')) {
$planet = new Legacies_Empire_Model_Planet(array(
'last_update' => 0,
'planet_type' => 1,
'b_building' => (3600 * 10000),
'metal' => 0,
'metal_perhour' => 20,
@ -26,10 +27,10 @@ $planet = new Legacies_Empire_Model_Planet(array(
'solar_satelit_porcent' => 10,
'deuterium_sintetizer_porcent' => 10,
'metal_mine' => 10,
'metal_mine' => 20,
'crystal_mine' => 0,
'deuterium_sintetizer' => 0,
'solar_plant' => 0,
'solar_plant' => 20,
'fusion_plant' => 0,
'robot_factory' => 0,
'nano_factory' => 0,
@ -47,9 +48,21 @@ $planet->updateStorages(3600);
var_dump($planet->getAllDatas());
$planet->updateResourceProduction(3600);
var_dump($planet->getAllDatas());
Legacies::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => 3600
));
var_dump($planet->getAllDatas());
var_dump((3600 + (3600 * 200)));
Legacies::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => (3600 + (3600 * 200))
));
var_dump($planet->getAllDatas());

View file

@ -0,0 +1,43 @@
<?php
if (!defined('DEBUG') && in_array(strtolower(getenv('DEBUG')), array('1', 'on', 'true'))) {
define('DEBUG', true);
}
if (!defined('DEBUG')) {
@ini_set('display_errors', false);
} else {
@ini_set('display_errors', true);
@error_reporting(E_ALL | E_STRICT);
}
defined('ROOT_PATH') || define('ROOT_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR);
defined('APPLICATION_PATH') || define('APPLICATION_PATH', ROOT_PATH . 'includes' . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR);
defined('PHPEXT') || define('PHPEXT', require ROOT_PATH . 'extension.inc');
defined('VERSION') || define('VERSION', '2009.5');
set_include_path(implode(PATH_SEPARATOR, array(
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'core',
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'community',
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'local',
get_include_path()
)));
function __autoload($class) {
include_once str_replace('_', '/', $class) . '.php';
}
if (0 === filesize(ROOT_PATH . 'config.php')) {
header('Location: install/');
die();
}
foreach (include ROOT_PATH . 'includes/data/events.php' as $event => $listenerList) {
foreach ($listenerList as $listener) {
Legacies::registerListener($event, $listener);
}
}
include ROOT_PATH . 'includes/constants.php';