1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @copyright Copyright (c) 2009-2017 by Gorlum for http://supernova.ws |
||
5 | */ |
||
6 | |||
7 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
8 | |||
9 | $unit_id = sys_get_param_id('gid'); |
||
10 | if ($unit_id == RES_DARK_MATTER) { |
||
11 | sys_redirect('dark_matter.php'); |
||
12 | } |
||
13 | |||
14 | if ($unit_id == RES_METAMATTER) { |
||
15 | sys_redirect('metamatter.php'); |
||
16 | } |
||
17 | |||
18 | lng_include('infos'); |
||
19 | if ( |
||
20 | !$unit_id |
||
21 | || |
||
22 | (!get_unit_param($unit_id) && !isset($lang['info'][$unit_id]) && !$unit_id == UNIT_CAN_NOT_BE_BUILD) |
||
23 | ) { |
||
24 | sys_redirect('index.php?page=techtree'); |
||
25 | } |
||
26 | |||
27 | $template = SnTemplate::gettemplate('novapedia', true); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
28 | |||
29 | $unit_data = get_unit_param($unit_id); |
||
30 | $unit_type = $unit_data['type']; |
||
31 | |||
32 | if ($unit_type == UNIT_SHIPS) { |
||
33 | $template_result['UNIT_IS_SHIP'] = true; |
||
34 | |||
35 | $ship_data = get_ship_data($unit_id, $user); |
||
36 | |||
37 | $template_result += array( |
||
38 | 'BASE_SPEED' => HelperString::numberFloorAndFormat($ship_data['speed_base']), |
||
39 | 'ACTUAL_SPEED' => HelperString::numberFloorAndFormat($ship_data['speed']), |
||
40 | 'BASE_CONSUMPTION' => HelperString::numberFloorAndFormat($ship_data['consumption_base']), |
||
41 | 'ACTUAL_CONSUMPTION' => HelperString::numberFloorAndFormat($ship_data['consumption']), |
||
42 | |||
43 | 'BASE_CAPACITY' => HelperString::numberFloorAndFormat($unit_data['capacity']), |
||
44 | 'ACTUAL_CAPACITY' => HelperString::numberFloorAndFormat($ship_data['capacity']), |
||
45 | ); |
||
46 | |||
47 | $engine_template_info = array(); |
||
48 | foreach ($unit_data['engine'] as $unit_engine_data) { |
||
49 | $unit_engine_data = get_engine_data($user, $unit_engine_data); |
||
50 | |||
51 | $engine_template_info[] = array( |
||
52 | 'NAME' => $lang['tech'][$unit_engine_data['tech']], |
||
53 | 'MIN_LEVEL' => $unit_engine_data['min_level'], |
||
54 | 'USER_TECH_LEVEL' => mrc_get_level($user, null, $unit_engine_data['tech']), |
||
55 | 'BASE_SPEED' => HelperString::numberFloorAndFormat($unit_engine_data['speed_base']), |
||
56 | 'BASE_CONSUMPTION' => HelperString::numberFloorAndFormat($unit_engine_data['consumption_base']), |
||
57 | 'ACTUAL_SPEED' => HelperString::numberFloorAndFormat($unit_engine_data['speed']), |
||
58 | 'ACTUAL_CONSUMPTION' => HelperString::numberFloorAndFormat($unit_engine_data['consumption']), |
||
59 | ); |
||
60 | } |
||
61 | $template_result['.']['engine'] = $engine_template_info; |
||
62 | |||
63 | } |
||
64 | |||
65 | |||
66 | $sn_data_group_combat = sn_get_groups('combat'); |
||
67 | if (in_array($unit_id, $sn_data_group_combat)) { |
||
68 | $template_result['UNIT_IS_COMBAT'] = true; |
||
69 | |||
70 | $unit_durability = $unit_data['shield'] + $unit_data['armor']; |
||
71 | |||
72 | $volley_arr = $rapid_to = $rapid_from = array(); |
||
73 | $str_rapid_from = ''; |
||
74 | $str_rapid_to = ''; |
||
75 | foreach ($sn_data_group_combat as $enemy_id) { |
||
76 | $enemy_data = get_unit_param($enemy_id); |
||
77 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
||
78 | |||
79 | $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability; |
||
80 | if ($rapid >= 1) { |
||
81 | $volley_arr[$enemy_id]['TO'] = floor($rapid); |
||
82 | } |
||
83 | |||
84 | $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability; |
||
85 | if ($rapid >= 1) { |
||
86 | $volley_arr[$enemy_id]['FROM'] = floor($rapid); |
||
87 | } |
||
88 | } |
||
89 | foreach ($volley_arr as $enemy_id => &$rapid) { |
||
90 | $rapid['ENEMY_ID'] = $enemy_id; |
||
91 | $rapid['ENEMY_NAME'] = $lang['tech'][$enemy_id]; |
||
92 | } |
||
93 | $template_result['.']['volley'] = $volley_arr; |
||
94 | |||
95 | $template_result += array( |
||
96 | 'BASE_ARMOR' => HelperString::numberFloorAndFormat($unit_data['armor']), |
||
97 | 'BASE_SHIELD' => HelperString::numberFloorAndFormat($unit_data['shield']), |
||
98 | 'BASE_WEAPON' => HelperString::numberFloorAndFormat($unit_data['attack']), |
||
99 | |||
100 | 'ACTUAL_ARMOR' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_data['armor'])), |
||
101 | 'ACTUAL_SHIELD' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_data['shield'])), |
||
102 | 'ACTUAL_WEAPON' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_data['attack'])), |
||
103 | ); |
||
104 | |||
105 | } |
||
106 | |||
107 | if ($lang['info'][$unit_id]['effect']) { |
||
108 | $template_result['UNIT_EFFECT'] = $lang['info'][$unit_id]['effect']; |
||
109 | } |
||
110 | |||
111 | if ($unit_data[P_BONUS_VALUE]) { |
||
112 | $unit_bonus = !$unit_data[P_BONUS_VALUE] || $unit_data[P_BONUS_TYPE] == BONUS_ABILITY ? '' : ( |
||
113 | ($unit_data[P_BONUS_VALUE] >= 0 ? '+' : '') . $unit_data[P_BONUS_VALUE] . ($unit_data[P_BONUS_TYPE] == BONUS_PERCENT ? '%' : '') |
||
114 | ); |
||
115 | $template_result['UNIT_BONUS'] = $unit_bonus; |
||
116 | } |
||
117 | |||
118 | $template_result += array( |
||
119 | 'PAGE_HEADER' => $lang['wiki_title'], |
||
120 | |||
121 | 'UNIT_ID' => $unit_id, |
||
122 | 'UNIT_NAME' => $lang['tech'][$unit_id], |
||
123 | 'UNIT_TYPE' => $unit_type, |
||
124 | 'UNIT_TYPE_NAME' => $lang['tech'][$unit_type], |
||
125 | 'UNIT_DESCRIPTION' => $lang['info'][$unit_id]['description'], |
||
126 | |||
127 | 'UNIT_IMAGE_LARGE' => SN::$gc->skinModel->isImageFileExists($unit_id . '_large'), |
||
128 | ); |
||
129 | |||
130 | $template_result['.'][TPL_BLOCK_REQUIRE] = unit_requirements_render($user, $planetrow, $unit_id); |
||
131 | |||
132 | $template->assign_recursive($template_result); |
||
133 | SnTemplate::display($template); |
||
134 |