public function game_over($sid, $roles, $wave, $time, $roles_time, $roles_wave, $roles_dmg) { $sid = intval($sid); $wave = intval($wave); $time = intval($time); if (!$sid || !is_array($roles)) { $this->throw_error(10107, 2010015); } $is_success = 0; $set = Cache_Athena::getInstance()->get_athena_set($sid); if (empty($set)) { $this->throw_error(10107, 2010016); } #判断次数已经在c++做处理了 #$hall_set = Cache_ActivityHall::getInstance()->get_activity_info($sid); #$used=$this->get_athena_remaining_count($player_id,$sid); #if($used>$hall_set['max_times']){ #次数超过不发奖励 # return false; #} if ($set['max_waves'] == $wave) { $is_success = 1; } $res = array(); $res['sid'] = $sid; $res['res'] = $is_success; $res['wave'] = $wave; $res['time'] = $time; $players = array(); if (!empty($roles) && count($roles) == count($roles_wave) && count($roles_time) == count($roles_wave) && count($roles_dmg) == count($roles_wave)) { for ($i = 0; $i < count($roles); $i++) { if ($roles[$i] > 0) { Protocol::input($roles[$i], 8, 11, 1112, $res); $temp = $this->get_data('Player')->get_player_info($roles[$i], array('player_id', 'name', 'career_type', 'level', 'sum_fpower', 'vip', 'ad_info', 'career_type')); $player_info = array('player_id' => $temp['player_id'], 'name' => $temp['name'], 'career_type' => $temp['career_type'], 'level' => $temp['level'], 'sum_fpower' => $roles_dmg[$i], 'wave' => $roles_wave[$i], 'time' => $roles_time[$i]); $players[] = $player_info; $this->get_data('PlayerDailyTime')->set_used_time($roles[$i], 'athena_resume_count', 0); //添加日志 $log_data = array('player_id' => $roles[$i], 'channel' => 62, 'player_level' => $temp['level'], 'vip_level' => $temp['vip'], 'add_time' => time(), 'sid' => $sid, 'role_dmg' => $roles_dmg[$i], 'wave' => $wave, 'type' => 2); Log_WorldBoss::getInstance()->add_log($log_data); #文斌 $this->get_game('UnionBoonHall')->async_trigger_union_task($roles[$i], 2, $sid); #添加活跃度 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($roles[$i], 3004); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $roles[$i]); } } } else { $this->throw_error('10107'); } #更新排行榜 $data = array('sid' => $sid, 'players' => json_encode($players), 'waves' => $wave, 'times' => $time, 'reptime' => time()); $this->get_data('Athena')->update_team_info($sid, $data); }
public function game_over($world_boss_id, $roles, $roles_dmg, $roles_online, $killer_role_id, $killer_role_name) { $world_boss_id = intval($world_boss_id); $killer_role_id = intval($killer_role_id); $baseinfo = $this->get_base_info_id($world_boss_id); if (empty($baseinfo)) { $this->throw_error('10222', 2010100); } #配置表错误 $res = array(); $reward_result = array(); if ($killer_role_id > 0) { $reward_result['sid'] = 1; } else { $reward_result['sid'] = 0; } if ($world_boss_id) { $killer_player_info = null; $rank_list = Cache_WorldBoss::getInstance()->get_rank_reward(); $rank_num = count($rank_list); #邮件内容 $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(4000); $time = time(); if (!empty($roles) && !empty($roles_dmg)) { $num = count($roles); $use_set = Cache_ActivityHall::getInstance()->get_Activity_set(4011); #功能按钮开启 $setting = Cache_WorldBoss::getInstance()->get_worldboss_set(); $dps_list = Cache_UnionBoss::getInstance()->get_dps_reward(); if ($killer_role_id) { #结束活动 $this->get_data('WorldBoss')->set_game_over(); } for ($i = 0; $i < $num; $i++) { if ($roles[$i] == 0) { continue; } if ($killer_role_id) { #重置挖尸体相关数据 $reset_list = array('list' => '', 'sid' => $world_boss_id, 'start_time' => $time, 'list_log' => json_encode(array())); $this->get_data('WorldBoss')->set_boss_reward_list($roles[$i], $reset_list); } $player_info = $this->get_data('Player')->get_player_info($roles[$i], array('player_id', 'privilege_level', 'level', 'vip', 'name', 'gm', 'is_dummy')); #非本服玩家忽略 if ($player_info['player_id'] <= 0) { continue; } #更新玩家伤害值,形成排行榜 if (!empty($player_info) && ($player_info['gm'] == 0 || $player_info['gm'] == 3) && $player_info['is_dummy'] == 0) { $this->get_data('WorldBoss')->set_harm_list($roles[$i], $roles_dmg[$i]); } #vip特权加成奖励 $vip_exp = 0; if ($player_info['privilege_level'] > 0) { $left_cd = $this->get_game('VipSpecial')->get_left_time($roles[$i]); if ($left_cd > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_info['privilege_level'], 10034); if (!empty($vip_set)) { $vip_exp = $vip_set['max_times']; } } } #获取排名奖励 $all_reward = $this->get_rank_reward($rank_list, $rank_num, $i, $roles[$i], $player_info, $vip_exp, $baseinfo); if ($roles[$i] == $killer_role_id) { #最后一击奖励走掉落库 $killer_player_info = $player_info; $bossreward = explode('|', $baseinfo['boss_reward']); if (!empty($bossreward)) { foreach ($bossreward as $lid) { $temp = Cache_FbLoot::getInstance()->get_loot($lid, $killer_role_id); if (!empty($temp)) { foreach ($temp as $v) { if ($v['item_id'] == 3) { $v['item_num'] = ($vip_exp / 10000 + 1) * $v['item_num']; } $all_reward[] = $v; } } } } } #伤害奖励 $dps_rewards = $this->get_dps_reward($baseinfo['dps_reward'], $baseinfo['crystal_reward'], $roles_dmg[$i], $vip_exp, $dps_list); $all_reward[] = $dps_rewards['exp']; $reward_result['rank_num'] = $i + 1; #排名 $reward_result['reward_list'] = array(); if ($roles_online[$i] == 1) { #在线直接发奖励 $result = $this->get_game('Reward')->send_reward($roles[$i], $all_reward, array('cmd_id' => '462', 'bind_flag' => 0), 1); if ($result === true) { $sum_exp = 0; $this->get_game('Reward')->add_reward_log(); //记录日志 $out_reward_log = $this->get_game('Reward')->get_out_reward(); if ($out_reward_log) { #获取修正倍率后的奖励 foreach ($out_reward_log as $item_id => $item_num) { if ($item_id == 1) { $sum_exp += $item_num; } } if ($sum_exp > 0) { $prop_attr = Cache_Prop::getInstance()->get_prop_info(1); $prop_attr['item_num'] = $sum_exp; $attr = Struct_Prop::get_prop_struct($prop_attr); if (!empty($attr)) { $reward_result['reward_list'][] = $attr; } } } $prop_logs = $this->get_game('Reward')->get_prop_log(); if ($prop_logs) { foreach ($prop_logs as $val) { if (isset($val['overlay_num'])) { $val['item_num'] = $val['overlay_num']; } $reward_result['reward_list'][] = Struct_Prop::get_prop_struct($val); } } } Protocol::input($roles[$i], 8, 11, 1118, $reward_result); } else { #不在线发邮件 if (!empty($phrase_config)) { $content = sprintf($phrase_config['content'], $res['rank_num']); $attachment = array(); if (!empty($all_reward)) { foreach ($all_reward as $val_reward) { $attachment[] = array("prop_id" => $val_reward['item_id'], "prop_num" => $val_reward['item_num']); } } $re = $this->get_game('Mail')->async_trigger_mail($roles[$i], $phrase_config['title'], $content, $attachment, $phrase_config['sender'], 1, 462, 0); $this->write_check($re); } } #-------------------------扣次数-----同步次数给c++--------------------------- $this->get_data("PlayerDailyTime")->add_used_time($roles[$i], "world_boss_count"); $used = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($roles[$i], "world_boss_count"); if (empty($use_set)) { $left_num = 0; } else { $left_num = $use_set[0]['max_times'] - $used; } if ($left_num < 0) { $left_num = 0; } Protocol_Player::p2c_part_update($roles[$i], array('worldboss_remaining_count' => $left_num)); #添加日常任务进度跟踪 $this->get_game('TaskTrigger')->async_trigger_task($roles[$i], 104, $world_boss_id, 1); //找回资源埋点 $this->get_game('GetBackCurrency')->add_function_day_times($roles[$i], 7); $rank = $i + 1; $this->get_data('GetBackCurrency')->set_player_times($roles[$i], 'world_boss_battle_rank', $rank); #活动日志 $_event_log = array('log_type' => 'world_boss', 'player_id' => $roles[$i], 'reg_time' => time(), 'map_id' => $world_boss_id, 'damage' => $roles_dmg[$i], 'rank' => $i + 1); $this->get_game('Event')->async_deal_event_log($_event_log); #添加活跃度 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($roles[$i], 3005); if ($killer_role_id) { #通知功能按钮开启 $func[0][] = array('operate' => 1, 'func_id' => 1110, 'open' => 1, 'guide' => 0, 'cd' => $setting[0]['corpse_save_time']); Protocol::input($roles[$i], 8, 7, 741, $func); } //添加日志 $log_data = array('player_id' => $roles[$i], 'channel' => 62, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'add_time' => time(), 'sid' => $world_boss_id, 'role_dmg' => $roles_dmg[$i], 'type' => 1); Log_WorldBoss::getInstance()->add_log($log_data); } } //保存世界boss纪录 $save_data['sid'] = $world_boss_id; $save_data['roles'] = json_encode($roles); $save_data['roles_dmp'] = json_encode($roles_dmg); $save_data['roles_online'] = json_encode($roles_online); $save_data['killer_role_id'] = $killer_role_id; if ($killer_role_id) { #if(is_null($killer_player_info)){ # $killer_player_info = $this->get_data('Player')->get_player_info($killer_role_id,array('name')); #} $save_data['killer_role_name'] = $killer_role_name; #$killer_player_info['name']; #发广播通知 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $killer_role_id, 'txt' => $killer_role_name); $msg = Language_Message::make_message(11018, $arr_replace); $this->get_game('SystemNotice')->send_system_msg($killer_role_id, $msg, 1, 6); #判断是否开启抢宝箱 $open_set = Cache_WorldBoss::getInstance()->get_open_boss_set($world_boss_id); if (!empty($open_set) && $open_set['treasure_loot_entrance_sid'] > 0) { $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $killer_role_id, 'txt' => $killer_role_name); $msg = Language_Message::make_message(11019, $arr_replace); $this->get_game('SystemNotice')->send_system_msg($killer_role_id, $msg, 1, 6); } } else { $save_data['killer_role_name'] = ''; } $this->get_data('WorldBoss')->save_rank_log($save_data, $world_boss_id); } else { #参数错误 $this->throw_error('10107', 2010101); } }