/** * 获取章节宝箱 * @param $player_id 玩家ID * @param $chapter_id 章节ID * @param $chest_id 宝箱ID */ public function get_chapter_chest($player_id, $chapter_id, $chest_id) { $player_id = intval($player_id); $chapter_id = intval($chapter_id); $chest_id = intval($chest_id); //获取副本信息 $obj_player_fb_data = $this->get_data('PlayerFB'); $player_fb_data = $obj_player_fb_data->get_player_fb_info($player_id); //字段格式转换 $player_fb_data['chapter_star'] = json_decode($player_fb_data['chapter_star'], true); $player_fb_data['chapter_chest'] = json_decode($player_fb_data['chapter_chest'], true); //是否可以领取宝箱 $is_get_res = $this->is_get_chest($chapter_id, $player_fb_data['chapter_star'][$chapter_id], $player_fb_data['chapter_chest'][$chapter_id], $chest_id); if (!$is_get_res) { $rtn_data['result'] = 0; return Struct_PlayerAttr::get_fb_chest_struct($rtn_data); } //获取宝箱道具 $prop_info = $this->get_chest_prop($chapter_id, $chest_id); $this->start_trans(); //更新玩家宝箱领取记录 $player_fb_data['chapter_chest'][$chapter_id][] = $chest_id; $update_res = $this->update_db($player_id, 'chapter_chest', $player_fb_data); if (!$update_res) { $this->throw_error('10104'); } #道具发送 if (Com_Array::is_good_arr($prop_info)) { $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '1102')); if ($result === false) { $this->throw_error('10104'); } else { if ($result !== true) { $this->throw_error($result); } } } $this->commit(); $this->get_game('Reward')->add_reward_log(true); $rtn_data['result'] = 1; $rtn_data['chapter_chest_info'] = $this->get_chest_info($chapter_id, $player_fb_data['chapter_star'][$chapter_id], $player_fb_data['chapter_chest'][$chapter_id]); return Struct_PlayerAttr::get_fb_chest_struct($rtn_data); }