Example #1
0
 /**
  * @Purpose:
  * 自动抽奖
  * @param $player_id	玩家ID
  * @param $fb_id 副本ID
  * @param $type 功能类型(0:超时抽卡1:异常退出检测抽卡)
  */
 public function auto_draw($player_id, $fb_id, $type = 0)
 {
     $player_id = intval($player_id);
     $fb_id = intval($fb_id);
     $data = array();
     //是否有抽卡次数
     $draw_data = $this->is_draw($player_id, $fb_id);
     if ($draw_data !== false) {
         $bag_data = array();
         $this->start_trans();
         //抽取剩余奖励
         for ($i = 0; $i < $draw_data['over_num']; $i++) {
             //抽奖道具
             $draw_res = $this->get_draw_item($fb_id, $draw_data, $bag_data, $player_id);
             if ($draw_res !== true) {
                 $this->throw_error($draw_res);
             }
             $data['item_list'][$i] = array($bag_data[$i]['item_id'], $bag_data[$i]['item_num']);
         }
         //加入背包
         $result = $this->get_game('Reward')->send_reward($player_id, $bag_data, array('cmd_id' => '813'), 1);
         if ($result !== true) {
             $this->throw_error('80002');
             //道具放入背包失败
         }
         //删除redis中的临时副本抽奖记录
         $del_res = $this->del_fb_draw_info($player_id);
         if (!$del_res) {
             $this->throw_error('10104');
         }
         $this->commit();
         $this->get_game('Reward')->add_reward_log();
     }
     //异常退出检测抽卡不返回数据,直接进背包
     if ($type) {
         return FALSE;
     }
     return Struct_PlayerAttr::get_fb_auto_draw_struct($data);
 }