@@ -57,9 +57,11 @@ discard block |
||
57 | 57 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
58 | 58 | } |
59 | 59 | |
60 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
60 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
61 | + // Existing friendship |
|
61 | 62 | { |
62 | 63 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
64 | + } |
|
63 | 65 | |
64 | 66 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
65 | 67 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -67,15 +69,19 @@ discard block |
||
67 | 69 | db_buddy_delete($buddy_id); |
68 | 70 | sn_db_transaction_commit(); |
69 | 71 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
70 | - } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
72 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
73 | + // Player's outcoming request - either denied or waiting |
|
71 | 74 | { |
72 | 75 | db_buddy_delete($buddy_id); |
76 | + } |
|
73 | 77 | sn_db_transaction_commit(); |
74 | 78 | throw new exception('buddy_err_delete_own', ERR_NONE); |
75 | - } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
79 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
80 | + // Deny incoming request |
|
76 | 81 | { |
77 | 82 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
78 | 83 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
84 | + } |
|
79 | 85 | |
80 | 86 | db_buddy_update_status($buddy_id, BUDDY_REQUEST_DENIED); |
81 | 87 | sn_db_transaction_commit(); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * Idea from buddy.php Created by Perberos. All rights reversed (C) 2006 |
11 | 11 | * */ |
12 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
12 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
13 | 13 | |
14 | 14 | lng_include('buddy'); |
15 | 15 | |
@@ -17,32 +17,32 @@ discard block |
||
17 | 17 | try { |
18 | 18 | sn_db_transaction_start(); |
19 | 19 | |
20 | - if($buddy_id = sys_get_param_id('buddy_id')) { |
|
20 | + if ($buddy_id = sys_get_param_id('buddy_id')) { |
|
21 | 21 | $buddy_row = db_buddy_get_row($buddy_id); |
22 | - if(!is_array($buddy_row)) { |
|
22 | + if (!is_array($buddy_row)) { |
|
23 | 23 | throw new exception('buddy_err_not_exist', ERR_ERROR); |
24 | 24 | } |
25 | 25 | |
26 | - switch($mode = sys_get_param_str('mode')) { |
|
26 | + switch ($mode = sys_get_param_str('mode')) { |
|
27 | 27 | case 'accept': |
28 | - if($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
28 | + if ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
29 | 29 | throw new exception('buddy_err_accept_own', ERR_ERROR); |
30 | 30 | } |
31 | 31 | |
32 | - if($buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
32 | + if ($buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
33 | 33 | throw new exception('buddy_err_accept_alien', ERR_ERROR); |
34 | 34 | } |
35 | 35 | |
36 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
36 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
37 | 37 | throw new exception('buddy_err_accept_already', ERR_WARNING); |
38 | 38 | } |
39 | 39 | |
40 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) { |
|
40 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) { |
|
41 | 41 | throw new exception('buddy_err_accept_denied', ERR_ERROR); |
42 | 42 | } |
43 | 43 | |
44 | 44 | db_buddy_update_status($buddy_id, BUDDY_REQUEST_ACTIVE); |
45 | - if(classSupernova::$db->db_affected_rows()) { |
|
45 | + if (classSupernova::$db->db_affected_rows()) { |
|
46 | 46 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], classLocale::$lang['buddy_msg_accept_title'], |
47 | 47 | sprintf(classLocale::$lang['buddy_msg_accept_text'], $user['username'])); |
48 | 48 | sn_db_transaction_commit(); |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | break; |
54 | 54 | |
55 | 55 | case 'delete': |
56 | - if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
56 | + if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) { |
|
57 | 57 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
58 | 58 | } |
59 | 59 | |
60 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
60 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
61 | 61 | { |
62 | 62 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
63 | 63 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | db_buddy_delete($buddy_id); |
68 | 68 | sn_db_transaction_commit(); |
69 | 69 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
70 | - } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
70 | + } elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
71 | 71 | { |
72 | 72 | db_buddy_delete($buddy_id); |
73 | 73 | sn_db_transaction_commit(); |
74 | 74 | throw new exception('buddy_err_delete_own', ERR_NONE); |
75 | - } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
75 | + } elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
76 | 76 | { |
77 | 77 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], classLocale::$lang['buddy_msg_deny_title'], |
78 | 78 | sprintf(classLocale::$lang['buddy_msg_deny_text'], $user['username'])); |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | |
88 | 88 | // New request? |
89 | 89 | // Checking for user ID - in case if it was request from outside buddy system |
90 | - if($new_friend_id = sys_get_param_id('request_user_id')) { |
|
90 | + if ($new_friend_id = sys_get_param_id('request_user_id')) { |
|
91 | 91 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
92 | - } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) { |
|
92 | + } elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) { |
|
93 | 93 | $new_friend_row = db_user_by_username($new_friend_name, true, '`id`, `username`'); |
94 | 94 | $new_friend_name = db_escape($new_friend_name); |
95 | 95 | } |
96 | 96 | |
97 | - if($new_friend_row['id'] == $user['id']) { |
|
97 | + if ($new_friend_row['id'] == $user['id']) { |
|
98 | 98 | unset($new_friend_row); |
99 | 99 | throw new exception('buddy_err_adding_self', ERR_ERROR); |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Checking for user name & request text - in case if it was request to adding new request |
103 | - if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) { |
|
103 | + if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) { |
|
104 | 104 | $check_relation = db_buddy_check_relation($user, $new_friend_row); |
105 | - if(isset($check_relation['BUDDY_ID'])) { |
|
105 | + if (isset($check_relation['BUDDY_ID'])) { |
|
106 | 106 | throw new exception('buddy_err_adding_exists', ERR_WARNING); |
107 | 107 | } |
108 | 108 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | sn_db_transaction_commit(); |
114 | 114 | throw new exception('buddy_err_adding_none', ERR_NONE); |
115 | 115 | } |
116 | -} catch(Exception $e) { |
|
116 | +} catch (Exception $e) { |
|
117 | 117 | $result[] = array( |
118 | 118 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
119 | 119 | 'MESSAGE' => classLocale::$lang[$e->getMessage()], |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | sn_db_transaction_rollback(); |
124 | 124 | |
125 | 125 | $query = db_buddy_list_by_user($user['id']); |
126 | -while($row = db_fetch($query)) { |
|
126 | +while ($row = db_fetch($query)) { |
|
127 | 127 | $row['BUDDY_REQUEST'] = sys_bbcodeParse($row['BUDDY_REQUEST']); |
128 | 128 | |
129 | 129 | $row['BUDDY_ACTIVE'] = $row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE; |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | -if(!$user_can_negotiate) { |
|
7 | +if (!$user_can_negotiate) { |
|
8 | 8 | message($lang['Denied_access'], $lang['ali_dip_title']); |
9 | 9 | } |
10 | 10 | |
@@ -15,24 +15,24 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if(sys_get_param_str('ali_dip_offer_make')) { |
|
18 | +if (sys_get_param_str('ali_dip_offer_make')) { |
|
19 | 19 | $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation'); |
20 | - if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) { |
|
20 | + if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) { |
|
21 | 21 | message($lang['ali_dip_err_wrong_offer'], $page_title); |
22 | 22 | } |
23 | 23 | |
24 | 24 | $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id'); |
25 | - if($alliance_negotiation_contr_ally_id == $user['ally_id']) { |
|
25 | + if ($alliance_negotiation_contr_ally_id == $user['ally_id']) { |
|
26 | 26 | message($lang['ali_dip_err_same_ally'], $page_title); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $contr_ally_row = db_ally_get_by_id($alliance_negotiation_contr_ally_id); |
30 | - if(!$contr_ally_row) { |
|
30 | + if (!$contr_ally_row) { |
|
31 | 31 | message($lang['ali_dip_err_no_ally'], $page_title); |
32 | 32 | } |
33 | 33 | |
34 | 34 | $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id); |
35 | - if($alliance_negotiation_relation == $relation_current_id) { |
|
35 | + if ($alliance_negotiation_relation == $relation_current_id) { |
|
36 | 36 | message(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title); |
37 | 37 | } |
38 | 38 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation]; |
45 | 45 | $relation_current = $sn_diplomacy_relation_list[$relation_current_id]; |
46 | - if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) { |
|
46 | + if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) { |
|
47 | 47 | sn_db_perform('{{alliance_negotiation}}', |
48 | 48 | array( |
49 | 49 | 'alliance_negotiation_ally_id' => $user['ally_id'], |
@@ -70,33 +70,33 @@ discard block |
||
70 | 70 | } |
71 | 71 | } else { |
72 | 72 | $offer_id = sys_get_param_id('offer_id'); |
73 | - if($offer_id) { |
|
73 | + if ($offer_id) { |
|
74 | 74 | $offer_answer = sys_get_param_str('answer'); |
75 | 75 | |
76 | 76 | $negotiation = db_ally_negotiation_get_by_offer_id($offer_id); |
77 | - if(!$negotiation) { |
|
77 | + if (!$negotiation) { |
|
78 | 78 | message($lang['ali_dip_err_offer_none'], $page_title); |
79 | - } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) { |
|
79 | + } elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) { |
|
80 | 80 | // TODO: Add log of hack attempt |
81 | 81 | message($lang['ali_dip_err_offer_alien'], $page_title); |
82 | - } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) { |
|
83 | - if($offer_answer == 'accept') { |
|
82 | + } elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) { |
|
83 | + if ($offer_answer == 'accept') { |
|
84 | 84 | // TODO: Add log of hack attempt |
85 | 85 | message($lang['ali_dip_err_offer_accept_own'], $page_title); |
86 | - } elseif($offer_answer == 'deny') { |
|
86 | + } elseif ($offer_answer == 'deny') { |
|
87 | 87 | db_ally_negotiation_delete_by_offer_id($offer_id); |
88 | 88 | } |
89 | 89 | } else { |
90 | - if($offer_answer == 'accept') { |
|
90 | + if ($offer_answer == 'accept') { |
|
91 | 91 | $accept_offer = true; |
92 | - } elseif($offer_answer == 'deny') { |
|
92 | + } elseif ($offer_answer == 'deny') { |
|
93 | 93 | db_ally_negotiation_update_status_1($offer_id); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | -if($accept_offer) { |
|
99 | +if ($accept_offer) { |
|
100 | 100 | sn_db_transaction_start(); |
101 | 101 | |
102 | 102 | // TODO: Make sn_db_perform() multirow |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | sn_db_transaction_commit(); |
126 | 126 | } |
127 | 127 | |
128 | -foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) { |
|
128 | +foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) { |
|
129 | 129 | $template->assign_block_vars('relation', array( |
130 | 130 | 'ID' => $diplomacy_relation_id, |
131 | 131 | 'TEXT' => $lang['ali_dip_relations'][$diplomacy_relation_id], |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | $query = db_ally_list_get_by_not_user_ally($user); |
137 | -while($alliance = db_fetch($query)) { |
|
137 | +while ($alliance = db_fetch($query)) { |
|
138 | 138 | $template->assign_block_vars('alliance', array( |
139 | 139 | 'ID' => $alliance['id'], |
140 | 140 | 'NAME' => js_safe_string($alliance['ally_name']), |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | $query = db_ally_negotiation_list($user); |
146 | -while($offer = db_fetch($query)) { |
|
146 | +while ($offer = db_fetch($query)) { |
|
147 | 147 | $template->assign_block_vars('offer', array( |
148 | 148 | 'ID' => $offer['alliance_negotiation_id'], |
149 | 149 | 'NAME' => $offer['ally_name'], |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | 7 | $template = gettemplate('ali_search', true); |
8 | 8 | |
9 | 9 | $ali_search_text = sys_get_param_str('searchtext'); |
10 | -if($ali_search_text) { |
|
10 | +if ($ali_search_text) { |
|
11 | 11 | $template->assign_var('SEARCH_TEXT', $ali_search_text); |
12 | 12 | |
13 | 13 | $search = db_ally_search_by_name_or_tag($ali_search_text); |
14 | - if(db_num_rows($search)) { |
|
15 | - while($ally_row = db_fetch($search)) { |
|
14 | + if (db_num_rows($search)) { |
|
15 | + while ($ally_row = db_fetch($search)) { |
|
16 | 16 | $template->assign_block_vars('alliances', array( |
17 | 17 | 'ID' => $ally_row['id'], |
18 | 18 | 'TAG' => $ally_row['ally_tag'], |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function geoip_status(){return sn_function_call(__FUNCTION__, array(&$result));} |
|
3 | +function geoip_status() {return sn_function_call(__FUNCTION__, array(&$result)); } |
|
4 | 4 | function sn_geoip_status(&$result) { |
5 | 5 | return $result = false; |
6 | 6 | } |
7 | 7 | |
8 | -function geoip_ip_info($ip){return sn_function_call(__FUNCTION__, array($ip, &$result));} |
|
8 | +function geoip_ip_info($ip) {return sn_function_call(__FUNCTION__, array($ip, &$result)); } |
|
9 | 9 | function sn_geoip_ip_info($ip, &$result) { |
10 | 10 | return $result = false; |
11 | 11 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * @copyright 2008 by Gorlum for Project "SuperNova.WS" |
11 | 11 | */ |
12 | 12 | function flt_mission_hold($mission_data) { |
13 | - if($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) { |
|
13 | + if ($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) { |
|
14 | 14 | $mission_data->fleet->mark_fleet_as_returned_and_save(); |
15 | 15 | |
16 | 16 | return CACHE_FLEET; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $source_planet = &$mission_data->src_planet; |
17 | 17 | $destination_planet = &$mission_data->dst_planet; |
18 | 18 | |
19 | - if(!isset($destination_planet['id']) || !$destination_planet['id_owner']) { |
|
19 | + if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) { |
|
20 | 20 | $objFleet->mark_fleet_as_returned_and_save(); |
21 | 21 | |
22 | 22 | return CACHE_FLEET; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']); |
32 | 32 | msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
33 | 33 | |
34 | - if($objFleet->target_owner_id <> $objFleet->playerOwnerId) { |
|
34 | + if ($objFleet->target_owner_id <> $objFleet->playerOwnerId) { |
|
35 | 35 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
36 | 36 | } |
37 | 37 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | /** |
32 | 32 | * Fleet mission "Relocate" |
33 | 33 | * |
34 | - * @param $mission_data Mission |
|
34 | + * @param Mission $mission_data Mission |
|
35 | 35 | * |
36 | 36 | * @return int |
37 | 37 | * |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | $destination_planet = &$mission_data->dst_planet; |
22 | 22 | |
23 | - if(empty($destination_planet['id'])) { |
|
23 | + if (empty($destination_planet['id'])) { |
|
24 | 24 | $objFleet->mark_fleet_as_returned(); |
25 | 25 | $objFleet->flush_changes_to_db(); |
26 | 26 | |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $OtherFleetCapacity = 0; |
32 | 32 | |
33 | 33 | $fleet_array = $objFleet->get_unit_list(); |
34 | - foreach($fleet_array as $unit_id => $unit_count) { |
|
35 | - if(in_array($unit_id, sn_get_groups('fleet'))) { |
|
34 | + foreach ($fleet_array as $unit_id => $unit_count) { |
|
35 | + if (in_array($unit_id, sn_get_groups('fleet'))) { |
|
36 | 36 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count; |
37 | - if(in_array($unit_id, sn_get_groups('flt_recyclers'))) { |
|
37 | + if (in_array($unit_id, sn_get_groups('flt_recyclers'))) { |
|
38 | 38 | $RecyclerCapacity += $capacity; |
39 | 39 | } else { |
40 | 40 | $OtherFleetCapacity += $capacity; |
@@ -43,33 +43,33 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | $fleet_resources_amount = $objFleet->get_resources_amount(); |
46 | - if($fleet_resources_amount > $OtherFleetCapacity) { |
|
46 | + if ($fleet_resources_amount > $OtherFleetCapacity) { |
|
47 | 47 | // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков |
48 | 48 | // Уменьшаем ёмкость переработчиков на указанную величину |
49 | 49 | $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity); |
50 | 50 | } |
51 | 51 | |
52 | 52 | $resources_recycled = array(); |
53 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
53 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
54 | 54 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
55 | 55 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
56 | 56 | } else { |
57 | - if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
57 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
58 | 58 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2) |
59 | 59 | ) { |
60 | 60 | $resources_recycled[RES_METAL] = $RecyclerCapacity / 2; |
61 | 61 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2; |
62 | 62 | } else { |
63 | - if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
63 | + if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
64 | 64 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
65 | - if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
65 | + if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
66 | 66 | $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL]; |
67 | 67 | } else { |
68 | 68 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
69 | 69 | } |
70 | 70 | } else { |
71 | 71 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
72 | - if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
72 | + if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
73 | 73 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL]; |
74 | 74 | } else { |
75 | 75 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | parent::setUnitId($unitId); |
51 | 51 | |
52 | 52 | // Reset combat stats?? |
53 | - if($this->_unitId) { |
|
53 | + if ($this->_unitId) { |
|
54 | 54 | $this->amplify = $this->info[P_AMPLIFY]; |
55 | 55 | $this->capacity = $this->info[P_CAPACITY]; |
56 | 56 | $this->price[RES_METAL] = $this->info[P_COST][RES_METAL]; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $this->bonus_attack = $this->info[P_ATTACK]; |
73 | 73 | $this->bonus_shield = $this->info[P_SHIELD]; |
74 | 74 | $this->bonus_armor = $this->info[P_ARMOR]; |
75 | - if(is_object($this->unit_bonus)) { |
|
75 | + if (is_object($this->unit_bonus)) { |
|
76 | 76 | $this->bonus_attack = floor($this->bonus_attack * $this->unit_bonus->calcBonus(P_ATTACK)); |
77 | 77 | $this->bonus_shield = floor($this->bonus_shield * $this->unit_bonus->calcBonus(P_SHIELD)); |
78 | 78 | $this->bonus_armor = floor($this->bonus_armor * $this->unit_bonus->calcBonus(P_ARMOR)); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->randomized_attack = $this->bonus_attack; |
81 | 81 | $this->randomized_shield = $this->bonus_shield; |
82 | 82 | $this->randomized_armor = $this->bonus_armor; |
83 | - if(!$is_simulator) { |
|
83 | + if (!$is_simulator) { |
|
84 | 84 | // TODO - randomize attack if is not simulator |
85 | 85 | $this->randomized_attack = floor($this->bonus_attack * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100)); |
86 | 86 | $this->randomized_shield = floor($this->bonus_shield * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100)); |
@@ -159,22 +159,22 @@ discard block |
||
159 | 159 | * @version 2016-02-25 23:42:45 41a4.68 |
160 | 160 | */ |
161 | 161 | public function restore_unit($is_simulator) { |
162 | - if($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) { |
|
162 | + if ($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - if($is_simulator) { |
|
166 | + if ($is_simulator) { |
|
167 | 167 | $units_giveback = round($this->units_lost * UBE_DEFENCE_RESTORATION_CHANCE_AVG / 100); // for simulation just return 75% of loss |
168 | 168 | } else { |
169 | 169 | // Checking - should we trigger mass-restore |
170 | - if($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) { |
|
170 | + if ($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) { |
|
171 | 171 | // For large amount - mass-restoring defence |
172 | 172 | $units_giveback = round($this->units_lost * mt_rand(UBE_DEFENCE_RESTORATION_CHANCE_MIN, UBE_DEFENCE_RESTORATION_CHANCE_MAX) / 100); |
173 | 173 | } else { |
174 | 174 | // For small amount - restoring defence per single unit |
175 | 175 | $units_giveback = 0; |
176 | - for($i = 1; $i <= $this->units_lost; $i++) { |
|
177 | - if(mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) { |
|
176 | + for ($i = 1; $i <= $this->units_lost; $i++) { |
|
177 | + if (mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) { |
|
178 | 178 | $units_giveback++; |
179 | 179 | } |
180 | 180 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function receive_damage($is_simulator) { |
195 | 195 | // TODO - Добавить взрывы от полуповрежденных юнитов - т.е. заранее вычислить из убитых юнитов еще количество убитых умножить на вероятность от структуры |
196 | - if($this->_count <= 0) { |
|
196 | + if ($this->_count <= 0) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $this->adjustCount(-$units_lost); |
217 | 217 | |
218 | 218 | // Проверяем - не взорвался ли текущий юнит |
219 | - while($this->_count > 0 && $this->attack_income > 0) { |
|
219 | + while ($this->_count > 0 && $this->attack_income > 0) { |
|
220 | 220 | $this->attack_damaged_unit($is_simulator); |
221 | 221 | } |
222 | 222 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $armor_left = $this->pool_armor % $this->randomized_armor; |
242 | 242 | // Проверка - не атакуем ли мы целый корабль |
243 | 243 | // Такое может быть, если на прошлой итерации поврежденный корабль был взорван и еще осталась входящяя атака |
244 | - if($shield_left == 0 && $armor_left == 0) { |
|
244 | + if ($shield_left == 0 && $armor_left == 0) { |
|
245 | 245 | $shield_left = $this->randomized_shield; |
246 | 246 | $armor_left = $this->randomized_armor; |
247 | 247 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | // Вычитаем этот дамадж из щитов пула |
256 | 256 | $this->pool_shield -= $damage_to_shield; |
257 | 257 | // Если весь дамадж был поглощён щитами - выходим |
258 | - if($this->attack_income <= 0) { |
|
258 | + if ($this->attack_income <= 0) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | 261 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $armor_left -= $damage_to_armor; |
273 | 273 | |
274 | 274 | // Проверяем - осталась ли броня на текущем корабле и вааще |
275 | - if($this->pool_armor <= 0 || $armor_left <= 0) { |
|
275 | + if ($this->pool_armor <= 0 || $armor_left <= 0) { |
|
276 | 276 | // Не осталось - корабль уничтожен |
277 | 277 | $this->adjustCount(-1); |
278 | 278 | |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | $armor_left_percent = $armor_left / $this->randomized_armor * 100; |
284 | 284 | // Проверяем % здоровья |
285 | 285 | // TODO - сделать динамический процент для каждого вида юнитов |
286 | - if($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) { |
|
286 | + if ($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) { |
|
287 | 287 | // Дамадж пошёл по структуре. Чем более поврежден юнит - тем больше шансов у него взорваться |
288 | 288 | $random = $is_simulator ? UBE_CRITICAL_DAMAGE_THRESHOLD / 2 : mt_rand(0, 100); |
289 | - if($random >= $armor_left_percent) { |
|
289 | + if ($random >= $armor_left_percent) { |
|
290 | 290 | $this->adjustCount(-1); |
291 | 291 | $this->unit_count_boom++; |
292 | 292 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | UBE_PLAYER_IS_DEFENDER => array(), |
56 | 56 | ); |
57 | 57 | |
58 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
58 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
59 | 59 | $result[$UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER][$player_id] = $UBEPlayer->getDbRow(); |
60 | 60 | } |
61 | 61 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function get_first_player_on_side($side) { |
72 | 72 | $result = null; |
73 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
74 | - if($UBEPlayer->getSide() == $side) { |
|
73 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
74 | + if ($UBEPlayer->getSide() == $side) { |
|
75 | 75 | $result = $UBEPlayer; |
76 | 76 | break; |
77 | 77 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function get_player_sides() { |
90 | 90 | $result = array(); |
91 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
91 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
92 | 92 | $result[$player_id] = $UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER; |
93 | 93 | } |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | public function ubeLoadPlayersAndSetSideFromFleetIdList(array $added_fleets, UBEFleetList $fleetList, $side = UBE_PLAYER_IS_DEFENDER) { |
99 | - foreach($added_fleets as $fleet_id) { |
|
99 | + foreach ($added_fleets as $fleet_id) { |
|
100 | 100 | $this->db_load_player_by_id($fleetList[$fleet_id]->owner_id, $side); |
101 | 101 | } |
102 | 102 | } |