1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* techtree.php |
5
|
|
|
* |
6
|
|
|
* version 2.0 copyright (c) 2012 by Gorlum for http://supernova.ws |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
function sn_techtree_view($template = null) |
10
|
|
|
{ |
11
|
|
|
global $lang, $user, $planetrow; |
12
|
|
|
|
13
|
|
|
$tech_tree = array(); |
14
|
|
|
foreach(get_unit_param('techtree') as $unit_group_id => $unit_list) |
15
|
|
|
{ |
16
|
|
|
$tech_tree[] = array( |
17
|
|
|
'NAME' => $lang['tech'][$unit_group_id], |
18
|
|
|
'GROUP_ID' => $unit_group_id, |
19
|
|
|
); |
20
|
|
|
|
21
|
|
|
foreach($unit_list as $unit_id) |
22
|
|
|
{ |
23
|
|
|
$sn_data_unit = get_unit_param($unit_id); |
24
|
|
|
$level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true); |
25
|
|
|
$unit_level = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id); |
26
|
|
|
$rendered_info = array( |
27
|
|
|
'ID' => $unit_id, |
28
|
|
|
'NAME' => $lang['tech'][$unit_id], |
29
|
|
|
'LEVEL' => $unit_level, |
30
|
|
|
'LEVEL_BASIC' => $level_basic, |
31
|
|
|
'LEVEL_BONUS' => max(0, $unit_level - $level_basic), |
32
|
|
|
'LEVEL_MAX' => $sn_data_unit['max'], |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
$rendered_info['.'][TPL_BLOCK_REQUIRE] = unit_requirements_render($user, $planetrow, $unit_id); |
36
|
|
|
$rendered_info['.']['grants'] = unit_requirements_render($user, $planetrow, $unit_id, P_UNIT_GRANTS); |
37
|
|
|
|
38
|
|
|
$tech_tree[] = $rendered_info; |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$template = SnTemplate::gettemplate('techtree', $template); |
43
|
|
|
$template_result['.']['techtree'] = $tech_tree; |
|
|
|
|
44
|
|
|
$template->assign_recursive($template_result); |
45
|
|
|
|
46
|
|
|
$template->assign_vars(array( |
47
|
|
|
'PAGE_HEADER' => $lang['tech'][UNIT_TECHNOLOGIES], |
48
|
|
|
'PLAYER_OPTION_TECH_TREE_TABLE' => SN::$user_options[PLAYER_OPTION_TECH_TREE_TABLE], |
49
|
|
|
)); |
50
|
|
|
|
51
|
|
|
return $template; |
52
|
|
|
} |
53
|
|
|
|