public function get_open_sid() { $list = $this->get_data('RankList')->get_sort_list('level'); $world_info = Cache_WorldBoss::getInstance()->get_worldboss_set(); $count = array(); $level_num = array(); $open_type = array(); if (!empty($world_info)) { foreach ($world_info as $val) { if ($val['level_num'] >= 0) { $count[$val['sid']] = $val['level']; $level_num[$val['sid']] = $val['level_num']; $open_type[$val['sid']] = $val['open_type']; } } } $sum = array(); if (!empty($list)) { foreach ($count as $sid => $level) { foreach ($list as $val) { if ($val['level'] >= $level) { $sum[$sid] += 1; } } } $flag = array(); foreach ($level_num as $sid => $val) { if ($sum[$sid] >= $val) { $flag[$sid] = true; } else { $flag[$sid] = false; } } $res_sid = array(); $res_sid[1] = 4011; $res_sid[2] = 0; $res_sid[3] = 0; if (!empty($flag)) { foreach ($flag as $sid => $val) { if ($flag[$sid] && $sid > $res_sid[1] && $open_type[$sid] == 1) { $res_sid[1] = $sid; } if ($flag[$sid] && $sid > $res_sid[2] && $open_type[$sid] == 2) { $res_sid[2] = $sid; } if ($flag[$sid] && $sid > $res_sid[3] && $open_type[$sid] == 3) { $res_sid[3] = $sid; } } } $hash = $this->get_adcache_key('open', 3); $res = array('open_1' => $res_sid[1], 'open_2' => $res_sid[2], 'open_3' => $res_sid[3]); if (!$this->redis()->hash_set($hash, $res, null)) { return false; } } return $res; }
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_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 create_raward_list($player_id, $reward_type, $career_type) { $sum = 14; $reward_list = Cache_WorldBoss::getInstance()->get_boss_reward_list(); #$player = $this->get_data('Player')->get_player_info($player_id,array('career_type')); if (empty($reward_list)) { $this->throw_error(10222, 2010118); } $base_list = array(); $private_list = array(); foreach ($reward_list as $v) { if ($v['reward_type'] == $reward_type && $v['rate_time'] == 0) { array_push($base_list, $v); } if ($v['reward_type'] == $reward_type && $v['rate_time'] > 0) { $private_list[$v['rate_time']][] = $v; } } $private_count = count($private_list); if (!empty($base_list) && count($base_list) >= $sum - $private_count) { $rand_list = array(); foreach ($base_list as $val) { for ($i = 0; $i < $val['show_rate']; $i++) { array_push($rand_list, $val); } } $rlist = $this->get_last_list($rand_list, $sum - $private_count, $career_type); if (!empty($private_list)) { foreach ($private_list as $pval) { $temp = array(); foreach ($pval as $v) { if ($v['item_type'] == 1) { $item = explode('|', $v['item_id']); if (4 != count($item)) { $this->throw_error(10222, 2010223); } $v['item_id'] = $item[$career_type - 1]; } for ($i = 0; $i < $v['show_rate']; $i++) { $temp[] = $v; } } $randid = rand(0, count($temp) - 1); $rlist[] = $temp[$randid]; } } return $rlist; } else { $this->throw_error(10222, 2010119); } }