public function get_suit_config() { $configs = Cache_ItemFlag::getInstance()->get_item_flag_info(); $out = array(); if ($configs) { $arr_type = array(); foreach ($configs as $key => $val) { if ($val['type'] == 'quality' && $val['equip_type'] == 1) { $type = 1; } elseif ($val['type'] == 'strength' && $val['equip_type'] == 1) { $type = 2; } elseif ($val['type'] == 'inlay' && $val['equip_type'] == 1) { $type = 3; } elseif ($val['type'] == 'quality' && $val['equip_type'] == 2) { $type = 4; } elseif ($val['type'] == 'strength' && $val['equip_type'] == 2) { $type = 5; } else { $type = 0; } $arr_type[$type]['type'] = $type; $arr_type[$type]['name'] = $val['type_name']; $arr_type[$type]['propertys'][] = $key; } foreach ($arr_type as $val) { $tmp = array('type' => $val['type'], 'name' => $val['name'], 'propertys' => array()); foreach ($val['propertys'] as $key) { $item = $configs[$key]; $flag = explode(":", $item['flag']); $arr_condition = explode("|", $item['condition']); $arr_cd = array(); foreach ($arr_condition as $con) { if (!empty($con)) { $ctmp = explode(":", $con); $arr_cd[] = array('key' => Cache_ItemKey::getInstance()->get_item_key($ctmp[0]), 'value' => $ctmp[1]); } } $attr = json_decode($item['attr'], true); $arr_attr = array(); foreach ($attr as $k => $v) { $arr_attr[] = array('key' => Cache_RoleKey::getInstance()->get_item_key($k), 'val' => $v['val']); } $tmp['propertys'][] = array('id' => $item['sid'], 'name' => $item['name'], 'num' => $flag[1], 'condition' => $arr_cd, 'attr' => $arr_attr); } $out[0][] = $tmp; } } return $out; }
/** * 道具属性结构体 * @param $data * @return array */ public static function get_item_additions(&$data) { $attr_index = Cache_ItemKey::getInstance()->get_item_key(); $role_index = Cache_RoleKey::getInstance()->get_item_key(); // echo "sub_type:".$data['sub_type']."<br>"; $out = array(); $arr_other = array(); $fpower_calc = array(); $fpower_base_calc = array(); if ($data['type'] == 1 || $data['type'] == 6) { if (empty($data['player_prop_id'])) { // $attrData = Cache_EquipBaseAttr::getInstance()->get_equip_base_attr($data['sub_type'],$data['quality'],$data['level'],$data['star_level']); $obj = new Game_Prop(); $attrData = $obj->get_equip_attr($data); unset($obj); // Com_Log::log($attrData,'cache_prop',1); $data['base_attr'] = $attrData['base_attr']; $data['addition_attr'] = $attrData['addition_attr']; $data['base_attr'] = $attrData['base_attr']; $data['level'] = $attrData['level']; $data['intensive_level'] = $attrData['intensive_level']; $data['intensive_desc'] = $attrData['intensive_desc']; } # ---------------------------------------------------------------- # 星图加成信息 # ---------------------------------------------------------------- $star_map = array(); $we_swallow_revise_info = array(); if (!empty($data['star_map_desc'])) { if (is_string($data['star_map_desc'])) { $data['star_map_desc'] = json_decode($data['star_map_desc'], true); } $star_map = self::parse_star_map($data['star_map_desc']); } # ---------------------------------------------------------------- # 基础属性 # ---------------------------------------------------------------- if (!empty($data['base_attr'])) { if (is_string($data['base_attr'])) { $data['base_attr'] = json_decode($data['base_attr'], true); } list($key, $val) = each($data['base_attr']); //基础属性 就一个 # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_base_calc[$key] += $val; # ---------------------------------------------------------------- # 强化属性加成 # ---------------------------------------------------------------- if (!empty($data['intensive_desc'])) { if (is_string($data['intensive_desc'])) { $data['intensive_desc'] = json_decode($data['intensive_desc'], true); } list($i_key, $i_val) = each($data['intensive_desc']); //强化属性 if ($i_key == 'atk' || $i_key == 'atk_max') { $i_key = 'atk_min'; } if (isset($star_map['intensify'])) { $i_val += ceil($i_val * ($star_map['intensify'] / 10000)); //星图加成 } $fpower_calc[$i_key] += $i_val; } $fpower_calc[$key] += $val; $out[] = array(0 => intval($attr_index['equip_base_val']), 1 => array(0 => $role_index[$key], 1 => ceil($val), 2 => 0, 3 => $i_val)); } # ---------------------------------------------------------------- # 附加属性 # ---------------------------------------------------------------- if (!empty($data['addition_attr']) && is_array($data['addition_attr'])) { $out_additional = array(); foreach ($data['addition_attr'] as $key => $val) { # -------------------------------------------------------- # 翅膀装备吞噬属性加成 # -------------------------------------------------------- if (!empty($data['we_swallow_info']) && is_array($data['we_swallow_info']['swallow_attr'])) { if (isset($data['we_swallow_info']['swallow_attr'][$key])) { $add_val = $data['we_swallow_info']['swallow_attr'][$key]; if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_calc[$key] += $add_val; } } # -------------------------------------------------------- # 星图加成 # -------------------------------------------------------- if (isset($star_map['additional'])) { $val += $val * ($star_map['additional'] / 10000); } # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_base_calc[$key] += $val; if (in_array($key, Cache_AttrConfig::getInstance()->get_percent_key())) { $show_type = 1; //前端显示百分比 } else { $show_type = 0; } $out_additional[] = array(0 => $role_index[$key], 1 => ceil($val), 2 => $show_type, 3 => ceil($add_val), 'sort_priority' => self::$_sort_priority[$key]); $fpower_calc[$key] += $val; } # 排序 Com_Array::multisort($out_additional, array('sort_priority' => 'asc')); unset($out_additional['sort_priority']); $out[] = array(0 => $attr_index['equip_additional'], 1 => $out_additional); } # ---------------------------------------------------------------- # 洗练属性 # ---------------------------------------------------------------- if ($data['type'] == 1) { # 只有装备类才获取 if (empty($data['refine_attr']) || empty($data['refine_info'])) { # 为空显示默认洗练属性 if (!Com_Util::is_first_charge_item($data['prop_id'])) { list($data['refine_attr'], $data['refine_info']) = TenYear::getInstance('Game_EquipRefine')->extend_refine($data['sub_type'], $data['level']); } } if (!empty($data['refine_attr']) && is_array($data['refine_attr'])) { $out_refine = array(); $attr_perfection_sum = 0; $attr_progress_sum = 0; foreach ($data['refine_attr'] as $attr_seq => $attr_info) { # -------------------------------------------------------- # 注意,这两项的取值必须在key做转换之前,否则在key转换后可能导致取不到值 # -------------------------------------------------------- $attr_limit = $data['refine_info']['attr_info'][$attr_seq]['refine_attr_value'] + $data['refine_info']['attr_info'][$attr_seq]['attr_stint']; $attr_ratio = $data['refine_info']['attr_info'][$attr_seq]['attr_ratio']; $attr_progress = ceil($data['refine_info']['attr_info'][$attr_seq]['en_refine_attr_value'] / $data['refine_info']['attr_info'][$attr_seq]['attr_stint'] * 10000); # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if (!is_array($attr_info)) { continue; } # TODO: 为了兼容旧的洗练数据,以后要清档上功能,可以除去这行 list($key, $val) = each($attr_info); if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_base_calc[$key] += $val; $fpower_calc[$key] += $val; $out_refine[] = array(0 => $role_index[$key], 1 => ceil($val), 2 => 0, 3 => $attr_limit, 'sort_priority' => self::$_sort_priority[$key]); $attr_perfection_sum += $attr_ratio; $attr_progress_sum += $attr_progress; } # 排序 Com_Array::multisort($out_refine, array('sort_priority' => 'asc')); unset($out_refine['sort_priority']); $out[] = array(0 => $attr_index['equip_refine'], 1 => $out_refine); $out[] = array(0 => $attr_index['equip_refine_perfection'], 1 => ceil($attr_perfection_sum / 5)); $out[] = array(0 => $attr_index['equip_en_refine_progress'], 1 => ceil($attr_progress_sum / $data['refine_info']['last_refine_type'])); } } #策划要一个道具的基础属性战力 $fpower_base = Formula_Fpower::calc_fpower($fpower_base_calc); $out[] = array(0 => intval($attr_index['raw_fpower']), 1 => $fpower_base); # ---------------------------------------------------------------- # 强化等级 # ---------------------------------------------------------------- if (!empty($data['intensive_level'])) { $out[] = array(0 => $attr_index['intensive_level'], 1 => $data['intensive_level']); } # ---------------------------------------------------------------- # 最大强化等级 # ---------------------------------------------------------------- if ($data['type'] == 1) { # 只有装备类才获取 $intensify_lv_limit = TenYear::getInstance('Game_EquipIntensifier')->get_intensify_lv_limit_by_item_level($data['level']); $out[] = array(0 => $attr_index['intensify_max'], 1 => $intensify_lv_limit); } # ---------------------------------------------------------------- # 强化属性 # ---------------------------------------------------------------- if (!empty($data['intensive_desc'])) { if (is_string($data['intensive_desc'])) { $data['intensive_desc'] = json_decode($data['intensive_desc'], true); } $val = 0; list($key, $val) = each($data['intensive_desc']); //强化属性 # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } if (isset($star_map['intensify'])) { $val += ceil($val * ($star_map['intensify'] / 10000)); //星图加成 } $fpower_calc[$key] += $val; $out[] = array(0 => $attr_index['equip_strengthen_val'], 1 => $val); } # ---------------------------------------------------------------- # 翅膀装备吞噬等级与经验 # ---------------------------------------------------------------- if ($data['type'] == 6) { # 只有翅膀装备类才获取 if (!empty($data['we_swallow_info'])) { $out[] = array(0 => $attr_index['wing_equip_swallow_lv'], 1 => $data['we_swallow_info']['swallow_lv']); $out[] = array(0 => $attr_index['wing_equip_swallow_exp'], 1 => $data['we_swallow_info']['swallow_exp']); } else { $out[] = array(0 => $attr_index['wing_equip_swallow_lv'], 1 => 0); $out[] = array(0 => $attr_index['wing_equip_swallow_exp'], 1 => 0); } } # ---------------------------------------------------------------- # 镶嵌宝石属性 # ---------------------------------------------------------------- $gem_item = array(); $gem_configs = array(); $hole_stint = TenYear::getInstance('Game_EquipInlayGems')->get_prop_inlay_gem_hole_stint($data); # 孔位上限 for ($i = 1; $i <= $hole_stint; $i++) { //镶嵌部分 if (!empty($data['inlay_gems'][$i])) { $gem_id = $data['inlay_gems'][$i]; if (!isset($gem_configs[$gem_id])) { $gem_configs[$gem_id] = Cache_Forge::getInstance()->get_inlay_gems_by_id($gem_id); } $attr = self::parse_gem_config_attr($gem_configs[$gem_id]); $out_additional = array(); $gem_fpower = 0; if (!empty($attr)) { foreach ($attr as $key => $val) { if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } if (isset($star_map['gem'])) { $val += ceil($val * ($star_map['gem'] / 10000)); //星图加成 } /** if(in_array($key,Cache_AttrConfig::getInstance()->get_percent_key())){ $show_type = 1; //前端显示百分比 } else{ $show_type = 0; } **/ if (isset($role_index[$key])) { $fpower_calc[$key] += $val; $out_additional[] = array(0 => $role_index[$key], 1 => intval($val)); } } $gem_fpower += Formula_Fpower::calc_fpower($attr); } $gem_item[] = array(0 => $i, 1 => self::get_prop_struct($gem_configs[$gem_id]), 2 => $gem_fpower, 3 => $out_additional); //0 sid 1 战力 2 属性 } else { $gem_item[] = array(0 => $i, 1 => array(), 2 => 0, 3 => array()); //0 sid 1 战力 2 属性 } } $out[] = array(0 => $attr_index['gem'], 1 => $gem_item); //星图属性 if (isset($data['star_map_id']) && $data['star_map_id'] > 0) { $star_attr = array(); $star_map_config = Cache_Prop::getInstance()->get_prop_info($data['star_map_id']); $star_attr['star'] = self::get_prop_struct($star_map_config); $star_attr['power'] = 0; //战力计算 $star_attr['property'] = array(); $star_map_info = Cache_Forge::getInstance()->get_star_map_config_byid($data['star_map_id']); if ($star_map_info) { foreach ($star_map_info as $k => $v) { $a = array(); $a['addition_type'] = self::$_star_map_attr_enum[$v['data']]; #$a['addition_key'] = $v['data']; $a['addition_val'] = $v['data_value']; if (isset($attr_index[$k])) { // if(!isset($attr_index[$k])){ // Com_Log::log($k,'addition',1); // } $a['condition_type'] = 0; $a['condition_key'] = array('k' => $attr_index[$k], 'v' => $v['limit_value'], 'per' => 0); } else { if ($k == 'inlay_gems_lv') { $a['condition_type'] = 1; } elseif ($k == 'inlay_gems') { $a['condition_type'] = 2; } elseif ($k == 'activate') { $a['condition_type'] = 3; } $a['condition_key'] = array('k' => 0, 'v' => $v['limit_value'], 'per' => 0); } $star_attr['property'][] = $a; } } $out[] = array(0 => $attr_index['star'], 1 => $star_attr); } # ---------------------------------------------------------------- # 吞噬属性:需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充 # ---------------------------------------------------------------- list($allow_swallow_sub_type, $allow_swallow_id) = TenYear::getInstance('Game_EquipSwallow')->get_swallow_restriction_info($data['sub_type']); $distinct_swallow_list = Cache_Forge::getInstance()->get_distinct_swallow_list(); foreach ($distinct_swallow_list as $swallow_info) { if (!empty($allow_swallow_id) && !in_array($swallow_info['swallow_id'], $allow_swallow_id)) { continue; } $swallow[$swallow_info['swallow_id']] = array('swallow_id' => $swallow_info['swallow_id'], 'swallow_lv' => 0, 'swallow_exp' => 0); } if (!empty($data['swallow_info'])) { foreach ($data['swallow_info'] as $swallow_id => $swallow_info) { $swallow[$swallow_id] = array('id' => $swallow_info['swallow_id'], 'lv' => $swallow_info['swallow_lv'], 'value' => $swallow_info['swallow_exp']); } } $out[] = array(0 => $attr_index['swallow'], 1 => $swallow); if (!empty($data['equip_view'])) { if (is_string($data['equip_view'])) { $equip_view = $data['equip_view']; } else { $equip_view = implode(':', $data['equip_view']); } if ($equip_view == '0:0:0:0' || $equip_view == '0:0:0') { $equip_view = ''; } } $out[] = array(0 => $attr_index['equip_view'], 1 => $equip_view); if (!empty($fpower_calc)) { // Com_Log::log('============[start]===========','equip_fpower',1); // Com_Log::log("prop_id:{$data['prop_id']}",'equip_fpower',1); // Com_Log::log($fpower_calc,'equip_fpower',1); $data['fpower'] = Formula_Fpower::calc_fpower($fpower_calc); // Com_Log::log("fpower:{$data['fpower']}",'equip_fpower',1); // Com_Log::log('============[end]===========','equip_fpower',1); } else { $data['fpower'] = 0; } } foreach (self::$_out_base_keys as $key) { if ($key == 'bind_type') { #特殊处理下 if (isset($attr_index[$key]) && isset($data['bind_flag'])) { $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data['bind_flag'])); } } elseif ($key == 'star_level') { if ($data['star_level'] > 10) { $data['star_level'] = $data['show_star']; } $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data['star_level'])); } else { if (isset($attr_index[$key]) && isset($data[$key]) && !empty($data[$key])) { $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data[$key])); } } } return $out; }