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 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; }