public function fix_hero_fit_data() { $player_ids = array(363, 120, 443, 6715, 14732, 354, 6144, 2242, 1165, 66868, 190, 11616, 65210, 4192, 6253, 14187, 136, 2874, 2258, 15272, 10760, 3059, 68758, 2003, 634, 3175, 5810, 3790, 65974, 221, 132, 93, 411, 3434, 55, 65738, 3508, 13260, 69386, 68686, 11935, 11655, 19, 1024, 3427, 3217, 72420, 2974); $union_attr = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'union_hero_attr'); foreach ($player_ids as $player_id) { $hero_list = $this->get_data('PlayerHero')->get_player_hero_list($player_id); foreach ($hero_list as $hero_id => $hero_info) { $hero_info = Com_FmtData::cus_json_decode($hero_info); if (!empty($hero_info) && $hero_info['fit'] > 4) { $attr_table = $this->get_game('Hero')->get_hero_attr_table($hero_info['hero_code']); if (!empty($attr_table)) { $skill_data = $this->get_game('Hero')->create_hero_skill_data($attr_table); $hero_info['skill_list'] = $skill_data; $hero_info['fit'] = 0; $hero_info['fit_life'] = 0; $hero_info['fit_attack'] = 0; $hero_info['fit_def'] = 0; $hero_info['fit_grow'] = 0; $hero_info['fit_attr_per'] = ''; $hero_info['fit_other_attr'] = ''; $hero_info['fit_expend_record'] = ''; $hero_info['fight'] = $this->get_game('Hero')->calc_fight($hero_info['player_id'], $hero_info, $hero_info['fit'], $hero_info['rune_hole_list'], $hero_info['star_add_attr_per'], $hero_info['skill_list'], $union_attr); $this->start_trans(); $update_field = array('fight', 'skill_list', 'fit', 'fit_life', 'fit_attack', 'fit_def', 'fit_grow', 'fit_attr_per', 'fit_other_attr', 'fit_expend_record'); //更新redis,sql数据 $update_res = $this->get_game('Hero')->update_db($player_id, $update_field, $hero_info, 519); if (!$update_res) { echo '10104' . '|' . $hero_id; exit; } $this->commit(); } } } Protocol_Player::p2c_part_update($player_id, array('hero_info' => array())); } }
public function get_award($level, $quality, $task_id) { $award_config = Cache_TaskRandomAward::getInstance()->get_task_random_award($task_id); if ($award_config) { $award = ''; foreach ($award_config as $val) { if ($level >= $val['lvl_min'] && $level <= $val['lvl_max']) { $award = $val['task_award']; break; } } if (!empty($award)) { $addition_config = Cache_TaskRandomAwardAdd::getInstance()->get_task_random_award_add($quality); $award = Com_FmtData::format_table_prop($award); foreach ($award as $key => $val) { $val['num'] = $val['num'] * $addition_config['quality_add']; $award[$key] = $val; } return $award; } } return array(); }
/** * @Purpose: * 获取fb_list字段数据 * @param $used_day_times 已使用的日次数 * @param $add_day_times 已增加的日次数 * @param $map_vip_table map_vip配置表 * @param $player_info 玩家信息(必须包含'level', 'vip', 'career_type') */ private function get_fb_list_field($player_id, $used_day_times, $add_day_times, $map_vip_table = null, $player_info = null) { if (empty($map_vip_table)) { $map_vip_table = Cache_MapVip::getInstance()->get_map_vip_info(); if (!Com_Array::is_good_arr($map_vip_table)) { $this->throw_error('113601'); #map_vip配置表读取错误 } } if (empty($player_info) || !isset($player_info['level']) || !isset($player_info['vip']) || !isset($player_info['career_type']) || !isset($player_info['privilege_level'])) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'career_type', 'privilege_level')); } $rtn_data = array(); if (Com_Array::is_good_arr($map_vip_table)) { $fb_data = $this->get_data('PlayerFB')->get_player_fb_info($player_id); $chapter_info = Com_FmtData::cus_json_decode($fb_data['chapter_info']); foreach ($map_vip_table as $mv_info) { $mv_data = array(); $mv_data['fb_id'] = intval($mv_info['map_id']); $mv_data['fb_name'] = $mv_info['name'] ? $mv_info['name'] : ''; $mv_data['level_desc'] = $mv_info['level_limit_desc'] ? $mv_info['level_limit_desc'] : ''; $mv_data['vip_desc'] = $mv_info['vip_level_limit_desc'] ? $mv_info['vip_level_limit_desc'] : ''; $mv_data['state'] = 3; #等级不足 if (!isset($player_info['level']) || intval($player_info['level']) < $mv_info['level_limit']) { $mv_data['state'] = 0; } else { if (!isset($player_info['vip']) || intval($player_info['vip']) < $mv_info['vip_level_limit']) { $mv_data['state'] = 1; } else { if ($used_day_times >= $this->vip_day_num_limit + $add_day_times) { $mv_data['state'] = 2; } } } $prop_list = array(); if (!empty($mv_info['drop_prop'])) { $prop_list = $this->format_prop_currency_struct_table($mv_info['drop_prop']); } $mv_data['drop_equip'] = array(); if (!empty($mv_info['drop_equip'])) { $mv_data['drop_equip'] = $this->format_prop_currency_struct_table($mv_info['drop_equip'], $player_info['career_type']); } if (Com_Array::is_good_arr($prop_list)) { foreach ($prop_list as $prop_data) { $mv_data['drop_equip'][] = $prop_data; } } $mv_data['is_sweep'] = 0; if ($player_info['vip'] > 2) { $cur_fb = $chapter_info[99][99][$mv_info['map_id']]; if (!empty($cur_fb) && isset($cur_fb['gl']) && $cur_fb['gl'] > 0) { $mv_data['is_sweep'] = 1; } } $map_grade_table = Cache_PlayerFB::getInstance()->get_map_grade_info(array('map_id' => $mv_info['map_id'], 'grade' => 1)); if (empty($map_grade_table)) { $this->throw_error('10109'); #配置表读取错误 } #3S下预计获得的经验 $mv_data['exp'] = 0; $map_vip_level_table = Cache_MapVip::getInstance()->get_map_vip_level_add_info(array('level' => $player_info['level'])); if (!empty($map_vip_level_table['add']) && is_string($map_vip_level_table['add'])) { $add_info = explode(":", $map_vip_level_table['add']); if (isset($add_info[1])) { $mv_data['exp'] = $add_info[1] * ($map_grade_table['award'] / 100); } } #buff药加成 $player_detail_buff_exp_addition = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'buff_exp_addition'); $buff_exp_addition = $player_detail_buff_exp_addition['exp']; $this->create_monster_data($mv_info['map_id'], 1, $player_info['level'], $mv_data['exp'], $buff_exp_addition); $rtn_data[] = $mv_data; } } return $rtn_data; }
/** * @Purpose: * 数据修复检测 */ public function hero_repair($player_id) { //获取玩家所有英雄 $data = $this->get_data('PlayerHero')->get_player_hero_list($player_id); #获取英雄公会科技属性加成 $union_attr = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'union_hero_attr'); $union_attr = Com_FmtData::cus_json_decode($union_attr); if (!empty($data) && Com_Array::is_good_arr($data)) { $this->start_trans(); foreach ($data as $key => $val) { $val = Com_FmtData::cus_json_decode($val); if (!empty($val) && isset($val['hero_id']) && !empty($val['hero_id'])) { $is_update = false; if (!isset($val['repair_flag']) || $val['repair_flag'] < 1) { //获取升级增加的属性 $add_attr = $this->get_upgrade_add_attr($val['hero_code'], $val['level'], $val['fit_grow']); $val['life'] = $add_attr['life']; $val['attack'] = $add_attr['attack']; $val['def'] = $add_attr['def']; //战斗力计算 $val['fight'] = $this->calc_fight($val['player_id'], $val, $val['fit'], $val['rune_hole_list'], $val['star_add_attr_per'], $val['skill_list'], $union_attr); $is_update = true; } if ($is_update) { $val['repair_flag'] = $this->repair_flag; //更新redis,sql数据 $update_res = $this->update_db($val['player_id'], array('fight', 'life', 'attack', 'def', 'repair_flag'), $val, 504); if (!$update_res) { $this->throw_error('10104'); } } } } $this->commit(); } }
/** * @Purpose: * 内部增加活动时间接口 * @Param $union_id 公会ID * @Param $type 活动类型 * @Param $time 增加的活动时间(单位:秒) */ public function add_activities_time_interface($union_id, $type, $time) { $union_id = intval($union_id); #获取公会活动天数据 $uad_data = $this->get_data('UnionActivities')->get_union_activities_daily_info($union_id, 'uad', 'day'); $uad_data['add_time'] = Com_FmtData::cus_json_decode($uad_data['add_time']); if ($time > 0) { $type = intval($type); $time = intval($time); $uad_data['add_time'][$type] += $time; $update_uad['add_time'] = json_encode($uad_data['add_time']); $is_commit = false; if (!$this->is_trans()) { $this->start_trans(); $is_commit = true; } #更新活动天数据 $this->get_data('UnionActivities')->update_union_activities_daily_data($union_id, 'uad', $update_uad); if ($is_commit) { $this->commit(); } } }
public function get_everyday_do($player_id, $type, $player_info_all = null, $player_detail_all = null, $player_used_time = null) { $everyday_config = Cache_EverydayDo::getInstance()->get_everyday_do_info($type); if (empty($everyday_config)) { $this->throw_error('10107'); } $out = array(); if (is_null($player_detail_all)) { $func_open = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'func_open'); } else { $func_open = $player_detail_all['func_open']; } if (is_null($player_info_all)) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'career_type')); } else { $player_info = $player_info_all; } if (is_null($player_used_time)) { $player_used_time = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id); } $arr_times = $this->get_daily_time($player_id, null, $player_used_time); $finish = array(); $out[0] = array(); $i = 0; // $func_configs = Cache_FuncConfig::getInstance()->get_func_config_info(); foreach ($everyday_config as $val) { if (!isset($func_open[$val['func_id']])) { #判断功能是否开启 continue; } $arr_reward = array(); if (!empty($val['reward_1'])) { $rewards1 = Com_FmtData::format_table_prop2($val['reward_1']); if ($rewards1) { foreach ($rewards1 as $item) { if ($item['career_type'] != $player_info['career_type']) { continue; } $data = Cache_Prop::getInstance()->get_prop_info($item['id']); $data['item_num'] = $item['num']; $arr_reward[] = Struct_Prop::get_prop_struct($data); } } } if (!empty($val['reward_2'])) { $rewards2 = Com_FmtData::format_table_prop($val['reward_2']); foreach ($rewards2 as $item) { $data = array('prop_id' => $item['id'], 'item_num' => $item['num']); $arr_reward[] = Struct_Prop::get_prop_struct($data); } } if (in_array($val['func_id'], $this->_can_add_times)) { $show_add_times = 1; } else { $show_add_times = 0; } if ($arr_times[$val['func_id']]['cur_num'] < $arr_times[$val['func_id']]['max_num']) { if ($i < 2 && $type > 0) { $recommend = 1; } else { $recommend = 0; } $out[0][] = array('type' => $type, 'icon_id' => $val['func_id'], 'reward' => $arr_reward, 'max_num' => intval($arr_times[$val['func_id']]['max_num']), 'cur_num' => intval($arr_times[$val['func_id']]['cur_num']), 'jump_id' => $val['jump_id'], 'recommend' => $recommend, 'show_add_times' => $show_add_times, 'star' => $val['star']); } else { $finish[] = array('type' => $type, 'icon_id' => $val['func_id'], 'reward' => $arr_reward, 'max_num' => intval($arr_times[$val['func_id']]['max_num']), 'cur_num' => intval($arr_times[$val['func_id']]['cur_num']), 'jump_id' => $val['jump_id'], 'recommend' => 0, 'show_add_times' => $show_add_times, 'star' => $val['star']); } ++$i; } if (!empty($finish)) { $out[0] = array_merge($out[0], $finish); } return $out; }
/** * @Purpose: * 平台礼包领取 * @Param $player_id 玩家ID * @Param $type 礼包类型(1:360加速球2:360游戏大厅) */ public function receive_platform_bag($player_id, $type) { $player_id = intval($player_id); $type = intval($type); $operator_id = OPERATOR_ID; #获取玩家微端礼包信息; $data = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'platform_bag_info'); if (empty($data) || !isset($data[$operator_id][$type]) || $data[$operator_id][$type] != 2) { #获取平台礼包配置表 $platformbag_table = Cache_PlatformBag::getInstance()->get_platform_bag_info(array('platform' => $operator_id, 'type' => $type)); if (empty($platformbag_table)) { $this->throw_error('10109'); #配置表读取错误 } #领奖时间验证 $start_time = Com_FmtData::format_table_time($platformbag_table['start_time']); $over_time = Com_FmtData::format_table_time($platformbag_table['over_time']); if (time() < $start_time || $over_time <= time()) { $this->throw_error('21001'); #非领奖时间 } if ($data[$operator_id][$type] == 2) { $this->throw_error('6010063'); #奖励领取过 } if ($platformbag_table['is_activate'] == 1 && $data[$operator_id][$type] != 1) { $this->throw_error('21002'); #礼包未激活 } $prop_list = Com_FmtData::format_table_prop($platformbag_table['prop_info']); $prop_info = Com_FmtData::format_send_prop($prop_list); $data[$operator_id][$type] = 2; $this->start_trans(); $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('platform_bag_info' => $data)); if (!$update_res) { $this->throw_error('10104'); } #道具发送 if (Com_Array::is_good_arr($prop_info)) { $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '2105', 'bind_flag' => 0), 1); if ($result !== true) { $this->throw_error('10104'); } } $this->commit(); $this->get_game('Reward')->add_reward_log(); $fun_id = 0; if ($type == 1) { $fun_id = 91101; } else { if ($type == 2) { $fun_id = 91102; } } if ($fun_id > 0) { #礼包全部领完后,通知前端隐藏ICON $func_data = array(); $func_data[0][$fun_id] = array('operate' => 2, 'func_id' => $fun_id, 'open' => 0, 'guide' => 0, 'cd' => 0, 'tip' => array()); Protocol::input($player_id, 8, 7, 741, $func_data); } return array(intval($data[$operator_id][$type]), $type); } }
/** * @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; }
public function get_reward($level, $finish_num) { $finish_num = $finish_num <= 0 ? 1 : $finish_num; $task_reward = Cache_TaskChainAwardBase::getInstance()->get_task_chain_award_base(); $reward = array(); $reward_addition = Cache_TaskChain::getInstance()->get_task_chain_info($finish_num); foreach ($task_reward as $val) { if ($level >= $val['min_lvl'] && $level <= $val['max_lvl']) { if (!empty($val['task_award'])) { $reward = Com_FmtData::format_table_prop($val['task_award']); foreach ($reward as $key => $val) { $val['num'] = $val['num'] * ($reward_addition['award_add'] / 100); $reward[$key] = $val; } if (!empty($reward_addition['award_extra'])) { $reward1 = Com_FmtData::format_table_prop($reward_addition['award_extra']); if ($reward1) { $reward = array_merge($reward, $reward1); } } } break; } } return $reward; }
public function get_main_dungeon_rank_cache($real_time = false) { $main_dungeon_list = array(); if ($real_time) { $list = $this->redis()->zsets_all($this->main_dungeon_rank, false, 0, 99, true); if (!empty($list) && Com_Array::is_good_arr($list)) { foreach ($list as $player_id => $star) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'career_type', 'sum_fpower', 'level')); $main_dungeon_list[$player_id] = array('player_id' => $player_id, 'name' => $player_info['name'], 'career_type' => $player_info['career_type'], 'level' => $player_info['level'], 'star' => $star, 'fight' => $player_info['sum_fpower']); } } } else { $rank_list = $this->redis()->hash_get($this->main_dungeon_rank_cache); $main_dungeon_list = $rank_list['main_dungeon_rank']; if (empty($main_dungeon_list)) { $main_dungeon_list = $this->update_main_dungeon_rank_cache(); } $main_dungeon_list = Com_FmtData::cus_json_decode($main_dungeon_list); } if (Com_Array::is_good_arr($main_dungeon_list)) { Com_Array::multisort($main_dungeon_list, array('star' => 'desc', 'fight' => 'desc')); } return empty($main_dungeon_list) ? $main_dungeon_list : array_values($main_dungeon_list); }
/** * 小红点提示 * @param $player_id * @param $type * @param $condition */ public function red_icon($player_id, $player_info = null, $player_detail = null) { if (is_null($player_info)) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('silver', 'crystal', 'level', 'fame_level', 'career_type', 'gold', 'online_time')); } if (is_null($player_detail)) { $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('func_open', 'equip_wing', 'wing_info', 'skill_info', 'skill_rune_info', 'skill_rune_cote_info', 'dower_info', 'train_info')); } $prop_list = $this->get_data('PlayerProp')->get_player_prop_by_item_position($player_id); //重包裹里去除道具 $arr_prop_num = array(); $arr_prop_type = array(); $func_open = $player_detail['func_open']; if ($prop_list) { foreach ($prop_list as $prop) { $arr_prop_num[$prop['prop_id']] += $prop['item_num']; $arr_prop_type[$prop['type']][$prop['sub_type']][] = $prop; } } ##################[翅膀进阶检查]#################### $wing_id = $player_detail['equip_wing']; $out = array(); if (!empty($wing_id)) { if (isset($func_open[111])) { $wing_table = Cache_PlayerWing::getInstance()->get_player_wing_info(array('id' => $wing_id, 'level' => $player_detail[$wing_id]['lvl'] + 1)); if ($wing_table) { $tip = false; if ($wing_table[0]['condition']) { list($type, $condition) = explode("|", $wing_table[0]['condition']); if ($type == 5) { if ($player_info['fame_level'] >= $condition) { $tip = true; } } } if ($tip) { $material_prop = Com_FmtData::format_table_prop($wing_table[0]['condition']); if (Com_Array::is_good_arr($material_prop)) { foreach ($material_prop as $id => $num) { if ($arr_prop_num[$id] >= intval($num)) { $tip = true; } } } } if ($tip) { $out[] = array('func_id' => 1, 'status' => intval($tip), 'param' => ''); } } } } ##################[翅膀进阶检查]#################### ###################[翅膀激活]####################### if (isset($func_open[110]) && $player_detail['wing_info']) { $tip = false; $data = $player_detail['wing_info']; foreach ($data as $key => $val) { if ($val['activation'] == 0) { #在线时间检测 if ($val['condition'][0] == 3) { $data[$key]['condition'][2] = $this->get_game('DailyBoon')->daily_online_time($player_id); if ($data[$key]['condition'][2] >= $data[$key]['condition'][1][0]) { $tip = true; } else { if ($player_info['online_time'] >= $data[$key]['condition'][1][0]) { $tip = true; } } } else { if ($val['condition'][0] == 7) { $data[$key]['condition'][2] = $player_info['level']; if ($data[$key]['condition'][2] >= $data[$key]['condition'][1][0]) { $tip = true; } } else { if ($val['condition'][0] == 6) { #获取翅膀配置表 $wing_table_task = $this->get_game('PlayerWing')->get_cache_table_data('player_wing_table', array('id' => $val['id'], 'level' => $val['lvl'])); if ($wing_table_task) { list($type, $task_id) = explode("|", $wing_table_task[0]['condition']); $task_res = $this->get_game('TaskMain')->task_is_finish($player_id, $task_id); if ($task_res) { $tip = true; } } } } } if ($val['condition'][0] == 4) { #获取翅膀配置表 $wing_table = $this->get_game('PlayerWing')->get_cache_table_data('player_wing_table', array('id' => $val['id'], 'level' => 1)); if (Com_Array::is_good_arr($wing_table)) { foreach ($wing_table as $wing) { list($type, $value) = explode("|", $wing['condition']); if ($type == 4) { if ($data[$val['id']]['activation'] != 0) { continue; } $is_activate = true; $wing_list = explode(":", $value); if (is_array($wing_list)) { #检测是否有被激活的翅膀 foreach ($wing_list as $wid) { if ($data[$wid]['activation'] != 2) { $is_activate = false; break; } } } else { if ($data[$wing_list]['activation'] != 2) { $is_activate = false; } } #改变隐藏翅膀激活状态 if ($is_activate) { $tip = true; } } } } } if ($val['condition'][0] == 2 || $val['condition'][0] == 1) { if ($data[$id]['condition'][2] >= $wing['condition'][1][0]) { $tip = true; } } } if ($tip == true) { break; } } if ($tip) { $out[] = array('func_id' => 15, 'status' => intval($tip), 'param' => ''); } } ###################[翅膀激活]####################### ###################[翅膀羽炼]####################### // if (isset($func_open[112])) { $start = strtotime(SERVER_FIRST_START_TIME); list($login_series_max, $login_acc) = $this->get_game('EventCondFunc')->_cal_login_refer($player_id, $start, $this->current_time); $deal_log_hash = $this->get_data('Wing')->get_deal_log_by_player_id($player_id); $tip = false; for ($i = 7; $i <= 8; $i++) { $item_list = Cache_PlayerWing::getInstance()->get_wing_equip_gift_info_list($i); if ($item_list) { foreach ($item_list as $item_info) { $gain_status = 0; # 领取状态:0可领,1条件未达成不可领,2已领取不可领[NOTE:可领只有一种情况,不可领有多种情况,所以这样表示] # 判断达成条件 if ($login_acc < $item_info['login_acc'] && empty($deal_log_hash[$item_info['item_id']])) { $tip = true; break 2; } } } } if ($tip) { $out[] = array('func_id' => 17, 'status' => intval($tip), 'param' => ''); } // } ###################[翅膀羽炼]####################### ##################[翅膀装备检查]################### $wing_info = $player_detail['wing_info'][$wing_id]; if (isset($func_open[110]) && $wing_info) { $tip = false; if ($wing_id == 7 && $wing_id == 8) { if (!empty($wing_info['equipment']) && Com_Array::is_good_arr($wing_info['equipment'])) { for ($i = 1; $i <= 7; $i++) { if (!isset($wing_info['equipment'][$i])) { if (isset($arr_prop_type[6][$i]) && count($arr_prop_type[6][$i] > 0)) { foreach ($arr_prop_type[6][$i] as $arr_prop_detail) { if ($wing_info['lvl'] < $arr_prop_detail['level']) { $tip = true; break 2; } } } } } } } if ($tip) { $out[] = array('func_id' => 2, 'status' => intval($tip), 'param' => ''); } } ##################[翅膀装备检查]################### ##################[英雄]############################## if (isset($func_open[20])) { $tip = false; $hero_list = $this->get_data('PlayerHero')->get_fight_hero($player_id); if (!empty($hero_list)) { foreach ($hero_list as $hero_id => $hero_code) { $obj_player_hero_data = $this->get_data('PlayerHero'); $hero_data = $obj_player_hero_data->get_player_hero_info($player_id, $hero_id); if ($hero_data) { ###################[成长值]######################################### if (isset($func_open[29])) { $hero_conf = Cache_HeroAttr::getInstance()->get_hero_attr_info($hero_data['hero_code']); if ($hero_data['grow_rate'] <= $hero_conf['grow_limit']) { $obj_hero_grow = $this->get_data('PlayerHeroGrow'); $hero_grow_id = $obj_hero_grow->get_player_hero_grow_data($hero_id); $hero_grow_conf = array(); $findFlag = false; if (!$hero_grow_id) { $findFlag = true; } else { $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id); if (empty($hero_grow_conf)) { $findFlag = true; } else { if ($hero_data['grow_rate'] < $hero_grow_conf['grow_left'] || $hero_data['grow_rate'] >= $hero_grow_conf['grow_right']) { #区间错误 $findFlag = true; } } } if ($findFlag) { #启动自动纠错 $hero_grow_id = $this->get_game('Hero')->find_hero_grow_id($hero_data['grow_rate'], $hero_grow_conf); } if ($hero_grow_id) { $last_props[$hero_grow_conf['item_id']] = intval($arr_prop_num[$hero_grow_conf['item_id']]); if ($last_props[$hero_grow_conf['item_id']] >= $hero_grow_conf['item_nums']) { $tip = true; } } if ($tip) { $out[] = array('func_id' => 3, 'status' => intval($tip), 'param' => $hero_id); } } } ###################[成长值]######################################### ##################[英雄等级]############################### if (isset($func_open[22])) { $tip = false; $is_culture = $this->get_game('Hero')->is_culture_hero($player_id, $hero_id, $hero_data['hero_code']); if ($is_culture) { if ($hero_data['level'] < $player_info['level']) { //英雄是否满级 $full_level_res = $this->get_game('Hero')->is_full_level($hero_data['hero_code'], $hero_data['level']); if (!$full_level_res) { //是否有同类型已培养的英雄 $upgrade_prop_list = $this->get_game('Hero')->upgrade_prop_list; foreach ($upgrade_prop_list as $prop_id) { if (isset($arr_prop_num[$prop_id])) { $tip = true; break; } } } } } if ($tip) { $out[] = array('func_id' => 4, 'status' => intval($tip), 'param' => $hero_id); } } ##################[英雄等级]############################### ##################[英雄潜能]############################### if (isset($func_open[23])) { $tip = false; //是否有同类型已培养的英雄 if ($is_culture) { for ($i = 1; $i <= 3; $i++) { $hero_potential_base_table = $this->get_game('Hero')->get_hero_potential_base_table($i, $hero_data['potential_level']); if ($player_info['silver'] >= $hero_potential_base_table['coin_num']) { if (!empty($hero_potential_base_table) && $hero_potential_base_table['prop_id'] && $hero_potential_base_table['prop_num']) { //获取玩家背包中的升级道具数量 $player_prop_num = $arr_prop_num[$hero_potential_base_table['prop_id']]; if ($player_prop_num >= $hero_potential_base_table['prop_num']) { $attr_max = $this->get_game('Hero')->get_potential_attr_max($hero_data['potential_level'], $i); if ($hero_data['potential_' . $i] < $attr_max) { $tip = true; break; } } } } } } if ($tip) { $out[] = array('func_id' => 5, 'status' => intval($tip), 'param' => $hero_id); } } ##################[英雄潜能]############################### ##################[英雄合体]############################### if (isset($func_open[24])) { $tip = false; if ($is_culture) { $full_stairs_res = $this->get_game('Hero')->is_full_stairs($hero_data['hero_code'], $hero_data['fit']); if (!$full_stairs_res) { $hero_attr_base = $this->get_game('Hero')->get_hero_attr_table($hero_data['hero_code']); $fit_table = $this->get_game('Hero')->get_hero_fit_table($hero_attr_base['fit_expend_type'], $hero_data['fit'] + 1); $player_prop_num = $arr_prop_num[$fit_table['prop_id']]; if ($player_prop_num >= $fit_table['prop_num']) { $hero_info = $this->get_game('Hero')->get_fit_hero_num($player_id, $hero_id, $hero_data['fit_type'], $hero_data['hero_code'], $hero_data['quality'], $hero_data['quality']); //英雄是否足够 $is_full_hero_res = $this->get_game('Hero')->is_full_hero($hero_attr_base['fit_expend_type'], $hero_data['fit'] + 1, $hero_info['num']); if ($is_full_hero_res) { $tip = true; } } } } if ($tip) { $out[] = array('func_id' => 6, 'status' => intval($tip), 'param' => $hero_id); } } ##################[英雄合体]############################### ##################[英雄星级]############################### if (isset($func_open[25])) { $tip = false; if ($is_culture) { $full_level_res = $this->get_game('Hero')->is_full_star($hero_data['hero_code'], $hero_data['star']); if (!$full_level_res) { $star_table = $this->get_game('Hero')->get_hero_star_table($hero_data['star'] + 1); if ($star_table && $star_table['prop_id1']) { $prop_id = $star_table['prop_id1']; $deduct_coin_num = $star_table['prop_id2']; $player_prop_num = $arr_prop_num[$prop_id]; if ($player_prop_num >= $star_table['prop_num1']) { if ($player_info['silver'] >= $deduct_coin_num) { $tip = true; } } } } } if ($tip) { $out[] = array('func_id' => 7, 'status' => intval($tip), 'param' => $hero_id); } } ##################[英雄星级]############################### } } } } ##################[英雄]################################################## ##################[女神]################################################# if (isset($func_open[30])) { $obj_player_fairy_data = $this->get_data('Fairy'); $fairy_list = $obj_player_fairy_data->get_player_fairy_list($player_id); $fairy_id = ''; if ($fairy_list) { foreach ($fairy_list as $val) { $fairy_id = $val['fairy_id']; if (!empty($fairy_id)) { $fairy_info = $this->get_data('Fairy')->get_player_fairy_info($fairy_id); if ($fairy_info) { ##################[女神强化]############################################ if ($fairy_info['type'] == 1) { $func_id = 35; } else { $func_id = 36; } if (isset($func_open[$func_id])) { $tip = false; $max_train_lv = Cache_FairyTrain::getInstance()->get_max_train_lv(); if (!empty($max_train_lv)) { $max_train_lv = 100; } if ($fairy_info['train_level'] < $max_train_lv) { $trainConfigs = $this->get_game('Fairy')->get_cache_table_data('fairy_train_table', array("lvl" => $fairy_info['train_level'])); if ($trainConfigs[0] || !empty($trainConfigs[0]['expend'])) { $train_config = $trainConfigs[0]; // 消耗需求 $cost_material = explode("|", $train_config['expend']); //升级下一级消耗 $costItemInfo = explode(':', $cost_material[0]); //道具消耗 $costGoldInfo = !empty($cost_material[1]) ? explode(':', $cost_material[1]) : 0; //金币消耗 if ($fairy_info['level'] >= $train_config['fairy_lvl']) { $cost_item_id = $costItemInfo[0]; $cost_item_num = intval($costItemInfo[1]); $player_prop_num = $arr_prop_num[$cost_item_id]; $cost_silver_num = is_array($costGoldInfo) ? intval($costGoldInfo[1]) : 0; if ($player_info['silver'] >= $cost_silver_num) { if ($player_prop_num >= $cost_item_num) { $tip = true; } } } } } if ($tip) { $out[] = array('func_id' => 8, 'status' => intval($tip), 'param' => $fairy_id); } } ##################[女神强化]############################################ ##################[女神培养]############################################ if (isset($func_open[31])) { $tip = false; $fairy_level_table = $this->get_game('Fairy')->get_fairy_lvl_tabel_data($fairy_info['fairy_code'], $fairy_info['star']); if ($fairy_level_table) { if ($player_info['fame_level'] >= $fairy_level_table['fame']) { $item_data = array(); $get_item_res = $this->get_game('Fairy')->get_item_data($fairy_info['fairy_code'], $fairy_info['star'], $item_data); if ($get_item_res == true) { $prop_id = $item_data['item']; $prop_num = $item_data['count']; $coin = $item_data['coin']; if ($item_data['fame'] > 0) { $coin = 0; } if ($prop_id && $prop_num) { if ($arr_prop_num[$prop_id] >= $prop_num) { if ($player_info['silver'] >= $coin) { $tip = true; } } } } } } if ($tip) { $out[] = array('func_id' => 9, 'status' => intval($tip), 'param' => $fairy_id); } } ##################[女神培养]############################################ ##################[女神符文位置]############################################ if (isset($func_open[31])) { $tip = false; if (Com_Array::is_good_arr($fairy_info['combination_list'])) { foreach ($fairy_info['combination_list'] as $value) { if ($value['state'] == 1) { $tip = true; } } } if ($tip) { $out[] = array('func_id' => 16, 'status' => intval($tip), 'param' => $fairy_id); } } ##################[女神符文位置]############################################ } } } } } ##################[女神]################################################# ########################[技能]########################################## $skill_list_all = Cache_Skill::getInstance()->get_skill_list($player_info['career_type']); $skill_list_distinct = Cache_Skill::getInstance()->get_distinct_skill_list($player_info['career_type'], 1); $skill_hash_all = $this->get_game('PlayerSkill')->convert_skill_list_to_hash($skill_list_all); $tip = false; foreach ($skill_list_distinct as $val) { if ($val['display'] == 0) { continue; } $skill_id = $val['sid']; $data['skill_status'] = 0; if (isset($player_detail['skill_info'][$skill_id]['level'])) { //已激活 $data['skill_status'] = 1; $data['skill_level'] = $player_detail['skill_info'][$skill_id]['level']; } if ($data['skill_status'] > 0) { if ($data['skill_level'] < $skill_hash_all[$skill_id][$data['skill_level']]['max_level'] && $player_info['level'] >= $skill_hash_all[$skill_id][$data['skill_level'] + 1]['unlock'] && $player_info['silver'] >= $skill_hash_all[$skill_id][$data['skill_level'] + 1]['levelup_cost_silver'] && $player_info['crystal'] >= $skill_hash_all[$skill_id][$data['skill_level'] + 1]['levelup_cost_skill_point']) { $tip = true; break; } } } if ($tip) { $out[] = array('func_id' => 10, 'status' => intval($tip), 'param' => ''); } ########################[技能]########################################## ########################[天赋]########################################## $tip = false; $active_dower_list = $this->get_data('PlayerDower')->get_player_dower($player_id); $dower_list_all = Cache_Dower::getInstance()->get_dower_list($player_info['career_type']); $dower_list_distinct = Cache_Dower::getInstance()->get_distinct_dower_list($player_info['career_type'], 0); // $dower_hash_all = $this->get_game('PlayerSkill')->convert_dower_list_to_hash($dower_list_all); if (!empty($dower_list_distinct)) { foreach ($dower_list_distinct as $val) { $dower_id = $val['sid']; if (isset($active_dower_list[$dower_id])) { $active_dower_list[$dower_id]['dower_lv'] += 1; } else { $active_dower_list[$dower_id] = array('dower_id' => $dower_id, 'dower_lv' => 1, 'player_id' => $player_id); } # 获取天赋配置信息 $dower_info = Cache_Dower::getInstance()->get_dower_info($dower_id, $active_dower_list[$dower_id]['dower_lv'], 0); if ($player_info['level'] > $dower_info['unlock']) { if ($player_info['crystal'] >= $dower_info['cost_crystal']) { if (!empty($dower_info['item_id']) && !empty($dower_info['item_num'])) { $player_prop_num = $arr_prop_num[$dower_info['item_id']]; if ($player_prop_num >= $dower_info['item_num']) { $tip = true; break; } } } } } if ($tip) { $out[] = array('func_id' => 11, 'status' => intval($tip), 'param' => ''); } } ########################[圣器]########################################## $trains = $player_detail['train_info']; if ($trains) { foreach ($trains as $train_type => $train) { $train_rank = $train['train_rank']; foreach ($train['train_detail'] as $train_attr_seq => $train_detail) { $train_step = $train_detail[$train_attr_seq]['train_step'] + 1; $train_detail = Cache_Train::getInstance()->get_train_detail($train_type, $train_rank, $train_attr_seq, $train_step); if ($train_detail) { if (!empty($train_detail['require_player_level']) && $player_info['level'] >= $train_detail['require_player_level']) { $cost_currency_value = Formula_Train::get_strengthen_train_cost(); $cost_currency_key = Cache_Currency::getInstance()->get_key($this->get_game('Train')->get_strengthen_train_cost_cur_type()); if ($player_info[$cost_currency_key] >= $cost_currency_value) { if ($player_info['silver'] >= $train_detail['consume_silver']) { if (!empty($train_detail['consume_item_id'])) { if ($arr_prop_num[$train_detail['consume_item_id']] >= $train_detail['consume_item_num']) { if ($train_type == 1) { $out[] = array('func_id' => 12, 'status' => intval($tip), 'param' => ''); } if ($train_type == 2) { $out[] = array('func_id' => 13, 'status' => intval($tip), 'param' => ''); } if ($train_type == 3) { $out[] = array('func_id' => 14, 'status' => intval($tip), 'param' => ''); } } } } } } } } } } ########################[圣器]######################################### return $out; }
/** * @Purpose: * 公会商店购买 * @Param $player_id 玩家ID * @Param $shop_id 商品ID * @Param $type 商品类型 * @Param $num 购买数量 */ public function union_shop_buy($player_id, $shop_id, $type, $num) { $player_id = intval($player_id); if ($num < 1) { $this->throw_error('10107'); #参数错误 } #获取玩家公会ID,验证公会信息 $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id'); if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } #获取商店数据 $data = $this->get_data('UnionShop')->get_union_shop_info($union_id); if (!$data) { $this->throw_error('10110'); #数据错误 } $shop_type = ''; $type = intval($type); if ($type == 1) { $shop_type = 'prop_info'; $data['player_buy_info'] = Com_FmtData::cus_json_decode($data['player_buy_info']); } else { if ($type == 2) { $shop_type = 'buff_info'; } else { $this->throw_error('1715001'); #购买失败 } } if ($data[$shop_type] && !is_array($data[$shop_type])) { $data[$shop_type] = json_decode($data[$shop_type], true); } $shop_id = intval($shop_id); #BUFF存在 if ($type == 2 && $data[$shop_type][$shop_id]['record'][$player_id]) { $this->throw_error('1715001'); #购买失败 } #商品验证 if (!$data[$shop_type][$shop_id]) { $this->throw_error('1715005'); #道具不足 } #商品是否解锁 if ($data[$shop_type][$shop_id]['state'] != 1) { $this->throw_error('1715004'); #道具未解锁 } #购买职务验证 #获取玩家公会职务 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $job = $player_data['job_id']; if ($job > $data[$shop_type][$shop_id]['job_level']) { $this->throw_error('1715003'); #职务过低 } #获取公会商店等级 $shop_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'shop_level'); #本次更新每个玩家可以购买的道具上限验证 $union_build_table = Cache_UnionBuild::getInstance()->get_union_build_info_two(array('build_type' => 'shop', 'build_lvl' => $shop_level)); if ($union_build_table['buy_limit'] > 0 && $data['player_buy_info'][$player_id] + $num > $union_build_table['buy_limit']) { $this->throw_error('1715009'); #本次刷新购买次数已满 } $time = time(); #道具数量验证 if ($data[$shop_type][$shop_id]['num'] < $num) { #刷新时间验证 if ($type == 1) { $next_refresh = 0; $update_prop_res = $this->check_shop_refresh($data['refresh_time'], $data[$shop_type], $next_refresh, $shop_level); if ($update_prop_res) { $update_data['refresh_time'] = $data['refresh_time']; #更新玩家购买次数 $data['player_buy_info'] = array(); } else { $this->throw_error('1715005'); #道具不足 } } else { if ($type == 2) { $record = $data[$shop_type][$shop_id]['record']; if (Com_Array::is_good_arr($record)) { foreach ($record as $pid => $re) { if ($time >= $re['expired_time']) { #增加商品数量 if ($data[$shop_type][$shop_id]['num'] + 1 < $data[$shop_type][$shop_id]['num_max']) { $data[$shop_type][$shop_id]['num']++; } else { $data[$shop_type][$shop_id]['num'] = $data[$shop_type][$shop_id]['num_max']; } #清除玩家购买记录 unset($data[$shop_type][$shop_id]['record'][$pid]); } } } #道具数量验证 if ($data[$shop_type][$shop_id]['num'] < $num) { $this->throw_error('1715005'); #道具不足 } /* #获取公会商店等级 $shop_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'shop_level'); #获取商店配置表 $shop_table = $this->get_cache_table_data('shop_table', array('level' => $shop_level, 'type' => $type)); if (!$shop_table || !$shop_table[0]['refresh_time']) { $this->throw_error('10109'); //配置表读取错误 } $next_time = $data[$shop_type][$shop_id]['next_refresh_time']; $refresh_time = $shop_table[0]['refresh_time'] * 3600; #更新下次刷新时间 $data[$shop_type][$shop_id]['next_refresh_time'] = $time + ($refresh_time - intval(($time - $next_time) % $refresh_time)); */ } else { $this->throw_error('1715005'); #道具不足 } } } #玩家贡献度验证 #获取玩家贡献度 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); if ($data[$shop_type][$shop_id]['contribution'] * $num > $player_data['total_dedicate']) { $this->throw_error('1715006'); #贡献度不足 } $player_name = $this->get_data('Player')->get_player_info($player_id, "name"); if ($type == 2) { #获取商店配置表 $shop_table = $this->get_cache_table_data('shop_table', array('level' => $shop_level, 'type' => $type)); if (!$shop_table || !$shop_table[0]['refresh_time']) { $this->throw_error('10109'); //配置表读取错误 } $refresh_time = $time + $shop_table[0]['refresh_time'] * 3600; #更新购买记录 $data[$shop_type][$shop_id]['record'][$player_id]['player_name'] = $player_name; $data[$shop_type][$shop_id]['record'][$player_id]['job'] = $job; $data[$shop_type][$shop_id]['record'][$player_id]['buy_time'] = $time; $data[$shop_type][$shop_id]['record'][$player_id]['expired_time'] = $refresh_time; } #扣除商品数量 $data[$shop_type][$shop_id]['num'] -= $num; #扣除贡献度 $front_amount_dedicate = $player_data['total_dedicate']; $dedicate = $data[$shop_type][$shop_id]['contribution'] * $num; $player_data['total_dedicate'] -= $dedicate; #增加公会记录 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $data[$shop_type][$shop_id]['name'], 'rep_color' => "ffb901"); $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, 1715007, $arr_replace); $this->start_trans(); if ($type == 1) { #发道具 $prop_info[] = array('type' => 'prop', 'item_id' => $data[$shop_type][$shop_id]['prop_id'], 'item_num' => $num); if (Com_Array::is_good_arr($prop_info)) { $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '1715'), 1); if ($result !== true) { $this->throw_error('10104'); } } #记录玩家购买次数 $data['player_buy_info'][$player_id] += $num; $update_data['player_buy_info'] = json_encode($data['player_buy_info']); } $update_data[$shop_type] = json_encode($data[$shop_type]); #更新商店 $this->get_data('UnionShop')->update_union_shop($union_id, $update_data); #更新玩家贡献度 $this->get_data('UnionPlayer')->update_union_player_info($union_id, $player_id, $player_data); //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 2, 'item_id' => 11, 'item_num' => $dedicate, 'amount' => $front_amount_dedicate, 'after_amount' => $player_data['total_dedicate'], 'cmd_id' => 1715); Log_Common::getInstance()->add_log($log_data); $this->commit(); if ($type == 1) { $this->get_game('Reward')->add_reward_log(); } else { if ($type == 2) { #通知C++给玩家增加BUFF Protocol::input($player_id, 7, 4, 490, array('0' => $player_id, '1' => $data[$shop_type][$shop_id]['prop_id'])); } } $this->update_temporary_data($data); return array('0' => 1, '1' => $data[$shop_type][$shop_id]['prop_id']); }