Updated data access layer

Renamed classes, methods & variables from "User" to "Player"
Fixed dependencies requirements in the research lab queue
Updated overview
Added MVC's controller
Added build files
Updated directory structure

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2012-02-28 22:43:37 +01:00
commit 690a7f60f3
1435 changed files with 5772 additions and 5764 deletions

View file

@ -1,2 +0,0 @@
SetEnv DEBUG On
SetEnv DEPRECATION Off

View file

@ -1,159 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
/**
*
* Enter description here ...
* @author Greg
*
*/
class Generations_Empire
{
const TYPE_BUILDING = 'building';
const TYPE_RESEARCH = 'technology';
const TYPE_SHIP = 'fleet';
const TYPE_DEFENSE = 'defense';
const TYPE_SPECIAL = 'special';
const TYPE_PRODUCTION = 'prodution';
const TYPE_FLEET_MISSION = 'mission';
const RESOURCE_GOLD = 'gold';
const RESOURCE_TITANIUM = 'titanium';
const RESOURCE_ZIRCONIUM = 'zirconium';
const RESOURCE_TRITIUM = 'tritium';
const RESOURCE_POPULATION = 'population';
const RESOURCE_ENERGY = 'energy';
const RESOURCE_MULTIPLIER = 'multiplier';
const RESOURCE_CLASS = 'class';
const BASE_BUILDING_TIME = 'base_time';
const SHIPS_CONSUMPTION_PRIMARY = 'primary_consumption';
const SHIPS_CELERITY_PRIMARY = 'primary_speed';
const SHIPS_CONSUMPTION_SECONDARY = 'secondary_consumption';
const SHIPS_CELERITY_SECONDARY = 'secondary_speed';
const SHIPS_CAPACITY_PRIMARY = 'primary_capacity';
const SHIPS_CAPACITY_SECONDARY = 'secondary_capacity';
const ID_BUILDING_GOLD_MINE = 1;
const ID_BUILDING_GERMANUIM_MINE = 2;
const ID_BUILDING_DEUTERIUM_SYNTHETISER = 3;
const ID_BUILDING_SOLAR_PLANT = 4;
const ID_BUILDING_FUSION_REACTOR = 12;
const ID_BUILDING_ROBOTIC_FACTORY = 14;
const ID_BUILDING_NANITE_FACTORY = 15;
const ID_BUILDING_SHIPYARD = 21;
const ID_BUILDING_METAL_STORAGE = 22;
const ID_BUILDING_CRISTAL_STORAGE = 23;
const ID_BUILDING_DEUTERIUM_TANK = 24;
const ID_BUILDING_RESEARCH_LAB = 31;
const ID_BUILDING_TERRAFORMER = 33;
const ID_BUILDING_ALLIANCE_DEPOT = 34;
const ID_BUILDING_LUNAR_BASE = 41;
const ID_BUILDING_SENSOR_PHALANX = 42;
const ID_BUILDING_JUMP_GATE = 43;
const ID_BUILDING_MISSILE_SILO = 44;
const ID_RESEARCH_ESPIONAGE_TECHNOLOGY = 106;
const ID_RESEARCH_COMPUTER_TECHNOLOGY = 108;
const ID_RESEARCH_WEAPON_TECHNOLOGY = 109;
const ID_RESEARCH_SHIELDING_TECHNOLOGY = 110;
const ID_RESEARCH_ARMOUR_TECHNOLOGY = 111;
const ID_RESEARCH_ENERGY_TECHNOLOGY = 113;
const ID_RESEARCH_HYPERSPACE_TECHNOLOGY = 114;
const ID_RESEARCH_COMBUSTION_DRIVE = 115;
const ID_RESEARCH_IMPULSE_DRIVE = 117;
const ID_RESEARCH_HYPERSPACE_DRIVE = 118;
const ID_RESEARCH_LASER_TECHNOLOGY = 120;
const ID_RESEARCH_ION_TECHNOLOGY = 121;
const ID_RESEARCH_PLASMA_TECHNOLOGY = 122;
const ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK = 123;
const ID_RESEARCH_EXPEDITION_TECHNOLOGY = 124;
const ID_RESEARCH_ASTROPHYSICS = 124;
const ID_RESEARCH_GRAVITON_TECHNOLOGY = 199;
const ID_SHIP_LIGHT_TRANSPORT = 202;
const ID_SHIP_LARGE_TRANSPORT = 203;
const ID_SHIP_LIGHT_FIGHTER = 204;
const ID_SHIP_HEAVY_FIGHTER = 205;
const ID_SHIP_CRUISER = 206;
const ID_SHIP_BATTLESHIP = 207;
const ID_SHIP_COLONY_SHIP = 208;
const ID_SHIP_RECYCLER = 209;
const ID_SHIP_SPY_DRONE = 210;
const ID_SHIP_BOMBER = 211;
const ID_SHIP_SOLAR_SATELLITE = 212;
const ID_SHIP_DESTRUCTOR = 213;
const ID_SHIP_DEATH_STAR = 214;
const ID_SHIP_BATTLECRUISER = 215;
const ID_SHIP_SUPERNOVA = 216;
const ID_DEFENSE_ROCKET_LAUNCHER = 401;
const ID_DEFENSE_LIGHT_LASER = 402;
const ID_DEFENSE_HEAVY_LASER = 403;
const ID_DEFENSE_ION_CANNON = 404;
const ID_DEFENSE_GAUSS_CANNON = 405;
const ID_DEFENSE_PLASMA_TURRET = 406;
const ID_DEFENSE_SMALL_SHIELD_DOME = 407;
const ID_DEFENSE_LARGE_SHIELD_DOME = 408;
const ID_SPECIAL_ANTIBALLISTIC_MISSILE = 502;
const ID_SPECIAL_INTERPLANETARY_MISSILE = 503;
const ID_COMBAT_SHIELDS = 'shield';
const ID_COMBAT_FIREPOWER = 'attack';
const ID_COMBAT_RAPID_FIRE = 'rapidfire';
const ID_MISSION_ATTACK = 1;
const ID_MISSION_GROUP_ATTACK = 2;
const ID_MISSION_TRANSPORT = 3;
const ID_MISSION_STATION = 4;
const ID_MISSION_STATION_ALLY = 5;
const ID_MISSION_SPY = 6;
const ID_MISSION_SETTLE_COLONY = 7;
const ID_MISSION_RECYCLE = 8;
const ID_MISSION_DESTROY = 9;
const ID_MISSION_MISSILES = 10;
const ID_MISSION_BLOCUS = 11;
const ID_MISSION_BLOCUS = 11;
const ID_MISSION_EXPEDITION = 15;
public static function getFieldName($id)
{
$fieldsAlias = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
if (!isset($fieldsAlias[$id])) {
return null;
}
return $fieldsAlias[$id];
}
}

View file

@ -1,70 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
/**
*
* Enter description here ...
* @author Greg
*
*/
class Legacies_Officers_Model_Observer
{
public static function planetUpdateListener($eventData)
{
if (isset($eventData['planet'])) {
$planet = $eventData['planet'];
$user = $planet->getUser();
$level = floor(sqrt($user->getData('xpminier') / 500));
if ($user->getData('lvl_minier') < $level) {
$difference = $level - $user->getData('lvl_minier');
if ($difference == 1) {
Wootook::getSession(Wootook_Empire_Model_User::SESSION_KEY)
->addInfo('You gained 1 miner level.');
} else {
Wootook::getSession(Wootook_Empire_Model_User::SESSION_KEY)
->addInfo('You gained %1$d miner level.', (int) $difference);
}
}
$level = floor(sqrt($user->getData('xpraid')));
if ($user->getData('lvl_raid') < $level) {
$difference = $level - $user->getData('lvl_raid');
if ($difference == 1) {
Wootook::getSession(Wootook_Empire_Model_User::SESSION_KEY)
->addInfo('You gained 1 raider level.');
} else {
Wootook::getSession(Wootook_Empire_Model_User::SESSION_KEY)
->addInfo('You gained %1$d raider level.', (int) $difference);
}
}
}
}
}

View file

@ -1,13 +0,0 @@
<?php
abstract class Wootook_Admin_Controller_Front_Action
extends Wootook_Core_Controller_Front_Action
{
protected function _initLayout()
{
$layout = new Wootook_Core_Layout(Wootook_Core_Layout::DOMAIN_BACKEND);
$layout->registerBlockNamespace('admin', 'Wootook_Admin_Block_', 'Wootook/Admin/Block');
return $layout;
}
}

View file

@ -1,10 +0,0 @@
<?php
class Wootook_Admin_IndexController
extends Wootook_Admin_Controller_Front_Action
{
public function indexAction()
{
$this->_forward('index', 'user');
}
}

View file

@ -1,40 +0,0 @@
<?php
class Wootook_Admin_UserController
extends Wootook_Admin_Controller_Front_Action
{
public function indexAction()
{
$this->_forward('grid');
}
public function gridAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function newAction()
{
}
public function editAction()
{
}
public function saveAction()
{
}
public function saveMassAction()
{
}
public function deleteAction()
{
}
public function deleteMassAction()
{
}
}

View file

@ -1,356 +0,0 @@
<?php
class Wootook_Core_Collection
extends Wootook_Core_Database_Resource
implements Iterator, Countable
{
protected $_tableName = null;
protected $_tableAlias = null;
protected $_entityClassName = 'Wootook_Object';
protected $_columns = array();
protected $_where = array();
protected $_join = array();
protected $_order = array();
protected $_union = array();
protected $_limit = null;
protected $_offset = null;
protected $_group = array();
protected $_items = array();
public function __construct($tableName = null, $entityClassName = null)
{
if ($tableName !== null) {
$this->setTableName($tableName);
}
if ($entityClassName != null) {
$this->setEntityClassName($entityClassName);
}
}
protected function _init()
{
return $this;
}
public function setTableName($tableName)
{
if (!is_array($tableName)) {
$this->_tableName = $tableName;
} else {
$this->_tableName = current($tableName);
$this->_tableAlias = key($tableName);
}
return $this;
}
public function getTableName()
{
return $this->_tableName;
}
public function setEntityClassName($entityClassName)
{
$this->_entityClassName = $entityClassName;
return $this;
}
public function getEntityClassName()
{
return $this->_entityClassName;
}
public function quote($data)
{
return $this->getReadConnection()->quote($data);
}
public function column($column = '*', $alias = null)
{
if (is_array($column)) {
foreach ($column as $alias => $field) {
if (is_int($alias)) {
$this->_columns[] = array($field);
} else {
$this->_columns[] = array($alias => $field);
}
}
} else if ($alias === null || is_int($alias)) {
$this->_columns[] = array($column);
} else {
$this->_columns[] = array($alias => $column);
}
return $this;
}
public function where($condition)
{
$this->_where[] = $condition;
return $this;
}
public function join($table, $condition, $fields = array('*'), $mode = 'INNER')
{
$database = $this->getReadConnection();
if (is_array($table)) {
$alias = key($table);
$table = current($table);
foreach ($fields as $fieldAlias => $fieldName) {
$this->column("{$alias}.{$field}", $fieldAlias);
}
$this->_join[] = "{$mode} JOIN {$database->getTable($table)} AS {$alias} ON {$condition}";
} else {
foreach ($fields as $field) {
$this->column("{$field}");
}
$this->_join[] = "{$mode} JOIN {$database->getTable($table)} ON {$condition}";
}
return $this;
}
public function order($field, $direction = 'ASC')
{
$this->_order[] = "{$field} {$direction}";
return $this;
}
public function union($collection)
{
$this->_union[] = $collection;
return $this;
}
public function limit($limit, $offset = null)
{
$this->_limit = intval($limit);
$this->_offset = $offset;
return $this;
}
public function group($groupField)
{
$this->_group[] = $groupField;
return $this;
}
protected function _prepareSql()
{
if (empty($this->_union)) {
$database = $this->getReadConnection();
$fields = array();
foreach ($this->_columns as $field) {
$fieldName = current($field);
$fieldAlias = key($field);
if (is_string($fieldAlias)) {
$fields[] = "{$fieldName} AS {$fieldAlias}";
} else {
$fields[] = $fieldName;
}
}
if (!empty($fields)) {
$fields = implode(", ", $fields);
} else {
$fields = '*';
}
if (!empty($this->_where)) {
$where = 'WHERE (' . implode(") AND (", $this->_where) . ')';
} else {
$where = '';
}
$joinedTables = implode("\n ", $this->_join);
$order = '';
if (!empty($this->_order)) {
$order = 'ORDER BY ' . implode(", ", $this->_order);
}
$alias = '';
if ($this->_tableAlias !== null) {
$alias = " AS {$this->_tableAlias}";
}
$limit = '';
if ($this->_limit) {
if ($this->_offset) {
$limit = "LIMIT {$this->_limit}, {$this->_offset}";
} else {
$limit = "LIMIT {$this->_limit}";
}
}
$group = '';
if (!empty($this->_group)) {
$group = 'GROUP BY ' . implode(', ', $this->_group);
}
return <<<SQL_EOF
SELECT {$fields}
FROM {$database->getTable($this->getTableName())}{$alias}
{$joinedTables}
{$where}
{$group}
{$order}
{$limit}
SQL_EOF;
} else {
$statements = array();
foreach ($this->_union as $statement) {
$statements[] = $statement->_prepareSql();
}
$statements = '(' . implode(') UNION (', $statements) . ')';
if (!empty($where)) {
$where = 'WHERE ' . implode(" AND ", $this->_where);
} else {
$where = '';
}
$where = implode(" AND ", $this->_where);
$limit = '';
if ($this->_limit) {
if ($this->_offset) {
$limit = "LIMIT {$this->_limit}, {$this->_offset}";
} else {
$limit = "LIMIT {$this->_limit}";
}
}
return <<<SQL_EOF
$statements
{$where}
{$limit}
SQL_EOF;
}
}
public function __toString()
{
return $this->_prepareSql();
}
protected function _load()
{
$sql = $this->_prepareSql();
$database = $this->getReadConnection();
$statement = $database->prepare($sql);
$args = func_get_args();
$statement->execute(array_shift($args));
$this->_items = array();
if (func_num_args() > 1) {
$reflection = new ReflectionClass(array_shift($args));
} else {
$reflection = new ReflectionClass($this->getEntityClassName());
}
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$params = array_merge(array($row), $args);
$this->_items[] = $reflection->newInstanceArgs($params);
}
return $this;
}
protected function _save()
{
foreach ($this->_items as $child) {
$child->save();
}
return $this;
}
protected function _delete()
{
foreach ($this->_items as $child) {
$child->delete();
}
return $this;
}
public function getSize()
{
$clone = clone $this;
$clone->_fields = array();
$clone->column('1');
$sql = $clone->_prepareSql();
$database = $this->getReadConnection();
$statement = $database->prepare($sql);
$args = func_get_args();
$statement->execute(array_shift($args));
$count = $statement->rowCount();
$statement->closeCursor();
return $count;
}
public function count()
{
return count($this->_items);
}
public function current()
{
return current($this->_items);
}
public function next()
{
next($this->_items);
return $this;
}
public function rewind()
{
reset($this->_items);
return $this;
}
public function key()
{
return key($this->_items);
}
public function valid()
{
return current($this->_items) !== false;
}
public function getFirstItem()
{
if (!$this->_)
if (count($this->_items) > 0) {
return $this->_items[0];
}
return null;
}
public function getLastItem()
{
$size = count($this->_items);
if ($size > 0) {
return $this->_items[$size - 1];
}
return null;
}
}

View file

@ -1,18 +0,0 @@
<?php
abstract class Wootook_Core_Controller_Response_Abstract
extends Wootook_Object
{
public function setParam($key, $value)
{
return $this->setData($key, $value);
}
public function getParam($key, $default = null)
{
if ($this->hasData($key)) {
return $this->getData($key);
}
return $default;
}
}

View file

@ -1,6 +0,0 @@
<?php
class Wootook_Core_Event
extends Wootook_Object
{
}

View file

@ -1,3 +0,0 @@
<?php
interface Wootook_Core_Exception extends Wootook_Exception {}

View file

@ -1,6 +0,0 @@
<?php
interface Wootook_Core_Singleton
{
public static function getSingleton();
}

View file

@ -1,17 +0,0 @@
<?php
class Wootook_Core_Time
{
public static function init($timezone = null)
{
if ($timezone === null) {
$timezone = Wootook::getConfig('system/date/timezone');
}
if ($timezone === null) {
$timezone = 'GMT';
}
date_default_timezone_set($timezone);
}
}

View file

@ -1,63 +0,0 @@
<?php
class Wootook_Empire_Block_Planet_Buildings_Queue_Item
extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract
{
protected $_itemIdField = 'building_id';
public function getLevel()
{
return $this->getPlanet()->getElement($this->getItemId());
}
public function getResourcesNeeded($level)
{
return $this->getPlanet()->getResourcesNeeded($this->getItemId(), $this->getQueuedLevel() + 1);
}
public function getItemQueuedLevel()
{
return $this->getItem()->getData('level');
}
public function getQueuedLevel()
{
return $this->getPlanet()->getBuildingLevelQueued($this->getItemId());
}
public function getBuildingTime($level)
{
return $this->getPlanet()->getBuildingTime($this->getItemId(), $level);
}
public function getResourcesConfigForLevel($level)
{
$resources = $this->getResourcesNeeded($level);
$resourceConfig = array();
foreach ($resources as $resourceId => $resourceValue) {
$resourceConfig[$resourceId] = new Wootook_Object(array(
'resource_id' => $resourceId,
'value' => $resourceValue
));
$amount = $this->getPlanet()->getResourceAmount($resourceId);
if (Math::comp($amount, $resourceValue) < 0) {
$resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue));
} else {
$resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue));
}
}
return $resourceConfig;
}
public function getResourcesConfigForNextLevel()
{
return $this->getResourcesConfigForLevel($this->getNextLevel());
}
public function getBuildingTimeForNextLevel()
{
return $this->getBuildingTime($this->getNextLevel());
}
}

View file

@ -1,3 +0,0 @@
<?php
interface Legacies_Empire_Exception extends Legacies_Exception {}

View file

@ -1,27 +0,0 @@
<?php
abstract class Wootook_Empire_Model_Planet_ShipAbstract
implements Wootook_Empire_Model_Planet_ShipInterface
{
public function getBaseSpeed(Wootook_Empire_Model_User $user)
{
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
}
public function getSpeedMultiplier(Wootook_Empire_Model_User $user)
{
return pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE));
}
public function getActualSpeed(Wootook_Empire_Model_User $user)
{
return $this->getBaseSpeed($user) * $this->getSpeedMultiplier($user);
}
public function getActualConsumption(Wootook_Empire_Model_User $user, $speed)
{
return $this->getBaseConsumption($user) * ($speed / 100) * $this->getSpeedMultiplier($user);
}
}

View file

@ -1,11 +0,0 @@
<?php
interface Wootook_Empire_Model_Planet_ShipInterface
{
public function getBaseSpeed(Wootook_Empire_Model_User $user);
public function getSpeedMultiplier(Wootook_Empire_Model_User $user);
public function getActualSpeed(Wootook_Empire_Model_User $user);
public function getBaseConsumption(Wootook_Empire_Model_User $user);
public function getActualConsumption(Wootook_Empire_Model_User $user, $speed);
}

View file

@ -1,3 +0,0 @@
<?php
interface Wootook_Exception {}

View file

@ -1,27 +0,0 @@
var _gaq = _gaq || [];
(function()){
var trackErrorThroughEvent = function(exception, f) {
_gaq.push(['_trackEvent',
'JS ERROR: '+ (f || 'native') + ' (nav:'+ navigator.userAgent +') Exception: '+ (exception.name || 'Error'),
exception.message || exception,
' url: '+document.location.href+' referer: '+ document.referrer
]);
};
var outLink = function(link){
var _gA = link.href.split('/');
var _gS = link.href.split('#');
var _gT = '/out-link/' + _gA[2] + '/?d=' + _gS[0];
_gaq.push(['_trackPageview',_gT]);
_gaq.push(function() {
try {
setTimeout('window.open(_gat._getTrackerByName()._getLinkerUrl(\'' + lien.href + '\',false),\'_blank\')', 100);
} catch(err) {
window.open(lien.href, '_blank'); /* préserve le fonctionnement du lien href en cas de pb */
trackErrorThroughEvent(err,'lienSortant : '+lien.href );
}
});
}
})();

View file

@ -1,41 +0,0 @@
<?php
/**
* Test class for Wootook_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Legacies_Core_LayoutTest extends PHPUnit_Framework_TestCase
{
/**
* @var Wootook_Object
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->markTestIncomplete();
/*
$layoutDir = vfsStreamWrapper::getContent('');
vfsStream::addStructure(array());
$this->_object = new Legacies_Core_Layout();
*/
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
public function testEmpty()
{
}
}

View file

@ -1,237 +0,0 @@
<?php
/**
* Test class for Wootook_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Legacies_Empire_Model_BuilderTest extends PHPUnit_Framework_TestCase
{
/**
* @var Legacies_Empire_Model_Planet
*/
protected $_planet = null;
/**
* @var Legacies_Empire_Model_User
*/
protected $_user = null;
protected $_class = 'Legacies_Empire_Model_BuilderAbstract';
protected $_queueItemsData = null;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->_planet = new Legacies_Empire_Model_Planet(array(
'id' => 1,
'id_owner' => 1
));
$this->_user = new Legacies_Empire_Model_User(array(
'id' => 1
));
$this->_planet->setUser($this->_user);
$this->_user->setCurrentPlanet($this->_planet);
$this->_user->setHomePlanet($this->_planet);
$this->_queueItemsData = array(
'IDX0001' => array(
'item_id' => 1,
'level' => 1,
'created_at' => 0,
'updated_at' => 0
),
'IDX0002' => array(
'item_id' => 1,
'level' => 2,
'created_at' => 100,
'updated_at' => 100
),
'IDX0003' => array(
'item_id' => 1,
'level' => 3,
'created_at' => 150,
'updated_at' => 150
)
);
}
protected function _getMockedInstance($planet, $user, $methods = array())
{
$reflector = new ReflectionClass($this->_class);
foreach ($reflector->getMethods() as $method) {
if ($method->isAbstract()) {
$methods[] = $method->getName();
}
}
if (empty($methods)) {
$methods = null;
}
return $this->getMock($this->_class, $methods, array($planet, $user));
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
public function testInit()
{
$stub = $this->getMockBuilder('Legacies_Empire_Model_BuilderAbstract')
->disableOriginalConstructor()
->setMethods(array('init', '_initItem', 'updateQueue', 'appendQueue', 'getResourcesNeeded', 'getBuildingTime'))
->getMock();
$stub->expects($this->once())
->method('init')
->will($this->returnValue($stub));
$stub->expects($this->never())
->method('_serializeQueue')
->will($this->returnValue($stub));
$stub->expects($this->never())
->method('_unserializeQueue')
->will($this->returnValue($stub));
$stub->__construct($this->_planet, $this->_user);
}
public function testSerializingQueue()
{
$items = array(
'IDX0001' => array(
'item_id' => 1,
'level' => 1,
'created_at' => 0,
'updated_at' => 0
),
'IDX0002' => array(
'item_id' => 1,
'level' => 2,
'created_at' => 100,
'updated_at' => 100
),
'IDX0003' => array(
'item_id' => 1,
'level' => 3,
'created_at' => 150,
'updated_at' => 150
)
);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0002']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0003'])
));
$stub->expects($this->exactly(3))
->method('_generateIndex')
->will($this->onConsecutiveCalls(
'IDX0001',
'IDX0002',
'IDX0003'
));
$stub->enqueue($this->_queueItemsData['IDX0001']);
$stub->enqueue($this->_queueItemsData['IDX0002']);
$stub->enqueue($this->_queueItemsData['IDX0003']);
$this->assertEquals(serialize($this->_queueItemsData), $stub->serialize());
}
public function testUnSerializingQueue()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0002']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0003'])
));
$stub->expects($this->never())
->method('_generateIndex');
$stub->unserialize($serializedData);
$this->assertAttributeNotEmpty('_queue', $stub);
$this->assertEquals(serialize($this->_queueItemsData), $stub->serialize());
}
public function testUnSerializingQueueWithInvalidData()
{
$serializedData = '';
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->never())
->method('_initItem');
$stub->expects($this->never())
->method('_generateIndex');
$stub->unserialize($serializedData);
$this->assertAttributeEmpty('_queue', $stub);
$this->assertEquals('a:0:{}', $stub->serialize());
}
public function testInitItemReturningNull()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->returnValue(null));
$stub->unserialize($serializedData);
$this->assertAttributeEmpty('_queue', $stub);
$this->assertEquals('a:0:{}', $stub->serialize());
}
public function testCheckAvailability()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->any())
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001'])
));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_METAL_MINE));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_CRISTAL_MINE));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_FUSION_REACTOR));
}
}

View file

@ -1,205 +0,0 @@
<?php
/**
* Test class for Wootook_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Wootook_ObjectTest extends PHPUnit_Framework_TestCase
{
/**
* @var Wootook_Object
*/
protected $_object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->_object = new Wootook_Object();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @todo Implement testSetData().
*/
public function testSetData()
{
$this->assertAttributeEmpty('_data', $this->_object);
$this->_object->setData('test', true);
$expected = array('test' => true);
$this->assertAttributeEquals($expected, '_data', $this->_object);
$this->_object->setData('test', 'testing');
$expected = array('test' => 'testing');
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @requires testSetData
*/
public function testGetData()
{
$this->_object->setData('test', 'testing');
$this->assertEquals('testing', $this->_object->getData('test'));
$this->_object->setData('test', true);
$this->assertTrue($this->_object->getData('test'));
$this->assertNull($this->_object->getData('testing'));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testGetAllDatas()
{
$this->_object->setData('test', 'testing');
$expected = array('test' => 'testing');
$this->assertEquals($expected, $this->_object->getAllDatas());
$this->_object->setData('test', true);
$expected = array('test' => true);
$this->assertEquals($expected, $this->_object->getAllDatas());
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testHasData()
{
$this->_object->setData('test', 'testing');
$this->assertTrue($this->_object->hasData('test'));
$this->assertFalse($this->_object->hasData('testing'));
}
/**
* @requires testSetData
*/
public function testAddData()
{
$this->_object->setData('test', 'testing');
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->addData(array(
'testing' => true,
'legacies' => false
));
$this->assertAttributeEquals($expected, '_data', $this->_object);
$expected = array(
'test' => 'legacies',
'testing' => false,
'legacies' => 'Wootook_Object'
);
$this->_object->addData($expected);
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @requires testSetData
*/
public function testUnsetData()
{
$this->_object->setData('test', 'testing');
$this->_object->setData('testing', true);
$this->_object->setData('removed', 'me!');
$this->_object->setData('legacies', false);
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->unsetData('removed');
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @todo Implement testClearData().
*/
public function testClearData()
{
$this->_object->setData('test', 'testing');
$this->_object->setData('testing', true);
$this->_object->setData('removed', 'me!');
$this->_object->setData('legacies', false);
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->clearData();
$this->assertAttributeEmpty('_data', $this->_object);
}
/**
* @requires testSetData
* @requires testHasData
*/
public function testOffsetExists()
{
$this->_object->setData('test', 'testing');
$this->assertTrue(isset($this->_object['test']));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testOffsetGet()
{
$this->_object->setData('test', 'testing');
$this->assertEquals('testing', $this->_object['test']);
}
/**
* @requires testGetData
* @requires testSetData
*/
public function testOffsetSet()
{
$this->_object['test'] = 'testing';
$this->assertEquals('testing', $this->_object->getData('test'));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testOffsetUnset()
{
$this->_object->setData('test', 'testing');
unset($this->_object['test']);
$this->assertAttributeEmpty('_data', $this->_object);
$this->assertNull($this->_object->getData('test'));
}
}

View file

@ -1,119 +0,0 @@
<?php
class Test_WootookTest
extends PHPUnit_Framework_TestCase
{
protected function tearDown()
{
Wootook::clearAllListeners();
}
public function nonStaticListener($observer)
{
$observer->setData('success', true);
}
public static function staticListener($observer)
{
$observer->setData('success', true);
}
public function testRegisteringNonStaticEvent()
{
Wootook::registerListener('testing', array($this, 'nonStaticListener'));
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
public function testRegisteringStaticEvent()
{
Wootook::registerListener('testing', array(get_class($this), 'staticListener'));
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
public function testDispatchNonExistingEvent()
{
$observer = Wootook::dispatchEvent('testing', array('success' => true));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
/**
* @depends testRegisteringNonStaticEvent
*/
public function testUnregisteringNonStaticEvent()
{
Wootook::registerListener('testing', array($this, 'nonStaticListener'));
Wootook::clearEventListeners('testing');
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertFalse($observer->getData('success'));
}
/**
* @depends testRegisteringStaticEvent
*/
public function testUnregisteringStaticEvent()
{
Wootook::registerListener('testing', array(get_class($this), 'staticListener'));
Wootook::clearEventListeners('testing');
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertFalse($observer->getData('success'));
}
public function testGetSession()
{
$this->markTestSkipped('Sessions could not be tested in CLI.');
$this->assertInstanceOf('Legacies_Core_Model_Session', Wootook::getSession('test'));
}
public function testGetTranslator()
{
$this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator('test'));
$this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator());
}
public function testTranslate()
{
$this->assertEquals('My testing message!', Wootook::translate('test', 'My %s message!', array('testing')));
}
public function testTranslateGettextStyle()
{
$this->assertEquals('My testing message!', Wootook::__('My %s message!', 'testing'));
}
public function testSetDefaultLocale()
{
Wootook::setDefaultLocale('test');
$this->assertAttributeEquals('test', '_defaultLocale', 'Beyond');
}
/**
*
* @requires testSetDefaultLocale
*/
public function testGetDefaultLocale()
{
Wootook::setDefaultLocale('test');
$this->assertEquals('test', Wootook::getDefaultLocale());
}
}

View file

@ -1,66 +0,0 @@
<?php
set_include_path(implode(PATH_SEPARATOR, array(
dirname(__DIR__),
get_include_path()
)));
function frameworkAutoload($class) {
include_once str_replace('_', '/', $class) . '.php';
}
spl_autoload_register('frameworkAutoload');
include 'vfsStream/vfsStream.php';
vfsStream::create(array(
'includes' => array(
'application' => array(
'code' => array(
'community' => array(),
'core' => array(),
'libraries' => array(),
'local' => array(),
),
'design' => array(
'layouts' => array(),
'scripts' => array()
)
),
'data' => array(
'combat.php' => '<?php echo ' . var_export(array(), true),
'events.php' => '<?php echo ' . var_export(array(), true),
'fields-alias.php' => '<?php echo ' . var_export(array(), true),
'prices.php' => '<?php echo ' . var_export(array(), true),
'production.php' => '<?php echo ' . var_export(array(), true),
'requirements.php' => '<?php echo ' . var_export(array(), true),
'resources.php' => '<?php echo ' . var_export(array(), true),
'types.php' => '<?php echo ' . var_export(array(), true),
)
),
'config.php' => '<?php echo ' . var_export(array(
'global' => array(
'date' => array(
'timezone' => 'Europe/Paris'
),
'database' => array(
'engine' => 'mysql',
'options' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'db_xnova'
),
'table_prefix' => 'game_',
),
'layout' => array(
'page' => 'page.php',
'empire' => 'empire.php'
)
)
), true) . ';'
), 'root', 644);
define('ROOT_PATH', vfsStream::url(''));
define('APPLICATION_PATH', vfsStream::url('includes/application'));

View file

@ -1,524 +0,0 @@
<?php return array(
'empire' => array(
'update' => '1column',
'reference' => array(
'header' => array(
'children' => array(
'navigation' => array(
'type' => 'core/html.navigation',
'template' => 'page/html/navigation.phtml',
'actions' => array(
array(
'method' => 'setNodeTitle',
'params' => array(
'path' => 'planet',
'title' => 'Planet'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'planet/overview',
'label' => 'Overview',
'title' => 'Overview',
'uri' => 'overview.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'planet/buildings',
'label' => 'Buildings',
'title' => 'Buildings',
'uri' => 'buildings.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'planet/research-lab',
'label' => 'Research Lab',
'title' => 'Research Lab',
'uri' => 'buildings.php',
'params' => array(
'mode' => 'research'
)
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'planet/shipyard',
'label' => 'Shipyard',
'title' => 'Shipyard',
'uri' => 'buildings.php',
'params' => array(
'mode' => 'fleet'
)
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'planet/defenses',
'label' => 'Defenses',
'title' => 'Defenses',
'uri' => 'buildings.php',
'params' => array(
'mode' => 'defense'
)
)
),
array(
'method' => 'setNodeTitle',
'params' => array(
'path' => 'universe',
'title' => 'Universe'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'universe/galaxy',
'label' => 'Check out the Galaxy',
'title' => 'Check out the Galaxy',
'uri' => 'galaxy.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'universe/fleet',
'label' => 'Send a Fleet',
'title' => 'Send a Fleet',
'uri' => 'fleet.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'universe/retailer',
'label' => 'Retailer',
'title' => 'Retailer',
'uri' => 'marchand.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'universe/records',
'label' => 'All Records',
'title' => 'All Records',
'uri' => 'records.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'universe/statistics',
'label' => 'My Stats',
'title' => 'My Stats',
'uri' => 'stat.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'universe/search-player',
'label' => 'Search a Player',
'title' => 'Search a Player',
'uri' => 'search.php'
)
),
array(
'method' => 'setNodeTitle',
'params' => array(
'path' => 'account',
'title' => 'My Account'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'account/empire',
'label' => 'Empire',
'title' => 'Empire',
'uri' => 'imperium.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'account/officers',
'label' => 'Officers',
'title' => 'Officers',
'uri' => 'officier.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'account/alliance',
'label' => 'My Alliance',
'title' => 'My Alliance',
'uri' => 'alliance.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'account/messages',
'label' => 'My Messages',
'title' => 'My Messages',
'uri' => 'messages.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'account/resources',
'label' => 'My Resources Production',
'title' => 'My Resources Production',
'uri' => 'resources.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'account/tech-tree',
'label' => 'Technology Tree',
'title' => 'Technology Tree',
'uri' => 'techtree.php'
)
),
array(
'method' => 'setNodeTitle',
'params' => array(
'path' => 'tools',
'title' => 'Tools'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'tools/notes',
'label' => 'Note Pad',
'title' => 'Note Pad',
'uri' => 'notes.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'tools/options',
'label' => 'Account Options',
'title' => 'Account Options',
'uri' => 'options.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'tools/logout',
'label' => 'Log Out',
'title' => 'Log Out',
'uri' => 'logout.php'
)
),
array(
'method' => 'setNodeTitle',
'params' => array(
'path' => 'community',
'title' => 'Community'
)
),
array(
'method' => 'addExternalLink',
'params' => array(
'name' => 'community/board',
'label' => 'Forum board',
'title' => 'Forum board',
'url' => 'http://www.wootook.org/'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'community/chat',
'label' => 'Chat',
'title' => 'Chat',
'uri' => 'chat.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'community/announcement',
'label' => 'Announcements',
'title' => 'Announcements',
'uri' => 'annonce.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'community/multi',
'label' => 'Declare Multi-account',
'title' => 'Declare Multi-account',
'uri' => 'delclare_multi.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'community/rules',
'label' => 'Rules',
'title' => 'Rules',
'uri' => 'rules.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'community/contact',
'label' => 'Contact Admin',
'title' => 'Contact Admin',
'uri' => 'contact.php'
)
),
array(
'method' => 'addLink',
'params' => array(
'name' => 'community/banned',
'label' => 'Banned Players',
'title' => 'Banned Players',
'uri' => 'banned.php'
)
)
)
),
'topnav' => array(
'type' => 'empire/topnav',
'template' => 'empire/topnav.phtml',
),
)
)
)
),
'overview' => array(
'update' => 'empire',
'reference' => array(
'content' => array(
'children' => array(
'overview.forms' => array(
'type' => 'core/concat'
),
'overview' => array(
'type' => 'empire/overview',
'template' => 'empire/overview.phtml'
),
)
),
'left' => array(
)
)
),
'overview.rename-planet' => array(
'update' => 'overview',
'reference' => array(
'overview.forms' => array(
'children' => array(
'rename-planet' => array(
'type' => 'empire/overview.rename-planet',
'template' => 'empire/overview/form/rename-planet.phtml'
),
)
)
)
),
'overview.destroy-planet' => array(
'update' => 'overview',
'reference' => array(
'overview.forms' => array(
'children' => array(
'destroy-planet' => array(
'type' => 'empire/overview.destroy-planet',
'template' => 'empire/overview/form/destroy-planet.phtml'
),
)
)
)
),
'planet.buildings' => array(
'update' => 'empire',
'reference' => array(
'content' => array(
'children' => array(
'queue' => array(
'type' => 'empire/planet.buildings.queue',
'template' => 'empire/planet/buildings/queue.phtml',
'actions' => array(
array(
'method' => 'setItemTemplate',
'params' => array(
'template' => 'empire/planet/buildings/queue/item.phtml'
)
),
array(
'method' => 'setItemBlockType',
'params' => array(
'blockType' => 'empire/planet.buildings.queue.item'
)
)
)
),
'item-list' => array(
'type' => 'empire/planet.buildings',
'template' => 'empire/planet/buildings.phtml',
'children' => array(
'item-list.items' => array(
'type' => 'core/concat'
),
),
'actions' => array(
array(
'method' => 'setItemTemplate',
'params' => array(
'template' => 'empire/planet/buildings/item.phtml'
)
),
array(
'method' => 'setItemBlockType',
'params' => array(
'blockType' => 'empire/planet.buildings.item'
)
)
)
),
)
)
)
),
'planet.shipyard' => array(
'update' => 'empire',
'reference' => array(
'content' => array(
'children' => array(
'item-list' => array(
'type' => 'legacies_empire/planet.shipyard',
'template' => 'empire/planet/shipyard.phtml',
'children' => array(
'item-list.items' => array(
'type' => 'core/concat'
),
),
'actions' => array(
array(
'method' => 'setItemTemplate',
'params' => array(
'template' => 'empire/planet/shipyard/item.phtml'
)
),
array(
'method' => 'setItemBlockType',
'params' => array(
'blockType' => 'legacies_empire/planet.shipyard.item'
)
),
)
),
'queue' => array(
'type' => 'legacies_empire/planet.shipyard.queue',
'template' => 'empire/planet/shipyard/queue.phtml',
'actions' => array(
array(
'method' => 'setItemTemplate',
'params' => array(
'template' => 'empire/planet/shipyard/queue/item.phtml'
)
),
array(
'method' => 'setItemBlockType',
'params' => array(
'blockType' => 'legacies_empire/planet.shipyard.queue.item'
)
)
)
),
)
)
)
),
'planet.defense' => array(
'update' => 'planet.shipyard',
'reference' => array(
'item-list' => array(
'actions' => array(
array(
'method' => 'setType',
'params' => array(
'type' => Legacies_Empire::TYPE_DEFENSE
)
)
)
)
)
),
'planet.research-lab' => array(
'update' => 'empire',
'reference' => array(
'content' => array(
'children' => array(
'item-list' => array(
'type' => 'legacies_empire/planet.research-lab',
'template' => 'empire/planet/research-lab.phtml',
'children' => array(
'item-list.items' => array(
'type' => 'core/concat'
),
),
'actions' => array(
array(
'method' => 'setItemTemplate',
'params' => array(
'template' => 'empire/planet/research-lab/item.phtml'
)
),
array(
'method' => 'setItemBlockType',
'params' => array(
'blockType' => 'legacies_empire/planet.research-lab.item'
)
),
)
),
'queue' => array(
'type' => 'legacies_empire/planet.research-lab.queue',
'template' => 'empire/planet/research-lab/queue.phtml',
'actions' => array(
array(
'method' => 'setItemTemplate',
'params' => array(
'template' => 'empire/planet/research-lab/queue/item.phtml'
)
),
array(
'method' => 'setItemBlockType',
'params' => array(
'blockType' => 'legacies_empire/planet.research-lab.queue.item'
)
)
)
)
)
)
)
)
);

View file

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<layout version="1.0">
<handle name="login">
<update name="1column" />
<reference name="content">
<block name="login" type="core/template" template="user/login.phtml" />
</reference>
<reference name="head">
<action method="addCss">
<params>
<param name="template">css/deprecated/styles.css</param>
</params>
</action>
<action method="addCss">
<params>
<param name="template">css/deprecated/about.css</param>
</params>
</action>
</reference>
</handle>
<handle name="registration">
<update name="1column" />
<reference name="content">
<block name="registration" type="core/template" template="user/registration.phtml" />
</reference>
<reference name="head">
<action method="addCss">
<params>
<param name="template">css/deprecated/styles.css</param>
</params>
</action>
<action method="addCss">
<params>
<param name="template">css/deprecated/about.css</param>
</params>
</action>
</reference>
</handle>
</layout>

View file

@ -1 +0,0 @@
<?php echo $this->planetList->render() ?>

View file

@ -1,8 +0,0 @@
<?php /** @var Legacies_Core_Block_Template $this */?>
<div class="item queue">
<a href="<?php echo $this->getItemInfoUrl()?>" class="image"><img src="<?php echo $this->getItemImageUrl()?>" alt="" width="30" height="30" /></a>
<a href="<?php echo $this->getItemInfoUrl()?>"><?php echo $this->escape($this->getName())?></a> (<?php echo $this->renderNumber($this->getItemQueuedLevel())?>)
<div class="cancel">
<p><a class="build" href="<?php echo $this->getUrl('buildings.php', array('cancel' => $this->getItem()->getIndex()))?>"><?php echo $this->__('Cancel')?></a></p>
</div>
</div>

View file

@ -1,8 +0,0 @@
<?php /** @var Legacies_Core_Block_Template $this */?>
<div class="item queue">
<a href="<?php echo $this->getItemInfoUrl()?>" class="image"><img src="<?php echo $this->getItemImageUrl()?>" alt="" width="30" height="30" /></a>
<a href="<?php echo $this->getItemInfoUrl()?>"><?php echo $this->escape($this->getName())?></a> (<?php echo $this->renderNumber($this->getItemQueuedLevel())?>)
<div class="cancel">
<p><a class="build" href="<?php echo $this->getUrl('buildings.php', array('cancel' => $this->getItem()->getIndex()))?>"><?php echo $this->__('Cancel')?></a></p>
</div>
</div>

View file

@ -1,54 +0,0 @@
<div id="main">
<div id="login">
<div id="login_input">
<form name="formular" action="" method="post" onsubmit="changeAction('login');">
<table width="400" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr style="vertical-align: top;">
<td style="padding-right: 4px;">
<?php echo $this->__('Username')?> <input name="username" value="" type="text">
<?php echo $this->__('Password')?> <input name="password" value="" type="password">
</td>
</tr><tr>
<td style="padding-right: 4px;">
<?php echo $this->__('Remember me')?> <input name="rememberme" type="checkbox">
<input name="submit" value="<?php echo $this->__('Log in!')?>" type="submit">
</td>
</tr><tr>
<td style="padding-right: 4px;">
<a href="lostpassword.php"><?php echo $this->__('I have lost my password.')?></a>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<div id="mainmenu" style="margin-top: 20px;">
<a href="reg.php"><?php echo $this->__('Register')?></a>
<a href="<?php echo $this->getData('board_url')?>"><?php echo $this->__('Boards')?></a>
<a href="contact.php"><?php echo $this->__('Contact')?></a>
</div>
<div id="rightmenu" class="rightmenu">
<div id="title"><?php echo $this->__('Welcome on %s!', $this->escape($this->getData('server_name')))?></div>
<div id="content">
<center>
<div id="text1">
<div style="text-align: left;"><?php echo $this->__('<strong>%1$s</strong> make you an emperor. Conquer outer space and master other players on <strong>%1$s</strong>.', $this->getData('server_name'))?></div>
</div>
<div id="register" class="bigbutton" onclick="document.location.href='reg.php';"><font color="#cc0000"><?php echo $this->__('Register now!')?></font></div>
<div id="text2">
<div id="text3">
<center>
<b>
<font color="#00cc00"><?php echo $this->__('Player count: ')?></font><font color="#c6c7c6"><?php echo $this->getData('user_count')?></font> -
<font color="#00cc00"><?php echo $this->__('Latest player: ')?></font><font color="#c6c7c6"><?php echo $this->getData('latest_player')?></font> -
<font color="#00cc00"><?php echo $this->__('Online players: ')?></font> <font color="#c6c7c6"><?php echo $this->getData('online_players')?></font>
</b>
</center>
</div>
</div>
</center>
</div>
</div>
</div>

View file

@ -1,9 +0,0 @@
<?php return array(
'block' => array(
'core' => array('Wootook_Core_Block_' => 'Wootook/Core/Block'),
'empire' => array('Wootook_Empire_Block_' => 'Wootook/Empire/Block'),
'legacies_core' => array('Legacies_Core_Block_' => 'Legacies/Core/Block'),
'legacies_empire' => array('Legacies_Empire_Block_' => 'Legacies/Empire/Block'),
'legacies_officers' => array('Legacies_Officers_Block_' => 'Legacies/Officers/Block')
)
);

View file

@ -1,265 +0,0 @@
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2009-Present, XNova Support Team <http://www.xnova-ng.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing XNova.
*
*/
/**
* Main application script execution class
*
* @param string responder
* @param int messageOffset
*/
function Legacies_Client(responder, messageOffset) {
if (!document.querySelectorAll) {
alert("Your browser is not compatible with CSS selectors API.\n\nCould not continue.");
return;
}
this.responder = responder;
this.messages = [];
this.messageId = messageOffset || 1;
this.callbacks = {};
this.recurrentMessages = [];
this.send = (function() {
if (this.messages.length == 0) {
return this;
}
var request = new XMLHttpRequest();
request.open('POST', this.responder, false);
request.send(JSON.stringify(this.messages));
this.messages = [];
for (var i in this.recurrentMessages) {
this.enqueue(this.recurrentMessages[i].action, this.recurrentMessages[i].params, this.recurrentMessages[i].callback);
}
if(request.status == 404) {
alert('Request failed, responder not found.');
return this;
}
try {
var response = JSON.parse(request.responseText);
} catch (e) {
alert('Invalid response.');
return this;
}
if(request.status == 200) {
for (var i in response) {
this._callback(response[i]);
}
}
return this;
}).bind(this);
this.main = (function(interval) {
setInterval(this.send, interval || 30000);
}).bind(this);
this.enqueue = (function(action, params){
this.messages.push({'uid':this.messageId++,'action':action,'params':params});
return this;
}).bind(this);
this.enqueueRecurrent = (function(action, params, callback) {
this.recurrentMessages.push({'callback':callback,'action':action,'params':params});
this.enqueue(action, params, callback);
}).bind(this);
this._callback = (function(message){
if (message.error === undefined || message.payload === undefined) {
return this;
}
if (message.error === true) {
if (typeof(message.payload.messages) == 'string') {
alert(message.payload.messages);
} else {
var info = '';
for (var i in message.payload.messages) {
info = info + "\n[" + i + "]:\n" + message.payload.messages[i].join("\n") + "\n";
}
alert("Errors were returned:\n" + info);
}
return this;
}
if (message.callback && this.CallbackType[message.callback]) {
(this.CallbackType[message.callback]).bind(this)(message.payload);
}
return this;
}).bind(this);
this.login = (function(username, password, rememberme) {
var params = {
'username': username,
'password': password,
'rememberme': rememberme || false
};
this.enqueue('user.account.login', params).send();
return this;
}).bind(this);
this.logout = (function() {
this.enqueue('user.account.logout', {}).send();
return this;
}).bind(this);
this.form = (function(event) {
event.preventDefault();
var form = event.target;
var params = {};
for (var i = 0; i < form.length; i++) {
if (!form[i].name || !form[i].type) {
continue;
}
if (form[i].type == 'checkbox') {
if (form[i].checked) {
params[form[i].name] = true;
} else {
params[form[i].name] = false;
}
} else if (form[i].type == 'radio') {
params[form[i].name] = form[i].value;
} else if (form[i].value !== undefined) {
params[form[i].name] = form[i].value;
}
}
var action = form.action.slice(form.action.indexOf('#') + 1);
this.enqueue(action, params, this.CallbackType.updater).send();
}).bind(this);
this.CallbackType = {
redirector: function(payload) {
if (payload.redirect) {
document.location.href = payload.redirect;
}
},
updater: function(payload) {
if (payload.html && payload.selector) {
var parent = $$(payload.selector);
var handler = document.createElement("div");
handler.innerHTML = payload.html;
var fragment = document.createDocumentFragment();
for (var i = 0; i < handler.childNodes.length; i++) {
fragment.appendChild(handler.childNodes[i]);
}
for (var i = 0; i < parent.length; i++) {
parent[i].appendChild(fragment.cloneNode(true));
}
}
},
script: function(payload) {
if (payload.script) {
eval(payload.script);
}
},
error: function(payload) {
if (payload.messages) {
alert(payload.messages.join(', '));
}
},
show: function(payload) {
if (payload.selector) {
var elementList = $$(payload.selector);
for (var i = 0; i < elementList.length; i++) {
elementList[i].style.display = 'block';
}
}
},
hide: function(payload) {
if (payload.selector) {
var elementList = $$(payload.selector);
for (var i = 0; i < elementList.length; i++) {
elementList[i].style.display = 'none';
}
}
},
callback: function(payload) {
if (payload.callback) {
payload.callback.apply(this, payload.params);
}
},
enqueueRecurrent: function(payload) {
if (payload.action && payload.params && payload.callback) {
this.enqueueRecurrent(payload.action, payload.params, payload.callback);
}
}
};
}
function Legacies_Element(object) {
object.listen = (function(event, callback) {
this.addEventListener(event, callback, false);
return this;
}).bind(object);
return object;
}
function Legacies_List(object) {
object.listen = (function(event, callback) {
for (var i in this) {
Legacies_Element(Legacies_Element[i]);
this[i].listen(event, callback);
}
return this;
}).bind(object);
return object;
}
function $A(object) {
return Array.prototype.slice.call(object);
}
function $(element) {
if (typeof(element) == 'string') {
element = document.getElementById(element);
}
Legacies_Element(element);
return element;
}
function $$(selector, context) {
context = context || document;
var nodeList = context.querySelectorAll(selector);
Legacies_List(nodeList);
return nodeList;
}
function $E(element, methods) {
for (var i in methods) {
if (methods[i] === undefined) {
continue;
}
element[i] = function(){
var args = $A(arguments);
args.unshift(element);
methods[i].apply(element, args);
}
element[i].bind(element);
}
return element;
}

File diff suppressed because it is too large Load diff

View file

@ -1,163 +0,0 @@
<?php
include './bootstrap.php';
if (!extension_loaded('xdebug')) {
header('Content-Type: text/plain');
}
$user = new Legacies_Empire_Model_User(array(
'rpg_stockeur' => 0,
'b_laboratory' => 0,
'b_laboratory_id' => serialize(array()),
"spy_tech" => 12,
"computer_tech" => 8,
"military_tech" => 10,
"defence_tech" => 10,
"shield_tech" => 10,
"energy_tech" => 8,
"hyperspace_tech" => 8,
"combustion_tech" => 6,
"impulse_motor_tech" => 6,
"hyperspace_motor_tech" => 6,
"laser_tech" => 6,
"ionic_tech" => 6,
"buster_tech" => 6,
"intergalactic_tech" => 0,
"expedition_tech" => 0,
"graviton_tech" => 0,
));
$data = array(
'last_update' => 0,
'planet_type' => 1,
'b_building_id' => '',
'b_hangar_id' => serialize(array(/*array(
'ship_id' => Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT,
'qty' => 10,
'created_at' => 0,
'updated_at' => 0
), array(
'ship_id' => Legacies_Empire::ID_SHIP_LARGE_TRANSPORT,
'qty' => 20,
'created_at' => 600,
'updated_at' => 600
), array(
'ship_id' => Legacies_Empire::ID_SHIP_LARGE_TRANSPORT,
'qty' => 30,
'created_at' => 650,
'updated_at' => 650
), array(
'ship_id' => Legacies_Empire::ID_SHIP_LARGE_TRANSPORT,
'qty' => 40,
'created_at' => 700,
'updated_at' => 700
)*/)),
'metal' => 500000,
'metal_perhour' => 20,
'cristal' => 500000,
'cristal_perhour' => 10,
'deuterium' => 300000,
'deuterium_perhour' => 0,
'energy_max' => 0,
'energy_used' => 0,
'metal_mine_porcent' => 10,
'cristal_mine_porcent' => 10,
'solar_plant_porcent' => 10,
'fusion_plant_porcent' => 10,
'solar_satelit_porcent' => 10,
'deuterium_sintetizer_porcent' => 10,
'metal_mine' => 20,
'cristal_mine' => 19,
'deuterium_sintetizer' => 0,
'solar_plant' => 20,
'fusion_plant' => 0,
'robot_factory' => 0,
'nano_factory' => 0,
'hangar' => 12,
'metal_store' => 10,
'cristal_store' => 10,
'deuterium_store' => 10,
'rpg_stockeur' => 0
);
$planet = new Legacies_Empire_Model_Planet($data);
$planet->setUser($user);
//var_dump(array('$planet->setUser($user)', array_diff($planet->getAllDatas(), $data)));
$data = $planet->getAllDatas();
$planet->updateStorages(0);
//var_dump(array('$planet->updateStorages(0)', array_diff($planet->getAllDatas(), $data)));
$data = $planet->getAllDatas();
$planet->updateResourceProduction(0);
//var_dump(array('$planet->updateResourceProduction(0)', array_diff($planet->getAllDatas(), $data)));
$data = $planet->getAllDatas();
$planet->getShipyard()->appendQueue(Legacies_Empire::ID_SHIP_LIGHT_FIGHTER, 10, 0);
//var_dump(array('$planet->getShipyard()->appendQueue(Legacies_Empire::ID_SHIP_LIGHT_FIGHTER, 10, 0)', array_diff($planet->getAllDatas(), $data)));
$data = $planet->getAllDatas();
$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 0);
//var_dump(array('$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 0)', array_diff($planet->getAllDatas(), $data)));
$data = $planet->getAllDatas();
$userData = $user->getAllDatas();
$planet->getResearchLab()->appendQueue(Legacies_Empire::ID_RESEARCH_ENERGY_TECHNOLOGY, false, 0);
var_dump(array('$planet->getResearchLab()->appendQueue(Legacies_Empire::ID_RESEARCH_ENERGY_TECHNOLOGY, false, 0)', array_diff($planet->getAllDatas(), $data), array_diff($user->getAllDatas(), $userData)));
$data = $planet->getAllDatas();
var_dump(array_diff($planet->getAllDatas(), $data));
$data = $planet->getAllDatas();
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => 5400
));
var_dump(array_diff($planet->getAllDatas(), $data));
$data = $planet->getAllDatas();
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => (3600 * 20)
));
$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 3600);
var_dump(array_diff($planet->getAllDatas(), $data));
$data = $planet->getAllDatas();
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => (3600 * 30)
));
var_dump(array_diff($planet->getAllDatas(), $data));
$data = $planet->getAllDatas();
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => (3600 * 5000)
));
var_dump(array_diff($planet->getAllDatas(), $data));
$data = $planet->getAllDatas();
$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 0);
$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_SOLAR_PLANT, false, 0);
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => (3600 * 10000)
));
var_dump(array_diff($planet->getAllDatas(), $data));
$data = $planet->getAllDatas();

View file

@ -1,42 +0,0 @@
<?php
//define('BCNUMBERS', true);
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(__FILE__))) . DIRECTORY_SEPARATOR);
defined('APPLICATION_PATH') || define('APPLICATION_PATH', ROOT_PATH . 'application' . DIRECTORY_SEPARATOR);
defined('PHPEXT') || define('PHPEXT', 'php');
defined('VERSION') || define('VERSION', '1.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',
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries',
get_include_path()
)));
function __autoload($class) {
include_once str_replace('_', '/', $class) . '.php';
}
if (0 === filesize(ROOT_PATH . 'config.php')) {
header('Location: install/');
die();
}
Wootook_Core_Model_Config_Events::registerEvents();
include ROOT_PATH . 'includes/constants.php';

View file

@ -1,9 +0,0 @@
<?php
include './bootstrap.php';
$username = uniqid();
$email = $username . '@wootook.org';
$password = substr(sha1(uniqid()), mt_rand(0, 32), 8);
Wootook_Empire_Model_User::register($username, $email, $password);

146
build.xml Normal file
View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="name-of-project" default="build">
<target name="build"
depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdoc,phpunit,phpcb"/>
<target name="build-parallel"
depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="tools-parallel"
description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="phpcpd"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc"/>
<antcall target="phpdoc"/>
</parallel>
</target>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/code-browser"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
</target>
<target name="prepare" depends="clean"
description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/code-browser"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
</target>
<target name="lint">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/src">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="pdepend"
description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpmd"
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpmd">
<arg path="${basedir}/src" />
<arg value="text" />
<arg value="${basedir}/build/phpmd.xml" />
</exec>
</target>
<target name="phpmd-ci"
description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${basedir}/src" />
<arg value="xml" />
<arg value="${basedir}/build/phpmd.xml" />
<arg value="--reportfile" />
<arg value="${basedir}/build/logs/pmd.xml" />
</exec>
</target>
<target name="phpcs"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpcs">
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpcs-ci"
description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpdoc"
description="Generate API documentation using PHPDocumentor">
<exec executable="phpdoc">
<arg value="--directory" />
<arg path="${basedir}/src" />
<arg value="--target" />
<arg path="${basedir}/build/api" />
</exec>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
</target>
<target name="phpcb"
description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log" />
<arg path="${basedir}/build/logs" />
<arg value="--source" />
<arg path="${basedir}/src" />
<arg value="--output" />
<arg path="${basedir}/build/code-browser" />
</exec>
</target>
</project>

36
build/phpcs.xml Normal file
View file

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<ruleset name="PPW-DEFAULT">
<description>Default coding standard</description>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="PEAR.NamingConventions.ValidClassName"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.NoSilencedErrors"/>
<rule ref="Generic.PHP.UpperCaseConstant"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
</ruleset>

26
build/phpmd.xml Normal file
View file

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<ruleset name="PPW-DEFAULT"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Default coding standard</description>
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
<rule ref="rulesets/codesize.xml/NPathComplexity" />
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity" />
<rule ref="rulesets/codesize.xml/ExcessiveClassLength" />
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength" />
<rule ref="rulesets/codesize.xml/ExcessiveParameterList" />
<rule ref="rulesets/design.xml/EvalExpression" />
<rule ref="rulesets/design.xml/ExitExpression" />
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" />
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" />
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
</ruleset>

View file

@ -1,87 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
define('INSIDE', true);
define('INSTALL', false);
define('DISABLE_IDENTITY_CHECK', true);
require_once dirname(__FILE__) . '/application/bootstrap.php';
includeLang('login');
$request = Wootook::getRequest();
if ($request->isPost() && $request->getPost('username') !== null && $request->getPost('password') !== null) {
$user = Wootook_Empire_Model_User::login($request->getPost('username'), $request->getPost('password'), (bool) $request->getPost('rememberme'));
$session = Wootook::getSession(Wootook_Empire_Model_User::SESSION_KEY);
if ($user !== null && $user->getId()) {
$url = Wootook::getUrl('overview.php');
header("Location: $url");
} else {
$url = Wootook::getUrl('login.php');
header("Location: $url");
}
Wootook_Core_ErrorProfiler::unregister(true);
exit(0);
}
$db = Wootook_Database::getSingleton();
$displayedPlayerLevels = implode(',', array(
//LEVEL_ADMIN,
LEVEL_OPERATOR,
LEVEL_MODERATOR,
LEVEL_PLAYER
));
$userCountStatement = $db->prepare("SELECT COUNT(DISTINCT user.id) AS `user_count` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels})");
$userCountStatement->execute();
$userCount = $userCountStatement->fetch(Wootook_Database::FETCH_COLUMN, 0);
$latestPlayerStatement = $db->prepare("SELECT user.username AS `latest_player` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels}) ORDER BY user.`register_time` DESC LIMIT 1");
$latestPlayerStatement->execute();
$latestPlayer = $latestPlayerStatement->fetch(Wootook_Database::FETCH_COLUMN, 0);
$onlinePlayersStatement = $db->prepare("SELECT COUNT(DISTINCT user.id) AS `online_players` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels}) AND user.`onlinetime` > (UNIX_TIMESTAMP() - 900)");
$onlinePlayersStatement->execute();
$onlinePlayers = $onlinePlayersStatement->fetch(Wootook_Database::FETCH_COLUMN, 0);
$layout = new Wootook_Core_Layout();
$layout->getMessagesBlock()->prepareMessages(Wootook_Empire_Model_User::SESSION_KEY);
$layout->load('login');
$block = $layout->getBlock('login');
$block['user_count'] = $userCount;
$block['latest_player'] = $latestPlayer;
$block['online_players'] = $onlinePlayers;
$block['server_name'] = Wootook::getWebsiteConfig('game/general/name');
$block['board_url'] = Wootook::getWebsiteConfig('game/general/boards-url');
echo $layout->render();

View file

@ -1,39 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) . '/application/bootstrap.php';
includeLang('logout');
Wootook_Empire_Model_User::getSingleton()->logout();
message($lang['see_you'], $lang['session_closed'], 'login.php');

View file

@ -1,358 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
$user = Wootook_Empire_Model_User::getSingleton();
$planet = $user->getCurrentPlanet();
$moon = $planet->getMoon();
$action = isset($_GET['action']) ? $_GET['action'] : null;
if (isset($_POST) && !empty($_POST)) {
$action = isset($_POST['action']) && !empty($_POST['action']) ? $_POST['action'] : $action;
$formKey = isset($_POST['form_key']) && !empty($_POST['form_key']) ? $_POST['form_key'] : null;
if ($formKey == Wootook::getSession('security')->getData('form_key')) {
if ($action == 'rename' && isset($_POST['name']) && !empty($_POST['name'])) {
$planet->setData('name', $_POST['name'])->save();
} else if ($action == 'destroy' && isset($_POST['password']) && !empty($_POST['password']) && isset($_POST['confirm'])) {
if (!$user->checkPassword($_POST['password'])) {
Wootook::getSession('user')
->addError(Wootook::__('Password was not correct.'));
}
try {
$user->getCurrentPlanet()->destroy();
Wootook::getSession('user')
->addSucces(Wootook::__('Planet has been successfully destroyed.'));
} catch (Wootook_Empire_Model_Planet_Exception $e) {
Wootook::getSession('user')
->addError($e->getMessage());
}
}
} else {
Wootook::getSession('user')
->addError(Wootook::__('Invalid security key.'));
}
header('HTTP/1.1 302 Found');
header('Location: ' . Wootook::getUrl(basename(__FILE__)));
exit(0);
} else if ($action == 'rename') {
$layout = new Wootook_Core_Layout();
$layout->load('overview.rename-planet');
echo $layout->render();
exit(0);
} else if ($action == 'destroy') {
$layout = new Wootook_Core_Layout();
$layout->load('overview.destroy-planet');
echo $layout->render();
exit(0);
} else {
includeLang('resources');
includeLang('overview');
$layout = new Wootook_Core_Layout();
$layout->load('overview');
if ($user->getId()) {
$planetCollection = $user->getPlanetCollection();
$planetBlock = $layout->createBlock('core/deprecated', 'planet.view');
$planetBlock->setTemplate('empire/overview/planet/view.phtml');
$planetList = $layout->createBlock('core/concat', 'planet.list');
$planetBlock->planetList = $planetList;
$i = 0;
foreach ($planetCollection as $userPlanet) {
if ($userPlanet->getId() == $planet->getId()) {
continue;
}
/*
* Update planet resources and constructions
*/
Wootook::dispatchEvent('planet.update', array(
'planet' => $userPlanet
));
$userPlanet->save();
if ($userPlanet->getId() != $user->getCurrentPlanet()->getId() && $userPlanet->isPlanet()) {
$id = uniqid();
$block = $layout->createBlock('core/deprecated', "planet.list.item.{$id}");
$block->setTemplate('empire/overview/planet/list/item.phtml');
$block['planet'] = $userPlanet;
$buildingQueue = $userPlanet->getBuildingQueue();
$buildingQueue->rewind();
$currentItem = $buildingQueue->current();
$block['queue_item'] = $currentItem;
$block['even'] = (($i++ % 4) == 3);
$planetList->$id = $block;
}
}
/**
* Missile attack management
* Refactoring needed
* {{{
*/
$iraks_query = doquery("SELECT * FROM {{table}} WHERE owner = '" . $user['id'] . "'", 'iraks');
$Record = 4000;
while ($irak = $iraks_query->fetch(PDO::FETCH_ASSOC)) {
$Record++;
$fpage[$irak['zeit']] = '';
if ($irak['zeit'] > time()) {
$time = $irak['zeit'] - time();
$fpage[$irak['zeit']] .= InsertJavaScriptChronoApplet ("fm", $Record, $time, true);
$planet_start = doquery("SELECT * FROM {{table}} WHERE
galaxy = '" . $irak['galaxy'] . "' AND
system = '" . $irak['system'] . "' AND
planet = '" . $irak['planet'] . "' AND
planet_type = '1'", 'planets');
$user_planet = doquery("SELECT * FROM {{table}} WHERE
galaxy = '" . $irak['galaxy_angreifer'] . "' AND
system = '" . $irak['system_angreifer'] . "' AND
planet = '" . $irak['planet_angreifer'] . "' AND
planet_type = '1'", 'planets', true);
if ($planet_start->rowCount() == 1) {
$planet = mysql_fetch_array($planet_start);
}
$fpage[$irak['zeit']] .= "<tr><th><div id=\"bxxfs$i\" class=\"z\"></div><font color=\"lime\">" . gmdate("H:i:s", $irak['zeit'] + 1 * 60 * 60) . "</font> </th><th colspan=\"3\"><font color=\"#0099FF\">Une attaque de missiles (" . $irak['anzahl'] . ") de " . $user_planet['name'] . " ";
$fpage[$irak['zeit']] .= '<a href="galaxy.php?mode=3&galaxy=' . $irak["galaxy_angreifer"] . '&system=' . $irak["system_angreifer"] . '&planet=' . $irak["planet_angreifer"] . '">[' . $irak["galaxy_angreifer"] . ':' . $irak["system_angreifer"] . ':' . $irak["planet_angreifer"] . ']</a>';
$fpage[$irak['zeit']] .= ' arrive sur la plan&egrave;te' . $planet["name"] . ' ';
$fpage[$irak['zeit']] .= '<a href="galaxy.php?mode=3&galaxy=' . $irak["galaxy"] . '&system=' . $irak["system"] . '&planet=' . $irak["planet"] . '">[' . $irak["galaxy"] . ':' . $irak["system"] . ':' . $irak["planet"] . ']</a>';
$fpage[$irak['zeit']] .= '</font>';
$fpage[$irak['zeit']] .= InsertJavaScriptChronoApplet ("fm", $Record, $time, false);
$fpage[$irak['zeit']] .= "</th>";
}
}
/**
* }}}
*/
/*
* Update fleet list
*/
Wootook::dispatchEvent('fleet.update', array(
'user' => $user
));
$fleetList = $layout->createBlock('core/concat', 'fleet.list');
$fleetCollection = $user->getFleetCollection();
foreach ($fleetCollection as $fleet) {
$id = uniqid();
$block = $layout->createBlock('core/deprecated', "fleet.list.item.{$id}");
$block->setTemplate('empire/overview/fleet/item.phtml');
$block['class'] = $fleet->getRowClass();
$block['fleet'] = $fleet;
$block['user'] = $user;
$fleetList->setPartial($id, $block);
}
$messageCollection = new Wootook_Core_Collection('messages');
$messageCollection->where('message_owner=:user');
$messageCollection->where('message_read_at<=0');
$count = $messageCollection->getSize(array('user' => $user->getId()));
$newMessages = $layout->createBlock('core/deprecated', 'overview.messages');
$newMessages->setTemplate('empire/overview/messages.phtml');
$newMessages['count'] = (int) $count;
/**
* Page display
* Refactoring needed
* {{{
*/
// -----------------------------------------------------------------------------------------------
$parse = $lang;
// -----------------------------------------------------------------------------------------------
// News Frame ...
// External Chat Frame ...
// Banner ADS Google (meme si je suis contre cela)
if (Wootook::getGameConfig('game/news/active')) {
$parse['NewsFrame'] = "<tr><th>" . $lang['ov_news_title'] . "</th><th colspan=\"3\">" . htmlentities(Wootook::getGameConfig('game/news/content'), ENT_QUOTES, 'UTF-8') . "</th></tr>";
}
if (Wootook::getGameConfig('engine/options/chat')) {
$parse['ExternalTchatFrame'] = "<tr><th colspan=\"4\">" . Wootook::__('Open the chat.') . "</th></tr>";
}
if (Wootook::getGameConfig('engine/options/banner')) {
$bannerUrl = Wootook::getUrl('scripts/createbanner.php', array('id' => $user['id']));
$parse['bannerframe'] = "<th colspan=\"4\"><img src=\"{$bannerUrl}\"><br>".$lang['InfoBanner']."<br><input name=\"bannerlink\" type=\"text\" id=\"bannerlink\" value=\"[img]".$bannerUrl."[/img]\" size=\"62\"></th></tr>";
}
// --- Gestion de l'affichage d'une lune ---------------------------------------------------------
if ($moon['id']) {
if ($planet->isPlanet()) {
$lune = doquery ("SELECT * FROM {{table}} WHERE `galaxy` = '" . $planet['galaxy'] . "' AND `system` = '" . $planet['system'] . "' AND `planet` = '" . $planet['planet'] . "' AND `planet_type` = '3'", 'planets', true);
$parse['moon_img'] = "<a href=\"?cp=" . $lune['id'] . "&re=0\" title=\"" . $lune['name'] . "\"><img src=\"" . Wootook::getSkinUrl('base', 'default', "graphics/planeten/{$lune['image']}.jpg") . '" height="50" width="50"></a>';
$parse['moon'] = $planet->getMoon()->getName();
} else {
$parse['moon_img'] = "";
$parse['moon'] = "";
}
} else {
$parse['moon_img'] = "";
$parse['moon'] = "";
}
// Moon END
$parse['planet_name'] = $planet['name'];
$parse['planet_diameter'] = Math::render($planet['diameter']);
$parse['planet_field_current'] = Math::render($planet->getUsedFields());
$parse['planet_field_max'] = Math::render($planet->getBuildingFields());
$parse['planet_temp_min'] = $planet['temp_min'];
$parse['planet_temp_max'] = $planet['temp_max'];
$parse['galaxy_galaxy'] = $planet['galaxy'];
$parse['galaxy_planet'] = $planet['planet'];
$parse['galaxy_system'] = $planet['system'];
$StatRecord = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $user['id'] . "';", 'statpoints', true);
$parse['user_points'] = Math::render($StatRecord['build_points']);
$parse['user_fleet'] = Math::render($StatRecord['fleet_points']);
$parse['player_points_tech'] = Math::render($StatRecord['tech_points']);
$parse['total_points'] = Math::render($StatRecord['total_points']);;
$parse['user_rank'] = $StatRecord['total_rank'];
$ile = $StatRecord['total_old_rank'] - $StatRecord['total_rank'];
if ($ile >= 1) {
$parse['ile'] = "<font color=lime>+" . $ile . "</font>";
} elseif ($ile < 0) {
$parse['ile'] = "<font color=red>-" . $ile . "</font>";
} elseif ($ile == 0) {
$parse['ile'] = "<font color=lightblue>" . $ile . "</font>";
}
$parse['u_user_rank'] = $StatRecord['total_rank'];
$parse['user_username'] = $user['username'];
$parse['fleet_list'] = $fleetList->render();
$parse['energy_used'] = $planet["energy_max"] - $planet["energy_used"];
$parse['Have_new_message'] = $newMessages->render();
$parse['time'] = "<div id=\"dateheure\"></div>";
$parse['planet_image'] = $planet['image'];
$parse['anothers_planets'] = $planetBlock->render();
$db = Wootook_Database::getConnection('default');
$displayedPlayerLevels = implode(',', array(
//LEVEL_ADMIN,
LEVEL_OPERATOR,
LEVEL_MODERATOR,
LEVEL_PLAYER
));
$userCountStatement = $db->prepare("SELECT COUNT(DISTINCT user.id) AS `user_count` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels})");
$userCountStatement->execute();
$userCount = $userCountStatement->fetch(Wootook_Database::FETCH_COLUMN, 0);
$parse['max_users'] = $userCount;
$galaxyData = $planet->getGalaxyData();
$parse['metal_debris'] = Math::render($galaxyData['metal']);
$parse['crystal_debris'] = Math::render($galaxyData['crystal']);
if (($galaxyData['metal'] != 0 || $galaxyData['crystal'] != 0) && Math::isPositive($planet->getElement(Legacies_Empire::ID_SHIP_RECYCLER))) {
$parse['get_link'] = " (<a href=\"quickfleet.php?mode=8&g=" . $galaxyData['galaxy'] . "&s=" . $galaxyData['system'] . "&p=" . $galaxyData['planet'] . "&t=2\">" . $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE] . "</a>)";
} else {
$parse['get_link'] = '';
}
$latestPlayerStatement = $db->prepare("SELECT user.username AS `latest_player` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels}) ORDER BY user.`register_time` DESC LIMIT 1");
$latestPlayerStatement->execute();
$latestPlayer = $latestPlayerStatement->fetch(Wootook_Database::FETCH_COLUMN, 0);
$onlinePlayersStatement = $db->prepare("SELECT COUNT(DISTINCT user.id) AS `online_players` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels}) AND user.`onlinetime` > (UNIX_TIMESTAMP() - 900)");
$onlinePlayersStatement->execute();
$onlinePlayers = $onlinePlayersStatement->fetch(Wootook_Database::FETCH_COLUMN, 0);
$query = doquery('SELECT username FROM {{table}} ORDER BY register_time DESC', 'users', true);
$parse['last_user'] = $latestPlayer;
$query = doquery("SELECT COUNT(DISTINCT(id)) FROM {{table}} WHERE onlinetime>" . (time()-900), 'users', true);
$parse['online_users'] = $onlinePlayers;
$parse['users_amount'] = $userCount;
// Rajout d'une barre pourcentage
// Calcul du pourcentage de remplissage
// Barre de remplissage
$size = Math::floor(Math::div($planet->getUsedFields(), $planet->getBuildingFields()) * 100);
// Couleur de la barre de remplissage
$parse['case_pourcentage'] = $size . $lang['o/o'];
if (Math::comp($size, 100) > 0) {
$size = 100;
$parse['case_barre_barcolor'] = '#C00000';
} elseif (Math::comp($size, 80) > 0) {
$parse['case_barre_barcolor'] = '#C0C000';
} else {
$parse['case_barre_barcolor'] = '#00C000';
}
$parse['case_barre'] = $size;
// Mode Améliorations
$parse['xpminier'] = $user['xpminier'];
$parse['xpraid'] = $user['xpraid'];
$parse['lvl_minier'] = $user['lvl_minier'];
$parse['lvl_raid'] = $user['lvl_raid'];
$LvlMinier = $user['lvl_minier'];
$LvlRaid = $user['lvl_raid'];
$parse['lvl_up_minier'] = $LvlMinier * 5000;
$parse['lvl_up_raid'] = $LvlRaid * 10;
// Nombre de raids, pertes, etc ...
$parse['Raids'] = $lang['Raids'];
$parse['NumberOfRaids'] = $lang['NumberOfRaids'];
$parse['RaidsWin'] = $lang['RaidsWin'];
$parse['RaidsLoose'] = $lang['RaidsLoose'];
$parse['raids'] = $user['raids'];
$parse['raidswin'] = $user['raidswin'];
$parse['raidsloose'] = $user['raidsloose'];
// Compteur de Membres en ligne
$OnlineUsers = doquery("SELECT COUNT(*) FROM {{table}} WHERE onlinetime>='" . (time()-15 * 60) . "'", 'users', 'true');
$parse['NumberMembersOnline'] = $OnlineUsers[0];
$page = parsetemplate(gettemplate('overview_body'), $parse);
display($page);
/**
* }}}
*/
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

18
src/.htaccess Normal file
View file

@ -0,0 +1,18 @@
SetEnv DEBUG On
SetEnv DEPRECATION On
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
## workaround for HTTP authorization in CGI environment
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/(skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
@ -33,7 +33,7 @@ define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
$user = Wootook_Empire_Model_User::getSingleton();
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
@ -34,7 +34,7 @@ define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
$user = Wootook_Empire_Model_User::getSingleton();
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
@ -33,7 +33,7 @@ define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
$user = Wootook_Empire_Model_User::getSingleton();
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
@ -38,7 +38,7 @@ if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
doquery("UPDATE {{table}} SET `bana` = '0' WHERE `banaday` < '1';",'users');
$response = Wootook::getResponse()
->setRedirect(Wootook::getUrl('admin/overview.php'))
->setRedirect(Wootook::getStaticUrl('admin/overview.php'))
->sendHeaders();
exit(0);
} else {

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
@ -32,8 +32,8 @@ define('INSTALL' , false);
define('INSIDE' , true);
require_once dirname(__FILE__) .'/application/bootstrap.php';
$user = Wootook_Empire_Model_User::getSingleton();
$db = Wootook_Database::getSingleton();
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
$db = Wootook_Core_Database::getSingleton();
if(!$user->getId()){
echo '<script language="javascript">';
@ -843,7 +843,7 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
}
} else if ($request->getPost('newrang') !== null) {
$newrank = $request->getPost('newrang');
$selectedUser = Wootook_Empire_Model_User::factory($id);
$selectedUser = Wootook_Player_Model_Entity::factory($id);
if ($newrank !== null && isset($ally_ranks[$newrank]) && $selectedUser->getId() != $ally['ally_owner']) {
$selectedUser->setData('ally_rank_id', $newrank)->save();

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved.
@ -28,6 +28,9 @@
*
*/
define('DEBUG', true);
define('DEPRECATION', true);
if (!defined('PHP_VERSION_ID')) {
$version = explode('.',PHP_VERSION);
define('PHP_VERSION_ID', (((int)$version[0]) * 10000 + ((int)$version[1]) * 100 + ((int)$version[2])));
@ -92,15 +95,14 @@ if (defined('IN_ADMIN')) {
include ROOT_PATH . 'includes/constants.php';
Wootook_Core_Time::init();
Wootook_Core_ErrorProfiler::register();
Wootook_Core_Model_Config_Events::registerEvents();
if (!defined('IN_INSTALL') && 0 === filesize(APPLICATION_PATH . 'config' . DIRECTORY_SEPARATOR . 'local.php')) {
header('HTTP/1.1 307 Temporary Redirect');
$url = Wootook::getUrl('install/');
header("Location: $url");
die();
if (!defined('IN_INSTALL') && 0 === filesize(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php')) {
Wootook::getResponse()
->setRedirect(Wootook::getStaticUrl('install/'), Wootook_Core_Controller_Response_Http::REDIRECT_TEMPORARY)
->sendHeaders();
exit(0);
}
$lang = array();
@ -117,16 +119,17 @@ include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg');
include(ROOT_PATH . 'includes/vars.' . PHPEXT);
include(ROOT_PATH . 'includes/strings.' . PHPEXT);
$user = Wootook_Empire_Model_User::getSingleton();
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
if (!defined('DISABLE_IDENTITY_CHECK')) {
if (($user === null || !$user->getId())) {
$url = Wootook::getUrl('login.php');
header("Location: $url");
if ($user === null || !$user->getId()) {
Wootook::getResponse()
->setRedirect(Wootook::getUrl('player/account/login'))
->sendHeaders();
exit(0);
}
if (Wootook::getGameConfig('game/general/active') && $user !== null && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) {
if (!Wootook::getGameConfig('game/general/active') && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) {
$layout = new Wootook_Core_Layout(Wootook_Core_Layout::DOMAIN_FRONTEND);
$layout->load('message');
@ -160,4 +163,4 @@ if (($user !== null && $user->getId())) {
'planet' => $planet
));
$planet->save();
}
}

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -49,7 +49,7 @@ class Legacies_Empire_Block_Planet_ResearchLab
public function getPlanet()
{
if ($this->_planet === null) {
$this->_planet = Wootook_Empire_Model_User::getSingleton()
$this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer()
->getCurrentPlanet()
;
}

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -27,6 +27,7 @@
* documentation for further information about customizing Wootook.
*
*/
/**
*
* Enter description here ...
@ -38,7 +39,7 @@ class Legacies_Empire_Block_Planet_ResearchLab_Item
{
public function getLevel()
{
return $this->getUser()->getElement($this->getItemId());
return $this->getPlayer()->getElement($this->getItemId());
}
public function getResourcesNeeded($level)

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -41,7 +41,7 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item
public function getLevel()
{
return $this->getUser()->getElement($this->getItemId());
return $this->getPlayer()->getElement($this->getItemId());
}
public function getResourcesNeeded($level)
@ -64,6 +64,15 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item
return $this->getPlanet()->getResearchLab()->getBuildingTime($this->getItemId(), $level);
}
public function getBuildingRemainingTime()
{
$totalTime = $this->getPlanet()->getResearchLab()
->getResearchTime($this->getItemId(), $this->getItemQueuedLevel());
$item = $this->getItem();
return $item->getData('created_at') - $item->getData('updated_at') + $totalTime;
}
public function getResourcesConfigForLevel($level)
{
$resources = $this->getResourcesNeeded($level);

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -54,7 +54,7 @@ class Legacies_Empire_Block_Planet_Shipyard
public function getPlanet()
{
if ($this->_planet === null) {
$this->_planet = Wootook_Empire_Model_User::getSingleton()
$this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer()
->getCurrentPlanet()
;
}

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -36,7 +36,7 @@
class Legacies_Empire_Model_Planet_Building_CristalMine
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{
public function getProductionRatios($level, $produtionRatio, $planet, $user)
public function getProductionRatios($level, $produtionRatio, $planet, $player)
{
return array(
Legacies_Empire::RESOURCE_CRISTAL => 10 + 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -36,7 +36,7 @@
class Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{
public function getProductionRatios($level, $produtionRatio, $planet, $user)
public function getProductionRatios($level, $produtionRatio, $planet, $player)
{
return array(
Legacies_Empire::RESOURCE_DEUTERIUM => 10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -36,7 +36,7 @@
class Legacies_Empire_Model_Planet_Building_FusionReactor
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{
public function getProductionRatios($level, $produtionRatio, $planet, $user)
public function getProductionRatios($level, $produtionRatio, $planet, $player)
{
return array(
Legacies_Empire::RESOURCE_DEUTERIUM => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -37,7 +37,7 @@
class Legacies_Empire_Model_Planet_Building_MetalMine
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{
public function getProductionRatios($level, $produtionRatio, $planet, $user)
public function getProductionRatios($level, $produtionRatio, $planet, $player)
{
return array(
Legacies_Empire::RESOURCE_METAL => 20 + 30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -38,7 +38,8 @@
* @subpackage Legacies_Empire
*/
class Legacies_Empire_Model_Planet_Building_ResearchLab
implements Wootook_Empire_Model_Planet_BuildingInterface
implements Wootook_Empire_Model_Planet_BuildingInterface,
Wootook_Empire_Model_Planet_QueueInterface
{
private $_eventPrefix = 'planet.laboratory.';
@ -49,14 +50,14 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
protected $_currentPlanet = null;
/**
* User instance
* @var Legacies_Empire_Model_User
* Player instance
* @var Woootook_Player_Model_Entity
*/
protected $_currentUser = null;
protected $_currentPlayer = null;
/**
* construction queue
* @var array
* @var Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
*/
protected $_builder = null;
@ -71,17 +72,17 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
* it doesn't yet exist.
*
* @param Legacies_Empire_Model_Planet $currentPlanet
* @param Legacies_Empire_Model_User $currentUser
* @param Woootook_Player_Model_Entity $currentPlayer
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/
public static function factory($currentPlanet, $currentUser)
public static function factory($currentPlanet, $currentPlayer)
{
if ($currentPlanet->getId()) {
return null;
}
if (!isset(self::$_instances[$currentPlanet->getId()])) {
self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentUser);
self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentPlayer);
}
return self::$_instances[$currentPlanet->getId()];
}
@ -92,14 +93,14 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
* @see Legacies_Empire_Model_Planet_Building_ResearchLab::factory()
*
* @param Legacies_Empire_Model_Planet $currentPlanet
* @param Legacies_Empire_Model_User $currentUser
* @param Woootook_Player_Model_Entity $currentPlayer
*/
public function __construct($currentPlanet, $currentUser)
public function __construct($currentPlanet, $currentPlayer)
{
$this->_currentPlanet = $currentPlanet;
$this->_currentUser = $currentUser;
$this->_currentPlayer = $currentPlayer;
$this->_builder = new Legacies_Empire_Model_Planet_Building_ResearchLab_Builder($currentPlanet, $currentUser);
$this->_builder = new Legacies_Empire_Model_Planet_Building_ResearchLab_Builder($currentPlanet, $currentPlayer);
}
/**
@ -119,16 +120,14 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
* @param int|string $level
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/
public function appendQueue($researchId, $destroy = false, $time = null)
public function appendQueue($researchId, $level = null, Wootook_Core_DateTime $time = null)
{
if ($time === null) {
$time = Wootook::now();
$time = new Wootook_Core_DateTime();
}
if ($destroy === false) {
$level = $this->_currentUser->getElement($researchId) + 1;
} else {
$level = max($this->_currentUser->getElement($researchId) - 1, 0);
if ($level === null) {
$level = $this->_currentPlayer->getElement($researchId) + 1;
}
// Dispatch event
@ -138,7 +137,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => &$time,
'laboratory' => $this,
'planet' => $this->_currentPlanet,
'user' => $this->_currentUser
'player' => $this->_currentPlayer
));
$this->_builder->appendQueue($researchId, $level, $time);
@ -150,7 +149,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => $time,
'laboratory' => $this,
'planet' => $this->_currentPlanet,
'user' => $this->_currentUser
'player' => $this->_currentPlayer
));
return $this;
@ -161,10 +160,10 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
*
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/
public function updateQueue($time = null)
public function updateQueue(Wootook_Core_DateTime $time = null)
{
if ($time === null) {
$time = Wootook::now();
$time = new Wootook_Core_DateTime();
}
// Dispatch event
@ -172,7 +171,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => &$time,
'laboratory' => $this,
'planet' => $this->_currentPlanet,
'user' => $this->_currentUser
'player' => $this->_currentPlayer
));
$this->_builder->updateQueue($time);
@ -182,7 +181,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => $time,
'laboratory' => $this,
'planet' => $this->_currentPlanet,
'user' => $this->_currentUser
'player' => $this->_currentPlayer
));
return $this;
@ -209,18 +208,22 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
public function checkAvailability($researchId)
{
try {
if (!$this->_builder->checkAvailability($researchId)) {
return false;
}
// Dispatch event
Wootook::dispatchEvent($this->_eventPrefix . 'check-availability', array(
'research_id' => $researchId,
'laboratory' => $this,
'planet' => $this->_currentPlanet,
'user' => $this->_currentUser
'player' => $this->_currentPlayer
));
} catch (Legacies_Core_Event_Break $e) {
return false;
}
return $this->_builder->checkAvailability($researchId);
return true;
}
public function getResourcesNeeded($researchId, $level)
@ -230,12 +233,12 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
public function getResearchTime($researchId, $level)
{
$this->_builder->getBuildingTime($researchId, $level);
return $this->_builder->getBuildingTime($researchId, $level);
}
public function getResearchLevelQueued($researchId)
{
$level = $this->_currentUser->getElement($researchId);
$level = $this->_currentPlayer->getElement($researchId);
foreach ($this->_builder as $item) {
if ($item->getData('research_id') != $researchId) {
continue;
@ -260,9 +263,9 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
$time = $eventData['time'];
}
$shipyard = $planet->getResearchLab();
if ($shipyard !== null) {
$shipyard->updateQueue();
$researchLab = $planet->getResearchLab();
if ($researchLab !== null) {
$researchLab->updateQueue();
}
}
}

View file

@ -3,7 +3,7 @@
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
* @see http://wootook.org/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
@ -27,6 +27,7 @@
* documentation for further information about customizing Wootook.
*
*/
/**
*
* Enter description here ...
@ -36,6 +37,9 @@
class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
extends Wootook_Empire_Model_BuilderAbstract
{
const FIELD_SERIALIZED = 'b_tech_id';
const FIELD_DATETIME = 'b_tech';
/**
* @var int
*/
@ -43,13 +47,13 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
public function init()
{
$this->_unserializeQueue($this->_currentUser->getData('b_laboratory_id'));
$this->_unserializeQueue($this->_currentPlanet->getData(self::FIELD_SERIALIZED));
$this->_maxLength = Wootook::getGameConfig('engine/core/lab_queue_size');
}
/**
* @param int $buildingId
* @param int $level
* @param int $time
* @param array $params
*/
protected function _initItem(Array $params)
{
@ -59,11 +63,19 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
$technologyId = $params['technology_id'];
$level = $params['level'];
if (!isset($params['created_at'])) {
$createdAt = time();
$createdAt = new Wootook_Core_DateTime();
} else {
$createdAt = $params['created_at'];
}
if (!isset($params['started_at'])) {
$startedAt = null;
} else {
$startedAt = $params['started_at'];
}
if (!isset($params['updated_at'])) {
$updatedAt = $createdAt;
} else {
@ -74,6 +86,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
'technology_id' => $technologyId,
'level' => $level,
'created_at' => $createdAt,
'started_at' => $startedAt,
'updated_at' => $updatedAt
));
}
@ -82,7 +95,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
* Check if a technology type is actually buildable on the current
* planet, depending on the technology and buildings requirements.
*
* @param int $technologyId
* @param int|string $technologyId
* @return bool
*/
public function checkAvailability($technologyId)
@ -93,53 +106,42 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
return false;
}
parent::checkAvailability($technologyId);
return true;
return parent::checkAvailability($technologyId);
}
/**
* Returns the time needed to build $level of $technologyId
*
* @param int $technologyId
* @param int|string $technologyId
* @param int $level
*/
public function getBuildingTime($technologyId, $level)
{
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
$types = Wootook_Empire_Model_Game_Types::getSingleton();
Math::setPrecision(50);
$firstLevelTime = $prices[$technologyId][Legacies_Empire::BASE_BUILDING_TIME];
$partialLevelTime = Math::mul($firstLevelTime, Math::pow($prices[$technologyId][Legacies_Empire::RESOURCE_MULTIPLIER], $level));
$levelTime = Math::sub($partialLevelTime, $firstLevelTime);
// FIXME: Resource dependency
$totalCost = Math::mul(Math::add($prices[$technologyId][Legacies_Empire::RESOURCE_METAL], $prices[$technologyId][Legacies_Empire::RESOURCE_CRISTAL]), $level);
$speedFactor = Wootook::getGameConfig('game/speed/general');
// FIXME: Building & Technology dependency
$extraLaboratoriesLevels = 0;
$researchNetworkLevel = $this->_currentUser->getElement(Legacies_Empire::ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK);
if ($researchNetworkLevel > 0) {
$laboratoriesLevels = array();
foreach ($this->_currentUser->getPlanetCollection() as $planet) {
if ($this->_currentPlanet->getId() == $planet->getId()) {
continue;
}
$level = $planet->getElement(Legacies_Empire::ID_BUILDING_RESEARCH_LAB);
if ($level > 0) {
$laboratoriesLevels[] = (int) $level;
}
}
sort($laboratoriesLevels, SORT_NUMERIC);
$extraLaboratoriesLevels = array_sum(array_slice(array_reverse($laboratoriesLevels), 0, $researchNetworkLevel));
if ($speedFactor == null) {
$speedFactor = 1;
}
$laboratorySpeedup = Math::div($totalCost, ($this->_currentPlanet->getElement(Legacies_Empire::ID_BUILDING_RESEARCH_LAB) + 1 + $extraLaboratoriesLevels));
$baseTime = $levelTime / ($speedFactor * 3600);
Math::setPrecision();
$baseTime = ($totalCost / $speedFactor) * $laboratorySpeedup;
$event = Wootook::dispatchEvent('planet.research-lab.technology.building-time', array(
'time' => $baseTime,
'base_time' => $baseTime,
'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer,
'technology_id' => $technologyId,
'level' => $level
));
return (int) Math::floor($baseTime * 3600);
return $event->getData('time');
}
/**
@ -174,35 +176,55 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
*
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/
public function updateQueue($time)
public function updateQueue(Wootook_Core_DateTime $time)
{
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
$elapsedTime = $time - $this->_currentUser->getData('b_laboratory');
$startingTime = clone $this->_currentPlanet->getData(self::FIELD_DATETIME);
$elapsedTime = $time->getTimestamp() - $this->_currentPlanet->getData(self::FIELD_DATETIME)->getTimestamp();
foreach ($this->getQueue() as $element) {
$technologyId = $element->getData('research_id');
$elementTime = $element->getData('started_at');
if ($elementTime === null) {
$element->setData('started_at', $startingTime->getTimestamp());
$elementTime = $startingTime->getTimestamp();
}
$level = $element->getData('level');
$technologyId = $element->getData('technology_id');
$buildTime = $this->getBuildingTime($technologyId, $level);
$elapsedTime = $time->getTimestamp() - $elementTime;
if ($elapsedTime >= $buildTime) {
$this->_currentUser[$fields[$technologyId]] = Math::add($this->_currentUser[$fields[$technologyId]], $level);
$elapsedTime -= $buildTime;
$this->dequeue($element);
$currentTime = clone $startingTime;
$currentTime->add($elapsedTime);
$this->_currentPlayer->setElement($technologyId, $level);
$this->_currentPlanet->updateStorages($currentTime);
$this->_currentPlanet->updateResourceProduction($currentTime);
$this->_currentPlanet->updateBuildingFields();
Wootook::dispatchEvent('planet.research-lab.technology.level-update', array(
'time' => $currentTime,
'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer,
'technology_id' => $technologyId,
'level' => $level
));
$startingTime->set($elementTime + $buildTime);
continue;
}
$timeRatio = $elapsedTime / $buildTime;
$itemsBuilt = Math::mul($timeRatio, $level);
$element->setData('updated_at', $time);
$element->setData('level', Math::sub($level, $itemsBuilt));
$this->_currentUser->setData($fields[$technologyId], Math::add($this->_currentUser->getData($fields[$technologyId]), $itemsBuilt));
break;
}
$this->_currentUser->setData('b_laboratory_id', $this->serialize());
$this->_currentUser->setData('b_laboratory', $time);
$this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize());
$this->_currentPlanet->setData(self::FIELD_DATETIME, $startingTime->now());
return $this;
}
@ -210,21 +232,22 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
/**
* Append items to build to the construction list
*
* @param int $technologyId
* @param int|string $level
* @param int|string $technologyId
* @param int $level
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/
public function appendQueue($technologyId, $level, $time)
public function appendQueue($technologyId, $level, Wootook_Core_DateTime $time)
{
if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) {
return $this;
}
$types = Wootook_Empire_Model_Game_Types::getSingleton();
if (!Math::isPositive($level)) {
return $this;
}
$types = Wootook_Empire_Model_Game_Types::getSingleton();
if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) {
return $this;
}
@ -239,8 +262,18 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
return $this;
}
$this->enqueue($technologyId, $level, $time);
$this->_currentUser->setData('b_laboratory_id', $this->serialize());
if ($this->count() == 0) {
$this->_currentPlanet->setData(self::FIELD_DATETIME, $time);
}
$this->enqueue(array(
'technology_id' => $technologyId,
'level' => $level,
'created_at' => $time->getTimestamp()
));
$this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize());
$this->_currentPlayer->setdata('b_tech_planet', $this->_currentPlanet->getId());
foreach ($remainingAmounts as $resourceId => $resourceAmount) {
$this->_currentPlanet[$resourceId] = $resourceAmount;
@ -248,4 +281,57 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
return $this;
}
};
/**
* Dequeues the first item to build to the construction list and removes all
* its successors of the same type.
*
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/
public function dequeueFirstItem()
{
$this->rewind();
$item = $this->current();
return $this->dequeueItem($item->getIndex());
}
/**
* Dequeues an item to build to the construction list and removes all its
* successors of the same type.
*
* @param string $itemId
* @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/
public function dequeueItem($itemId)
{
$item = $this->getItem($itemId);
if (!$item) {
return $this;
}
$technologyId = $item->getData('technology_id');
$keys = array_keys($this->_queue);
$size = count($keys);
$start = array_search($item->getIndex(), $keys);
for ($i = $start; $i < $size; $i++) {
$index = $keys[$i];
if ($this->_queue[$index]->getData('technology_id') != $technologyId) {
continue;
}
$resourcesNeeded = $this->getResourcesNeeded($technologyId, $this->_queue[$index]->getData('level'));
$reclaimedAmounts = $this->_calculateResourceReclaimedAmounts($resourcesNeeded);
$this->dequeue($this->_queue[$index]);
foreach ($reclaimedAmounts as $resourceId => $resourceAmount) {
$this->_currentPlanet[$resourceId] = $resourceAmount;
}
}
$this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize());
return $this;
}
}

Some files were not shown because too many files have changed in this diff Show more