Passed
Push — trunk ( 72cafa...79712a )
by SuperNova.WS
03:36
created
Labels
Severity
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 (!$unit_id || (!get_unit_param($unit_id) && !isset($lang['info'][$unit_id]))) {
20
  sys_redirect('index.php?page=techtree');
21
}
22
23
$template = gettemplate('novapedia', true);
0 ignored issues
show
true of type true is incompatible with the type null|template expected by parameter $template of gettemplate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
$template = gettemplate('novapedia', /** @scrutinizer ignore-type */ true);
Loading history...
24
25
$unit_data = get_unit_param($unit_id);
26
$unit_type = $unit_data['type'];
27
28
if ($unit_type == UNIT_SHIPS) {
29
  $template_result['UNIT_IS_SHIP'] = true;
30
31
  $ship_data = get_ship_data($unit_id, $user);
32
33
  $template_result += array(
34
    'BASE_SPEED'         => HelperString::numberFloorAndFormat($ship_data['speed_base']),
35
    'ACTUAL_SPEED'       => HelperString::numberFloorAndFormat($ship_data['speed']),
36
    'BASE_CONSUMPTION'   => HelperString::numberFloorAndFormat($ship_data['consumption_base']),
37
    'ACTUAL_CONSUMPTION' => HelperString::numberFloorAndFormat($ship_data['consumption']),
38
39
    'BASE_CAPACITY'   => HelperString::numberFloorAndFormat($unit_data['capacity']),
40
    'ACTUAL_CAPACITY' => HelperString::numberFloorAndFormat($ship_data['capacity']),
41
  );
42
43
  $engine_template_info = array();
44
  foreach ($unit_data['engine'] as $unit_engine_data) {
45
    $unit_engine_data = get_engine_data($user, $unit_engine_data);
46
47
    $engine_template_info[] = array(
48
      'NAME'               => $lang['tech'][$unit_engine_data['tech']],
49
      'MIN_LEVEL'          => $unit_engine_data['min_level'],
50
      'USER_TECH_LEVEL'    => mrc_get_level($user, null, $unit_engine_data['tech']),
51
      'BASE_SPEED'         => HelperString::numberFloorAndFormat($unit_engine_data['speed_base']),
52
      'BASE_CONSUMPTION'   => HelperString::numberFloorAndFormat($unit_engine_data['consumption_base']),
53
      'ACTUAL_SPEED'       => HelperString::numberFloorAndFormat($unit_engine_data['speed']),
54
      'ACTUAL_CONSUMPTION' => HelperString::numberFloorAndFormat($unit_engine_data['consumption']),
55
    );
56
  }
57
  $template_result['.']['engine'] = $engine_template_info;
58
59
}
60
61
62
$sn_data_group_combat = sn_get_groups('combat');
63
if (in_array($unit_id, $sn_data_group_combat)) {
64
  $template_result['UNIT_IS_COMBAT'] = true;
65
66
  $unit_durability = $unit_data['shield'] + $unit_data['armor'];
67
68
  $volley_arr = $rapid_to = $rapid_from = array();
69
  $str_rapid_from = '';
70
  $str_rapid_to = '';
71
  foreach ($sn_data_group_combat as $enemy_id) {
72
    $enemy_data = get_unit_param($enemy_id);
73
    $enemy_durability = $enemy_data['shield'] + $enemy_data['armor'];
74
75
    $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability;
76
    if ($rapid >= 1) {
77
      $volley_arr[$enemy_id]['TO'] = floor($rapid);
78
    }
79
80
    $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability;
81
    if ($rapid >= 1) {
82
      $volley_arr[$enemy_id]['FROM'] = floor($rapid);
83
    }
84
  }
85
  foreach ($volley_arr as $enemy_id => &$rapid) {
86
    $rapid['ENEMY_ID'] = $enemy_id;
87
    $rapid['ENEMY_NAME'] = $lang['tech'][$enemy_id];
88
  }
89
  $template_result['.']['volley'] = $volley_arr;
90
91
  $template_result += array(
92
    'BASE_ARMOR'  => HelperString::numberFloorAndFormat($unit_data['armor']),
93
    'BASE_SHIELD' => HelperString::numberFloorAndFormat($unit_data['shield']),
94
    'BASE_WEAPON' => HelperString::numberFloorAndFormat($unit_data['attack']),
95
96
    'ACTUAL_ARMOR'  => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_data['armor'])),
97
    'ACTUAL_SHIELD' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_data['shield'])),
98
    'ACTUAL_WEAPON' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_data['attack'])),
99
  );
100
101
}
102
103
if ($lang['info'][$unit_id]['effect']) {
104
  $template_result['UNIT_EFFECT'] = $lang['info'][$unit_id]['effect'];
105
}
106
107
if ($unit_data[P_BONUS_VALUE]) {
108
  $unit_bonus = !$unit_data[P_BONUS_VALUE] || $unit_data[P_BONUS_TYPE] == BONUS_ABILITY ? '' : (
109
    ($unit_data[P_BONUS_VALUE] >= 0 ? '+' : '') . $unit_data[P_BONUS_VALUE] . ($unit_data[P_BONUS_TYPE] == BONUS_PERCENT ? '%' : '')
110
  );
111
  $template_result['UNIT_BONUS'] = $unit_bonus;
112
}
113
114
$template_result += array(
115
  'PAGE_HEADER' => $lang['wiki_title'],
116
117
  'UNIT_ID'          => $unit_id,
118
  'UNIT_NAME'        => $lang['tech'][$unit_id],
119
  'UNIT_TYPE'        => $unit_type,
120
  'UNIT_TYPE_NAME'   => $lang['tech'][$unit_type],
121
  'UNIT_DESCRIPTION' => $lang['info'][$unit_id]['description'],
122
);
123
124
$template_result['.']['require'] = unit_requirements_render($user, $planetrow, $unit_id);
125
126
$template->assign_recursive($template_result);
127
display($template);
128