/** * @Purpose: 任务信息更新 * @Method Name: CMD2_1002() * @Parameter: int task_id 任务ID * @Parameter: int step_id 步骤ID * @Return: array 返回主线任务信息 */ public function CMD2_1002() { $player_id = $this->_authuser['player_id']; $task_id = $this->_param[0]; $step_id = $this->_param[1]; $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id); if ($task_config['task_type'] == 1) { //主线 $this->get_game('TaskMain')->finish_main_task($player_id, $task_id, $step_id); } elseif ($task_config['task_type'] == 3) { //日常 // $this->get_game('TaskMain')->finish_daily_task($player_id,$task_id,$step_id); } }
public function run($player_id, $s_task_id) { $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id); foreach ($arr_player_task['main_val'] as $task_id => $val) { $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id); if (!empty($arr_player_task['main_val'][$task_id]['target'])) { foreach ($arr_player_task['main_val'][$task_id]['target'] as $target) { unset($arr_player_task['target_val'][$arr_player_task['main_val'][$task_id]['step_type']][$target['target_id']][$task_config['task_type']][$task_id]); } } } $arr_task_main = array(); $target_val = $arr_player_task['target_val']; $task_id = $s_task_id; $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id); if ($task_config['task_type'] == 1) { $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id, 1); if (!empty($step_config['guide_type'])) { $guides = explode("|", $step_config['guide_type']); foreach ($guides as $guide) { if ($step_config['task_guide'] == 1) { $this->get_game('TaskMain')->do_guide_task($player_id, $guide, 1, $arr_player_task, $out); } } } if (!empty($target_val)) { foreach ($target_val as $step_type => $val) { if ($val) { foreach ($val as $target_id => $tar) { if ($tar) { foreach ($tar as $type => $v) { if ($type == 1 && $v) { foreach ($v as $tid => $vv) { // // echo $step_type."|".$target_id."|".$type."|".$task_id."<br>"; // echo $arr_player_task['target_val'][$step_type][$target_id][$type][$task_id]."<br>"; unset($arr_player_task['target_val'][$step_type][$target_id][$type][$tid]); } } if (count($arr_player_task['target_val'][$step_type][$target_id][$type]) == 0) { unset($arr_player_task['target_val'][$step_type][$target_id][$type]); if (count($arr_player_task['target_val'][$step_type][$target_id]) == 0) { unset($arr_player_task['target_val'][$step_type][$target_id]); if (count($arr_player_task['target_val'][$step_type]) == 0) { unset($arr_player_task['target_val'][$step_type]); } } } } } } } } } $target_val = $arr_player_task['target_val']; $arr_target = $this->get_game('TaskMain')->get_target_val($player_id, $step_config); if (!empty($arr_target)) { foreach ($arr_target as $target) { if (!empty($target)) { $target_val[$step_config['step_type']][$target['target_id']][$task_config['task_type']][$task_id] = $target['target_num']; } } } if ($step_config['step_type'] == 2) { $task_status = 2; } else { $task_status = 1; } $arr_task_main[$task_id] = array('task_id' => $task_id, 'task_steps' => $task_config['task_steps'], 'step' => 1, 'task_status' => $task_status, 'next_task_id' => $task_config['next_task_id'], 'step_type' => $step_config['step_type'], 'dungeon_event_sid' => $step_config['dungeon_event_sid'], 'buff_id' => $step_config['buff_id'], 'target' => $arr_target); } $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('main_val' => $arr_task_main, 'target_val' => $target_val, 'guide_val' => $arr_player_task['guide_val'], 'guide_target_val' => $arr_player_task['guide_target_val'])); var_dump($result); if ($result) { $this->open_func($player_id, $step_config['city_id']); } if ($result) { echo 'success'; } else { echo 'error'; } exit; }
/** * 获取完成任务数量 * @param $player_id * @param $chapter_id * @param $chapter_part * @param null $finish_task * @return int */ public function get_chapter_task_finish_num($player_id, $chapter_id, $chapter_part) { $finish_num = 0; $player_task = $this->get_data('PlayerTask')->get_task_info($player_id, array('main_val')); $tasks = Cache_TaskConfig::getInstance()->get_chapter_part_task($chapter_id, $chapter_part); if ($tasks) { foreach ($tasks as $task_id) { $status = $this->task_is_finish($player_id, $task_id, $player_task); if ($status) { ++$finish_num; } } } return $finish_num; }
public function reset_task($player_id, $s_task_id) { $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id); foreach ($arr_player_task['main_val'] as $task_id => $val) { $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id); if (!empty($arr_player_task['main_val'][$task_id]['target'])) { foreach ($arr_player_task['main_val'][$task_id]['target'] as $target) { unset($arr_player_task['target_val'][$arr_player_task['main_val'][$task_id]['step_type']][$target['target_id']][$task_config['task_type']][$task_id]); } } } $arr_task_main = array(); $target_val = $arr_player_task['target_val']; $task_id = $s_task_id; $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id); if ($task_config['task_type'] == 1) { $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id, 1); if (!empty($target_val)) { foreach ($target_val as $step_type => $val) { if ($val) { foreach ($val as $target_id => $tar) { if ($tar) { foreach ($tar as $type => $v) { if ($type == 1 && $v) { foreach ($v as $tid => $vv) { // // echo $step_type."|".$target_id."|".$type."|".$task_id."<br>"; // echo $arr_player_task['target_val'][$step_type][$target_id][$type][$task_id]."<br>"; unset($arr_player_task['target_val'][$step_type][$target_id][$type][$tid]); } } if (count($arr_player_task['target_val'][$step_type][$target_id][$type]) == 0) { unset($arr_player_task['target_val'][$step_type][$target_id][$type]); if (count($arr_player_task['target_val'][$step_type][$target_id]) == 0) { unset($arr_player_task['target_val'][$step_type][$target_id]); if (count($arr_player_task['target_val'][$step_type]) == 0) { unset($arr_player_task['target_val'][$step_type]); } } } } } } } } } $target_val = $arr_player_task['target_val']; $arr_target = $this->get_game('TaskMain')->get_target_val($player_id, $step_config); if (!empty($arr_target)) { foreach ($arr_target as $target) { if (!empty($target)) { $target_val[$step_config['step_type']][$target['target_id']][$task_config['task_type']][$task_id] = $target['target_num']; } } } if ($step_config['step_type'] == 2) { $task_status = 2; } else { $task_status = 1; } $arr_task_main[$task_id] = array('task_id' => $task_id, 'task_steps' => $task_config['task_steps'], 'step' => 1, 'task_status' => $task_status, 'next_task_id' => $task_config['next_task_id'], 'step_type' => $step_config['step_type'], 'dungeon_event_sid' => $step_config['dungeon_event_sid'], 'buff_id' => $step_config['buff_id'], 'target' => $arr_target); } $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('main_val' => $arr_task_main, 'target_val' => $target_val)); if ($result) { echo "{$player_id} \n"; } }
/** * 替换一个特定星级的保底任务 * 规则:保底5|4星,从task_config表中star_type=1|2的任务集中随机一个任务置为5|4星 * 说明: 部分star_type的task不允许出现4星或5星,其配置权重为0,保底规则不能随机某一个置为4|5星 * 注意:删除最后一个任务,取一个特定星级任务代替的方式,要注意确保最终task_hash等于8个 * @param $task_hash, $player_level, $star[保底任务星级5|4] */ private function replace_one_special_task(&$task_hash, $player_level, $star, $player_id) { if ($star != 5 && $star != 4) { return; } $star_type = $star == 5 ? 1 : 2; $special_task = Cache_TaskConfig::getInstance()->get_special_bounty_task($player_level, $star_type); $special_task['star'] = $star; $special_task['step'] = 1; $special_task['task_status'] = 0; $task_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($special_task['task_id'], $special_task['step']); $special_task['step_type'] = $task_step_config['step_type']; $special_task['target'] = $this->get_game('TaskMain')->get_target_val($player_id, $task_step_config); if (isset($task_hash[$special_task['task_id']])) { $task_hash[$special_task['task_id']] = $special_task; } else { array_pop($task_hash); # 剔除最后一个随机任务 $task_hash[$special_task['task_id']] = $special_task; } #Com_Log::write('xcg.debug', "======".$special_task['task_id']."======".$star."======".count($task_hash)); #Com_Log::write('xcg.debug', var_export($task_hash, true)); }
/** * 触发主线任务的时候主线任务处理 * @param $player_id * @param $tasks 要处理的任务id 一维数组 * @param $target_id * @param $add_num * @param $arr_player_task 角色任务数据 * */ public function deal_main_task($player_id, $tasks, $target_type, $target_id, $add_num, &$arr_player_task, &$out_1002, &$logs, &$unlock_skill_info, $player_info) { $up_flag = false; //判断是否有任务变化 $jin_du = intval($arr_player_task['current_num']); foreach ($tasks as $task_id => $num) { if (isset($arr_player_task['main_val'][$task_id]) && $arr_player_task['main_val'][$task_id]['task_status'] == 0) { continue; } if (isset($arr_player_task['main_val'][$task_id]) && $arr_player_task['main_val'][$task_id]['task_status'] > 1) { continue; } if (!isset($arr_player_task['main_val'][$task_id]['target'][$target_id])) { continue; } $up_flag = true; $target_num = $arr_player_task['main_val'][$task_id]['target'][$target_id]['target_num']; // Com_Log::write("trigger_drama_task","target_num:".var_export($target_num,true)); if ($target_type == 8) { $arr_player_task['main_val'][$task_id]['target'][$target_id]['current_num'] = $add_num; } else { // Com_Log::log("task_id:{$task_id} | target_id:{$target_id} | current_num:{$arr_player_task['main_val'][$task_id]['target'][$target_id]['current_num']} | num:{$add_num}","test_target",1); $arr_player_task['main_val'][$task_id]['target'][$target_id]['current_num'] += $add_num; if ($arr_player_task['main_val'][$task_id]['target'][$target_id]['current_num'] > $target_num) { $arr_player_task['main_val'][$task_id]['target'][$target_id]['current_num'] = $target_num; } // Com_Log::log("task_id:{$task_id} | target_id:{$target_id} | current_num:{$arr_player_task['main_val'][$task_id]['target'][$target_id]['current_num']}","test_target",1); } $finsh_flag = true; foreach ($arr_player_task['main_val'][$task_id]['target'] as $val) { if ($val['target_num'] > $val['current_num']) { $finsh_flag = false; } } // Com_Log::write("trigger_drama_task","finsh_flag:".var_export($finsh_flag,true)); if ($finsh_flag) { $dup_id2 = 0; if (!empty($arr_player_task['main_val'][$task_id]['target'])) { foreach ($arr_player_task['main_val'][$task_id]['target'] as $target_id => $val) { $this->clear_main_task_target_val($arr_player_task, $task_id, $target_id); #清理target_val } } if ($arr_player_task['main_val'][$task_id]['dungeon_event_sid']) { Protocol::input($player_id, 7, 4, 471, $arr_player_task['main_val'][$task_id]['dungeon_event_sid']); //副本触发 } if (isset($arr_player_task['main_val'][$task_id]['buff_id']) && $arr_player_task['main_val'][$task_id]['buff_id'] > 0) { Protocol::input($player_id, 7, 4, 496, array('status' => 0, 'buff_id' => $arr_player_task['main_val'][$task_id]['buff_id'])); } //buff停止 $cur_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id, $arr_player_task['main_val'][$task_id]['step']); if ($arr_player_task['main_val'][$task_id]['task_steps'] == $arr_player_task['main_val'][$task_id]['step']) { if ($task_id == 11071) { try { $this->get_game('PlayerSkill')->default_set($player_id); Protocol_Player::p2c_part_update($player_id, array('skill_infos' => '')); } catch (Exception $e) { // Com_Log::write("task_skill_reset","player_id:{$player_id} skill_def_set error"); } } if ($cur_step_config['btn_dialog'] > 0) { $arr_player_task['main_val'][$task_id]['task_status'] = 2; $arr_player_task['main_val'][$task_id]['target'][$target_id]['current_num'] = $target_num; $logs[] = array('type' => 1, 'task_id' => $task_id, 'step' => $arr_player_task['main_val'][$task_id]['step'], 'status' => 2); } else { // $cur_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id,$arr_player_task['main_val'][$task_id]['step']); if (!empty($cur_step_config['unlock_skill_info'])) { $unlock_skill_info = $cur_step_config['unlock_skill_info']; } if ($task_id == 11071 || $task_id == 11045) { $this->get_game('PlayerWing')->update_wing_activation_condition($player_id, 6, $task_id); #激活翅膀 } $out_1002 = array('old' => array(), 'new' => array()); $old_task_status = 3; $out_1002['old'] = array('task_id' => $task_id, 'step' => $arr_player_task['main_val'][$task_id]['step'], 'task_status' => $old_task_status, 'task_data' => $this->get_game('TaskMain')->format_target($arr_player_task['main_val'][$task_id]['target'], $arr_player_task['main_val'][$task_id]['step_type']), 'index' => 1, 'current_num' => $jin_du, 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 1, 'task_star' => 0); $logs[] = array('type' => 1, 'task_id' => $task_id, 'step' => $arr_player_task['main_val'][$task_id]['step'], 'status' => $old_task_status); #自动完成的任务 统计任务进度 $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id); $max_num = Cache_TaskConfig::getInstance()->get_chapter_task_num($task_config['chapter_id'], $task_config['chapter_part']); $finish_num = $this->get_game('TaskMain')->get_chapter_task_finish_num($player_id, $task_config['chapter_id'], $task_config['chapter_part']); if ($finish_num <= 1) { $jin_du = 0; $arr_player_task['current_num'] = $jin_du; } else { $jin_du = ceil($finish_num / $max_num * 100); $arr_player_task['current_num'] = $jin_du; } $next_task_id = $arr_player_task['main_val'][$task_id]['next_task_id']; $next_task_config = Cache_TaskConfig::getInstance()->get_task_config($next_task_id); if (!empty($next_task_config)) { $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($next_task_id, 1); $arr_target = $this->get_game('TaskMain')->get_target_val($player_id, $step_config); if (!empty($arr_target)) { foreach ($arr_target as $target) { if (!empty($target)) { $arr_player_task['target_val'][$step_config['step_type']][$target['target_id']][$next_task_config['task_type']][$next_task_id] = $target['target_num']; } } } if ($step_config['dup_id2']) { $dup_id2 = $step_config['dup_id2']; // Com_Log::write("fb_city.".$player_id,"task_id:{$next_task_id} city:{$city_id}"); } // Com_Log::write("task_targeter.".$player_id,"min_level:{$next_task_config['min_level']} level:{$player_info['level']}"); if ($next_task_config['min_level'] > $player_info['level']) { $task_status = 0; } else { if ($step_config['step_type'] == 2) { $task_status = 2; //直接完成 } else { $task_status = 1; } } if ($step_config['buff_id']) { Protocol::input($player_id, 7, 4, 496, array('status' => 1, 'buff_id' => $step_config['buff_id'])); } //buff开始 $arr_player_task['main_val'][$next_task_id] = array('task_id' => $next_task_id, 'task_steps' => $next_task_config['task_steps'], 'step' => 1, 'task_status' => $task_status, 'next_task_id' => $next_task_config['next_task_id'], 'step_type' => $step_config['step_type'], 'dungeon_event_sid' => $step_config['dungeon_event_sid'], 'buff_id' => $step_config['buff_id'], 'btn_dialog' => $step_config['btn_dialog'], 'target' => $arr_target); // $arr_player_task['current_chapter'] = $next_task_config['chapter_id']; $out_1002['new'] = array('task_id' => $next_task_id, 'step' => 1, 'task_status' => $task_status, 'task_data' => $this->get_game('TaskMain')->format_target($arr_target, $next_task_config['task_steps']), 'index' => 1, 'cur_finish_num' => $jin_du, 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 1, 'task_star' => 0); $logs[] = array('type' => 1, 'task_id' => $next_task_id, 'step' => 1, 'status' => $task_status); ##新手引导 // Com_Log::write('guide_'.$player_id,"task_id:{$next_task_id} task_target_next:".$step_config['guide_type']); if (!empty($step_config['guide_type'])) { $guides = explode("|", $step_config['guide_type']); foreach ($guides as $guide) { // Com_Log::write('guide_'.$player_id,"task_id:{$next_task_id} task_target_next_guide:".$guide); Protocol_Guide::add($guide, 1); // Com_Log::write('task_guide.'.$player_id,"task trigger next guide:{$guide} task_guide:{$step_config['task_guide']}"); if ($step_config['task_guide'] == 1) { $out = array(); $this->get_game('TaskMain')->do_guide_task($player_id, $guide, 1, $arr_player_task, $out); } } } ++$arr_player_task['main_finish_count_acc']; unset($arr_player_task['main_val'][$task_id]); $this->get_game('FuncOpen')->do_func_open($player_id, 1, $task_id); #任务开启功能 // Com_Replication::asyn_call_func('PlayerTaskLog','data','add_player_task_log',array($player_id, $task_id)); #一步插入日志 } } } else { //自动接下一步 // $cur_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id,$arr_player_task['main_val'][$task_id]['step']); if (!empty($cur_step_config['unlock_skill_info'])) { $unlock_skill_info = $cur_step_config['unlock_skill_info']; } $out_1002 = array('old' => array(), 'new' => array()); $old_task_status = $arr_player_task['main_val'][$task_id]['task_status'] + 1; $out_1002['old'] = array('task_id' => $task_id, 'step' => $arr_player_task['main_val'][$task_id]['step'], 'task_status' => $old_task_status, 'task_data' => $this->get_game('TaskMain')->format_target($arr_player_task['main_val'][$task_id]['target'], $arr_player_task['main_val'][$task_id]['step_type']), 'index' => 1, 'cur_finish_num' => 0, 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 1, 'task_star' => 0); $logs[] = array('type' => 1, 'task_id' => $task_id, 'step' => $arr_player_task['main_val'][$task_id]['step'], 'status' => $old_task_status); $next_step = $arr_player_task['main_val'][$task_id]['step'] + 1; $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id); $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id, $next_step); $arr_target = $this->get_game('TaskMain')->get_target_val($player_id, $step_config); if (!empty($arr_target)) { foreach ($arr_target as $target) { if (!empty($target)) { $arr_player_task['target_val'][$step_config['step_type']][$target['target_id']][$task_config['task_type']][$task_id] = $target['target_num']; } } } if ($step_config['buff_id']) { Protocol::input($player_id, 7, 4, 496, array('status' => 1, 'buff_id' => $step_config['buff_id'])); } //buff开始 if ($step_config['dup_id2']) { $dup_id2 = $step_config['dup_id2']; // Com_Log::write("fb_city.".$player_id,"task_id:{$task_id} city:{$city_id}"); } if ($step_config['step_type'] == 2) { $task_status = 2; // if($step_config['dungeon_event_sid']) // Protocol::input($player_id,7,4,471,$step_config['dungeon_event_sid']); //副本触发 } else { $task_status = 1; } $arr_player_task['main_val'][$task_id]['step'] = $next_step; $arr_player_task['main_val'][$task_id]['task_status'] = $task_status; $arr_player_task['main_val'][$task_id]['step_type'] = $step_config['step_type']; $arr_player_task['main_val'][$task_id]['target'] = $arr_target; $arr_player_task['main_val'][$task_id]['dungeon_event_sid'] = $step_config['dungeon_event_sid']; $arr_player_task['main_val'][$task_id]['buff_id'] = $step_config['buff_id']; $arr_player_task['main_val'][$task_id]['btn_dialog'] = $step_config['btn_dialog']; $arr_player_task['current_chapter'] = $task_config['chapter_id']; $arr_player_task['current_chapter_part'] = $task_config['chapter_part']; $out_1002['new'] = array('task_id' => $task_id, 'step' => $next_step, 'task_status' => $task_status, 'task_data' => $this->get_game('TaskMain')->format_target($arr_target, $step_config['step_type']), 'index' => 1, 'cur_finish_num' => $arr_player_task['current_num'], 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 1, 'task_star' => 0); ##新手引导 // Com_Log::write('guide_'.$player_id,"task_id:{$task_id} task_target:".$step_config['guide_type']); if (!empty($step_config['guide_type'])) { $guides = explode("|", $step_config['guide_type']); foreach ($guides as $guide) { // Com_Log::write('guide_'.$player_id,"task_id:{$task_id} task_target_guide:".$guide); Protocol_Guide::add($guide, 1); // Com_Log::write('task_guide.'.$player_id,"task trigger step guide:{$guide} task_guide:{$step_config['task_guide']}"); if ($step_config['task_guide'] == 1) { $out = array(); $this->get_game('TaskMain')->do_guide_task($player_id, $guide, 1, $arr_player_task, $out); } } } $logs[] = array('type' => 1, 'task_id' => $task_id, 'step' => $next_step, 'status' => $task_status); } if ($dup_id2) { #开启副本 // Com_Log::write("fb_city.".$player_id," city:{$city_id}"); $this->get_game('PlayerFB')->update_fb_chapter_data_interface($player_id, $dup_id2); } } } return $up_flag; }