/** * @Purpose: * 获取公会商店信息 * @Param $player_id 玩家ID */ public function get_union_shop_info($player_id) { $player_id = intval($player_id); #获取玩家公会ID,验证公会信息 $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id'); if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } #获取临时数据区数据 $data = $this->get_temporary_data(); if (!$data) { #获取商店数据 $data = $this->get_data('UnionShop')->get_union_shop_info($union_id); } if ($data) { $data['prop_info'] = Com_FmtData::cus_json_decode($data['prop_info']); $data['buff_info'] = Com_FmtData::cus_json_decode($data['buff_info']); $data['player_buy_info'] = Com_FmtData::cus_json_decode($data['player_buy_info']); #获取公会商店等级 $shop_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'shop_level'); $data['level'] = $shop_level; $is_update = false; $update_data = array(); #道具更新检验 $update_prop_res = $this->check_shop_refresh($data['refresh_time'], $data['prop_info'], $data['next_refresh'], $shop_level); if ($update_prop_res) { $update_data['refresh_time'] = $data['refresh_time']; $update_data['prop_info'] = json_encode($data['prop_info']); #更新玩家购买次数 $data['player_buy_info'] = array(); $update_data['player_buy_info'] = json_encode($data['player_buy_info']); $is_update = true; } $update_buff_res = $this->check_buff_refresh($shop_level, $data['buff_info']); if ($update_buff_res) { $update_data['buff_info'] = json_encode($data['buff_info']); $is_update = true; } #更新商店 if ($is_update) { $this->start_trans(); $this->get_data('UnionShop')->update_union_shop($union_id, $update_data); $this->commit(); } #获取玩家公会数据 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $data['contribution'] = $player_data['total_dedicate']; $data['job'] = $player_data['job_id']; #本次刷新玩家已经购买的道具数量 $data['buy_times'] = $data['player_buy_info'][$player_id]; #本次更新每个玩家可以购买的道具上限 $union_build_table = Cache_UnionBuild::getInstance()->get_union_build_info_two(array('build_type' => 'shop', 'build_lvl' => $shop_level)); $data['buy_limit'] = $union_build_table['buy_limit']; } return Struct_Union::get_union_shop_info_struct($data); }
/** * @Purpose: * 获取福利大厅信息 * @Param $player_id 玩家ID */ public function get_boon_hall_info($player_id) { $player_id = intval($player_id); #获取玩家公会ID,验证公会信息 $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id'); if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } #获取临时数据区数据 $data = $this->get_temporary_data(); if (!$data['task_info']) { #获取任务信息 $task_data = $this->get_data('UnionBoonHall')->get_boon_hall_info($union_id, 'ubt', 'day'); $data['task_info'] = $task_data['task_info']; } if (!$data['chest_info']) { #获取宝箱信息 $chest_data = $this->get_data('UnionBoonHall')->get_boon_hall_info($union_id, 'ubtc', 'day'); $data['chest_info'] = $chest_data['chest_info']; } if (!$data['player_chest']) { #获取玩家公会信息 $player_chest = $this->get_data('UnionBoonHall')->get_boon_hall_info($player_id, 'pruc', 'day'); $data['player_chest'] = $player_chest['chest_id']; } $rtn_data = array(); if ($data['task_info'] && !is_array($data['task_info'])) { #字段格式转换 $data['task_info'] = json_decode($data['task_info'], true); } else { /* #获取福利大厅等级 $hall_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'hall_level'); #创建初始任务结构 $task_data = $this->create_task_data($hall_level); $data['task_info']['task'] = $task_data['task']; $data['task_info']['task_target'] = $task_data['task_target']; #创建宝箱数据 $chest_data = $this->create_chest_data($union_id, $hall_level); if ($data['task_info'] && $chest_data) { $task_info['task_info'] = json_encode($data['task_info']); $chest_info['chest_info'] = json_encode($chest_data); $this->start_trans(); $this->get_data('UnionBoonHall')->update_boon_hall_data($union_id, 'ubt', $task_info); $this->get_data('UnionBoonHall')->update_boon_hall_data($union_id, 'ubtc', $chest_info, true); $this->commit(); } */ return Struct_Union::get_boon_hall_info_struct($rtn_data); } if ($data['chest_info'] && !is_array($data['chest_info'])) { #字段格式转换 $data['chest_info'] = json_decode($data['chest_info'], true); } if ($data['player_chest'] && !is_array($data['player_chest'])) { #字段格式转换 $data['player_chest'] = json_decode($data['player_chest'], true); } #获取福利大厅等级 $hall_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'hall_level'); $rtn_data['level'] = $hall_level; if ($data['task_info']) { $rtn_data['liveness'] = $data['task_info']['liveness']; #任务进度 if (is_array($data['task_info']['task'])) { foreach ($data['task_info']['task'] as $task_id => $task) { if ($task['add_liveness'] < 1) { #获取任务配置表 $task_table = $this->get_cache_table_data('task_table', array('level' => $hall_level, 'boon_task_id' => $task_id)); $task_table = $task_table[0]; if (!empty($task_table) && $task_table['add_liveness'] > 0 && $task_table['times_complete'] > 0) { $task['add_liveness'] = $task_table['add_liveness']; $task['need_finish'] = $task_table['times_complete']; $task['task_desc'] = $task_table['task_desc']; } } $rtn_data['task_info'][$task_id][] = $task_id; $rtn_data['task_info'][$task_id][] = $task['add_liveness']; $rtn_data['task_info'][$task_id][] = $task['cur_finish']; $rtn_data['task_info'][$task_id][] = $task['need_finish']; $rtn_data['task_info'][$task_id][] = $task['finish_state']; $rtn_data['task_info'][$task_id][] = $task['task_desc']; $rtn_data['task_info'][$task_id][] = $task['func_jump']; $rtn_data['task_info'][$task_id][] = $task['task_name']; $rtn_data['task_info'][$task_id][] = $task['player_info']; } } /* #任务记录 if (is_array($data['task_info']['record'])) { foreach ($data['task_info']['record'] as $id => $record) { $rtn_data['task_record'][$id][] = $record['player_name']; $rtn_data['task_record'][$id][] = $record['task_id']; $rtn_data['task_record'][$id][] = $record['cur_finish']; $rtn_data['task_record'][$id][] = $record['need_finish']; } } */ } if ($data['chest_info']) { #宝箱信息 if (is_array($data['chest_info']['chest'])) { foreach ($data['chest_info']['chest'] as $chest_id => $chest) { $rtn_data['chest_info'][$chest_id][] = $chest_id; $rtn_data['chest_info'][$chest_id][] = $chest['liveness']; if (is_array($data['player_chest']) && in_array($chest_id, $data['player_chest'])) { $rtn_data['chest_info'][$chest_id][] = 2; } else { $rtn_data['chest_info'][$chest_id][] = $chest['state']; } $rtn_data['chest_info'][$chest_id][] = $chest['prop_info']; } } } return Struct_Union::get_boon_hall_info_struct($rtn_data); }
/** * @Purpose: * 获取公会活动信息 * @Param $player_id 玩家ID */ public function get_union_activities_info($player_id) { $player_id = intval($player_id); #获取玩家公会ID,验证公会信息 $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id'); if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } #获取公会活动配置表 $activities_table = $this->get_cache_table_data('activities_table', null); if (!$activities_table) { $this->throw_error('10109'); //配置表读取错误 } $rtn_data = array(); if (Com_Array::is_good_arr($activities_table)) { #获取公会等级 $union_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'union_level'); #获取玩家公会职务 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $job = $player_data['job_id']; #获取公会活动天数据 $uad_data = $this->get_data('UnionActivities')->get_union_activities_daily_info($union_id, 'uad', 'day'); $uad_data['activities_info'] = Com_FmtData::cus_json_decode($uad_data['activities_info']); $uad_data['end_activities'] = Com_FmtData::cus_json_decode($uad_data['end_activities']); $uad_data['open_times'] = Com_FmtData::cus_json_decode($uad_data['open_times']); $uad_data['add_time'] = Com_FmtData::cus_json_decode($uad_data['add_time']); foreach ($activities_table as $act_data) { $act_info = array(); $act_info['act_id'] = $act_data['activities_id']; $act_info['fb_id'] = $act_data['fb_id']; $act_data['award'] = $this->format_table_field($act_data['award']); if (Com_Array::is_good_arr($act_data['award'])) { $award = array(); foreach ($act_data['award'] as $id => $num) { $award[$id][] = $id; $award[$id][] = $num; } $act_info['award'] = $award; unset($award); } $act_info['activities_type'] = $act_data['activities_type']; $act_info['open_way'] = $act_data['open_way']; $act_info['desc'] = $act_data['desc']; $act_info['union_level_desc'] = $act_data['union_level_desc']; switch ($act_info['activities_type']) { case 3: //公会战 $num = $this->get_game('UnionGrabDomain')->get_union_num(); if ($num) { $act_info['union_level_desc'] = sprintf($act_info['union_level_desc'], $num); } else { $act_info['union_level_desc'] = '活动未开启'; } break; } if ($act_info['open_way'] == 0) { $act_info['open_week'] = explode("|", $act_data['open_week']); $open_t = explode(":", $act_data['open_time']); $act_info['open_time_h'] = $open_t[0]; $act_info['open_time_m'] = $open_t[1]; $close_t = explode(":", $act_data['close_time']); $act_info['close_time_h'] = $close_t[0]; $act_info['close_time_m'] = $close_t[1]; $act_info['open_time'] = mktime($act_info['open_time_h'], $act_info['open_time_m'], 0, date('m'), date('d'), date('Y')); $act_info['close_time'] = mktime($act_info['close_time_h'], $act_info['close_time_m'], 0, date('m'), date('d'), date('Y')); $act_info['close_time'] += intval($uad_data['add_time'][$act_data['activities_type']]); if (!empty($union_level) && $union_level >= $act_data['union_level']) { #公会活动是否开启 $open_res = $this->is_open_activities($act_info['open_week'], $act_info['open_time'], $act_info['close_time']); if ($open_res['surplus_open_time']) { $act_info['surplus_open_time'] = $open_res['surplus_open_time']; } else { $act_info['state'] = $open_res; } if ($act_info['state']) { #活动是否提前结束 if ($uad_data['end_activities']) { if (in_array($act_info['act_id'], $uad_data['end_activities'])) { $act_info['state'] = 0; } } } } else { $act_info['state'] = 4; } } else { if ($act_info['open_way'] == 1) { $act_info['open_week'] = explode("|", $act_data['open_week']); $act_info['open_job'] = explode("|", $act_data['open_job']); $act_info['activities_time'] = $act_data['activities_time']; $act_info['open_times_max'] = $act_data['open_times']; $act_info['open_time'] = $uad_data['activities_info'][$act_info['act_id']]['open_time']; $act_info['close_time'] = $uad_data['activities_info'][$act_info['act_id']]['close_time']; $act_info['close_time'] += $uad_data['activities_info'][$act_info['act_id']]['add_time']; $act_info['close_time'] += intval($uad_data['add_time'][$act_data['activities_type']]); $act_info['state'] = $uad_data['activities_info'][$act_info['act_id']]['state']; $act_info['expend_coin'] = $act_data['expend_coin']; $act_info['open_times'] = $act_info['open_times_max'] - $uad_data['open_times'][$act_info['act_id']]; if (!empty($union_level) && $union_level >= $act_data['union_level']) { if ($act_info['state'] > 0) { #公会活动是否开启 $open_res = $this->is_open_activities($act_info['open_week'], $act_info['open_time'], $act_info['close_time']); if ($open_res['surplus_open_time']) { $act_info['state'] = 0; } else { $act_info['state'] = $open_res; } } else { #有权限开启活动的玩家显示额外的按键状态(0:未开启1:已开启2:可开启) if (Com_Array::is_good_arr($act_info['open_job'])) { if (in_array($job, $act_info['open_job'])) { if ($uad_data['open_times'][$act_info['act_id']] < $act_info['open_times_max']) { $act_info['state'] = 2; } else { $act_info['state'] = 0; } } } } } else { $act_info['state'] = 4; } } } $rtn_data[$act_info['act_id']] = Struct_Union::get_union_activities_info_struct($act_info); } } return $rtn_data ? $rtn_data : array(); }
/** * @Purpose: * 获取公会通缉榜信息 * @Param $player_id 玩家ID * @Param $active_push 主动推送 */ public function get_union_wanted_info($player_id, $active_push = 0) { $player_id = intval($player_id); #获取玩家公会ID,验证公会信息 $player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'vip', 'privilege_level')); $union_id = $player_info['union_id']; if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } #获取临时数据区数据 $data = $this->get_temporary_data(); if (!$data) { #获取玩家通缉榜数据 $data = $this->get_data("UnionWanted")->get_union_wanted_info($player_id); } if ($data) { if (!is_array($data['wanted_info'])) { $wanted_info = json_decode($data['wanted_info'], true); } else { $wanted_info = $data['wanted_info']; } #获取公会通缉榜等级 $wanted_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'wanted_level'); $is_update = false; #更新建筑等级相关的数据 if ($wanted_level > $data['level']) { $base_table = $this->get_cache_table_data('base_table', array('level' => $wanted_level)); if (!$base_table) { $this->throw_error('10109'); //配置表读取错误 } $wanted_info['fortune_times_max'] = $base_table['refresh_fortune_times']; $wanted_info['finish_times_max'] = $base_table['daily_complete_times']; $wanted_info['use_free_max'] = $base_table['free_times_max']; #$wanted_info['refresh_fb_times_max'] = $base_table['refresh_times_max']; #$wanted_info['times_max_update_time'] = $base_table['refresh_time']; #$wanted_info['diamond_refresh_fb'] = $base_table['diamond_refresh_fb']; #$wanted_info['diamond_refresh_quality'] = $base_table['diamond_refresh_quality']; $update_data['level'] = $wanted_level; $is_update = true; } $is_update_daily = false; #获取玩家通缉榜天数据 $uwd_data = $this->get_data("UnionWanted")->get_union_wanted_daily_info($player_id, 'uwd', 'day'); if (!$uwd_data) { $base_table = $this->get_cache_table_data('base_table', array('level' => $wanted_level)); if (!$base_table) { $this->throw_error('10109'); //配置表读取错误 } #创建玩家公会通缉榜天数据 $uwd_data = $this->get_fortune_star(0); $uwd_data['refresh_fortune_times'] = $base_table['refresh_fortune_times']; $uwd_data['finished_times'] = 0; #$uwd_data['finish_times'] = $base_table['daily_complete_times']; $uwd_data['use_free'] = $base_table['free_times_max']; $uwd_data['used_free'] = 0; $uwd_data['used_times'] = 1; $uwd_data['use_expend'] = 0; $is_update_daily = true; } #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10060); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } $free_times_vip_table = array(); if ($player_vip > 0) { #获取VIP配置表免费次数配置 $free_times_vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, 10060); } #获取玩家公会数据 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $rtn_data = $wanted_info; $rtn_data['wanted_level'] = $wanted_level; $rtn_data['fortune_star'] = $uwd_data['fortune_star']; $rtn_data['refresh_fortune_times'] = $uwd_data['refresh_fortune_times']; $rtn_data['contribution'] = $player_data['total_dedicate']; #$rtn_data['finish_times'] = $uwd_data['finish_times']; $rtn_data['use_free'] = $free_times_vip_table['max_times'] + $uwd_data['use_free'] - $uwd_data['used_free']; $rtn_data['use_free'] = $rtn_data['use_free'] > 0 ? $rtn_data['use_free'] : 0; $rtn_data['finished_times'] = $uwd_data['finished_times']; if ($uwd_data['use_expend'] && !is_array($uwd_data['use_expend'])) { $rtn_data['use_expend'] = json_decode($uwd_data['use_expend'], true); } else { $rtn_data['use_expend'] = $uwd_data['use_expend']; } #获取玩家等级对应的任务基础奖励 $player_level = $this->get_data('Player')->get_player_info($player_id, 'level'); $level_base_reward = $this->get_reward_by_level($player_level); if (Com_Array::is_good_arr($rtn_data['union_wanted_info'])) { $union_wanted_info = $rtn_data['union_wanted_info']; foreach ($union_wanted_info as $key => $wanted_fb) { #计算加成奖励 $union_wanted_info[$key]['union_award']['exp']['num'] = $this->calculation_reward($level_base_reward['exp'], $wanted_fb['union_award']['exp']['num'], $uwd_data['fortune_award_per']); $union_wanted_info[$key]['union_award']['player_exp']['num'] = $this->calculation_reward($level_base_reward['player_exp'], $wanted_fb['union_award']['player_exp']['num'], $uwd_data['fortune_award_per']); $union_wanted_info[$key]['union_award']['contribution']['num'] = $this->calculation_reward($level_base_reward['contribution'], $wanted_fb['union_award']['contribution']['num'], $uwd_data['fortune_award_per']); } $rtn_data['union_wanted_info'] = $union_wanted_info; } /* #到达更新免费刷新次数时间 $time = time(); if ($wanted_info['times_max_update_next_time'] && $time >= $wanted_info['times_max_update_next_time']) { #增加的刷新次数 $add_times = intval(($time - $wanted_info['times_max_update_next_time']) / $wanted_info['times_max_update_time']) + 1; if ($wanted_info['refresh_fb_times'] + $add_times < $wanted_info['refresh_fb_times_max']) { $wanted_info['refresh_fb_times'] += $add_times; } else { $wanted_info['refresh_fb_times'] = $wanted_info['refresh_fb_times_max']; } #刷新更新时间 $next_time = $wanted_info['times_max_update_next_time']; $refresh_time = $wanted_info['times_max_update_time']; $wanted_info['times_max_update_next_time'] = $time + ($refresh_time - intval(($time - $next_time) % $refresh_time)); $is_update = true; } $wanted_info['remaining_time'] = $wanted_info['times_max_update_next_time'] - $time; #过0点增加一次刷新次数 $date = date('y') . date('m') . date('d'); if ($date != $wanted_info['zero_update_time']) { $add_time = $date - $wanted_info['zero_update_time']; if ($wanted_info['refresh_fb_times'] + $add_time < $wanted_info['refresh_fb_times_max']) { $wanted_info['refresh_fb_times'] += $add_time; } $wanted_info['zero_update_time'] = $date; $is_update = true; } */ if ($is_update) { $update_data['wanted_info'] = json_encode($wanted_info); $this->start_trans(); $update_res = $this->get_data("UnionWanted")->update_union_wanted($player_id, $update_data); if (!$update_res) { $this->throw_error('10104'); } } if ($is_update_daily) { if (!$this->is_trans()) { $this->start_trans(); } #更新玩家公会通缉榜天数据 $this->get_data("UnionWanted")->update_union_wanted_daily_data($player_id, 'uwd', $uwd_data); } if ($this->is_trans()) { $this->commit(); } } $rtn_data['active_push'] = $active_push; return Struct_Union::get_union_wanted_info_struct($rtn_data); }