/imperium.php
https://github.com/vem882/SuperNova · PHP · 185 lines · 140 code · 36 blank · 9 comment · 13 complexity · 33da680cf5d68b578aaf58a91a9ce61b MD5 · raw file
- <?php
- /**
- * imperium.php
- *
- * Overview you empire
- *
- * @version 1.0
- * @copyright 2008 by Chlorel for XNova
- // Created by Perberos. All rights reserved (C) 2006
- */
- $ugamela_root_path = (defined('SN_ROOT_PATH')) ? SN_ROOT_PATH : './';
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
- include("{$ugamela_root_path}common.{$phpEx}");
- if ($IsUserChecked == false) {
- includeLang('login');
- header('Location: login.php');
- }
- $planets = array();
- $ques = array();
- $planet_row_list = doquery("SELECT `id` FROM {{planets}} WHERE `id_owner` = '{$user['id']}';");
- while ($planet = mysql_fetch_assoc($planet_row_list))
- {
- $global_data = sys_o_get_updated($user, $planet['id'], $time_now, true);
- $planets[$planet['id']] = $global_data['planet'];
- $ques[$planet['id']] = $global_data['que'];
- }
- $template = gettemplate('imperium', true);
- $template->assign_var('amount', count($planets) + 2);
- $fleet_id = 1;
- $fleets = array();
- foreach ($planets as $planet_index => &$planet)
- {
- $list_planet_que = $ques[$planet_index];
- $planet_template = tpl_parse_planet($planet, $list_planet_que);
- $planet_fleet_id = 0;
- $fleet_list = $planet_template['fleet_list'];//flt_get_fleets_to_planet($planet);
- if($fleet_list['own']['count'])
- {
- $planet_fleet_id = "p{$fleet_id}";
- $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
- $fleet_id++;
- }
- $template->assign_block_vars('planet', array_merge($planet_template, array(
- 'PLANET_FLEET_ID' => $planet_fleet_id,
- 'FIELDS_CUR' => $planet['field_current'],
- 'FIELDS_MAX' => $planet['field_max'] + $planet[$sn_data[33]['name']] * 5,
- 'METAL_CUR' => pretty_number($planet['metal'], true, $planet['metal_max']),
- 'METAL_PROD' => pretty_number($planet['metal_perhour']),
- 'CRYSTAL_CUR' => pretty_number($planet['crystal'], true, $planet['crystal_max']),
- 'CRYSTAL_PROD' => pretty_number($planet['crystal_perhour']),
- 'DEUTERIUM_CUR' => pretty_number($planet['deuterium'], true, $planet['deuterium_max']),
- 'DEUTERIUM_PROD' => pretty_number($planet['deuterium_perhour']),
- 'ENERGY_CUR' => pretty_number($planet['energy_max'] - $planet['energy_used'], true, true),
- 'ENERGY_MAX' => pretty_number($planet['energy_max']),
- )));
- $planet['fleet_list'] = $planet_template['fleet_list'];
- $planet['BUILDING_ID'] = $planet_template['BUILDING_ID'];
- $planet['hangar_que'] = $planet_template['hangar_que'];
- $planet['full_que'] = $list_planet_que;
- $total['fields'] += $planet['field_current'];
- $total['metal'] += $planet['metal'];
- $total['crystal'] += $planet['crystal'];
- $total['deuterium'] += $planet['deuterium'];
- $total['energy'] += $planet['energy_max'] - $planet['energy_used'];
- $total['fields_max'] += $planet['field_max'] + $planet[$sn_data[33]['name']] * 5;
- $total['metal_perhour'] += $planet['metal_perhour'];
- $total['crystal_perhour'] += $planet['crystal_perhour'];
- $total['deuterium_perhour'] += $planet['deuterium_perhour'];
- $total['energy_max'] += $planet['energy_max'];
- }
- tpl_assign_fleet($template, $fleets);
- $template->assign_block_vars('planet', array_merge(array(
- 'NAME' => 'ÈÒÎÃÎ',
- 'FIELDS_CUR' => $total['fields'],
- 'FIELDS_MAX' => $total['fields_max'],
- 'METAL_CUR' => pretty_number($total['metal']),
- 'METAL_PROD' => pretty_number($total['metal_perhour']),
- 'CRYSTAL_CUR' => pretty_number($total['crystal']),
- 'CRYSTAL_PROD' => pretty_number($total['crystal_perhour']),
- 'DEUTERIUM_CUR' => pretty_number($total['deuterium']),
- 'DEUTERIUM_PROD' => pretty_number($total['deuterium_perhour']),
- 'ENERGY_CUR' => pretty_number($total['energy']),
- 'ENERGY_MAX' => pretty_number($total['energy_max']),
- )));
- unset($planet);
- $last = -1000;
- foreach ($sn_data as $unit_id => $res) {
- if (in_array($unit_id, $reslist['build']))
- $mode = 'buildings';
- elseif (in_array($unit_id, $reslist['fleet']))
- $mode = 'fleet';
- elseif (in_array($unit_id, $reslist['defense']))
- $mode = 'defense';
- else
- $mode = '';
- if($mode)
- {
- if((int) ($unit_id/100) != (int)($last/100))
- {
- $template->assign_block_vars('prods', array(
- 'NAME' => $lang['tech'][(int) ($unit_id/100)*100],
- ));
- }
- $template->assign_block_vars('prods', array(
- 'ID' => $unit_id,
- 'FIELD' => $resource[$unit_id],
- 'NAME' => $lang['tech'][$unit_id],
- 'MODE' => $mode,
- ));
- $unit_count = 0;
- foreach($planets as $planet)
- {
- $level_plus['LEVEL_PLUS_YELLOW'] = 0;
- $level_plus['LEVEL_PLUS_GREEN'] = 0;
- switch($mode)
- {
- case 'buildings':
- $level_plus_build = $planet['full_que']['in_que'][$unit_id];
- if($level_plus_build)
- {
- $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build<0 ? $level_plus_build : "+{$level_plus_build}";
- }
- break;
- case 'fleet':
- $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id]<=0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}";
- case 'defense':
- if($planet['hangar_que'][$unit_id])
- {
- $level_plus['LEVEL_PLUS_GREEN'] = "+{$planet['hangar_que'][$unit_id]}";
- }
- break;
- default:
- break;
- }
- $template->assign_block_vars('prods.planet', array_merge($level_plus, array(
- 'ID' => $planet['id'],
- 'TYPE' => $planet['planet_type'],
- 'LEVEL' => $planet[$resource[$unit_id]] == 0 && !$level_plus['LEVEL_PLUS_YELLOW'] && !$level_plus['LEVEL_PLUS_GREEN'] ? '-' : $planet[$resource[$unit_id]],
- )));
- $unit_count += $planet[$resource[$unit_id]];
- }
- $template->assign_block_vars('prods.planet', array(
- 'LEVEL' => $unit_count,
- ));
- $last = $unit_id;
- }
- }
- display(parsetemplate($template), $lang['imp_overview']);
- ?>