@@ -3,8 +3,7 @@ discard block |
||
3 | 3 | * Created by Gorlum 05.08.2018 8:05 |
4 | 4 | */ |
5 | 5 | |
6 | -class Timer |
|
7 | -{ |
|
6 | +class Timer { |
|
8 | 7 | /** |
9 | 8 | * @var array[] $times [ |
10 | 9 | * 'time' => (float)microtime(true), |
@@ -14,8 +13,7 @@ discard block |
||
14 | 13 | */ |
15 | 14 | private static $times = []; |
16 | 15 | |
17 | - public static function init() |
|
18 | - { |
|
16 | + public static function init() { |
|
19 | 17 | if (empty(static::$times)) { |
20 | 18 | static::$times[] = ['time' => microtime(true)]; |
21 | 19 | } |
@@ -24,8 +22,7 @@ discard block |
||
24 | 22 | /** |
25 | 23 | * @param string $message Message to attach to timestamp |
26 | 24 | */ |
27 | - public static function mark($message = '') |
|
28 | - { |
|
25 | + public static function mark($message = '') { |
|
29 | 26 | static::init(); |
30 | 27 | |
31 | 28 | foreach (debug_backtrace() as $trace) { |
@@ -51,8 +48,7 @@ discard block |
||
51 | 48 | * |
52 | 49 | * @return string |
53 | 50 | */ |
54 | - public static function elapsed($message = '', $fromStart = false) |
|
55 | - { |
|
51 | + public static function elapsed($message = '', $fromStart = false) { |
|
56 | 52 | $prevTime = $fromStart ? static::first()['time'] : static::last()['time']; |
57 | 53 | |
58 | 54 | static::mark($message); |
@@ -62,8 +58,7 @@ discard block |
||
62 | 58 | return number_format(static::last()['time'] - $prevTime, 6) . 's'; |
63 | 59 | } |
64 | 60 | |
65 | - public static function msg($message, $fromStart = false) |
|
66 | - { |
|
61 | + public static function msg($message, $fromStart = false) { |
|
67 | 62 | |
68 | 63 | $message . |
69 | 64 | ($fromStart ? ' FROM START ' : ' in ') . |
@@ -75,21 +70,18 @@ discard block |
||
75 | 70 | /** |
76 | 71 | * @return mixed |
77 | 72 | */ |
78 | - public static function last() |
|
79 | - { |
|
73 | + public static function last() { |
|
80 | 74 | return end(static::$times); |
81 | 75 | } |
82 | 76 | |
83 | 77 | /** |
84 | 78 | * @return mixed |
85 | 79 | */ |
86 | - public static function first() |
|
87 | - { |
|
80 | + public static function first() { |
|
88 | 81 | return reset(static::$times); |
89 | 82 | } |
90 | 83 | |
91 | - public static function getLog() |
|
92 | - { |
|
84 | + public static function getLog() { |
|
93 | 85 | return static::$times; |
94 | 86 | } |
95 | 87 |
@@ -23,18 +23,24 @@ discard block |
||
23 | 23 | |
24 | 24 | // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu |
25 | 25 | $errorlist = ''; |
26 | - if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) |
|
27 | - $errorlist .= $lang['fl_limit_galaxy']; |
|
28 | - if (!$system || $system > $config->game_maxSystem || $system < 1) |
|
29 | - $errorlist .= $lang['fl_limit_system']; |
|
30 | - if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE )) |
|
31 | - $errorlist .= $lang['fl_limit_planet']; |
|
32 | - if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) |
|
33 | - $errorlist .= $lang['fl_ownpl_err']; |
|
34 | - if (!$planet_type) |
|
35 | - $errorlist .= $lang['fl_no_planettype']; |
|
36 | - if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) |
|
37 | - $errorlist .= $lang['fl_fleet_err_pl']; |
|
26 | + if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) { |
|
27 | + $errorlist .= $lang['fl_limit_galaxy']; |
|
28 | + } |
|
29 | + if (!$system || $system > $config->game_maxSystem || $system < 1) { |
|
30 | + $errorlist .= $lang['fl_limit_system']; |
|
31 | + } |
|
32 | + if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE )) { |
|
33 | + $errorlist .= $lang['fl_limit_planet']; |
|
34 | + } |
|
35 | + if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
36 | + $errorlist .= $lang['fl_ownpl_err']; |
|
37 | + } |
|
38 | + if (!$planet_type) { |
|
39 | + $errorlist .= $lang['fl_no_planettype']; |
|
40 | + } |
|
41 | + if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
42 | + $errorlist .= $lang['fl_fleet_err_pl']; |
|
43 | + } |
|
38 | 44 | if (empty($missiontype[$target_mission])) { |
39 | 45 | $errorlist .= $lang['fl_bad_mission']; |
40 | 46 | } |
@@ -61,29 +67,35 @@ discard block |
||
61 | 67 | } |
62 | 68 | } else { |
63 | 69 | if ($TargetPlanet['id_owner']){ |
64 | - if ($target_mission == MT_COLONIZE) |
|
65 | - $errorlist .= $lang['fl_colonized']; |
|
70 | + if ($target_mission == MT_COLONIZE) { |
|
71 | + $errorlist .= $lang['fl_colonized']; |
|
72 | + } |
|
66 | 73 | |
67 | 74 | if ($TargetPlanet['id_owner'] == $planetrow['id_owner']){ |
68 | - if ($target_mission == MT_ATTACK) |
|
69 | - $errorlist .= $lang['fl_no_self_attack']; |
|
70 | - |
|
71 | - if ($target_mission == MT_SPY) |
|
72 | - $errorlist .= $lang['fl_no_self_spy']; |
|
73 | - }else{ |
|
74 | - if ($target_mission == MT_RELOCATE) |
|
75 | - $errorlist .= $lang['fl_only_stay_at_home']; |
|
75 | + if ($target_mission == MT_ATTACK) { |
|
76 | + $errorlist .= $lang['fl_no_self_attack']; |
|
77 | + } |
|
78 | + |
|
79 | + if ($target_mission == MT_SPY) { |
|
80 | + $errorlist .= $lang['fl_no_self_spy']; |
|
81 | + } |
|
82 | + } else{ |
|
83 | + if ($target_mission == MT_RELOCATE) { |
|
84 | + $errorlist .= $lang['fl_only_stay_at_home']; |
|
85 | + } |
|
76 | 86 | } |
77 | - }else{ |
|
87 | + } else{ |
|
78 | 88 | if ($target_mission < MT_COLONIZE){ |
79 | 89 | $errorlist .= $lang['fl_unknow_target']; |
80 | - }else{ |
|
81 | - if ($target_mission == MT_DESTROY) |
|
82 | - $errorlist .= $lang['fl_nomoon']; |
|
90 | + } else{ |
|
91 | + if ($target_mission == MT_DESTROY) { |
|
92 | + $errorlist .= $lang['fl_nomoon']; |
|
93 | + } |
|
83 | 94 | |
84 | 95 | if ($target_mission == MT_RECYCLE){ |
85 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) |
|
86 | - $errorlist .= $lang['fl_nodebris']; |
|
96 | + if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
97 | + $errorlist .= $lang['fl_nodebris']; |
|
98 | + } |
|
87 | 99 | } |
88 | 100 | } |
89 | 101 | } |
@@ -131,8 +143,7 @@ discard block |
||
131 | 143 | $aks = DbFleetStatic::dbAcsGetById($fleet_group); |
132 | 144 | if (!$aks) { |
133 | 145 | $fleet_group = 0; |
134 | - } |
|
135 | - else |
|
146 | + } else |
|
136 | 147 | { |
137 | 148 | $galaxy = $aks['galaxy']; |
138 | 149 | $system = $aks['system']; |