Example #1
0
 /**
  * 获取章节副本信息
  * @param $player_id 玩家ID
  * @param $chapter_id 章节ID
  * @param $page 页数
  */
 public function get_chapter_fb_info($player_id, $chapter_id, $page)
 {
     $player_id = intval($player_id);
     $chapter_id = intval($chapter_id);
     $page = intval($page);
     $this->start_trans();
     $obj_player_fb_data = $this->get_data('PlayerFB');
     $fb_data = $obj_player_fb_data->get_player_fb_info($player_id);
     if (!$fb_data) {
         $chapter_id = $chapter_id > -1 ? $chapter_id : 0;
         $page = $page > 0 ? $page : 1;
         $data = $this->create_player_fb($player_id, $chapter_id, $page);
         $obj_player_fb_data = $this->get_data('PlayerFB');
         $add_fb_res = $obj_player_fb_data->add_player_fb($data);
         if (!$add_fb_res) {
             $this->throw_error('10101');
         }
         $data['cur_max_chapter'] = $chapter_id;
         $data['cur_max_page'] = $page;
         $data['chapter_info'] = json_decode($data['chapter_info'], true);
         $data['chapter_star'] = json_decode($data['chapter_star'], true);
         $data['chapter_chest'] = json_decode($data['chapter_chest'], true);
         //更新临时数据区数据
         $this->update_temporary_player_fb_data($data);
     } else {
         $fb_data['cur_max_chapter'] = intval($fb_data['chapter_id']);
         if ($chapter_id > -1 && $chapter_id < $fb_data['chapter_id']) {
             #获取副本章节配置表
             $map_chapter_table = $this->get_cache_table_data('map_chapter_table', array('chapter' => $chapter_id));
         }
         $fb_data['cur_max_page'] = $map_chapter_table['max_page'] < 1 ? $fb_data['page'] : $map_chapter_table['max_page'];
         $chapter_id = $chapter_id > -1 && $chapter_id <= $fb_data['chapter_id'] ? $chapter_id : intval($fb_data['chapter_id']);
         $page = $page > 0 && $page <= $fb_data['cur_max_page'] ? $page : intval($fb_data['page']);
         $fb_data['chapter_id'] = $chapter_id;
         $fb_data['page'] = $page;
         $fb_data['chapter_info'] = json_decode($fb_data['chapter_info'], true);
         $fb_data['chapter_star'] = json_decode($fb_data['chapter_star'], true);
         $fb_data['chapter_chest'] = json_decode($fb_data['chapter_chest'], true);
         $update_data = array();
         $repair_flag = $fb_data['repair_flag'];
         $this->data_repair($player_id, $fb_data);
         if ($repair_flag != $fb_data['repair_flag']) {
             $update_data['repair_flag'] = $fb_data['repair_flag'];
         }
         //更新临时数据区数据
         $this->update_temporary_player_fb_data($fb_data);
         /*
         $player_fb_data = $this->get_player_chapter_by_id($player_id, $chapter_id);
         if (!$player_fb_data['chapter_info'])
         {
         	$add_fb_res = $this->add_player_chapter_info($player_id, $chapter_id, $page);
         	if (!$add_fb_res)
         	{
         		$this->throw_error('10101');
         	}
         }
         */
         if ($fb_data['first_enter'] == 1) {
             $update_data['first_enter'] = 0;
         }
         if (!empty($update_data)) {
             $update_res = $this->get_data('PlayerFB')->update_player_fb($player_id, $update_data);
             if (!$update_res) {
                 $this->throw_error('10101');
             }
         }
     }
     /*
     //玩家第一次使用副本
     $use_fb_res = $this->is_first_use_fb($player_id);
     if (!$use_fb_res)
     {
     	 //玩家第一次进此章节创建初始章节副本数据
     	$enter_fb_res = $this->is_first_enter_chapter($player_id);
     }
     */
     $this->commit();
     //获取临时数据区英雄数据
     $player_fb_data = $this->get_temporary_player_fb_data();
     if (!$player_fb_data) {
         $this->throw_error('10110');
         //数据错误
     }
     //获取日使用副本次数
     $player_fb_data['fb_num'] = $this->get_day_num($player_id);
     #日最大次数
     $player_fb_data['fb_num_max'] = $this->get_day_num_max($player_id);
     if ($chapter_id <= -1) {
         $chapter_id = $player_fb_data['chapter_id'];
     }
     if ($page <= 0) {
         $page = $player_fb_data['page'];
     }
     //副本信息格式化
     $chapter_list = $this->format_fb_info($player_id, $player_fb_data['chapter_info'][$chapter_id][$page], $chapter_id, $page);
     //输出字段格式化
     $player_fb_data['chapter_list'] = $chapter_list;
     $player_fb_data['star'] = $player_fb_data['chapter_star'][$chapter_id];
     $player_fb_data['chapter_chest_list'] = $player_fb_data['chapter_chest'][$chapter_id];
     $player_fb_data['chapter_chest_info'] = $this->get_chest_info($chapter_id, $player_fb_data['star'], $player_fb_data['chapter_chest_list']);
     $buy_times_table = $this->get_cache_table_data('buy_times_table', 1);
     if (!$buy_times_table) {
         $this->throw_error('10109');
         #配置表读取错误
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('privilege_level', 'vip'));
     #获取VIP类型
     $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10007);
     if ($vip_type['fun_type'] == 2) {
         $player_vip = $player_info['privilege_level'];
     } else {
         $player_vip = $player_info['vip'];
     }
     $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10007);
     if ($vip_table['vip_level'] > 0 && $player_vip >= $vip_table['vip_level']) {
         if (!isset($vip_table['max_times']) || $vip_table['max_times'] < 1) {
             $vip_table['max_times'] = 0;
         }
     }
     #获取玩家已购买的次数
     $player_times = $this->get_data('PlayerFB')->get_player_fb_num($player_id, 'day_buy_times');
     #剩余购买次数
     $player_fb_data['buy_times'] = $buy_times_table['max_times'] + $vip_table['max_times'] - $player_times;
     #消耗货币
     $cost_num = explode("|", $buy_times_table['cost_num']);
     $player_fb_data['buy_times_expend']['id'] = $buy_times_table['cost_type'];
     $player_fb_data['buy_times_expend']['num'] = $cost_num[$player_times] ? $cost_num[$player_times] : 0;
     #购买一次增加的副本挑战次数
     $player_fb_data['add_times'] = $buy_times_table['per_num'];
     return Struct_PlayerAttr::get_select_fb_panel_struct($player_fb_data);
 }