public function run() { $item = Cache_ItemFlag::getInstance()->get_item_flag_info(); if (!empty($item)) { $str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $str .= "<equip_flag>\n"; foreach ($item as $val) { $str .= "<type value=\"{$val['type']}\" name=\"{$val['type_name']}\" >\n"; $str .= " <step id=\"{$val['sid']}\" flag=\"{$val['flag']}\" condition=\"{$val['condition']}\" name=\"全套紫色装备\">\n"; $attr = json_decode($val['flag_attr'], true); foreach ($attr as $key => $v) { $str .= " <reward key=\"{$key}\" value=\"{$v['val']}\" per=\"{$v['per']}\"/>\n"; } $str .= " </step>\n"; $str .= "</type>\n"; } $str .= "</equip_flag>"; } header("Content-Type: text/xml"); header("Content-Disposition: attachment;filename=\"equip_flag.xml\""); header("Cache-Control: max-age=0"); echo $str; }
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 $player_id * @return mixed */ public function equip_attr($player_id) { $get_field = Protocol_Player::get_player_attr_detail_key(); $get_field[] = 'skill_starmap_info'; $get_field[] = 'skill_info'; $get_field[] = 'skill_rune_info'; $get_field[] = 'dower_info'; $get_field[] = 'fashion_fit'; $get_field[] = 'player_settings'; $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, $get_field); # 需要将星图对技能的加成信息初始化为空后,再重新计算身上装备的星图对技能的加成信息,否则,skill_starmap_info只增不减 # 即每次重新计算身上装备的属性时,都重新计算skill_starmap_info $player_detail['skill_starmap_info'] = array(); $equip_lists = $this->get_game('Prop')->get_player_equip($player_id); $arr_equip_attr = array(); $equip_skill = array(); $equip_swallow = array(); if (!empty($equip_lists)) { $equip_suit_quality = array(); $equip_suit_strength = array(); $equip_suit_star = array(); $equip_suit_inlay = 0; $equip_level = array(); foreach ($equip_lists as $equip) { if ($equip['grid'] < 10) { $equip_level[$equip['level']] += 1; $equip_suit_quality[$equip['quality']] += 1; if ($equip['intensive_level']) { $equip_suit_strength[$equip['intensive_level']] += 1; } $equip_suit_star[$equip['star_level']] += 1; } if (is_string($equip['base_attr'])) { $base_attr = json_decode($equip['base_attr'], true); } else { $base_attr = $equip['base_attr']; } $star_map = array(); if (!empty($equip['star_map_desc'])) { if (is_string($equip['star_map_desc'])) { $equip['star_map_desc'] = json_decode($equip['star_map_desc'], true); } $star_map = Struct_Prop::parse_star_map($equip['star_map_desc']); # 星图觉醒技能信息更新到player_detail表的skill_starmap_info中 if (!empty($equip['career_type']) && !empty($star_map['skill'])) { foreach ($star_map['skill'] as $career_type => $skill_info) { if ($equip['career_type'] != $career_type) { continue; } $player_detail['skill_starmap_info'][$skill_info['skill_id']] += $skill_info['skill_level']; } } } # 吞噬属性 if (!empty($equip['swallow_info']) && is_array($equip['swallow_info'])) { foreach ($equip['swallow_info'] as $swallow_id => $swallow_info) { $swallow_config = Cache_Forge::getInstance()->get_swallow_config($swallow_id, $swallow_info['swallow_lv']); $equip_swallow[$swallow_id] += intval($swallow_config['swallow_param']); } } if (!empty($base_attr)) { //计算基础属性 foreach ($base_attr as $key => $val) { $val += $val * (intval($star_map['equip_attr']) / 100); //星图加成 if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') { $arr_equip_attr['atk_min'] += $val; } else { $arr_equip_attr[$key] += $val; } } } if (intval($equip['addition_attr']) > 0) { foreach ($equip['addition_attr'] as $key => $val) { if (isset($star_map['additional'])) { $val += ceil($val * ($star_map['additional'] / 10000)); //星图加成 } if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') { $arr_equip_attr['atk_min'] += $val; } else { $arr_equip_attr[$key] += $val; } } } # ------------------------------------------------------------ # 洗练属性处理 # ------------------------------------------------------------ if (!empty($equip['refine_attr'])) { foreach ($equip['refine_attr'] as $attr_seq => $attr_info) { if (!is_array($attr_info)) { continue; } # TODO: 为了兼容旧的洗练数据,以后要清档上功能,可以除去这行 list($key, $val) = each($attr_info); # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $arr_equip_attr[$key] += $val; } } if (is_string($equip['intensive_desc'])) { $intensive_desc = json_decode($equip['intensive_desc'], true); } else { $intensive_desc = $equip['intensive_desc']; } if (!empty($intensive_desc)) { foreach ($intensive_desc as $key => $val) { $val += $val * (intval($star_map['intensify']) / 10000); //星图加成 if ($key == 'atk' || $key == 'atk_min' || $key == 'atk_max') { $arr_equip_attr['atk_min'] += $val; } else { $arr_equip_attr[$key] += $val; } } } $gem_configs = array(); if (is_string($equip['inlay_gems'])) { $inlay_gems = json_decode($equip['intensive_desc'], true); } else { $inlay_gems = $equip['inlay_gems']; } if (!empty($inlay_gems)) { foreach ($inlay_gems as $gem_id) { if (!isset($gem_configs[$gem_id])) { $gem_configs[$gem_id] = Cache_Forge::getInstance()->get_inlay_gems_by_id($gem_id); } if ($equip['grid'] < 10) { $equip_suit_inlay += $gem_configs[$gem_id]['lv']; } $attr = Struct_Prop::parse_gem_config_attr($gem_configs[$gem_id]); if (!empty($attr)) { foreach ($attr as $key => $val) { if ($key == 'atk' || $key == 'atk_min' || $key == 'atk_max') { $arr_equip_attr['atk_min'] += $val; } else { $arr_equip_attr[$key] += $val; } } } } } } //套装加成 $item_flags = Cache_ItemFlag::getInstance()->get_item_flag_info(1); $level_count = count($equip_level); if (!empty($item_flags)) { $flags_addition = array(); foreach ($item_flags as $flag) { if ($flag['type'] == 'quality') { $conditions = explode("|", $flag['condition']); $fnum = explode(":", $flag['flag']); $add_flag = 0; foreach ($conditions as $c) { $condition = explode(":", $c); if ($condition[0] == 'quality' && $this->get_conditions_num($equip_suit_quality, $condition[1]) >= $fnum[1]) { $add_flag += 1; } if ($condition[0] == 'level' && $this->get_conditions_num($equip_level, $condition[1]) >= $fnum[1]) { $add_flag += 1; } if ($condition[0] == 'star' && $this->get_conditions_num($equip_suit_star, $condition[1]) >= $fnum[1]) { $add_flag += 1; } } if (count($conditions) == $add_flag) { $flag_attr = json_decode($flag['attr'], true); $flags_addition['quality'] = $flag_attr; # 改同一类型覆盖了 // Com_Log::write('equip_flags.'.$player_id,"quality_flag_attr:".var_export($flag_attr,true)); // foreach($flag_attr as $key=>$val){ // $arr_equip_attr[$key] += $val['val']; // } } } elseif ($flag['type'] == 'strength') { $conditions = explode("|", $flag['condition']); $fnum = explode(":", $flag['flag']); $add_flag = 0; foreach ($conditions as $c) { $condition = explode(":", $c); if ($condition[0] == 'intensive_level' && $this->get_conditions_num($equip_suit_strength, $condition[1]) >= $fnum[1]) { $add_flag += 1; } } if (count($conditions) == $add_flag) { $flag_attr = json_decode($flag['attr'], true); $flags_addition['strength'] = $flag_attr; // Com_Log::write('equip_flags.'.$player_id,"strength_flag_attr:".var_export($flag_attr,true)); // foreach($flag_attr as $key=>$val){ // $arr_equip_attr[$key] += $val['val']; // } } } elseif ($flag['type'] == 'inlay') { $fnum = explode(":", $flag['flag']); if ($equip_suit_inlay >= $fnum[1]) { $flag_attr = json_decode($flag['attr'], true); $flags_addition['inlay'] = $flag_attr; // Com_Log::write('equip_flags.'.$player_id,"inlay_flag_attr:".var_export($flag_attr,true)); // foreach($flag_attr as $key=>$val){ // $arr_equip_attr[$key] += $val['val']; // } } } } } if (!empty($flags_addition)) { foreach ($flags_addition as $flag_attr) { foreach ($flag_attr as $key => $val) { $arr_equip_attr[$key] += $val['val']; } } } } $equip_model = array(); for ($i = 0; $i < 10; $i++) { if (isset($equip_lists[$i])) { if (!empty($equip_lists[$i]['equip_view'])) { if (is_string($equip_lists[$i]['equip_view'])) { $equip_model[$i] = $equip_lists[$i]['equip_view']; } else { $equip_model[$i] = implode(':', $equip_lists[$i]['equip_view']); //先这样 不想清理数据了 下次清理完数据改了 } if ($equip_model[$i] == '0:0:0:0' || $equip_model[$i] == '0:0:0') { $equip_model[$i] = ''; } } else { $equip_model[$i] = ''; } } } $player_detail['equip_attr'] = $arr_equip_attr; $player_detail['skill_starmap_info'] = $player_detail['skill_starmap_info']; $result = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('equip_attr' => $arr_equip_attr, 'skill_starmap_info' => $player_detail['skill_starmap_info'])); if ($result) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level')); //同步人物属性 $arr_part_update['attr'] = ''; $arr_part_update['player_data'] = array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])); $arr_part_update['equip_skill'] = $equip_skill; $arr_part_update['equip_model'] = $equip_model; $arr_part_update['equip_swallow'] = $equip_swallow; $arr_part_update['skill_infos'] = ''; Protocol_Player::p2c_part_update($player_id, $arr_part_update); } return $result; }
/** * @Purpose: * 更新翅膀装备属性 * @Param $wing_equipment_list 装备在翅膀上的装备列表 */ public function get_wing_equip_attr($wing_equipment_list) { $rtn_attr = array(); if (!empty($wing_equipment_list) && Com_Array::is_good_arr($wing_equipment_list)) { $equip_level = array(); $equip_quality = array(); $equip_intensify = array(); $equip_star = array(); foreach ($wing_equipment_list as $equip) { #品质,等级,强化等级,星级计数 $equip_level[$equip['level']] += 1; $equip_quality[$equip['quality']] += 1; if ($equip['intensive_level']) { $equip_intensify[$equip['intensive_level']] += 1; } $equip_star[$equip['star_level']] += 1; #计算基础属性 $equip['base_attr'] = Com_FmtData::cus_json_decode($equip['base_attr']); if (!empty($equip['base_attr']) && Com_Array::is_good_arr($equip['base_attr'])) { foreach ($equip['base_attr'] as $key => $val) { if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') { $rtn_attr['atk_min'] += ceil($val); } else { $rtn_attr[$key] += ceil($val); } } } #计算附加属性 $equip['addition_attr'] = Com_FmtData::cus_json_decode($equip['addition_attr']); if (!empty($equip['addition_attr']) && Com_Array::is_good_arr($equip['addition_attr'])) { foreach ($equip['addition_attr'] as $key => $val) { if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') { $rtn_attr['atk_min'] += ceil($val); } else { $rtn_attr[$key] += ceil($val); } } } #计算强化属性 $equip['intensive_desc'] = Com_FmtData::cus_json_decode($equip['intensive_desc']); if (!empty($equip['intensive_desc']) && Com_Array::is_good_arr($equip['intensive_desc'])) { foreach ($equip['intensive_desc'] as $key => $val) { if ($key == 'atk' || $key == 'atk_min' || $key == 'atk_max') { $rtn_attr['atk_min'] += ceil($val); } else { $rtn_attr[$key] += ceil($val); } } } # 计算吞噬属性 if (!empty($equip['we_swallow_info']) && is_array($equip['we_swallow_info'])) { foreach ($equip['we_swallow_info']['swallow_attr'] as $key => $val) { if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $rtn_attr[$key] += ceil($val); } } } #套装加成 $flags_attr = array(); $item_flags = Cache_ItemFlag::getInstance()->get_item_flag_info(2); if (!empty($item_flags) && Com_Array::is_good_arr($item_flags)) { foreach ($item_flags as $flag) { if ($flag['type'] == 'quality') { $conditions = explode("|", $flag['condition']); $fnum = explode(":", $flag['flag']); $add_flag = 0; foreach ($conditions as $c) { $condition = explode(":", $c); if ($condition[0] == 'quality' && $this->get_conditions_num($equip_quality, $condition[1]) >= $fnum[1]) { $add_flag += 1; } if ($condition[0] == 'level' && $this->get_conditions_num($equip_level, $condition[1]) >= $fnum[1]) { $add_flag += 1; } if ($condition[0] == 'star' && $this->get_conditions_num($equip_star, $condition[1]) >= $fnum[1]) { $add_flag += 1; } } if (count($conditions) == $add_flag) { $flag_attr = json_decode($flag['attr'], true); $flags_attr['quality'] = $flag_attr; } } elseif ($flag['type'] == 'strength') { $conditions = explode("|", $flag['condition']); $fnum = explode(":", $flag['flag']); $add_flag = 0; foreach ($conditions as $c) { $condition = explode(":", $c); if ($condition[0] == 'intensive_level' && $this->get_conditions_num($equip_intensify, $condition[1]) >= $fnum[1]) { $add_flag += 1; } } if (count($conditions) == $add_flag) { $flag_attr = json_decode($flag['attr'], true); $flags_attr['intensify'] = $flag_attr; } } } } #计算套装加成属性 if (!empty($flags_attr) && Com_Array::is_good_arr($flags_attr)) { foreach ($flags_attr as $flag_attr) { foreach ($flag_attr as $key => $val) { $rtn_attr[$key] += ceil($val['val']); } } } } return $rtn_attr; }