Пример #1
0
 /**
  * 获取新手引导s
  * @param $player_id
  * @return array
  */
 public function get_guid($player_id, $player_detail = null, $task_info = null)
 {
     $out = array();
     if (is_null($player_detail) || !isset($player_detail['guide'])) {
         $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('guide'));
         $data = $player_detail['guide'];
     } else {
         $data = $player_detail['guide'];
     }
     if (!isset($task_info['main_val'])) {
         $task_info = $this->get_data('PlayerTask')->get_task_info($player_id, array('main_val'));
     }
     $task_guides = array();
     if (!empty($task_info['main_val'])) {
         $task_main_info = reset($task_info['main_val']);
         $task_id = $task_main_info['task_id'];
         $task_step = $task_main_info['step'];
         $task_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id, $task_step);
         if (!empty($task_config['guide_type'])) {
             $task_guides = explode("|", $task_config['guide_type']);
         }
     }
     if ($data) {
         foreach ($data as $guide_id => $step) {
             //                if($step > 0  || ($data[$task_config['guide_id']] > )) continue; #0是已经完成的不给前端
             //                if($step > 0 || ($step == 0 && in_array($guide_id,$task_guides))){
             //                    $out[0][] = array('guide_id'=>$guide_id,'step'=>$step);
             //                }
             $out[0][] = array('guide_id' => $guide_id, 'step' => $step);
         }
     }
     return $out;
 }
Пример #2
0
 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;
 }
Пример #3
0
 /**
  * 完成任务
  * @param $player_id
  * @param $task_id
  * @param $step_id
  * @param $arr_player_task 任务数据
  */
 public function finish_main_task($player_id, $task_id, $step_id)
 {
     $time_start = microtime(true);
     $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id);
     if (empty($arr_player_task['main_val'][$task_id])) {
         $this->throw_error('10107');
         //参数错误
     }
     if ($arr_player_task['main_val'][$task_id]['task_status'] < 2) {
         $this->throw_error('10015');
         //任务还未完成
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level', 'vip', 'privilege_level', 'union_id'));
     $out = array('old' => array(), 'new' => array());
     $current_num = intval($arr_player_task['current_num']);
     $task_config = Cache_TaskConfig::getInstance()->get_task_config($task_id);
     $cur_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id, $step_id);
     if (!empty($arr_player_task['main_val'][$task_id]['target'])) {
         foreach ($arr_player_task['main_val'][$task_id]['target'] as $target_id => $val) {
             $this->get_game('TaskTrigger')->clear_main_task_target_val($arr_player_task, $task_id, $target_id);
             #清理target_val
         }
     }
     #更新任务进度
     if ($arr_player_task['main_val'][$task_id]['task_steps'] == $arr_player_task['main_val'][$task_id]['step']) {
         $max_num = Cache_TaskConfig::getInstance()->get_chapter_task_num($task_config['chapter_id'], $task_config['chapter_part']);
         $finish_num = $this->get_chapter_task_finish_num($player_id, $task_config['chapter_id'], $task_config['chapter_part']);
         if ($max_num) {
             $jin_du = ceil($finish_num / $max_num * 100);
         } else {
             $jin_du = 0;
         }
         $arr_player_task['current_num'] = $jin_du;
     }
     if ($cur_step_config['dungeon_event_sid']) {
         Protocol::input($player_id, 7, 4, 471, $cur_step_config['dungeon_event_sid']);
     }
     //副本触发
     if ($cur_step_config['buff_id']) {
         Protocol::input($player_id, 7, 4, 496, array('status' => 0, 'buff_id' => $cur_step_config['buff_id']));
     }
     //buff结束
     $logs = array();
     $old_task_status = $arr_player_task['main_val'][$task_id]['task_status'] + 1;
     $out['old'] = array('task_id' => $task_id, 'step' => $step_id, 'task_status' => $old_task_status, 'task_data' => $this->format_target($arr_player_task['main_val'][$task_id]['target'], $cur_step_config['step_type']), 'index' => 1, 'cur_finish_num' => $current_num, 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 1, 'task_star' => 0);
     $logs[] = array('type' => 1, 'task_id' => $task_id, 'step' => $step_id, 'status' => $old_task_status);
     //        //统计对象清除   触发的时候已经删除 这地方先注释
     //        if(!empty($arr_player_task['main_val'][$task_id]['target'])){
     //            unset($arr_player_task['target_val'][$arr_player_task['main_val'][$task_id]['step_type']][$arr_player_task['main_val'][$task_id]['target']['target_id']][$task_config['task_type']][$task_id]);
     //        }
     $deduct_prop = array();
     //收集道具任务 扣除道具
     if ($arr_player_task['main_val'][$task_id]['step_type'] == 5) {
         //收集道具任务
         foreach ($arr_player_task['main_val'][$task_id]['target'] as $target) {
             $deduct_prop[$target['target_id']] = $target['target_num'];
         }
     }
     $out_12 = array();
     $dup_id2 = 0;
     $func_open_task_id = 0;
     #功能开启的任务id
     $reset_skill = false;
     $upgrade_async = true;
     if ($arr_player_task['main_val'][$task_id]['step'] >= $arr_player_task['main_val'][$task_id]['task_steps']) {
         //下一个任务
         $func_open_task_id = $task_id;
         $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 ($task_id == 11071) {
             $reset_skill = true;
         }
         if (!empty($next_task_config)) {
             $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($next_task_id, 1);
             //                Com_Log::log("================[step config]================","fb_task",1);
             //                Com_Log::log($step_config,"fb_task",1);
             $arr_target = $this->get_target_val($player_id, $step_config);
             //                Com_Log::log("================[target]================","fb_task",1);
             //                Com_Log::log($arr_target,"fb_task",1);
             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,"main task_id:{$next_task_id} city:{$city_id}");
             }
             //                Com_Log::write("deal_main_task.".$player_id,"task_main  min_level:{$next_task_config['min_level']} level:{$next_task_config['level']}");
             //                Com_Log::write("task_targeter.".$player_id,"main min_level:{$next_task_config['min_level']} level:{$player_info['level']}");
             if ($next_task_config['min_level'] > $player_info['level']) {
                 $task_status = 0;
                 $upgrade_async = false;
             } 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'];
             $arr_player_task['current_chapter_part'] = $next_task_config['chapter_part'];
             $finish_num = $this->get_chapter_task_finish_num($player_id, $next_task_config['chapter_id'], $next_task_config['chapter_part']);
             if ($finish_num <= 1) {
                 $arr_player_task['current_num'] = 0;
             }
             $out['new'] = array('task_id' => $next_task_id, 'step' => 1, 'task_status' => $task_status, 'task_data' => $this->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);
             $logs[] = array('type' => 1, 'task_id' => $next_task_id, 'step' => 1, 'status' => $task_status);
             ++$arr_player_task['main_finish_count_acc'];
             if ($step_config['step_type'] == 12) {
                 $out_12['city_escort_map_sid'] = $step_config['city_id'];
                 $out_12['city_escort_target_x'] = $step_config['pro_addr_x'];
                 $out_12['city_escort_target_y'] = $step_config['pro_addr_y'];
                 $pro_npc = explode("|", $step_config['pro_npc']);
                 $out_12['city_escort_npc_sid'] = $pro_npc[0];
             }
             ##新手引导
             //                Com_Log::write('guide_'.$player_id,"task_id:{$next_task_id} task_main:".$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_main_guide:".$guide);
                     Protocol_Guide::add($guide, 1);
                     //                        Com_Log::write('task_guide.'.$player_id,"task main next guide:{$guide} task_guide:{$step_config['task_guide']}");
                     if ($step_config['task_guide'] == 1) {
                         $this->do_guide_task($player_id, $guide, 1, $arr_player_task, $out);
                     }
                 }
             }
             if ($task_id != $next_task_id) {
                 #压力测试 接重复的任务 所以这地方不能unset
                 unset($arr_player_task['main_val'][$task_id]);
             }
         }
     } else {
         //下一步任务
         $next_step = $arr_player_task['main_val'][$task_id]['step'] + 1;
         $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($task_id, $next_step);
         $arr_target = $this->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['dup_id2']) {
             $dup_id2 = $step_config['dup_id2'];
             //                Com_Log::write("fb_city.".$player_id,"main task_id:{$task_id} city:{$city_id}");
         }
         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'][$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['new'] = array('task_id' => $task_id, 'step' => $next_step, 'task_status' => $task_status, 'task_data' => $this->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);
         $logs[] = array('type' => 1, 'task_id' => $task_id, 'step' => $next_step, 'status' => $task_status);
         if ($step_config['step_type'] == 12) {
             $out_12['city_escort_map_sid'] = $step_config['city_id'];
             $out_12['city_escort_target_x'] = $step_config['pro_addr_x'];
             $out_12['city_escort_target_y'] = $step_config['pro_addr_y'];
             $pro_npc = explode("|", $step_config['pro_npc']);
             $out_12['city_escort_npc_sid'] = $pro_npc[0];
         }
         ##新手引导
         //            Com_Log::write('guide_'.$player_id,"task_id:{$task_id} task_main_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:{$task_id} task_main_next_guide:".$guide);
                 Protocol_Guide::add($guide, 1);
                 //                    Com_Log::write('task_guide.'.$player_id,"task main step guide:{$guide} task_guide:{$step_config['task_guide']}");
                 if ($step_config['task_guide'] == 1) {
                     $this->do_guide_task($player_id, $guide, 1, $arr_player_task, $out);
                 }
             }
         }
     }
     $career_type = $player_info['career_type'];
     $this->start_trans();
     $result = $this->get_data('PlayerTask')->set_task_info($player_id, $arr_player_task);
     //更新任务
     if ($result) {
         //领奖励
         $task_award_config = Cache_TaskAwardConfig::getInstance()->get_task_award_info($task_id, $step_id);
         if (!empty($task_award_config)) {
             $reward = array();
             if (!empty($task_award_config['prop_info'])) {
                 $prop_info = explode('|', $task_award_config['prop_info']);
                 foreach ($prop_info as $v) {
                     $prop = explode(':', $v);
                     if ($prop[0] > 100) {
                         $reward[] = array('type' => 'prop', 'item_id' => $prop[0], 'item_num' => $prop[1]);
                     } else {
                         $key = Cache_PropLoot::getInstance()->get_item_key($prop[0]);
                         if ($key != 'prop') {
                             $reward[] = array('type' => $key, 'item_id' => $prop[0], 'item_num' => $prop[1]);
                         }
                     }
                 }
             }
             $career_reward_key = "career_type_reward_{$career_type}";
             //                Com_Log::log("career_reward_key:".$career_reward_key,"task_award,log",1);
             if (isset($task_award_config[$career_reward_key]) && !empty($task_award_config[$career_reward_key])) {
                 $prop_info = explode('|', $task_award_config[$career_reward_key]);
                 foreach ($prop_info as $v) {
                     $prop = explode(':', $v);
                     if ($prop[0] > 100) {
                         $reward[] = array('type' => 'prop', 'item_id' => $prop[0], 'item_num' => $prop[1]);
                     } else {
                         $key = Cache_PropLoot::getInstance()->get_item_key($prop[0]);
                         if ($key != 'prop') {
                             $reward[] = array('type' => $key, 'item_id' => $prop[0], 'item_num' => $prop[1]);
                         }
                     }
                 }
             }
             //                Com_Log::log("prop:".var_export($reward,true),"task_award,log",1);
             if (!empty($reward)) {
                 $params = array('cmd_id' => '1002', 'func_id' => 1020, 'bind_flag' => 0, 'chapter' => $task_config['chapter_id'], 'map_id' => $cur_step_config['city_id']);
                 //                    Com_Log::log($params,"sysnotice.log",1);
                 //                    Com_Log::write("task_reward.".$player_id,"task_id:{$task_id} step:{$step_id} #".var_export($reward,true));
                 $result = $this->get_game('Reward')->send_reward($player_id, $reward, $params, 0);
                 if ($result !== true) {
                     if ($result == '80001') {
                         $result = "10018";
                     }
                     $this->throw_error($result);
                 }
             }
         }
     }
     if ($result && !empty($deduct_prop) && $cur_step_config['step_type'] != 11) {
         $arr_logs = array();
         foreach ($deduct_prop as $prop_id => $need_num) {
             $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $prop_id, $need_num, $arr_logs, 1, array('cmd_id' => 1010, 'level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level']));
         }
     }
     if ($result) {
         $this->commit();
         if (!empty($cur_step_config['unlock_skill_info'])) {
             $this->get_game('PlayerSkill')->flush_locked_skill($player_id, $player_info['career_type'], $cur_step_config['unlock_skill_info'], $player_info['level'], $arr_player_task['main_val'], $task_id, $step_id);
         }
         if ($dup_id2) {
             #开启副本
             //                Com_Log::write("fb_city.".$player_id,"main city:{$city_id}");
             $this->get_game('PlayerFB')->update_fb_chapter_data_interface($player_id, $dup_id2);
         }
         Protocol::input($player_id, 3, 10, 1002, array(0 => $out));
         //            Com_Log::write('task_1002.'.$player_id,"task_main_finish:".var_export($out,true));
         $this->get_game('Reward')->add_reward_log(false, 0, 1, $upgrade_async);
         if (isset($arr_logs) && !empty($arr_logs)) {
             Protocol_Prop::prop_806($player_id, $arr_logs);
         }
         $task_main_info = reset($arr_player_task['main_val']);
         $out_12['task_id'] = $task_main_info['task_id'];
         $out_12['task_step'] = $task_main_info['step'];
         if ($task_main_info['task_status'] == 1) {
             $out_12['task_start_status'] = 1;
         } else {
             $out_12['task_start_status'] = 0;
         }
         Protocol_Player::p2c_part_update($player_id, $out_12);
         #同步状态 分进程了 不能合下面skill_infos一起发了发了脏数据会乱
         //            Com_Log::write('out_12.'.$player_id,"trigger:".var_export($out_12,true));
         if ($reset_skill) {
             try {
                 $this->get_game('PlayerSkill')->default_set($player_id, $player_info);
                 Protocol_Player::p2c_part_update($player_id, array('skill_infos' => array()));
             } catch (Exception $e) {
                 //                    Com_Log::write("task_skill_reset","player_id:{$player_id} skill_def_set error");
             }
         }
         //            SynPlayer::set_syn_data($out_12);
         //            $data = SynPlayer::get_data();
         //            Protocol::input($player_id,7,4,417,array(0=>$data['m'],1=>$data['u']));
         if ($func_open_task_id) {
             $this->get_game('FuncOpen')->do_func_open($player_id, 1, $func_open_task_id);
             if ($func_open_task_id == 11071 || $func_open_task_id == 11045) {
                 $this->get_game('PlayerWing')->update_wing_activation_condition($player_id, 6, $func_open_task_id);
             }
             //                Com_Replication::asyn_call_func('PlayerTaskLog','data','add_player_task_log',array($player_id, $func_open_task_id)); #一步插入日志
         }
         # 公会成就处理
         $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 4, 1, 1, $player_info['union_id'] ? $player_info['union_id'] : 0);
         if ($logs) {
             Log_Task::getInstance()->add_multi_task_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], $logs);
         }
         #推新手引导
         Protocol_Guide::out($player_id, $player_info);
     } else {
         $this->throw_error('10104');
     }
 }
Пример #4
0
 public function fix_chain_task($player_id)
 {
     $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id, array('chain_val', 'target_val'));
     $chain_val = $arr_player_task['chain_val'];
     if (empty($chain_val)) {
         return true;
     }
     $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($chain_val['task_id'], $chain_val['task_step']);
     if ($step_config['step_type'] != $chain_val['step_type']) {
         $arr_player_task = $this->get_init_chain_val($player_id, $chain_val['task_id'], $chain_val['task_step']);
         $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('chain_val' => $arr_player_task['chain_val'], 'target_val' => $arr_player_task['target_val']));
         if ($result) {
             $data = $this->get_chain_task_list($player_id, $arr_player_task);
             Protocol::input($player_id, 8, 10, 1025, $data);
             Protocol::out();
         }
     }
 }
Пример #5
0
 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";
     }
 }
Пример #6
0
 /**
  * 替换一个特定星级的保底任务
  * 规则:保底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));
 }
Пример #7
0
 /**
  * 触发主线任务的时候主线任务处理
  * @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;
 }