public function get_open_sid() { #$old_status = $this->redis()->hash_get($this->cacheKey_open); #if(!empty($old_status)) return $old_status['sid']; $list = $this->get_data('RankList')->get_sort_list('level'); $sid_list = Cache_Athena::getInstance()->get_athena_set(0); if (empty($list) || empty($sid_list)) { return 0; } $count = array(); foreach ($sid_list as $val) { foreach ($list as $level) { if ($val['open_level'] <= $level['level']) { $count[$val['sid']] += 1; } } } $sid = 0; foreach ($sid_list as $val) { if ($count[$val['sid']] >= $val['open_num'] && $val['sid'] > $sid) { $sid = $val['sid']; } } $expireAtTimestamp = strtotime("+1 hours"); $this->redis()->hash_set($this->cacheKey_open, array('sid' => $sid)); $this->redis()->expire($this->cacheKey_open, $expireAtTimestamp, true); return $sid; }
/** * 取出相关功能的次数 * @param $player_id * @return array */ protected function get_daily_time($player_id, $func_id = null) { $out = array(); if ($func_id == 1030 || $func_id == null) { //挑战 $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'used_fight_num'); $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'used_fight_num'); $out = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 1050 || $func_id == null) { //王座之战 $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'challenge_battle_num'); $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'challenge_battle_num'); $out = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 1060 || $func_id == null) { //竞技场 $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_arena_use_times'); $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'kf_arena_add_times_max'); $out = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 1080 || $func_id == null) { //日常任务 $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'daily_task_finish_count'); $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'daily_task_finish_count'); $out = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 4001 || $func_id == null) { //守护雅典娜-初级 $cur_ydn_num = $this->get_game("Athena")->get_athena_remaining_count($player_id, 4001); $max_ydn_num = Cache_Athena::getInstance()->get_athena_set(4001); $out = array('max_num' => $max_ydn_num['max_times'], 'cur_num' => $cur_ydn_num); //守护雅典娜-初级 } if ($func_id == 4011 || $func_id == null) { //世界BOSS $cur_world_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'world_boss_count'); $max_world_num = $this->get_game("WorldBoss")->get_max_time(); $out = array('max_num' => $max_world_num, 'cur_num' => $cur_world_num); } if ($func_id == 4011 || $func_id == null) { $out = array('max_num' => 2, 'cur_num' => 1); //抢矿 } if ($func_id == 1020 || $func_id == null) { #主线副本 $max_num = $this->get_game('PlayerFB')->get_day_num($player_id); $cur_num = $this->get_game("PlayerFB")->get_day_num_max($player_id); $out = array('max_num' => $cur_num, 'cur_num' => $max_num); } if ($func_id == 9030 || $func_id == null) { #公会任务 $data = $this->get_game('UnionWanted')->get_times_max_interface($player_id, 0); $max_num = $data['max_times']; $cur_num = $data['used_times']; $out = array('max_num' => $max_num, 'cur_num' => $cur_num); } return $out['max_num'] - $out['cur_num']; }
private function sort_hall_list($res_hall, $level, $union_info, $pre_view_group) { $res = array(); $datetime = time(); $date = date('Y-m-d'); $res_0 = array(); $res_1 = array(); $res_2 = array(); $res_3 = array(); $world_boss_base = Cache_WorldBoss::getInstance()->get_worldboss_set(); if (empty($res_hall)) { return $res; } $rank_list = $this->get_data('RankList')->get_sort_list('level'); foreach ($res_hall as $v) { $temp = array(); $start = strtotime($date . ' ' . $v['start_time']); $end = strtotime($date . ' ' . $v['end_time']); $status = 0; #0:结束,1:进行中,2:即将开始,3:等级未达到,4服务器开启条件未达到,5非公会成员 $lefttime = 0; #倒计时 #1:进行中 if ($start <= $datetime && $datetime <= $end) { $status = 1; $lefttime = $end - $datetime; } #2:即将开始 if ($start > $datetime) { $status = 2; $lefttime = $start - $datetime; } #0:结束 if ($end < $datetime) { $status = 0; $lefttime = $datetime - $end; } #提前结束 if ($status == 1 && $v['category'] == 1) { $check_over = $this->get_data('WorldBoss')->check_is_over(); if ($check_over) { $status = 0; } } if ($level < $v['join_min_lvl']) { $status = 3; } $joined = 0; if (!$v['category'] != 1 && $status == 1) { $joined = 1; } #判断世界boss加入条件 if ($this->check_in_world_boss($v['id'], $world_boss_base) && $status == 1) { $joined = 1; } if ($joined == 0 && $status == 1) { $status = 3; } #判断是否为公会活动 if ($v['category'] == 5 || $v['category'] == 6) { if (empty($union_info)) { $status = 5; } else { if ($v['category'] == 5) { $u_type = 1; } else { $u_type = 2; } foreach ($union_info as $union) { if ($union[1] == $u_type) { if ($union[13] == 1) { $status = 1; } else { $status = 0; } } } } } $temp['activity_id'] = $v['sid']; $temp['status'] = $status; $temp['lefttime'] = $lefttime; $temp['joined'] = $joined; $temp['tid'] = $v['id']; $temp['join_lvl'] = $v['join_min_lvl']; $temp['open_level'] = 0; $temp['open_num'] = 0; $temp['nums'] = 0; $temp['start_time'] = $start; $temp['end_time'] = $end; if (0 == $status) { array_push($res_0, $temp); } else { if (1 == $status) { array_push($res_1, $temp); } else { if (2 == $status) { array_push($res_2, $temp); } else { if (3 == $status || 5 == $status) { array_push($res_3, $temp); } } } } } $this->sort_by_time($res_0, 'lefttime', 'asc'); $this->sort_by_time($res_1, 'lefttime'); $this->sort_by_time($res_2, 'lefttime'); $this->sort_by_time($res_3, 'lefttime'); if (!empty($res_1)) { foreach ($res_1 as $v) { # array_push($res,$v); $res[] = $v; } } if (!empty($res_2)) { foreach ($res_2 as $v) { $res[] = $v; } } if (!empty($res_0)) { foreach ($res_0 as $v) { $res[] = $v; } } if (empty($pre_view_group)) { return $res; } $res_4 = array(); if (!empty($res_3)) { foreach ($res_3 as $v) { if ($v['join_lvl'] <= $level) { if (!$pre_view_group['worldboss']['open'] && $v['category'] == 1) { #世界boss $world_set = Cache_WorldBoss::getInstance()->get_worldboss_set($v['id']); $v['status'] = 4; #服务器未开启 $v['open_level'] = $world_set['level']; $v['open_num'] = $world_set['level_num']; $v['nums'] = $this->get_open_level_num($world_set['level'], $rank_list); } if (!$pre_view_group['athena']['open'] && $v['category'] == 2) { #守护女神 $athena_set = Cache_Athena::getInstance()->get_athena_set($v['id']); $v['status'] = 4; $v['open_level'] = $athena_set['open_level']; $v['open_num'] = $athena_set['open_num']; $v['nums'] = $this->get_open_level_num($athena_set['open_level'], $rank_list); } if (!$pre_view_group['trial']['open'] && $v['category'] == 10) { #神之试炼 $trial_set = Cache_Trial::getInstance()->get_trial_set($v['id']); $v['status'] = 4; $v['open_level'] = $trial_set['open_level']; $v['open_num'] = $trial_set['open_num']; $v['nums'] = $this->get_open_level_num($trial_set['open_level'], $rank_list); } if (!$pre_view_group['grab']['open'] && $v['category'] == 4) { #水晶争夺 $trial_set = Cache_GrabMine::getInstance()->get_base_info($v['id']); $v['status'] = 4; $v['open_level'] = $trial_set['open_level']; $v['open_num'] = $trial_set['open_num']; $v['nums'] = $this->get_open_level_num($trial_set['open_level'], $rank_list); } $res[] = $v; } else { $res_4[] = $v; } } } if (!empty($res_4)) { foreach ($res_4 as $v) { $res[] = $v; } } foreach ($pre_view_group as $key => $pre_list) { if (empty($pre_list['list'])) { continue; } foreach ($pre_list['list'] as $v) { switch ($key) { case "athena": $set = Cache_Athena::getInstance()->get_athena_set($v['id']); break; case 'worldboss': $set_boss = Cache_WorldBoss::getInstance()->get_worldboss_set($v['id']); $set['open_level'] = $set_boss['level']; $set['open_num'] = $set_boss['level_num']; break; case 'trial': $set = Cache_Trial::getInstance()->get_trial_set($v['id']); break; case 'grab': $set = Cache_GrabMine::getInstance()->get_base_info($v['id']); break; } $start = strtotime($date . ' ' . $v['start_time']); $end = strtotime($date . ' ' . $v['end_time']); $temp = array(); $temp['activity_id'] = $v['sid']; $temp['status'] = 4; $temp['lefttime'] = 0; $temp['joined'] = 0; $temp['tid'] = $v['id']; $temp['join_lvl'] = $v['join_min_lvl']; $temp['open_level'] = $set['open_level']; $temp['open_num'] = $set['open_num']; $temp['nums'] = $this->get_open_level_num($set['open_level'], $rank_list); $temp['start_time'] = $start; $temp['end_time'] = $end; $res[] = $temp; } } return $res; }
public function get_function_list() { return Cache_Athena::getInstance()->get_function_list(); }
public function get_reward_by_sid($player_id, $sid, $times, $currency_types, $pinfo, $union_level, $wanted_level, $player_times = array()) { $currency_types = explode(',', $currency_types); $reward = ''; switch ($sid) { case 1: //主线副本 $exp_num = $this->get_game('PlayerFB')->main_fb_resource_retrieve($player_id, $times, 3, $pinfo, $union_level); if ($exp_num) { $reward = "1:" . ceil($exp_num); } break; case 2: //挑战副本 $send_reward = $this->get_game('PlayerPVE')->get_compensation_reward($player_id, 2, null, null, null, $pinfo); $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num'] * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 3: //vip副本 $exp_num = $this->get_game('PlayerFB')->vip_fb_resource_retrieve($player_id, $pinfo['level'], $pinfo['vip'], $times); if ($exp_num) { $reward = "1:" . ceil($exp_num); } break; case 4: //日常任务 $arr_reward = $this->get_game('TaskHandler')->get_daily_task_reward($player_id, $pinfo); if ($arr_reward) { $send_reward = $arr_reward[0]; $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num'] * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 5: //天梯 $reward_detail = $this->get_game('Challenge')->get_challenge_battle_reward($player_id, $pinfo); if ($reward_detail) { $arr_award = array(); foreach ($reward_detail as $key => $value) { if (in_array($key, $currency_types)) { $arr_award[] = $key . ':' . ceil($value * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 6: //竞技场 $send_reward = $this->get_game('KFArena')->get_back_reward($player_id, $pinfo['privilege_level'], $times); $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num']); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 7: //世界boss if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $baseinfo = $this->get_game('WorldBoss')->get_base_info_id($f_sid); #vip加成奖励 $vip_exp = 0; if ($pinfo['privilege_level'] > 0) { $left_cd = $this->get_game('VipSpecial')->get_left_time($player_id); if ($left_cd > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($pinfo['privilege_level'], 10034); if (!empty($vip_set)) { $vip_exp = $vip_set['max_times']; } } } $rank_list = Cache_WorldBoss::getInstance()->get_rank_reward(); $rankreward = $rank_list[25]['reward_per']; $item_num = ($vip_exp / 10000 + 1) * ceil($baseinfo['dps_reward'] * $rankreward / 100); $reward = '1:' . ceil($item_num * $times); if (isset($player_times['world_boss_battle_rank']) && $player_times['world_boss_battle_rank']) { $count = count($rank_list); if ($player_times['world_boss_battle_rank'] > $count) { $rank_num = $count; } else { $rank_num = $player_times['world_boss_battle_rank']; } if ($rank_list[$rank_num - 1]['item_id'] && in_array($rank_list[$rank_num - 1]['item_id'], $currency_types) && $rank_list[$rank_num - 1]['item_reward_cnt']) { $item_num = ceil($rank_list[$rank_num - 1]['item_reward_cnt'] * 0.7) * $times; $reward = $reward . '|' . $rank_list[$rank_num - 1]['item_id'] . ':' . $item_num; } } break; case 8: //水晶争夺 if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $send_reward = $this->get_game('GrabMine')->get_grabmine_reward($player_id, $pinfo, $f_sid); $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num'] * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 9: //智力问答 $reward_detail = $this->get_game('AthenaQuestion')->get_athena_question_socre_reward($player_id, $pinfo); if ($reward_detail) { $arr_award = array(); foreach ($reward_detail as $key => $value) { if (in_array($key, $currency_types)) { $arr_award[] = $key . ':' . ceil($value * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 10: //欢乐魔蛋 $rewards = $this->get_game('PlayerFB')->egg_active_resource_retrieve($player_id, $pinfo['level'], $times); if ($rewards) { $arr_award = array(); foreach ($rewards as $value) { if (in_array($value['id'], $currency_types)) { $arr_award[] = $value['id'] . ':' . ceil($value['num']); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 11: //守卫女神 if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $athena_set = Cache_Athena::getInstance()->get_athena_set($f_sid); $max_waves = $athena_set['max_waves']; $wave = ceil($max_waves * 0.7); $rewards = Cache_Athena::getInstance()->get_athena_reward($f_sid); if ($rewards && $wave > 0) { $reward_ids = array(); foreach ($rewards as $val) { if ($val['sid'] == $f_sid && $wave == $val['waves']) { $reward_ids = explode('|', $val['rewards']); } } if (!empty($reward_ids)) { $arr_award = array(); $vip_exp = $this->get_game('Athena')->get_vip_add_exp($player_id); foreach ($reward_ids as $v) { $temp = explode(':', $v); if (count($temp) > 1) { if (in_array($temp[0], $currency_types)) { $item_num = $temp[1] * (1 + $vip_exp); $arr_award[] = $temp[0] . ':' . ceil($item_num * $times); } } } if ($arr_award) { $reward = implode('|', $arr_award); } } } break; case 12: //神之试炼 if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $buff = Cache_Trial::getInstance()->get_buff($f_sid, 3); $rewards = Cache_Trial::getInstance()->get_trial_reward(); $reward_string = Cache_Trial::getInstance()->get_reward($pinfo['level'], $rewards); $reward_array = explode("|", $reward_string); $arr_award = array(); foreach ($reward_array as $arr) { list($item_idx, $item_num) = explode(":", $arr); if (empty($item_num)) { continue; } if (in_array($item_idx, $currency_types)) { $arr_award[] = $item_idx . ':' . ceil($item_num * $buff * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 13: //公会通缉 $exp_num = $this->get_game('UnionWanted')->wanted_fb_resource_retrieve($pinfo['level'], $wanted_level, 3, 2, $times); if ($exp_num) { $reward = "1:" . ceil($exp_num); } break; case 14: //3v3 $id = $this->get_data('KFDuel')->get_open_sid($pinfo['level']); $reward = ''; if ($id) { $reward_conf = Cache_CrossDuel::getInstance()->get_battle_reward_conf($id, $pinfo['level']); $point = intval($reward_conf['point'] * $times / 2); $rewards = array(); $arr_reward = explode('|', $reward_conf['reward']); foreach ($arr_reward as $value) { $ar_re = explode(':', $value); if (in_array($ar_re[0], $currency_types)) { $rewards[] = $ar_re[0] . ':' . intval($ar_re[1] * $times / 2); } } $reward = implode('|', $rewards); if (in_array(16, $currency_types)) { $reward = $reward . '|16:' . $point; } } break; case 15: //8v8 $rank_conf = Cache_FlameBattle::getInstance()->get_rank_conf(11); $gold = $rank_conf['gold']; $score = $rank_conf['reward']; $rewards = array(); $reward = ''; if (in_array(3, $currency_types)) { $rewards[] = '3:' . $gold * $times; } if (in_array(17, $currency_types)) { $rewards[] = '17:' . $score * $times; } $reward = implode('|', $rewards); break; default: //pass break; } return $reward; }
public function athena_replace($player_id, $sid, $type) { $player_id = intval($player_id); $res = array(); $res['res'] = 1; $set = Cache_Athena::getInstance()->get_athena_set($sid); $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'athena_resume_count'); if ($used_time > 0) { $this->throw_error(11001); #次数已用完 } if (empty($set)) { $this->throw_error(10222, 2010018); } $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10021); if (empty($vip_set) || $set['athena_resume_cost_num'] < 0) { $this->throw_error(10222, 2010019); } $p_info = $this->get_data('Player')->get_player_info($player_id, array('gold', 'silver', 'vip', 'level', 'player_id', 'ticket', 'privilege_level')); #判断vip级别 if (intval($p_info['vip']) >= $vip_set['vip_level'] || $vip_set['vip_level'] <= $p_info['privilege_level']) { if ($set['athena_resume_cost_type'] == 1) { $this->get_data('Player')->check_player_resource($player_id, $p_info, '-', 'silver', $set['athena_resume_cost_num']); } $arr_consume = array(); if ($set['athena_resume_cost_type'] == 2 || $set['athena_resume_cost_type'] == 20) { /***************/ $ticket = 0; $gold = $set['athena_resume_cost_num']; if ($p_info['ticket'] > 0) { if ($p_info['ticket'] >= $set['athena_resume_cost_num']) { $ticket = $set['athena_resume_cost_num']; $gold = 0; } else { $ticket = $p_info['ticket']; $gold = $set['athena_resume_cost_num'] - $p_info['ticket']; } } $arr_consume = array('price' => $set['athena_resume_cost_num'], 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 /**************/ $this->get_data('Player')->check_player_resource($player_id, $p_info, '-', 'gold', $set['athena_resume_cost_num'], 1, 1); } $result = $this->get_data('Player')->update_player_resource($player_id, $p_info, 1109, array(), $arr_consume); if (true === $result) { Protocol::input($player_id, 7, 4, 450, 1); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'athena_resume_count'); $res['res'] = 1; $res['type'] = $type; $res['left'] = 0; } else { $this->throw_error(10110, 2010020); } } else { $this->throw_error(11002); #vip等级不够 } return $res; }
/** * 取出相关功能的次数 * @param $player_id * @return array */ protected function get_daily_time($player_id, $func_id = null, $player_used_time = null) { $out = array(); if ($func_id == 1030 || $func_id == null) { //挑战 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'used_fight_num'); } else { $cur_num = $player_used_time['used_fight_num']; } $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'used_fight_num'); $out[1030] = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 1050 || $func_id == null) { //王座之战 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'challenge_battle_num'); } else { $cur_num = $player_used_time['challenge_battle_num']; } $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'challenge_battle_num'); $out[1050] = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 1060 || $func_id == null) { //竞技场 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_arena_use_times'); } else { $cur_num = $player_used_time['kf_arena_use_times']; } $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'kf_arena_add_times_max'); $out[1060] = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 1080 || $func_id == null) { //日常任务 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'daily_task_finish_count'); } else { $cur_num = $player_used_time['daily_task_finish_count']; } $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'daily_task_finish_count'); $out[1080] = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 4001 || $func_id == null) { //守护雅典娜-初级 // $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id,'athena_easy_remaining_count'); // // $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id,'daily_task_finish_count'); $cur_ydn_num = $this->get_game("Athena")->get_athena_remaining_count($player_id, 4001); $max_ydn_num = Cache_Athena::getInstance()->get_athena_set(4001); $out[4001] = array('max_num' => $max_ydn_num['max_times'], 'cur_num' => $cur_ydn_num); //守护雅典娜-初级 } if ($func_id == 4011 || $func_id == null) { //世界BOSS // $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id,'world_boss_count'); // // $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id,'daily_task_finish_count'); if (is_null($player_used_time)) { $cur_world_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'world_boss_count'); } else { $cur_world_num = $player_used_time['world_boss_count']; } $max_world_num = $this->get_game("WorldBoss")->get_max_time(); $out[4011] = array('max_num' => $max_world_num, 'cur_num' => $cur_world_num); } if ($func_id == 4041 || $func_id == null) { #水晶争夺 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'grabmine_involved_num'); } else { $cur_num = $player_used_time['grabmine_involved_num']; } $out[4041] = array('max_num' => 1, 'cur_num' => $cur_num); //抢矿 } if ($func_id == 1020 || $func_id == null) { #主线副本 $cur_num = $this->get_game('PlayerFB')->get_day_num($player_id); $max_num = $this->get_game("PlayerFB")->get_day_num_max($player_id); $out[1020] = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 4051 || $func_id == null) { #vip副本 $max_num = $this->get_game('PlayerFB')->get_vip_fb_times_max_interface($player_id); $cur_num = $this->get_data('PlayerFB')->get_player_fb_num($player_id, 'vip_used_times'); $out[4051] = array('max_num' => $max_num, 'cur_num' => $cur_num); } if ($func_id == 4031 || $func_id == null) { #vip副本 $out[4031] = array('max_num' => 99, 'cur_num' => 0); } if ($func_id == 1100 || $func_id == null) { #炼金 $player_info = $this->get_data('Player')->get_player_info($player_id, array('privilege_level', 'vip')); $info = $this->get_game('PlayerCoinExchange')->get_exchange_coin_times_interface($player_id, $player_info); $out[1100] = array('max_num' => $info['max_times'], 'cur_num' => $info['used_times']); } if ($func_id == 9091 || $func_id == 9092 || $func_id == 9093 || $func_id == null) { $info = $this->get_game('UnionActivities')->get_union_active_times_interface($player_id); if ($func_id == 9091 || $func_id == null) { #公会游泳 $out[9091] = array('max_num' => $info[1]['max_times'], 'cur_num' => $info[1]['used_times']); } if ($func_id == 9092 || $func_id == null) { #公会BOSS $out[9092] = array('max_num' => $info[2]['max_times'], 'cur_num' => $info[2]['used_times']); } if ($func_id == 9093 || $func_id == null) { #公会篝火 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_bonfire_count'); } else { $cur_num = $player_used_time['union_bonfire_count']; } $out[9093] = array('max_num' => $info[4]['max_times'], 'cur_num' => intval($cur_num)); } } if ($func_id == 9040 || $func_id == null) { #公会巨炮 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_bomb_count'); } else { $cur_num = $player_used_time['union_bomb_count']; } $max_time = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'union_bomb_count'); $out[9040] = array('max_num' => $max_time, 'cur_num' => $cur_num); } if ($func_id == 4061 || $func_id == null) { #金蛋副本 $info = $this->get_game('PlayerFB')->get_egg_active_times_interface($player_id, $player_used_time['egg_active_times']); $out[4061] = array('max_num' => $info['max_times'], 'cur_num' => $info['used_times']); } if ($func_id == 9030 || $func_id == null) { #公会任务 $info = $this->get_game('UnionWanted')->get_times_max_interface($player_id, 0); $out[9030] = array('max_num' => $info['max_times'], 'cur_num' => $info['used_times']); } if ($func_id == 4071 || $func_id == null) { #神之试炼 $info = $this->get_game('Trial')->get_player_times($player_id, $player_used_time); $num = $info['max_times'] - $info['left_num']; $num = $num < 0 ? 0 : $num; $out[4071] = array('max_num' => $info['max_times'], 'cur_num' => $num); } if ($func_id == 4081 || $func_id == null) { #女神问答 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'athena_question_involved_num'); #当前参与次数 } else { $cur_num = $player_used_time['athena_question_involved_num']; } $out[4081] = array('max_num' => 1, 'cur_num' => $cur_num); } if ($func_id == 4110 || $func_id == null) { #3v3竞技 if (is_null($player_used_time)) { $cur_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_duel_use_times'); #当前参与次数 } else { $cur_num = $player_used_time['kf_duel_use_times']; } $kf_duel_stint = intval($this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'kf_duel_add_times_max')); $out[4110] = array('max_num' => $kf_duel_stint, 'cur_num' => $cur_num); } return $out; }
public function get_close_info($player_id) { $player_used_time = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, array('flame_battle_count', 'kf_duel_use_times', 'grab_treasure_battle_times', 'athena_question_involved_num', 'trial_remaining_count', 'athena_easy_remaining_count', 'grabmine_involved_num', 'world_boss_count', 'challenge_battle_num', 'kf_arena_use_times', 'used_fight_num')); $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('func_open')); $func_open = $player_detail['func_open']; $info = ''; if (isset($func_open['1131'])) { $num = $this->get_game('DailySign')->get_free_times_interface($player_id); if ($num > 0) { $info .= "★每日福利:今日还可免费获得 " . $num . " 次签到奖励\n"; } } if (isset($func_open['1132'])) { $num = $this->get_game('DailyBoon')->get_daily_onine_reward_nums($player_id); if ($num > 0) { $info .= "★每日福利:今日还可免费抽取 " . $num . " 次在线奖励\n"; } } if (isset($func_open['1100'])) { $num = $this->get_game('PlayerCoinExchange')->get_free_times_interface($player_id); if ($num > 0) { $info .= "★炼金大师:今日还可免费炼化 " . $num . " 次\n"; } } if (isset($func_open['1070'])) { $num = $this->get_game('PubHero')->get_left_free_time($player_id); if ($num > 0) { $info .= "★英雄酒馆:今日还可免费抽取 " . $num . " 次\n"; } } if (isset($func_open['1020'])) { $cur_num = $this->get_game('PlayerFB')->get_day_num($player_id); $max_num = $this->get_game("PlayerFB")->get_day_num_max($player_id); $num = $max_num - $cur_num; if ($num > 0) { $info .= "★副本大厅:今日还可免费挑战 " . $num . " 次主线副本\n"; } } if (isset($func_open['1030'])) { $cur_num = $player_used_time['used_fight_num']; $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'used_fight_num'); $num = $max_num - $cur_num; if ($num > 0) { $info .= "★副本大厅:今日还可免费挑战 " . $num . " 次挑战副本\n"; } } if (isset($func_open['4051'])) { $max_num = $this->get_game('PlayerFB')->get_vip_fb_times_max_interface($player_id); $cur_num = $this->get_data('PlayerFB')->get_player_fb_num($player_id, 'vip_used_times'); $num = $max_num - $cur_num; if ($num > 0) { $info .= "★副本大厅:今日还可免费挑战 " . $num . " 次VIP副本\n"; } } if (isset($func_open['1050'])) { $cur_num = $player_used_time['challenge_battle_num']; $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'challenge_battle_num'); $num = $max_num - $cur_num; if ($num > 0) { $info .= "★竞技大厅:今日还可免费挑战 " . $num . " 次天梯\n"; } } if (isset($func_open['1060'])) { $cur_num = $player_used_time['kf_arena_use_times']; $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'kf_arena_add_times_max'); $num = $max_num - $cur_num; if ($num > 0) { $info .= "★竞技大厅:今日还可免费挑战 " . $num . " 次竞技场\n"; } } if (isset($func_open['1240'])) { $cur_num = $player_used_time['grab_treasure_battle_times']; $max_num = $this->get_data('PlayerDailyTime')->get_max_daily_time($player_id, 'grab_treasure_battle_times_max'); $num = $max_num - $cur_num; if ($num > 0) { $info .= "★竞技大厅:今日还可免费参与 " . $num . " 次夺宝\n"; } } if (isset($func_open['4011'])) { $cur_num = $player_used_time['world_boss_count']; $max_num = $this->get_game("WorldBoss")->get_max_time(); $num = $max_num - $cur_num; if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次世界BOSS\n"; } } if (isset($func_open['4041'])) { $num = $this->get_game('GrabMine')->get_grabmine_remain_involved_num($player_id, $player_used_time); if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次水晶争夺\n"; } } if (isset($func_open['4001'])) { $cur_num = $this->get_game("Athena")->get_athena_remaining_count($player_id, 4001, $player_used_time); $max_ydn_num = Cache_Athena::getInstance()->get_athena_set(4001); $num = $max_ydn_num['max_times'] - $cur_num; if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次守护女神\n"; } } if (isset($func_open['4061'])) { $tiems = $this->get_game('PlayerFB')->get_egg_active_times_interface($player_id, $player_used_time['egg_active_times']); $num = $tiems['max_times'] - $tiems['used_times']; if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次欢乐魔蛋\n"; } } if (isset($func_open['4071'])) { $times = $this->get_game('Trial')->get_player_times($player_id, $player_used_time); $num = $times['left_num']; if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次神之试炼副本\n"; } } if (isset($func_open['4081']) && time() <= strtotime("12:10")) { $num = $player_used_time['athena_question_involved_num']; $num = 1 - $num; if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次智力问答\n"; } } if (isset($func_open['4110'])) { $num = $this->get_game('KFDuel')->get_left_times($player_id, $player_used_time); if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次3V3竞技\n"; } } if (isset($func_open['4120'])) { $num = $player_used_time['flame_battle_count']; $num = 1 - $num; if ($num > 0) { $info .= "★玩法大厅:今日还可免费参与 " . $num . " 次烈焰战场\n"; } } if (isset($func_open['1080'])) { $num = $this->get_game('TaskHandler')->get_daily_task_avail_finish_count($player_id); if ($num > 0) { $info .= "★日常任务:今日还可免费完成 " . $num . " 轮日常任务\n"; } } $info .= "-------------------------------------\n"; $info .= "【明日登录】可获得:\n"; $info .= "★签到奖励:免费彩钻、强化石、金币\n"; $info .= "★在线奖励:免费抽取彩钻、魔晶、强化石、宝石\t\n"; $info .= "★炼金大师炼化金币:免费获取大量金币\t\n"; $info .= "★英雄酒馆抽取英雄:免费抽取橙色英雄及大量英雄养成材料\n"; return array('info' => $info); }
/** * 钻石鼓舞 * @param int $player_id 玩家id * @param int $sid 地图id * @return array */ public function inspire($player_id, $sid) { $player_id = intval($player_id); $sid = intval($sid); //$type = intval($type); if (!$sid || !$player_id) { //参数错误 $this->throw_error(10107, 6010117); } $arr_consume = $res = array(); $set = Cache_Athena::getInstance()->get_athena_inspire($sid); $pinfo = $this->get_data('Player')->get_player_info($player_id, array('gold', 'vip', 'player_id', 'level', 'ticket', 'privilege_level')); $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10083); if ($pinfo['vip'] < $vip_set['vip_level']) { $this->throw_error(6010091, 6010118); #vip等级未达到 } $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_duel_inspire_gold_count'); $max_time = $set['inspire_gold_max_times']; $cost_num = $this->get_cost_num($used_time, $set['inspire_gold_cost_num']); if ($cost_num <= 0) { //配置错误 $this->throw_error(10222, 6010119); } //先扣除彩钻 $rand_num = $set['inspire_gold_rand']; /***************/ $ticket = 0; $gold = $cost_num; if ($pinfo['ticket'] >= $cost_num) { $ticket = $cost_num; $gold = 0; } else { $ticket = $pinfo['ticket']; $gold = $cost_num - $pinfo['ticket']; } $arr_consume = array('price' => $cost_num, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); //数据中心推送 /**************/ $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', 'gold', $cost_num, 1, 1); if ($used_time < $max_time) { //还有次数 $res['res'] = 1; $result = $this->get_data('Player')->update_player_resource($player_id, $pinfo, 1239, array(), $arr_consume); if (true === $result) { $rand_id = rand(1, 100); if ($rand_id <= $rand_num) { $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'kf_duel_inspire_gold_count'); Protocol::input($player_id, 7, 4, 562, 0); //成功通知C++ $res['res'] = 1; $res['time'] = $max_time - $used_time - 1; } else { $res['res'] = 0; $res['time'] = $max_time - $used_time; } } else { $res['res'] = 0; $res['time'] = $max_time - $used_time; } } else { //次数已用完 $res['res'] = 2; $res['time'] = 0; $this->throw_error(11016, 6010005); } return $res; }
public function relive($player_id, $sid, $type) { $player_id = intval($player_id); $type = intval($type); $sid = intval($sid); $player_info = $this->get_data('Player')->get_player_info($player_id, array('silver', 'gold', 'vip', 'player_id', 'ticket', 'level', 'privilege_level')); if (1 == $type) { #无次数限制 $baseinfo = $this->get_base_info_id($sid); if (empty($baseinfo)) { $this->throw_error(10222, 2010104); } $relive_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'world_boss_relive_count'); $costval = $this->get_relive_cost($relive_time, $baseinfo['pve_cost_num']); $arr_consume = array(); if ($baseinfo['pve_cost_type'] == 3) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $costval); } elseif ($baseinfo['pve_cost_type'] == 2 || $baseinfo['pve_cost_type'] == 20) { if ($player_info['ticket'] >= $costval) { $gold = 0; } else { $gold = $costval - intval($player_info['ticket']); } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $costval, 1, 1); $arr_consume = array('price' => $costval, 'gold' => $gold, 'ticket' => $costval - $gold, 'count' => 1); #数据中心推送 } else { $this->throw_error(10222, 2010105); } $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1116, array(), $arr_consume); if (true === $result) { $res = array('res' => 1); Protocol::input($player_id, 7, 4, 461, 0); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'world_boss_relive_count'); $res['type'] = $type; return $res; } else { $this->throw_error(10110, 2010106); } } elseif (2 == $type) { #有次数限制--复活 $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'world_boss_box_count'); $box_list = Cache_WorldBoss::getInstance()->get_box_relive(); $sum = 0; $cost_list = array(); $cost_type = 0; if (!empty($box_list)) { $sum = $box_list[0]['max_times']; $cost_list = explode('|', $box_list[0]['cost_num']); $cost_type = $box_list[0]['cost_type']; #vip 增加次数 $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_info['vip'], 10053); if (!empty($vip_set)) { $sum += $vip_set['max_times']; } if ($used_time >= $sum) { $res = array('res' => 0); $this->throw_error(11019); #次数已用完 } if (count($cost_list) < $sum) { $used_time = count($cost_list) - 1; } $cost_num = $cost_list[$used_time]; $arr_consume = array(); if ($cost_type == 1) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $cost_num); } elseif ($cost_type == 2 || $cost_type == 20) { # 消耗货币 /***************/ $ticket = 0; $gold = $cost_num; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] >= $cost_num) { $ticket = $cost_num; $gold = 0; } else { $ticket = $player_info['ticket']; $gold = $cost_num - $player_info['ticket']; } } $arr_consume = array('price' => $cost_num, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 /***************/ $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost_num, 1, 1); } else { $this->throw_error(10222, 2010107); } $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1116, array(), $arr_consume); if (true === $result) { $res = array('res' => 1); Protocol::input($player_id, 7, 4, 461, 0); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'world_boss_box_count'); } else { $this->throw_error(10110, 2010108); } } else { $this->throw_error(10222, 2010109); } $res['type'] = $type; return $res; } elseif (3 == $type) { #vip开启钻石鼓舞 $res['res'] = 1; $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10037); if ($vip_set['vip_level'] > $player_info['vip']) { $this->throw_error('11006'); #vip等级不够 } #次数限制 $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'world_boss_inspire_count'); $set_info = Cache_Athena::getInstance()->get_athena_inspire($sid); #Cache_WorldBoss::getInstance()->get_worldboss_set($sid); if (empty($set_info)) { $this->throw_error(10222, 2010110); } if ($used_time >= $set_info['inspire_gold_max_times']) { $this->throw_error(11007); #鼓舞次数已用完 } #先扣除彩钻 $cost = $this->get_game('Athena')->get_cost_num($used_time, $set_info['inspire_gold_cost_num']); $ticket = 0; $price = $cost; if ($player_info['ticket'] >= $cost) { $ticket = $cost; $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $cost); $cost = 0; } else { $ticket = intval($player_info['ticket']); $cost = $cost - intval($player_info['ticket']); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', intval($player_info['ticket'])); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost); } $arr_consume = array('price' => $price, 'gold' => $cost, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 11161, array(), $arr_consume); if (true === $result) { Protocol::input($player_id, 7, 4, 461, 2); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'world_boss_inspire_count'); } else { $this->throw_error(10110, 2010111); #数据错误 } $res['type'] = $type; return $res; } elseif (4 == $type) { #金币鼓舞 $res['res'] = 1; #次数限制 $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'world_boss_inspire_silver_count'); $set_info = Cache_Athena::getInstance()->get_athena_inspire($sid); if (empty($set_info)) { $this->throw_error(10222, 2010112); } if ($used_time >= $set_info['inspire_silever_max_times']) { $this->throw_error(11007); #鼓舞次数已用完 } $cost_num = $this->get_game('Athena')->get_cost_num($used_time, $set_info['inspire_silever_cost_num']); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $cost_num); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 11161); if (true === $result) { Protocol::input($player_id, 7, 4, 461, 1); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'world_boss_inspire_silver_count'); } else { $this->throw_error(10110, 2010128); #数据错误 } $res['type'] = $type; return $res; } }
public function relive($player_id, $sid, $type) { $player_id = intval($player_id); $sid = intval($sid); $type = intval($type); if (!$sid || !$player_id) { $this->throw_error(70112, 20120181); } $relive_set = Cache_FlameBattle::getInstance()->get_relive_cost($sid); if (empty($relive_set)) { $this->throw_error(10222, 20120182); } $res = array(); $res['res'] = 0; $res['cost_num'] = 0; $res['type'] = $type; $res['inspire_num'] = 0; $res['first_open'] = 0; switch ($type) { case 0: #查复活消耗 $cost_nums = explode('|', $relive_set['cost_num']); $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'flame_battle_relive_count'); if ($used_time >= count($cost_nums)) { $used_time = count($cost_nums) - 1; } $cost_num = abs(intval($cost_nums[$used_time])); $res['res'] = 1; $res['cost_num'] = $cost_num; $res['type'] = $type; break; case 1: #复活 $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'flame_battle_relive_count'); $cost_nums = explode('|', $relive_set['cost_num']); if (empty($cost_nums)) { $this->throw_error(10222, 20120184); } if ($used_time >= count($cost_nums)) { $used_time = count($cost_nums) - 1; } $cost_num = abs(intval($cost_nums[$used_time])); $res['res'] = 1; $res['cost_num'] = $cost_num; $res['type'] = $type; #复活扣资源 $arr_consume = array(); $player_info = $this->get_data('Player')->get_player_info($player_id, array('silver', 'gold', 'player_id', 'ticket')); if ($relive_set['cost_type'] == 2) { if ($player_info['ticket'] >= $cost_num) { $gold = 0; } else { $gold = $cost_num - intval($player_info['ticket']); } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost_num, 1, 1); $arr_consume = array('price' => $cost_num, 'gold' => $gold, 'ticket' => $cost_num - $gold, 'count' => 1); #数据中心推送 } elseif ($relive_set['cost_type'] == 3) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $cost_num); } else { $this->throw_error(10222, 20120183); } $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2022, array(), $arr_consume); if (true === $result) { Protocol::input($player_id, 7, 4, 535, 0); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'flame_battle_relive_count'); #下一次消耗 $used_time++; if ($used_time >= count($cost_nums)) { $used_time = count($cost_nums) - 1; } $cost_num = abs(intval($cost_nums[$used_time])); $res['cost_num'] = $cost_num; } else { $this->throw_error(10110, 2010106); } break; case 2: #获取面板信息 $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'flame_battle_count'); $player_info = $this->get_data('Player')->get_player_info($player_id, array('battle_score')); if ($used_time > 0) { $res['res'] = 1; } $res['cost_num'] = 0 + $player_info['battle_score']; #鼓舞次数 $res['inspire_num'] = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'flame_inspire_gold_count'); $flame_data = $this->get_data('FlameBattle')->get_flame_battle_data($player_id); if (empty($flame_data) || !isset($flame_data['first_open'])) { $res['first_open'] = 1; $this->get_data('FlameBattle')->set_flame_battle_data($player_id, array('first_open' => 1)); } return $res; break; case 3: #钻石鼓舞 $inspire_set = Cache_Athena::getInstance()->get_athena_inspire($sid); $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'flame_inspire_gold_count'); if ($inspire_set['inspire_gold_max_times'] <= $used_time) { $this->throw_error(11016); } $cost_nums = explode('|', $inspire_set['inspire_gold_cost_num']); if (empty($inspire_set) || empty($cost_nums)) { $this->throw_error(10222, 20120183); } if ($used_time >= count($cost_nums)) { $used_time = count($cost_nums) - 1; } $cost_num = abs(intval($cost_nums[$used_time])); $player_info = $this->get_data('Player')->get_player_info($player_id, array('silver', 'gold', 'player_id', 'ticket')); if ($player_info['ticket'] >= $cost_num) { $gold = 0; } else { $gold = $cost_num - intval($player_info['ticket']); } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost_num, 1, 1); $arr_consume = array('price' => $cost_num, 'gold' => $gold, 'ticket' => $cost_num - $gold, 'count' => 1); #数据中心推送 $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2023, array(), $arr_consume); if (true === $result) { Protocol::input($player_id, 7, 4, 536, 0); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'flame_inspire_gold_count'); #下一次消耗 $used_time++; $res['inspire_num'] = $used_time; if ($used_time >= count($cost_nums)) { $used_time = count($cost_nums) - 1; } $cost_num = abs(intval($cost_nums[$used_time])); $res['cost_num'] = $cost_num; } else { $this->throw_error(10110, 2010106); } break; } return $res; }
/** * 鼓舞 * @param int $player_id 玩家id * @param int $sid 活动ID 对应activity_hall.id * @param int $type 消耗类型 1:金币;2:钻石 * @return array */ public function inspire($player_id, $sid, $type) { $player_id = intval($player_id); $sid = intval($sid); $type = intval($type); if (!$sid || !$player_id || !in_array($type, array(1, 2))) { //参数错误 $this->throw_error(10107, 6010001); } $arr_consume = $res = array(); $set = Cache_Athena::getInstance()->get_athena_inspire($sid); $pinfo = $this->get_data('Player')->get_player_info($player_id, array('gold', 'silver', 'vip', 'player_id', 'level', 'ticket', 'privilege_level')); switch ($type) { case 1: //金币 $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'trial_inspire_silver_count'); $max_time = $set['inspire_silever_max_times']; $my_num = $pinfo['silver']; $cost_num = $this->get_cost_num($used_time, $set['inspire_silever_cost_num']); if ($cost_num <= 0) { //配置错误 $this->throw_error(10222, 6010002); } $rand_num = $set['inspire_silever_rand']; $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', 'silver', $cost_num); break; case 2: //钻石 //钻石鼓舞 $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10078); if ($pinfo['vip'] < $vip_set['vip_level']) { $this->throw_error(6010091); #vip等级未达到 } $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'trial_inspire_gold_count'); $max_time = $set['inspire_gold_max_times']; $my_num = $pinfo['gold']; $cost_num = $this->get_cost_num($used_time, $set['inspire_gold_cost_num']); if ($cost_num <= 0) { //配置错误 $this->throw_error(10222, 6010003); } //先扣除彩钻 $rand_num = $set['inspire_gold_rand']; /***************/ $ticket = 0; $gold = $cost_num; if ($pinfo['ticket'] >= $cost_num) { $ticket = $cost_num; $gold = 0; } else { $ticket = $pinfo['ticket']; $gold = $cost_num - $pinfo['ticket']; } $arr_consume = array('price' => $cost_num, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); //数据中心推送 /**************/ $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', 'gold', $cost_num, 1, 1); break; default: return false; break; } if ($used_time < $max_time) { //还有次数 $res['res'] = 1; $result = $this->get_data('Player')->update_player_resource($player_id, $pinfo, 1139, array(), $arr_consume); if (true === $result) { $rand_id = rand(1, 100); if ($rand_id <= $rand_num) { if (1 == $type) { $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'trial_inspire_silver_count'); Protocol::input($player_id, 7, 4, 531, 1); //成功通知C++ } else { $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'trial_inspire_gold_count'); Protocol::input($player_id, 7, 4, 531, 0); //成功通知C++ } $res['res'] = 1; $res['type'] = $type; $res['time'] = $max_time - $used_time - 1; } else { $res['res'] = 0; $res['type'] = $type; $res['time'] = $max_time - $used_time; } } else { $res['res'] = 0; $res['type'] = $type; $res['time'] = $max_time - $used_time; } } else { //次数已用完 $res['res'] = 2; $res['type'] = $type; $res['time'] = 0; if ($type == 1) { $this->throw_error(11015, 6010004); } elseif ($type == 2) { $this->throw_error(11016, 6010005); } } return $res; }