@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function castAs($type, $value) { |
| 14 | 14 | // TODO: Here should be some conversions to property type |
| 15 | - switch($type) { |
|
| 15 | + switch ($type) { |
|
| 16 | 16 | case TYPE_INTEGER: |
| 17 | 17 | $value = intval($value); |
| 18 | 18 | break; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | break; |
| 31 | 31 | |
| 32 | 32 | case TYPE_ARRAY: |
| 33 | - $value = (array)$value; |
|
| 33 | + $value = (array) $value; |
|
| 34 | 34 | break; |
| 35 | 35 | |
| 36 | 36 | case TYPE_STRING: |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | case TYPE_EMPTY: |
| 39 | 39 | // No-type defaults to string |
| 40 | 40 | default: |
| 41 | - $value = (string)$value; |
|
| 41 | + $value = (string) $value; |
|
| 42 | 42 | break; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * @package Buddy |
| 22 | 22 | */ |
| 23 | -class BuddyModel extends \Entity\KeyedModel{ |
|
| 23 | +class BuddyModel extends \Entity\KeyedModel { |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Name of table for this entity |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | * |
| 16 | 16 | * @package Buddy |
| 17 | 17 | */ |
| 18 | -class BuddyModel extends \Entity\KeyedModel{ |
|
| 18 | +class BuddyModel extends \Entity\KeyedModel { |
|
| 19 | 19 | /** |
| 20 | 20 | * Name of table for this entity |
| 21 | 21 | * |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | |
| 240 | 240 | $factory = $this->values[$id]; |
| 241 | 241 | |
| 242 | - $extended = function ($c) use ($callable, $factory) { |
|
| 242 | + $extended = function($c) use ($callable, $factory) { |
|
| 243 | 243 | return $callable($factory($c), $c); |
| 244 | 244 | }; |
| 245 | 245 | |
@@ -31,8 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @author Fabien Potencier |
| 33 | 33 | */ |
| 34 | -class Container implements \ArrayAccess |
|
| 35 | -{ |
|
| 34 | +class Container implements \ArrayAccess { |
|
| 36 | 35 | private $values = array(); |
| 37 | 36 | private $factories; |
| 38 | 37 | private $protected; |
@@ -47,8 +46,7 @@ discard block |
||
| 47 | 46 | * |
| 48 | 47 | * @param array $values The parameters or objects. |
| 49 | 48 | */ |
| 50 | - public function __construct(array $values = array()) |
|
| 51 | - { |
|
| 49 | + public function __construct(array $values = array()) { |
|
| 52 | 50 | $this->factories = new \SplObjectStorage(); |
| 53 | 51 | $this->protected = new \SplObjectStorage(); |
| 54 | 52 | |
@@ -71,8 +69,7 @@ discard block |
||
| 71 | 69 | * |
| 72 | 70 | * @throws \RuntimeException Prevent override of a frozen service |
| 73 | 71 | */ |
| 74 | - public function offsetSet($id, $value) |
|
| 75 | - { |
|
| 72 | + public function offsetSet($id, $value) { |
|
| 76 | 73 | if (isset($this->frozen[$id])) { |
| 77 | 74 | throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id)); |
| 78 | 75 | } |
@@ -90,8 +87,7 @@ discard block |
||
| 90 | 87 | * |
| 91 | 88 | * @throws \InvalidArgumentException if the identifier is not defined |
| 92 | 89 | */ |
| 93 | - public function offsetGet($id) |
|
| 94 | - { |
|
| 90 | + public function offsetGet($id) { |
|
| 95 | 91 | if (!isset($this->keys[$id])) { |
| 96 | 92 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
| 97 | 93 | } |
@@ -125,8 +121,7 @@ discard block |
||
| 125 | 121 | * |
| 126 | 122 | * @return bool |
| 127 | 123 | */ |
| 128 | - public function offsetExists($id) |
|
| 129 | - { |
|
| 124 | + public function offsetExists($id) { |
|
| 130 | 125 | return isset($this->keys[$id]); |
| 131 | 126 | } |
| 132 | 127 | |
@@ -135,8 +130,7 @@ discard block |
||
| 135 | 130 | * |
| 136 | 131 | * @param string $id The unique identifier for the parameter or object |
| 137 | 132 | */ |
| 138 | - public function offsetUnset($id) |
|
| 139 | - { |
|
| 133 | + public function offsetUnset($id) { |
|
| 140 | 134 | if (isset($this->keys[$id])) { |
| 141 | 135 | if (is_object($this->values[$id])) { |
| 142 | 136 | unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]); |
@@ -155,8 +149,7 @@ discard block |
||
| 155 | 149 | * |
| 156 | 150 | * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object |
| 157 | 151 | */ |
| 158 | - public function factory($callable) |
|
| 159 | - { |
|
| 152 | + public function factory($callable) { |
|
| 160 | 153 | if (!method_exists($callable, '__invoke')) { |
| 161 | 154 | throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.'); |
| 162 | 155 | } |
@@ -177,8 +170,7 @@ discard block |
||
| 177 | 170 | * |
| 178 | 171 | * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object |
| 179 | 172 | */ |
| 180 | - public function protect($callable) |
|
| 181 | - { |
|
| 173 | + public function protect($callable) { |
|
| 182 | 174 | if (!method_exists($callable, '__invoke')) { |
| 183 | 175 | throw new \InvalidArgumentException('Callable is not a Closure or invokable object.'); |
| 184 | 176 | } |
@@ -197,8 +189,7 @@ discard block |
||
| 197 | 189 | * |
| 198 | 190 | * @throws \InvalidArgumentException if the identifier is not defined |
| 199 | 191 | */ |
| 200 | - public function raw($id) |
|
| 201 | - { |
|
| 192 | + public function raw($id) { |
|
| 202 | 193 | if (!isset($this->keys[$id])) { |
| 203 | 194 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
| 204 | 195 | } |
@@ -223,8 +214,7 @@ discard block |
||
| 223 | 214 | * |
| 224 | 215 | * @throws \InvalidArgumentException if the identifier is not defined or not a service definition |
| 225 | 216 | */ |
| 226 | - public function extend($id, $callable) |
|
| 227 | - { |
|
| 217 | + public function extend($id, $callable) { |
|
| 228 | 218 | if (!isset($this->keys[$id])) { |
| 229 | 219 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
| 230 | 220 | } |
@@ -256,8 +246,7 @@ discard block |
||
| 256 | 246 | * |
| 257 | 247 | * @return array An array of value names |
| 258 | 248 | */ |
| 259 | - public function keys() |
|
| 260 | - { |
|
| 249 | + public function keys() { |
|
| 261 | 250 | return array_keys($this->values); |
| 262 | 251 | } |
| 263 | 252 | |
@@ -269,8 +258,7 @@ discard block |
||
| 269 | 258 | * |
| 270 | 259 | * @return static |
| 271 | 260 | */ |
| 272 | - public function register(ServiceProviderInterface $provider, array $values = array()) |
|
| 273 | - { |
|
| 261 | + public function register(ServiceProviderInterface $provider, array $values = array()) { |
|
| 274 | 262 | $provider->register($this); |
| 275 | 263 | |
| 276 | 264 | foreach ($values as $key => $value) { |
@@ -154,15 +154,15 @@ discard block |
||
| 154 | 154 | * @param string $group_name |
| 155 | 155 | */ |
| 156 | 156 | public static function _init($group_name = '') { |
| 157 | - if(static::$_is_static_init) { |
|
| 157 | + if (static::$_is_static_init) { |
|
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($group_name) { |
|
| 161 | + if ($group_name) { |
|
| 162 | 162 | static::$_sn_group_name = $group_name; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if(static::$_sn_group_name) { |
|
| 165 | + if (static::$_sn_group_name) { |
|
| 166 | 166 | static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name); |
| 167 | 167 | empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false; |
| 168 | 168 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | // TODO - Reset combat stats?? |
| 188 | 188 | $this->_unitId = $unitId; |
| 189 | 189 | |
| 190 | - if($this->_unitId) { |
|
| 190 | + if ($this->_unitId) { |
|
| 191 | 191 | $this->info = get_unit_param($this->_unitId); |
| 192 | 192 | $this->_type = $this->info[P_UNIT_TYPE]; |
| 193 | 193 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | protected function setCount($value) { |
| 200 | 200 | // TODO - Reset combat stats?? |
| 201 | - if($value < 0) { |
|
| 201 | + if ($value < 0) { |
|
| 202 | 202 | classSupernova::$debug->error('Can not set Unit::$count to negative value'); |
| 203 | 203 | } |
| 204 | 204 | $this->_count = $value; |
@@ -31,6 +31,9 @@ |
||
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param integer $snId |
|
| 36 | + */ |
|
| 34 | 37 | public function unitAdd($snId, $level) { |
| 35 | 38 | if($this->indexIsSet($snId)) { |
| 36 | 39 | $this->indexGetObject($snId)->$level += $level; |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | |
| 8 | 8 | use Common\V2Location; |
| 9 | 9 | use DBStatic\DBStaticFleetACS; |
| 10 | -use V2Unit\V2UnitList; |
|
| 11 | 10 | use Vector\Vector; |
| 12 | 11 | use Entity\KeyedModel; |
| 13 | 12 | |
@@ -93,28 +93,28 @@ discard block |
||
| 93 | 93 | public function __construct(\Common\GlobalContainer $gc) { |
| 94 | 94 | parent::__construct($gc); |
| 95 | 95 | |
| 96 | - $this->accessors->set(P_CONTAINER_SET, 'dbId', function (V2FleetContainer $that, $value) { |
|
| 96 | + $this->accessors->set(P_CONTAINER_SET, 'dbId', function(V2FleetContainer $that, $value) { |
|
| 97 | 97 | $that->setDirect('dbId', $value); |
| 98 | 98 | $that->location->setLocationId($value); |
| 99 | 99 | }); |
| 100 | 100 | |
| 101 | - $this->accessors->set(P_CONTAINER_SET, 'ownerId', function (V2FleetContainer $that, $value) { |
|
| 101 | + $this->accessors->set(P_CONTAINER_SET, 'ownerId', function(V2FleetContainer $that, $value) { |
|
| 102 | 102 | $that->setDirect('ownerId', $value); |
| 103 | 103 | $that->location->setLocationPlayerId($value); |
| 104 | 104 | }); |
| 105 | 105 | |
| 106 | - $this->accessors->set(P_CONTAINER_SET, 'owner', function (V2FleetContainer $that, $value) { |
|
| 106 | + $this->accessors->set(P_CONTAINER_SET, 'owner', function(V2FleetContainer $that, $value) { |
|
| 107 | 107 | $that->owner = $value; |
| 108 | - if(isset($value['id'])) { |
|
| 108 | + if (isset($value['id'])) { |
|
| 109 | 109 | $that->ownerId = $value['id']; |
| 110 | 110 | } else { |
| 111 | 111 | $that->ownerId = 0; |
| 112 | 112 | } |
| 113 | 113 | }); |
| 114 | 114 | |
| 115 | - $this->accessors->set(P_CONTAINER_SET, 'departure', function (V2FleetContainer $that, $value) { |
|
| 115 | + $this->accessors->set(P_CONTAINER_SET, 'departure', function(V2FleetContainer $that, $value) { |
|
| 116 | 116 | $that->departure = $value; |
| 117 | - if(isset($value['id'])) { |
|
| 117 | + if (isset($value['id'])) { |
|
| 118 | 118 | $that->departurePlanetId = $value['id']; |
| 119 | 119 | $that->vectorDeparture = $value; |
| 120 | 120 | } else { |
@@ -122,20 +122,20 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | }); |
| 124 | 124 | |
| 125 | - $this->accessors->set(P_CONTAINER_GET, 'vectorDeparture', function (V2FleetContainer $that) { |
|
| 125 | + $this->accessors->set(P_CONTAINER_GET, 'vectorDeparture', function(V2FleetContainer $that) { |
|
| 126 | 126 | $vector = new Vector(); |
| 127 | 127 | $that->setDirect('vectorDeparture', $vector); |
| 128 | 128 | |
| 129 | 129 | return $vector; |
| 130 | 130 | }, ACCESSOR_SHARED); |
| 131 | - $this->accessors->set(P_CONTAINER_SET, 'vectorDeparture', function (V2FleetContainer $that, $value) { |
|
| 131 | + $this->accessors->set(P_CONTAINER_SET, 'vectorDeparture', function(V2FleetContainer $that, $value) { |
|
| 132 | 132 | $vector = $that->vectorDeparture; |
| 133 | 133 | |
| 134 | - if(is_array($value)) { |
|
| 134 | + if (is_array($value)) { |
|
| 135 | 135 | $value = Vector::convertToVector($value); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if($value instanceof Vector) { |
|
| 138 | + if ($value instanceof Vector) { |
|
| 139 | 139 | $vector->readFromVector($value); |
| 140 | 140 | } else { |
| 141 | 141 | throw new \Exception('V2Fleet::vectorDeparture setter - value is not a Vector or array!', ERR_ERROR); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $this->accessors->set(P_CONTAINER_EXPORT, 'vectorArrive', array($this, 'exportVector')); |
| 149 | 149 | |
| 150 | 150 | |
| 151 | - $this->accessors->set(P_CONTAINER_GET, 'location', function (V2FleetContainer $that) { |
|
| 151 | + $this->accessors->set(P_CONTAINER_GET, 'location', function(V2FleetContainer $that) { |
|
| 152 | 152 | // if (is_null($location = $that->getDirect('location'))) {} |
| 153 | 153 | $location = new V2Location(LOC_FLEET); |
| 154 | 154 | $that->setDirect('location', $location); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return $location; |
| 157 | 157 | }, ACCESSOR_SHARED); |
| 158 | 158 | |
| 159 | - $this->accessors->set(P_CONTAINER_GET, 'units', function (V2FleetContainer $that) { |
|
| 159 | + $this->accessors->set(P_CONTAINER_GET, 'units', function(V2FleetContainer $that) { |
|
| 160 | 160 | // if (is_null($units = $that->getDirect('units'))) {} |
| 161 | 161 | $units = \classSupernova::$gc->unitList; |
| 162 | 162 | $that->setDirect('units', $units); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | return $units; |
| 165 | 165 | }, ACCESSOR_SHARED); |
| 166 | 166 | |
| 167 | - $this->accessors->set(P_CONTAINER_GET, 'isReturning', function (V2FleetContainer $that) { |
|
| 167 | + $this->accessors->set(P_CONTAINER_GET, 'isReturning', function(V2FleetContainer $that) { |
|
| 168 | 168 | return $that->status == FLEET_FLAG_RETURNING; |
| 169 | 169 | }); |
| 170 | 170 | |
@@ -213,7 +213,7 @@ |
||
| 213 | 213 | /** |
| 214 | 214 | * @param int|string $dbId |
| 215 | 215 | * |
| 216 | - * @return V2FleetContainer|false |
|
| 216 | + * @return V2FleetContainer |
|
| 217 | 217 | */ |
| 218 | 218 | public function loadById($dbId) { |
| 219 | 219 | /** |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | * @since 5.0.0 |
| 81 | 81 | */ |
| 82 | 82 | public function offsetUnset($offset) { |
| 83 | - if($this->offsetExists($offset)) { |
|
| 83 | + if ($this->offsetExists($offset)) { |
|
| 84 | 84 | parent::offsetUnset($this->offsetGet($offset)); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public static function build($callable) { |
| 18 | - if(is_array($callable) && count($callable) == 2 && is_object($callable[0])) { |
|
| 18 | + if (is_array($callable) && count($callable) == 2 && is_object($callable[0])) { |
|
| 19 | 19 | return new static($callable); |
| 20 | 20 | } else { |
| 21 | 21 | return false; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $source_planet = &$mission_data->src_planet; |
| 19 | 19 | $destination_planet = &$mission_data->dst_planet; |
| 20 | 20 | |
| 21 | - if(empty($destination_planet['id_owner'])) { |
|
| 21 | + if (empty($destination_planet['id_owner'])) { |
|
| 22 | 22 | $objFleet->markReturnedAndSave(); |
| 23 | 23 | |
| 24 | 24 | return $result; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium']); |
| 34 | 34 | DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_transport'], $Message); |
| 35 | 35 | |
| 36 | - if($objFleet->target_owner_id <> $objFleet->playerOwnerId) { |
|
| 36 | + if ($objFleet->target_owner_id <> $objFleet->playerOwnerId) { |
|
| 37 | 37 | DBStaticMessages::msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_transport'], $Message); |
| 38 | 38 | } |
| 39 | 39 | |