Exemplo n.º 1
0
 public function open_func($player_id, $city_id)
 {
     if ($city_id) {
         $mdata = Cache_PlayerFB::getInstance()->get_player_fb_info($city_id);
         if ($mdata['link_key']) {
             $sql = "select * from map_chapter where link_key = {$mdata['link_key']}";
             $result = $this->query($sql, 'setting');
             $arrSortData = array();
             $arrData = array();
             while ($this->next_record('setting')) {
                 $sid = $this->get_field('sid');
                 $arrSortData[] = $sid;
                 $arrData[$sid] = $this->get_record();
             }
             if ($arrData) {
                 rsort($arrSortData);
                 $max_sid = reset($arrSortData);
                 $mapData = $arrData[$max_sid];
                 $obj_player_fb_data = $this->get_data('PlayerFB');
                 $fb_data = $obj_player_fb_data->get_player_fb_info($player_id);
                 $data['chapter_info'] = json_decode($fb_data['chapter_info'], true);
                 $sql = "select * from map where chapter <= {$mapData['chapter']}";
                 $this->query($sql, 'setting');
                 $maps = array();
                 $pass_id = array();
                 $end_page = array();
                 while ($this->next_record('setting')) {
                     $map = $this->get_record();
                     //{"1":{"1":{"2111":{"fb_id":"2111","link_key":"66"};
                     $maps[$map['chapter']][$map['page']][] = $map;
                     $data['chapter_info'][$map['chapter']][$map['page']][$map['sid']]['fb_id'] = $map['sid'];
                     $data['chapter_info'][$map['chapter']][$map['page']][$map['sid']]['link_key'] = $map['link_key'];
                     if ($map['chapter'] == $mapData['chapter'] && $mapData['page'] == $map['page']) {
                         $data['chapter_info'][$map['chapter']][$map['page']][$map['sid']]['passed'] = 0;
                         $end_page[] = $map;
                     } else {
                         $data['chapter_info'][$map['chapter']][$map['page']][$map['sid']]['passed'] = 1;
                         $pass_id[$map['sid']] = 1;
                     }
                 }
                 foreach ($end_page as $m) {
                     if (isset($pass_id[$m['required_passed_dungeon_map_sid_0']])) {
                         $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['fb_id'] = $m['sid'];
                         $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['link_key'] = $m['link_key'];
                         $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['passed'] = 1;
                         $pass_id[$m['sid']] = 1;
                     } else {
                         $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['fb_id'] = $m['sid'];
                         $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['link_key'] = $m['link_key'];
                         $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['passed'] = 0;
                     }
                 }
                 //                    foreach($maps as $chapter=>$c){
                 //                        if($mapData['chapter'] > $chapter) continue;
                 //                        foreach($c as $page=>$m){
                 //
                 ////                            if($mapData['page'] < $page){
                 //                                $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['fb_id'] = $m['sid'];
                 //                                $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['link_key'] = $m['link_key'];
                 //                                $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['passed'] = 1;
                 ////                                $pass_id[$m['sid']] = 1;
                 ////                            }
                 ////                            else{
                 ////
                 ////                                $end_page = $m;
                 ////                            }
                 //                        }
                 //                    }
                 //                    var_dump($data);exit;
                 //                    foreach($end_page as $m){
                 //                        if(isset($pass_id[$m['required_passed_dungeon_map_sid_0']])){
                 //                            $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['fb_id'] = $m['sid'];
                 //                            $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['link_key'] = $m['link_key'];
                 //                            $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['passed'] = 1;
                 //                            $pass_id[$m['sid']] = 1;
                 //                        }
                 //                        else{
                 //                            $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['fb_id'] = $m['sid'];
                 //                            $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['link_key'] = $m['link_key'];
                 //                            $data['chapter_info'][$m['chapter']][$m['page']][$m['sid']]['passed'] = 0;
                 //                        }
                 //                    }
                 $data['chapter_id'] = $mapData['chapter'];
                 $data['page'] = $mapData['page'];
                 $data['chapter_info'] = json_encode($data['chapter_info']);
                 $res = $this->get_data('PlayerFB')->update_player_fb($player_id, $data);
                 var_dump($res);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @Purpose:
  * VIP副本资源挽回接口
  * @param $player_id 玩家ID
  * @param $player_level 玩家等级
  * @param $player_vip 玩家等级
  * @param $times 奖励次数
  * @param $fb_grade 副本奖励评分等级
  */
 public function vip_fb_resource_retrieve($player_id, $player_level, $player_vip, $times = 1, $fb_grade = 2)
 {
     $player_id = intval($player_id);
     $times = intval($times);
     $player_level = intval($player_level);
     $player_vip = intval($player_vip);
     $fb_grade = intval($fb_grade);
     $rtn_exp = 0;
     $fb_id = 0;
     $map_vip_table = Cache_MapVip::getInstance()->get_map_vip_info();
     if (empty($map_vip_table) || !Com_Array::is_good_arr($map_vip_table)) {
         $this->throw_error('113601');
         #map_vip配置表读取错误
     }
     foreach ($map_vip_table as $fb_data) {
         if ($player_level >= $fb_data['level_limit'] && $player_vip >= $fb_data['vip_level_limit']) {
             $fb_id = $fb_data['map_id'];
         } else {
             break;
         }
     }
     if ($fb_id > 0) {
         $map_vip_level_table = Cache_MapVip::getInstance()->get_map_vip_level_add_info(array('level' => $player_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])) {
                 $map_grade_table = Cache_PlayerFB::getInstance()->get_map_grade_info(array('map_id' => $fb_id, 'grade' => $fb_grade));
                 $rtn_exp = intval($add_info[1] * ($map_grade_table['award'] / 100));
             }
         }
         $this->create_monster_data($fb_id, 1, $player_level, $rtn_exp);
     }
     return $rtn_exp * $times;
 }
Exemplo n.º 3
0
 /**
  * C++拾取道具到包裹接口 S2P_LootItemReq 详细看文档 拾取道具请求
  * @param $item_entity_id
  * @param $prop_id
  * @param $prop_num
  * @param $player_id
  * @return array
  */
 public function loot_item($item_entity_id, $prop_id, $prop_num, $player_id)
 {
     $out = array();
     $out[0] = intval($item_entity_id);
     $out[1] = intval($prop_id);
     $out[2] = intval($prop_num);
     $out[3] = intval($player_id);
     $result = false;
     $reward = array();
     if ($this->_begin_batch) {
         if (!isset($this->_player_infos[$player_id])) {
             $this->_player_infos[$player_id] = $this->get_data('Player')->get_player_info($player_id, array('name', 'map_id', 'career_type', 'level', 'exp', 'level_exp', 'silver', 'gold', 'ticket', 'chips', 'honor', 'kf_coin', 'vip', 'crystal', 'fame', 'fame_level', 'fame_level_exp', 'kf_score', 'union_id', 'privilege_level', 'bag_num'));
         }
         $params = $this->_player_infos[$player_id];
     } else {
         $params = $this->get_data('Player')->get_player_info($player_id, array('name', 'map_id', 'career_type', 'level', 'exp', 'level_exp', 'silver', 'gold', 'ticket', 'chips', 'honor', 'kf_coin', 'vip', 'crystal', 'fame', 'fame_level', 'fame_level_exp', 'kf_score', 'union_id', 'privilege_level', 'bag_num'));
     }
     if (defined('JSON_PROTOCOL') && JSON_PROTOCOL > 0 && $prop_id > 30) {
         if ($params['career_type'] == 3) {
             switch ($prop_id) {
                 case 142001:
                     $prop_id = 132001;
                     break;
                 case 146001:
                     $prop_id = 136001;
                     break;
                 case 143001:
                     $prop_id = 133001;
                     break;
                 case 144001:
                     $prop_id = 134001;
                     break;
                 case 147001:
                     $prop_id = 137001;
                     break;
                 case 141001:
                     $prop_id = 131001;
                     break;
                 case 140001:
                     $prop_id = 130001;
                     break;
                 case 148001:
                     $prop_id = 138001;
                     break;
             }
         }
     }
     $reward[] = array('type' => Cache_Currency::getInstance()->get_key($prop_id), 'item_id' => $prop_id, 'item_num' => $prop_num);
     if ($prop_id > 30) {
         $map_id = $params['map_id'];
         $map_config = Cache_PlayerFB::getInstance()->get_player_fb_info($map_id);
         if ($map_config['dungeon_type'] == 0) {
             $fun_id = 1020;
         } elseif ($map_config['dungeon_type'] == 24) {
             $fun_id = 4071;
         } else {
             $fun_id = 1010;
         }
         $params['func_id'] = $fun_id;
         $params['chapter'] = $map_config['chapter_id'];
         $params['map_id'] = $map_id;
     }
     $params['cmd_id'] = '408';
     $result = $this->get_game('Reward')->send_reward($player_id, $reward, $params, 1);
     if ($result !== true) {
         if ($result == '80001') {
             $out[4] = intval(5);
             //包裹已经满了
         } else {
             $out[4] = intval(7);
             //道具配置出错
         }
     } else {
         $out[4] = 0;
         if (defined('JSON_PROTOCOL') && JSON_PROTOCOL > 0) {
             $props = $this->get_game('Reward')->get_prop_log();
             if ($props) {
                 $j_ids = array();
                 foreach ($props as $prop) {
                     $j_ids['player_prop_id'][] = $prop['player_prop_id'];
                 }
                 echo json_encode($j_ids);
             } else {
                 echo json_encode(array());
             }
         } else {
             $this->get_game('Reward')->add_reward_log();
         }
         if ($prop_id > 30) {
             #只统计道具
             $this->get_game('TaskTrigger')->async_trigger_task($player_id, 5, $prop_id, $prop_num);
             //收集道具
         }
     }
     return $out;
 }
Exemplo n.º 4
0
 private function daily_task_rule_apply($player_id, $task_info)
 {
     if ($task_info['task_step_type'] == 100 || $task_info['task_step_type'] == 101) {
         # [主线|挑战]副本类型日常任务
         $rule = Cache_TaskDaily::getInstance()->get_task_daily_rule($task_info['task_step_type']);
         if (empty($rule)) {
             $this->throw_error('10019');
             # 日常任务特殊规则未配置
         }
         # 随机副本权重列表
         $weight_list = explode(":", $rule['rule_param2']);
         if (empty($weight_list) || $rule['rule_param1'] != count($weight_list)) {
             $this->throw_error('10020');
             # 日常任务特殊规则配置错误
         }
         if ($task_info['task_step_type'] == 100) {
             $map_list = $this->get_game('PlayerFB')->get_pass_fb_last_interface($player_id, $rule['rule_param1']);
             Com_Log::write('xgame.dailytask', "player_id:{$player_id}:task_step_type:100" . json_encode($map_list));
             if (empty($map_list)) {
                 #$this->throw_error('10021'); # 特定类型的日常任务无法生成
                 $map_info = Cache_PlayerFB::getInstance()->get_player_fb_info($this->task_first_fb_map_id);
                 $map_list[] = array('map_id' => $this->task_first_fb_map_id, 'difficulty' => $map_info['difficulty']);
             }
             # 考虑map_list可能少于weight_list,先去除无效的索引
             for ($i = count($map_list); $i < $rule['rule_param1']; $i++) {
                 unset($weight_list[$i]);
             }
             $rand_idx = Com_Random::get_probability_key($weight_list);
             # 随机一个索引
             $task_info['dup_id'] = $map_list[$rand_idx]['map_id'];
             # 要求通关的副本ID
             # 处理难度加星
             if (!empty($rule['rule_param3'])) {
                 $star_add_info = explode("|", $rule['rule_param3']);
                 $star_add_hash = array();
                 foreach ($star_add_info as $key => $val) {
                     list($difficulty, $star_add) = explode(":", $val);
                     $star_add_hash[$difficulty] = $star_add;
                 }
                 $task_info['star'] += $star_add_hash[$map_list[$rand_idx]['difficulty']];
             }
             # 处理要求通关的水平以及通关水平加星
             if (!empty($rule['rule_param4'])) {
                 $clear_grade_info = explode("|", $rule['rule_param4']);
                 $weight_hash = array();
                 $star_add_hash = array();
                 foreach ($clear_grade_info as $key => $val) {
                     list($clear_grade, $weight, $star_add) = explode(":", $val);
                     $weight_hash[$clear_grade] = $weight;
                     $star_add_hash[$clear_grade] = $star_add;
                 }
                 $rand_clear_grade = Com_Random::get_probability_key($weight_hash);
                 # 随机一个通关水平
                 $task_info['star'] += $star_add_hash[$rand_clear_grade];
                 $task_info['dup_cle_grade'] = $rand_clear_grade;
             }
             # 星级边界值修正
             $task_info['star'] = min($task_info['star'], $this->task_star_stint);
         } elseif ($task_info['task_step_type'] == 101) {
             $map_list = $this->get_game('PlayerPVE')->get_last_three_chapter_id($player_id, $rule['rule_param1']);
             Com_Log::write('xgame.dailytask', "task_step_type:101" . json_encode($map_list));
             if (empty($map_list)) {
                 #$this->throw_error('10021'); # 特定类型的日常任务无法生成
                 $map_list[] = $this->task_first_pve_map_id;
             }
             $map_list = array_reverse($map_list);
             # 倒序
             # 考虑map_list可能少于weight_list,先去除无效的索引
             for ($i = count($map_list); $i < $rule['rule_param1']; $i++) {
                 unset($weight_list[$i]);
             }
             $rand_idx = Com_Random::get_probability_key($weight_list);
             # 随机一个索引
             $task_info['dup_id'] = $map_list[$rand_idx];
             # 要求通关的副本ID
         }
     } else {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('level'));
         if ($task_info['task_step_type'] == 103) {
             # 守卫雅典娜副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 2);
         } elseif ($task_info['task_step_type'] == 104) {
             # 世界BOSS副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 1);
         } elseif ($task_info['task_step_type'] == 105) {
             # 抢矿副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 4);
         } elseif ($task_info['task_step_type'] == 116) {
             # 通关副本ID
             #$task_info['dup_id'] = $task_info['city_id'];
         } elseif ($task_info['task_step_type'] == 117) {
             $task_info['dialog_task_id'] = Cache_TaskDaily::getInstance()->get_task_daily_dialog_id($player_info['level']);
         } elseif ($task_info['task_step_type'] == 10) {
             # 随机一个关联的采集主线任务ID
             $main_task_id = Cache_TaskDaily::getInstance()->get_task_daily_collection_id($player_info['level']);
             $main_task_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($main_task_id, 1);
             if (empty($main_task_step_config) || !is_array($main_task_step_config)) {
                 Com_Log::write('xgame.dailytask', "task_step_type:10\t" . $main_task_id);
             } else {
                 $main_task_step_config['kill_npc_sid'] = $main_task_step_config['task_id'];
                 $task_info = array_merge($main_task_step_config, $task_info);
                 # 显示需要使用task_daily_base表的task_id,故而合并时,task_info靠后
             }
         }
     }
     return $task_info;
 }