supernova-ws /
SuperNova
| 1 | <?php |
||
| 2 | |||
| 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
| 4 | |||
| 5 | if (sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG')) { |
||
| 6 | define('BE_DEBUG', true); |
||
| 7 | } |
||
| 8 | |||
| 9 | require_once("includes/includes/ube_attack_calculate.php"); |
||
| 10 | require_once('includes/includes/coe_simulator_helpers.php'); |
||
| 11 | |||
| 12 | $replay = $_GET['replay'] ? $_GET['replay'] : $_POST['replay']; |
||
| 13 | $execute = intval($_GET['execute']); |
||
| 14 | $sym_defender = $_POST['defender'] ? $_POST['defender'] : array(); |
||
| 15 | $sym_attacker = $_POST['attacker'] ? $_POST['attacker'] : array(); |
||
| 16 | |||
| 17 | if ($replay) { |
||
| 18 | $unpacked = sn_ube_simulator_decode_replay($replay); |
||
| 19 | |||
| 20 | $sym_defender = $unpacked['D']; |
||
| 21 | $sym_attacker = $unpacked['A']; |
||
| 22 | } else { |
||
| 23 | $sym_defender = array(0 => $sym_defender); |
||
| 24 | $sym_attacker = array(1 => $sym_attacker); |
||
| 25 | } |
||
| 26 | |||
| 27 | if ($_POST['submit'] || $execute) { |
||
| 28 | $replay = sn_ube_simulator_encode_replay($sym_defender, 'D'); |
||
| 29 | $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A'); |
||
| 30 | |||
| 31 | $ubePrepare = new \Ube\Ube4_1\Ube4_1Prepare(); |
||
| 32 | $combat_data = $ubePrepare->sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender); |
||
| 33 | |||
| 34 | $combat_data[UBE_OPTIONS][UBE_METHOD] = SN::$config->game_ube_method ? SN::$config->game_ube_method : 0; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 35 | $ubeCalc = new \Ube\Ube4_1\Ube4_1Calc(); |
||
| 36 | $ubeCalc->sn_ube_combat($combat_data); |
||
| 37 | // Это используется для тестов - отключено в стандартном режиме |
||
| 38 | // if(!sys_get_param_int('simulator') || sys_get_param_str('reload')) { |
||
| 39 | // sn_ube_report_save($combat_data); |
||
| 40 | // } |
||
| 41 | |||
| 42 | if (sys_get_param_str('reload')) { |
||
| 43 | $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
||
| 44 | } |
||
| 45 | |||
| 46 | //debug($combat_data); |
||
| 47 | // Рендерим их в темплейт |
||
| 48 | sn_ube_report_generate($combat_data, $template_result); |
||
| 49 | |||
| 50 | $template_result['MICROTIME'] = $combat_data[UBE_TIME_SPENT]; |
||
| 51 | |||
| 52 | $template = SnTemplate::gettemplate('ube_combat_report', true); |
||
| 53 | $template->assign_recursive($template_result); |
||
| 54 | |||
| 55 | $template->assign_vars(array( |
||
| 56 | 'MENU' => false, |
||
| 57 | 'NAVBAR' => false, |
||
| 58 | )); |
||
| 59 | |||
| 60 | SnTemplate::display($template); |
||
| 61 | } else { |
||
| 62 | $template = SnTemplate::gettemplate('simulator', true); |
||
| 63 | $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL); |
||
| 64 | |||
| 65 | foreach ($techs_and_officers as $tech_id) { |
||
| 66 | if (!$sym_attacker[1][$tech_id]) { |
||
| 67 | $sym_attacker[1][$tech_id] = mrc_get_level($user, false, $tech_id); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | $show_groups = array( |
||
| 72 | UNIT_TECHNOLOGIES => array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), |
||
| 73 | UNIT_MERCENARIES => array(MRC_ADMIRAL), |
||
| 74 | UNIT_SHIPS => sn_get_groups('fleet'), |
||
| 75 | UNIT_RESOURCES => sn_get_groups('resources_loot'), |
||
| 76 | UNIT_GOVERNORS => array(MRC_FORTIFIER), |
||
| 77 | UNIT_DEFENCE => sn_get_groups('defense_active'), |
||
| 78 | ); |
||
| 79 | foreach ($show_groups as $unit_group_id => $unit_group) { |
||
| 80 | $template->assign_block_vars('simulator', array( |
||
| 81 | 'GROUP' => $unit_group_id, |
||
| 82 | 'NAME' => $lang['tech'][$unit_group_id], |
||
| 83 | )); |
||
| 84 | |||
| 85 | foreach ($unit_group as $unit_id) { |
||
| 86 | $tab++; |
||
| 87 | |||
| 88 | $value = mrc_get_level($user, $planetrow, $unit_id); |
||
| 89 | |||
| 90 | $template->assign_block_vars('simulator', array( |
||
| 91 | 'NUM' => $tab < 9 ? "0{$tab}" : $tab, |
||
| 92 | 'ID' => $unit_id, |
||
| 93 | 'GROUP' => $unit_group_id, |
||
| 94 | 'NAME' => $lang['tech'][$unit_id], |
||
| 95 | 'ATTACKER' => intval($sym_attacker[1][$unit_id]), |
||
| 96 | 'DEFENDER' => intval($sym_defender[0][$unit_id]), |
||
| 97 | 'VALUE' => $value, |
||
| 98 | )); |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | $template->assign_vars(array( |
||
| 103 | 'BE_DEBUG' => BE_DEBUG, |
||
| 104 | 'UNIT_DEFENCE' => UNIT_DEFENCE, |
||
| 105 | 'UNIT_GOVERNORS' => UNIT_GOVERNORS, |
||
| 106 | )); |
||
| 107 | |||
| 108 | $template->assign_vars(array( |
||
| 109 | 'NAVBAR' => false, |
||
| 110 | )); |
||
| 111 | SnTemplate::display($template, $lang['coe_combatSimulator']); |
||
| 112 | } |
||
| 113 |