当前位置: 首页>>代码示例>>PHP>>正文


PHP get_unit_param函数代码示例

本文整理汇总了PHP中get_unit_param函数的典型用法代码示例。如果您正苦于以下问题:PHP get_unit_param函数的具体用法?PHP get_unit_param怎么用?PHP get_unit_param使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_unit_param函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sn_ube_simulator_fill_side

function sn_ube_simulator_fill_side(&$combat_data, $side_info, $attacker, $player_id = -1)
{
    global $ube_convert_techs;
    $player_id = $player_id == -1 ? count($combat_data[UBE_PLAYERS]) : $player_id;
    foreach ($side_info as $fleet_data) {
        $combat_data[UBE_PLAYERS][$player_id][UBE_NAME] = $attacker ? 'Attacker' : 'Defender';
        $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] = $attacker;
        $combat_data[UBE_FLEETS][$player_id][UBE_OWNER] = $player_id;
        foreach ($fleet_data as $unit_id => $unit_count) {
            if (!$unit_count) {
                continue;
            }
            $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
            if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
                $combat_data[UBE_FLEETS][$player_id][UBE_COUNT][$unit_id] = $unit_count;
            } elseif ($unit_type == UNIT_RESOURCES) {
                $combat_data[UBE_FLEETS][$player_id][UBE_RESOURCES][$unit_id] = $unit_count;
            } elseif ($unit_type == UNIT_TECHNOLOGIES) {
                $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_convert_techs[$unit_id]] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
            } elseif ($unit_type == UNIT_GOVERNORS) {
                if ($unit_id == MRC_FORTIFIER) {
                    foreach ($ube_convert_techs as $ube_id) {
                        $combat_data[UBE_FLEETS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
                    }
                }
            } elseif ($unit_type == UNIT_MERCENARIES) {
                if ($unit_id == MRC_ADMIRAL) {
                    foreach ($ube_convert_techs as $ube_id) {
                        $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100;
                    }
                }
            }
        }
    }
}
开发者ID:divyinfo,项目名称:SuperNova,代码行数:35,代码来源:coe_simulator_helpers.php

示例2: sn_admin_planet_edit_query_string

function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode)
{
    if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) {
        $unit_amount = round($unit_amount);
        $unit_name = get_unit_param($unit_id, P_NAME);
        $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))";
    } else {
        $result = '';
    }
    return $result;
}
开发者ID:divyinfo,项目名称:SuperNova,代码行数:11,代码来源:admin_planet_edit.inc.php

示例3: sn_techtree_view

function sn_techtree_view($template = null)
{
    global $lang, $user, $planetrow;
    $tech_tree = array();
    foreach (get_unit_param('techtree') as $unit_group_id => $unit_list) {
        $tech_tree[] = array('NAME' => $lang['tech'][$unit_group_id]);
        foreach ($unit_list as $unit_id) {
            $sn_data_unit = get_unit_param($unit_id);
            $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true);
            $unit_level = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id);
            $rendered_info = array('ID' => $unit_id, 'NAME' => $lang['tech'][$unit_id], 'LEVEL' => $unit_level, 'LEVEL_BASIC' => $level_basic, 'LEVEL_BONUS' => max(0, $unit_level - $level_basic), 'LEVEL_MAX' => $sn_data_unit['max']);
            $rendered_info['.']['require'] = unit_requirements_render($user, $planetrow, $unit_id);
            $tech_tree[] = $rendered_info;
        }
    }
    $template = gettemplate('techtree', $template);
    $template_result['.']['techtree'] = $tech_tree;
    $template->assign_recursive($template_result);
    return $template;
}
开发者ID:hayalolsam,项目名称:SuperNova,代码行数:20,代码来源:techtree.php

示例4: sn_techtree_view

function sn_techtree_view($template = null)
{
    global $lang, $user, $planetrow;
    $tech_tree = array();
    foreach (get_unit_param('techtree') as $unit_group_id => $unit_list) {
        $tech_tree[] = array('NAME' => $lang['tech'][$unit_group_id], 'GROUP_ID' => $unit_group_id);
        foreach ($unit_list as $unit_id) {
            $sn_data_unit = get_unit_param($unit_id);
            $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true);
            $unit_level = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id);
            $rendered_info = array('ID' => $unit_id, 'NAME' => $lang['tech'][$unit_id], 'LEVEL' => $unit_level, 'LEVEL_BASIC' => $level_basic, 'LEVEL_BONUS' => max(0, $unit_level - $level_basic), 'LEVEL_MAX' => $sn_data_unit['max']);
            $rendered_info['.']['require'] = unit_requirements_render($user, $planetrow, $unit_id);
            $rendered_info['.']['grants'] = unit_requirements_render($user, $planetrow, $unit_id, P_UNIT_GRANTS);
            $tech_tree[] = $rendered_info;
        }
    }
    $template = gettemplate('techtree', $template);
    $template_result['.']['techtree'] = $tech_tree;
    $template->assign_recursive($template_result);
    $template->assign_vars(array('PAGE_HEADER' => $lang['tech'][UNIT_TECHNOLOGIES], 'PLAYER_OPTION_TECH_TREE_TABLE' => classSupernova::$user_options[PLAYER_OPTION_TECH_TREE_TABLE]));
    return $template;
}
开发者ID:divyinfo,项目名称:SuperNova,代码行数:22,代码来源:techtree.php

示例5: tpl_planet_density_info

function tpl_planet_density_info(&$template, &$density_price_chart, $user_dark_matter)
{
    global $lang;
    $density_base_cost = get_unit_param(UNIT_PLANET_DENSITY, P_COST);
    $density_base_cost = $density_base_cost[RES_DARK_MATTER];
    foreach ($density_price_chart as $density_price_index => &$density_price_data) {
        $density_number_style = pretty_number($density_cost = $density_base_cost * $density_price_data, true, $user_dark_matter, false, false);
        $density_price_data = array('COST' => $density_cost, 'COST_TEXT' => $density_number_style['text'], 'COST_TEXT_CLASS' => $density_number_style['class'], 'REST' => $user_dark_matter - ceil($density_base_cost * $density_price_data), 'ID' => $density_price_index, 'TEXT' => $lang['uni_planet_density_types'][$density_price_index]);
        $template->assign_block_vars('densities', $density_price_data);
    }
}
开发者ID:hayalolsam,项目名称:SuperNova,代码行数:11,代码来源:template.php

示例6: db_planet_set_by_id

    }
    //  $SubQry = substr($SubQry, 0, -1);
    //  if($SubQry) {
    //    db_planet_set_by_id($planetrow['id'], $SubQry);
    //  }
    !empty($SubQry) ? db_planet_set_by_id($planetrow['id'], implode(',', $SubQry)) : false;
}
// -------------------------------------------------------------------------------------------------------
// $BuildTemp                   = $planetrow[ 'temp_max' ];
// $BuildEnergyTech             = $user['energy_tech'];
for ($Option = 10; $Option >= 0; $Option--) {
    $template->assign_block_vars('option', array('VALUE' => $Option * 10));
}
$caps_real = eco_get_planet_caps($user, $planetrow, 3600);
$template->assign_block_vars('production', array('TYPE' => $lang['res_basic_income'], 'METAL_TYPE' => pretty_number($caps_real['production'][RES_METAL][0], true, true), 'CRYSTAL_TYPE' => pretty_number($caps_real['production'][RES_CRYSTAL][0], true, true), 'DEUTERIUM_TYPE' => pretty_number($caps_real['production'][RES_DEUTERIUM][0], true, true), 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][0], true, true)));
foreach ($sn_group_factories as $unit_id) {
    if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) {
        $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true);
        $template->assign_block_vars('production', array('ID' => $unit_id, 'PERCENT' => $planetrow[pname_factory_production_field_name($unit_id)] * 10, 'TYPE' => $lang['tech'][$unit_id], 'LEVEL' => $level_plain, 'LEVEL_BONUS' => mrc_get_level($user, $planetrow, $unit_id) - $level_plain, 'LEVEL_TYPE' => $unit_id > 200 ? $lang['quantity'] : $lang['level'], 'METAL_TYPE' => pretty_number($caps_real['production'][RES_METAL][$unit_id], true, true), 'CRYSTAL_TYPE' => pretty_number($caps_real['production'][RES_CRYSTAL][$unit_id], true, true), 'DEUTERIUM_TYPE' => pretty_number($caps_real['production'][RES_DEUTERIUM][$unit_id], true, true), 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][$unit_id], true, true), 'METAL_FULL' => pretty_number($caps_real['production_full'][RES_METAL][$unit_id], true, true), 'CRYSTAL_FULL' => pretty_number($caps_real['production_full'][RES_CRYSTAL][$unit_id], true, true), 'DEUTERIUM_FULL' => pretty_number($caps_real['production_full'][RES_DEUTERIUM][$unit_id], true, true), 'ENERGY_FULL' => pretty_number($caps_real['production_full'][RES_ENERGY][$unit_id], true, true), 'SELECT' => $row_select, 'P_MINING_IS_MANAGED' => get_unit_param($unit_id, P_MINING_IS_MANAGED)));
    }
}
$user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER);
$planet_density_index = $planetrow['density_index'];
$density_price_chart = planet_density_price_chart($planetrow);
tpl_planet_density_info($template, $density_price_chart, $user_dark_matter);
$template->assign_block_vars('production', array('TYPE' => $lang['res_total'], 'METAL_TYPE' => pretty_number($caps_real['total'][RES_METAL], true, true), 'CRYSTAL_TYPE' => pretty_number($caps_real['total'][RES_CRYSTAL], true, true), 'DEUTERIUM_TYPE' => pretty_number($caps_real['total'][RES_DEUTERIUM], true, true), 'ENERGY_TYPE' => pretty_number($caps_real['total'][RES_ENERGY], true, true), 'METAL_FULL' => pretty_number($caps_real['total_production_full'][RES_METAL], true, true), 'CRYSTAL_FULL' => pretty_number($caps_real['total_production_full'][RES_CRYSTAL], true, true), 'DEUTERIUM_FULL' => pretty_number($caps_real['total_production_full'][RES_DEUTERIUM], true, true), 'ENERGY_FULL' => pretty_number($caps_real['total_production_full'][RES_ENERGY], true, true)));
int_calc_storage_bar(RES_METAL);
int_calc_storage_bar(RES_CRYSTAL);
int_calc_storage_bar(RES_DEUTERIUM);
$template->assign_vars(array('PLANET_NAME' => $planetrow['name'], 'PLANET_TYPE' => $planetrow['planet_type'], 'PLANET_DENSITY_INDEX' => $planet_density_index, 'PLANET_CORE_TEXT' => $lang['uni_planet_density_types'][$planet_density_index], 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), 'PAGE_HINT' => $lang['res_hint']));
display($template, $lang['res_planet_production']);
开发者ID:divyinfo,项目名称:SuperNova,代码行数:31,代码来源:resources.php

示例7: sn_db_transaction_rollback

            sn_db_transaction_rollback();
            break;
        case ACTION_USE:
            art_use($user, $planetrow, $unit_id);
            header("Location: artifacts.php#{$unit_id}");
            ob_end_flush();
            die;
            break;
    }
    message($Message, $lang['tech'][UNIT_ARTIFACTS], 'artifacts.' . PHP_EX, 5);
}
$template = gettemplate('artifacts', true);
foreach ($sn_group_artifacts as $artifact_id) {
    $artifact_level = mrc_get_level($user, array(), $artifact_id, true);
    $build_data = eco_get_build_data($user, $planetrow, $artifact_id, $artifact_level);
    $artifact_data = get_unit_param($artifact_id);
    $artifact_data_bonus = $artifact_data['bonus'];
    $artifact_data_bonus = $artifact_data_bonus >= 0 ? "+{$artifact_data_bonus}" : "{$artifact_data_bonus}";
    switch ($artifact_data['bonus_type']) {
        case BONUS_PERCENT:
            $artifact_data_bonus = "{$artifact_data_bonus}% ";
            break;
        case BONUS_ADD:
            break;
        case BONUS_ABILITY:
            $artifact_data_bonus = '';
            break;
        default:
            break;
    }
    $template->assign_block_vars('artifact', array('ID' => $artifact_id, 'NAME' => $lang['tech'][$artifact_id], 'DESCRIPTION' => $lang['info'][$artifact_id]['description'], 'EFFECT' => $lang['info'][$artifact_id]['effect'], 'COST' => $build_data[BUILD_CREATE][RES_DARK_MATTER], 'COST_TEXT' => pretty_number($build_data[BUILD_CREATE][RES_DARK_MATTER]), 'LEVEL' => intval($artifact_level), 'LEVEL_MAX' => intval($artifact_data['max']), 'BONUS' => $artifact_data_bonus, 'BONUS_TYPE' => $artifact_data['bonus_type'], 'CAN_BUY' => $build_data['CAN'][BUILD_CREATE]));
开发者ID:divyinfo,项目名称:SuperNova,代码行数:31,代码来源:artifacts.php

示例8: killer_add_planet

function killer_add_planet($planet)
{
    global $final_cost;
    $final_cost = array();
    $sn_group_resources_loot = sn_get_groups('resources_loot');
    /*
    foreach($sn_group_resources_loot as &$value)
    {
      $value = get_unit_param($value, P_NAME);
    }
    */
    foreach (sn_get_groups('structures') as $unit_id) {
        $build_level = mrc_get_level($user, $planet, $unit_id, true, true);
        if ($build_level > 0) {
            $unit_cost = get_unit_param($unit_id, 'cost');
            $build_factor = $unit_cost['factor'] != 1 ? (1 - pow($unit_cost['factor'], $build_level)) / (1 - $unit_cost['factor']) : $unit_cost['factor'];
            foreach ($sn_group_resources_loot as $resource_id) {
                $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $build_factor) : 0;
            }
        }
    }
    foreach (sn_get_groups(array('defense', 'fleet')) as $unit_id) {
        $unit_count = mrc_get_level($user, $planet, $unit_id, true, true);
        if ($unit_count > 0) {
            $unit_cost = get_unit_param($unit_id, 'cost');
            foreach ($sn_group_resources_loot as $resource_id) {
                $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $unit_count) : 0;
            }
        }
    }
    foreach ($sn_group_resources_loot as $resource_id) {
        $final_cost[$resource_id] += floor(mrc_get_level($user, $planet, $resource_id, true, true));
    }
}
开发者ID:divyinfo,项目名称:SuperNova,代码行数:34,代码来源:planet_compensate.php

示例9: sn_eco_build

function sn_eco_build($que_type, &$auser, &$planet)
{
    global $lang, $config;
    if ($ally_id = sys_get_param_id('ally_id')) {
        define('SN_IN_ALLY', true);
        $ranks = ally_get_ranks($auser['ally']);
        if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
            $user =& $auser['ally']['player'];
            $planet = array('metal' => $user['metal'], 'crystal' => $user['crystal'], 'deuterium' => $user['deuterium']);
        }
    }
    if (!$user) {
        $user =& $auser;
    }
    switch ($action = sys_get_param_escaped('action')) {
        case 'create':
            // Add unit to que for build
        // Add unit to que for build
        case 'destroy':
            // Add unit to que for remove
            $operation_result = que_build($user, $planet, $action == 'destroy' ? BUILD_DESTROY : BUILD_CREATE);
            break;
        case 'trim':
            que_delete($que_type, $user, $planet, false);
            break;
        case 'clear':
            que_delete($que_type, $user, $planet, true);
            break;
    }
    $group_missile = sn_get_groups('missile');
    $silo_capacity_free = 0;
    if ($que_type == QUE_STRUCTURES) {
        $build_unit_list = sn_get_groups('build_allow');
        $build_unit_list = $build_unit_list[$planet['planet_type']];
        $artifact_id = ART_NANO_BUILDER;
        $page_header = $lang['tech'][UNIT_STRUCTURES];
    } elseif ($que_type == QUE_RESEARCH) {
        if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
            message($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
        }
        if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
            message($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]);
        }
        $build_unit_list = sn_get_groups('tech');
        $artifact_id = ART_HEURISTIC_CHIP;
        $page_header = $lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : '');
    } elseif ($que_type == QUE_MERCENARY) {
        //    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
        //      message($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
        //    }
        //    if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
        //      message($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]);
        //    }
        $build_unit_list = sn_get_groups('mercenaries');
        $artifact_id = 0;
        $page_header = $lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : '');
    } else {
        if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
            message($lang['need_hangar'], $lang['tech'][STRUC_FACTORY_HANGAR]);
        }
        $build_unit_list = sn_get_groups($page_mode = $que_type == SUBQUE_FLEET ? 'fleet' : 'defense');
        $page_header = $lang[$page_mode];
        $artifact_id = 0;
        $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY);
        foreach ($group_missile as $unit_id) {
            $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE);
        }
        $silo_capacity_free = max(0, $silo_capacity_free);
    }
    // Caching values that used more then one time into local variables
    //  $config_resource_multiplier = $config->resource_multiplier;
    $config_resource_multiplier = game_resource_multiplier();
    /*
    // Code for fully working new que system
    $hangar_busy = count($que['que'][QUE_HANGAR]);
    $lab_busy    = count($que['que'][QUE_RESEARCH]) && !$config->BuildLabWhileRun;
    */
    $template = gettemplate('buildings_builds', true);
    if (!empty($operation_result)) {
        $template->assign_block_vars('result', $operation_result);
    }
    $planet_id = $que_type == QUE_RESEARCH || $que_type == QUE_MERCENARY ? 0 : $planet['id'];
    $ques = que_get($user['id'], $planet_id, $que_type);
    $in_que =& $ques['in_que'][$que_type][$user['id']][$planet_id];
    $que =& $ques['ques'][$que_type][$user['id']][$planet_id];
    que_tpl_parse($template, $que_type, $user, $planet, $que);
    $que_length = count($que);
    $can_que_element = $que_length < que_get_max_que_length($user, $planet, $que_type);
    $fleet_list = flt_get_fleets_to_planet($planet);
    $planet_fields_max = eco_planet_fields_max($planet);
    $planet_fields_current = $planet['field_current'];
    $planet_fields_que = is_array($in_que) ? -array_sum($in_que) : 0;
    $planet_fields_free = max(0, $planet_fields_max - $planet_fields_current + $planet_fields_que);
    $planet_fields_queable = $que_type != QUE_STRUCTURES || $planet_fields_free > 0;
    //$planet_temp_max       = $planet['temp_max'];
    $sn_modifiers_resource = sn_get_groups('modifiers');
    $sn_modifiers_resource = $sn_modifiers_resource[MODIFIER_RESOURCE_PRODUCTION];
    $sn_groups_density = sn_get_groups('planet_density');
    $density_info = $sn_groups_density[$planet['density_index']][UNIT_RESOURCES];
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
//.........这里部分代码省略.........
开发者ID:hayalolsam,项目名称:SuperNova,代码行数:101,代码来源:eco_bld_structures.php

示例10: tpl_parse_planet

function tpl_parse_planet($planet)
{
    global $lang;
    $fleet_list = flt_get_fleets_to_planet($planet);
    $que = que_get($planet['id_owner'], $planet['id'], false);
    $structure_que = tpl_parse_planet_que($que, $planet, QUE_STRUCTURES);
    // TODO Заменить на que_tpl_parse_element($que_element);
    $structure_que_first = is_array($structure_que['que']) ? reset($structure_que['que']) : array();
    $hangar_que = tpl_parse_planet_que($que, $planet, SUBQUE_FLEET);
    // TODO Заменить на que_tpl_parse_element($que_element);
    $hangar_que_first = is_array($hangar_que['que']) ? reset($hangar_que['que']) : array();
    $defense_que = tpl_parse_planet_que($que, $planet, SUBQUE_DEFENSE);
    // TODO Заменить на que_tpl_parse_element($que_element);
    $defense_que_first = is_array($defense_que['que']) ? reset($defense_que['que']) : array();
    $result = array('ID' => $planet['id'], 'NAME' => $planet['name'], 'IMAGE' => $planet['image'], 'GALAXY' => $planet['galaxy'], 'SYSTEM' => $planet['system'], 'PLANET' => $planet['planet'], 'TYPE' => $planet['planet_type'], 'COORDINATES' => uni_render_coordinates($planet), 'METAL_PERCENT' => $planet['metal_mine_porcent'] * 10, 'CRYSTAL_PERCENT' => $planet['crystal_mine_porcent'] * 10, 'DEUTERIUM_PERCENT' => $planet['deuterium_sintetizer_porcent'] * 10, 'STRUCTURE' => isset($structure_que_first['id']) ? $lang['tech'][$structure_que_first['id']] : '', 'HANGAR' => isset($hangar_que_first['id']) ? $lang['tech'][$hangar_que_first['id']] : '', 'hangar_que' => $hangar_que, 'DEFENSE' => isset($defense_que_first['id']) ? $lang['tech'][$defense_que_first['id']] : '', 'defense_que' => $defense_que, 'FIELDS_CUR' => $planet['field_current'], 'FIELDS_MAX' => eco_planet_fields_max($planet), 'FILL' => min(100, floor($planet['field_current'] / eco_planet_fields_max($planet) * 100)), 'FLEET_OWN' => $fleet_list['own']['count'], 'FLEET_ENEMY' => $fleet_list['enemy']['count'], 'FLEET_NEUTRAL' => $fleet_list['neutral']['count'], 'fleet_list' => $fleet_list, 'PLANET_GOVERNOR_ID' => $planet['PLANET_GOVERNOR_ID'], 'PLANET_GOVERNOR_NAME' => $lang['tech'][$planet['PLANET_GOVERNOR_ID']], 'PLANET_GOVERNOR_LEVEL' => $planet['PLANET_GOVERNOR_LEVEL'], 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK));
    if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) {
        $result['building_que'] = array();
        $building_que =& $que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']];
        foreach ($building_que as $que_element) {
            $result['building_que'][] = que_tpl_parse_element($que_element);
        }
    }
    return $result;
}
开发者ID:divyinfo,项目名称:SuperNova,代码行数:24,代码来源:tpl_helpers.php

示例11: sn_eco_can_build_unit

function sn_eco_can_build_unit($user, $planet, $unit_id, &$result)
{
    global $config;
    $result = isset($result) ? $result : BUILD_ALLOWED;
    $result = $result == BUILD_ALLOWED && eco_unit_busy($user, $planet, $unit_id) ? BUILD_UNIT_BUSY : $result;
    $unit_param = get_unit_param($unit_id);
    if ($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) {
        $requirement =& $unit_param[P_REQUIRE];
        if ($result == BUILD_ALLOWED && $requirement) {
            foreach ($requirement as $require_id => $require_level) {
                if (mrc_get_level($user, $planet, $require_id) < $require_level) {
                    $result = BUILD_REQUIRE_NOT_MEET;
                    break;
                }
            }
        }
    }
    return $result;
}
开发者ID:hayalolsam,项目名称:SuperNova,代码行数:19,代码来源:eco_get_build_data.php

示例12: sn_ube_combat_prepare_first_round

function sn_ube_combat_prepare_first_round(&$combat_data)
{
    global $ube_combat_bonus_list, $ube_convert_to_techs;
    // Готовим информацию для первого раунда - проводим все нужные вычисления из исходных данных
    $first_round_data = array();
    foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) {
        $fleet_info[UBE_COUNT] = is_array($fleet_info[UBE_COUNT]) ? $fleet_info[UBE_COUNT] : array();
        $player_data =& $combat_data[UBE_PLAYERS][$fleet_info[UBE_OWNER]];
        $fleet_info[UBE_FLEET_TYPE] = $player_data[UBE_ATTACKER] ? UBE_ATTACKERS : UBE_DEFENDERS;
        foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value) {
            // Вычисляем бонус игрока
            $bonus_value = isset($player_data[UBE_BONUSES][$bonus_id]) ? $player_data[UBE_BONUSES][$bonus_id] : 0;
            // Добавляем к бонусам флота бонусы игрока
            $fleet_info[UBE_BONUSES][$bonus_id] += $bonus_value;
        }
        $first_round_data[$fleet_id][UBE_COUNT] = $fleet_info[UBE_PRICE] = array();
        foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) {
            if ($unit_count <= 0) {
                continue;
            }
            $unit_info = get_unit_param($unit_id);
            // Заполняем информацию о кораблях в информации флота
            foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value) {
                $fleet_info[$bonus_id][$unit_id] = floor($unit_info[$ube_convert_to_techs[$bonus_id]] * (1 + $fleet_info[UBE_BONUSES][$bonus_id]));
            }
            $fleet_info[UBE_AMPLIFY][$unit_id] = $unit_info[P_AMPLIFY];
            // TODO: Переделать через get_ship_data()
            $fleet_info[UBE_CAPACITY][$unit_id] = $unit_info[P_CAPACITY];
            $fleet_info[UBE_TYPE][$unit_id] = $unit_info[P_UNIT_TYPE];
            // TODO: Переделать через список ресурсов
            $fleet_info[UBE_PRICE][RES_METAL][$unit_id] = $unit_info[P_COST][RES_METAL];
            $fleet_info[UBE_PRICE][RES_CRYSTAL][$unit_id] = $unit_info[P_COST][RES_CRYSTAL];
            $fleet_info[UBE_PRICE][RES_DEUTERIUM][$unit_id] = $unit_info[P_COST][RES_DEUTERIUM];
            $fleet_info[UBE_PRICE][RES_DARK_MATTER][$unit_id] = $unit_info[P_COST][RES_DARK_MATTER];
            // Копируем её в информацию о первом раунде
            $first_round_data[$fleet_id][UBE_ARMOR][$unit_id] = $fleet_info[UBE_ARMOR][$unit_id] * $unit_count;
            $first_round_data[$fleet_id][UBE_COUNT][$unit_id] = $unit_count;
            $first_round_data[$fleet_id][UBE_ARMOR_REST][$unit_id] = $fleet_info[UBE_ARMOR][$unit_id];
            $first_round_data[$fleet_id][UBE_SHIELD_REST][$unit_id] = $fleet_info[UBE_SHIELD][$unit_id];
        }
    }
    $combat_data[UBE_ROUNDS][0][UBE_FLEETS] = $first_round_data;
    $combat_data[UBE_ROUNDS][1][UBE_FLEETS] = $first_round_data;
    sn_ube_combat_round_prepare($combat_data, 0);
}
开发者ID:hayalolsam,项目名称:SuperNova,代码行数:45,代码来源:ube_attack_calculate.php

示例13: flt_mission_recycle

/**
 * MissionCaseRecycling.php
 *
 * @version 1.0
 * @copyright 2008 By Chlorel for XNova
 */
function flt_mission_recycle(&$mission_data)
{
    $fleet_row =& $mission_data['fleet'];
    $destination_planet =& $mission_data['dst_planet'];
    if (!$fleet_row) {
        return CACHE_NOTHING;
    }
    if (!isset($destination_planet['id'])) {
        // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
        flt_send_back($mission_data['fleet']);
        return CACHE_FLEET;
    }
    global $lang;
    $RecyclerCapacity = 0;
    $OtherFleetCapacity = 0;
    $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']);
    foreach ($fleet_array as $unit_id => $unit_count) {
        if (in_array($unit_id, sn_get_groups('fleet'))) {
            $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count;
            if (in_array($unit_id, sn_get_groups('flt_recyclers'))) {
                $RecyclerCapacity += $capacity;
            } else {
                $OtherFleetCapacity += $capacity;
            }
        }
    }
    $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"];
    if ($IncomingFleetGoods > $OtherFleetCapacity) {
        $RecyclerCapacity -= $IncomingFleetGoods - $OtherFleetCapacity;
    }
    if ($destination_planet["debris_metal"] + $destination_planet["debris_crystal"] <= $RecyclerCapacity) {
        $RecycledGoods["metal"] = $destination_planet["debris_metal"];
        $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
    } else {
        if ($destination_planet["debris_metal"] > $RecyclerCapacity / 2 and $destination_planet["debris_crystal"] > $RecyclerCapacity / 2) {
            $RecycledGoods["metal"] = $RecyclerCapacity / 2;
            $RecycledGoods["crystal"] = $RecyclerCapacity / 2;
        } else {
            if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
                $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
                if ($destination_planet["debris_metal"] > $RecyclerCapacity - $RecycledGoods["crystal"]) {
                    $RecycledGoods["metal"] = $RecyclerCapacity - $RecycledGoods["crystal"];
                } else {
                    $RecycledGoods["metal"] = $destination_planet["debris_metal"];
                }
            } else {
                $RecycledGoods["metal"] = $destination_planet["debris_metal"];
                if ($destination_planet["debris_crystal"] > $RecyclerCapacity - $RecycledGoods["metal"]) {
                    $RecycledGoods["crystal"] = $RecyclerCapacity - $RecycledGoods["metal"];
                } else {
                    $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
                }
            }
        }
    }
    $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"];
    $NewCargo['Crystal'] = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"];
    $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"];
    db_planet_set_by_gspt($fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], PT_PLANET, "`debris_metal` = `debris_metal` - '{$RecycledGoods['metal']}', `debris_crystal` = `debris_crystal` - '{$RecycledGoods['crystal']}'");
    $Message = sprintf($lang['sys_recy_gotten'], pretty_number($RecycledGoods["metal"]), $lang['Metal'], pretty_number($RecycledGoods["crystal"]), $lang['Crystal']);
    msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message);
    $QryUpdateFleet = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' ";
    $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;";
    doquery($QryUpdateFleet);
    return CACHE_FLEET | CACHE_PLANET_DST;
}
开发者ID:divyinfo,项目名称:SuperNova,代码行数:72,代码来源:flt_mission_recycle.php

示例14: while

     while ($user_row = db_fetch($user_query)) {
         foreach ($sn_group_tech as $tech_id) {
             if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) {
                 $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
             }
         }
     }
     if (!empty($que_lines)) {
         upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines));
     }
     upd_alter_table('users', array("DROP COLUMN `graviton_tech`"), $update_tables['users']['graviton_tech']);
 }
 if (!$update_indexes['unit']['I_unit_record_search']) {
     upd_alter_table('unit', array("ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)"), !$update_indexes['unit']['I_unit_record_search']);
     foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) {
         $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
     }
     $drop_index = array();
     $create_index =& $drop_index;
     // array();
     foreach ($planet_units as $unit_name => $unit_create) {
         if ($update_indexes['planets']['I_' . $unit_name]) {
             $drop_index[] = "DROP KEY I_{$unit_name}";
         }
         if ($update_indexes['planets']['i_' . $unit_name]) {
             $drop_index[] = "DROP KEY i_{$unit_name}";
         }
         if ($unit_create) {
             $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
         }
     }
开发者ID:divyinfo,项目名称:SuperNova,代码行数:31,代码来源:update_old.php

示例15: sn_sn_powerup_get_price_matrix

function sn_sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false, &$result)
{
    global $sn_powerup_buy_discounts;
    $result = array();
    $powerup_data = get_unit_param($powerup_id);
    //pdump($powerup_data, '$powerup_data');
    $is_upgrade = !empty($powerup_unit) && $powerup_unit;
    // pdump($powerup_unit, '$powerup_unit');
    $level_current = $term_original = $time_left = 0;
    if ($is_upgrade) {
        $time_finish = strtotime($powerup_unit['unit_time_finish']);
        $time_left = max(0, $time_finish - SN_TIME_NOW);
        if ($time_left > 0) {
            $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']);
            $level_current = $powerup_unit['unit_level'];
        }
    }
    $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK];
    $original_cost = 0;
    for ($i = 1; $i <= $level_max; $i++) {
        $base_cost = eco_get_total_cost($powerup_id, $i);
        $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER];
        foreach ($sn_powerup_buy_discounts as $period => $discount) {
            $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH);
            $result[$i][$period] = $upgrade_price;
            $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost;
        }
    }
    if ($is_upgrade && $time_left) {
        $term_original = round($term_original / PERIOD_DAY);
        $time_left = min(floor($time_left / PERIOD_DAY), $term_original);
        $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0;
        array_walk_recursive($result, function (&$value) use($cost_left) {
            $value -= $cost_left;
        });
    }
    return $result;
}
开发者ID:hayalolsam,项目名称:SuperNova,代码行数:38,代码来源:general.php


注:本文中的get_unit_param函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。