Beispiel #1
0
 protected function adult_remind($player_id, $status)
 {
     if ($status == 1) {
         $msg = Language_Message::make_message('10223');
         $type = 1;
     } else {
         $msg = Language_Message::make_message('10224');
         $type = 2;
     }
     Com_Log::write("do_timeer." . $player_id, "msg:" . var_export($msg, true));
     Protocol::input($player_id, 8, 7, 755, array(0 => $msg, 1 => $type));
 }
Beispiel #2
0
 public static function msg($player_id, $code, $out_code = 0)
 {
     if (!IS_FRONT || defined('FROM_GATEWAY')) {
         $cmd0 = 8;
     } else {
         $cmd0 = 3;
     }
     if ($out_code > 0) {
         $msg = Language_Message::make_message($code, array(0 => array('rep_type' => 7, 'rep_val' => "-" . $out_code)));
     } else {
         $msg = Language_Message::make_message($code);
     }
     Protocol::input($player_id, $cmd0, 7, 742, array(0 => array($msg)));
     #提示采集成功
 }
Beispiel #3
0
 /**
  * @Purpose:
  * 更新公会活动状态
  * @Param $union_id 公会ID
  * @Param $type 活动类型
  * @Param $state 活动状态
  */
 public function update_union_activities_state($player_id, $union_id, $type, $state)
 {
     $state = intval($state);
     if ($type == 4) {
         $objUnionInfoData = $this->get_data('UnionInfo');
         $unionInfo = $objUnionInfoData->get_union_info($union_id);
         if (intval($unionInfo['create_player_id']) > 0) {
             if ($state == 1) {
                 //Com_Log::write('xgame.union_activities_state',"union_id={$union_id}|player_id={$unionInfo['create_player_id']}\t");
                 $arr_replace = array();
                 $arr_replace[] = array('rep_type' => 7, 'txt' => "");
                 $arr_replace[] = array('rep_type' => 1, 'txt' => 1, 'rep_val' => 9093, 'underLine' => 1);
                 $msg = Language_Message::make_message(174507, $arr_replace, 0, '', true);
                 $this->get_game('SystemNotice')->send_system_msg($unionInfo['create_player_id'], $msg, 7, 7);
             }
             if ($state == 2) {
                 $arr_replace = array();
                 $arr_replace[] = array('rep_type' => 7, 'txt' => "");
                 $msg = Language_Message::make_message(175708, $arr_replace);
                 $this->get_game('SystemNotice')->send_system_msg($unionInfo['create_player_id'], $msg, 7, 7);
             }
         }
     }
     if ($state != 2) {
         return;
     }
     $union_id = intval($union_id);
     $type = intval($type);
     #获取公会活动天数据
     $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['add_time'] = Com_FmtData::cus_json_decode($uad_data['add_time']);
     $uad_update = false;
     if (Com_Array::is_good_arr($uad_data['activities_info'])) {
         foreach ($uad_data['activities_info'] as $act_id => $act_data) {
             if (isset($act_data['activities_type']) && $act_data['activities_type'] == $type) {
                 $uad_data['activities_info'][$act_id]['state'] = 0;
                 $uad_data['activities_info'][$act_id]['open_time'] = 0;
                 $uad_data['activities_info'][$act_id]['close_time'] = 0;
                 $uad_data['end_activities'][] = $act_id;
                 $update_uad['activities_info'] = json_encode($uad_data['activities_info']);
                 $update_uad['end_activities'] = json_encode($uad_data['end_activities']);
                 $uad_update = true;
                 break;
             }
         }
     }
     $add_time_update = false;
     if (!empty($uad_data['add_time'][$type]) && $uad_data['add_time'][$type] > 0) {
         $uad_data['add_time'][$type] = 0;
         $update_uad['add_time'] = json_encode($uad_data['add_time']);
         $add_time_update = true;
     }
     #更新活动天数据
     if ($uad_update || $add_time_update) {
         $this->start_trans();
         $this->get_data('UnionActivities')->update_union_activities_daily_data($union_id, 'uad', $update_uad);
         $this->commit();
     }
     #同步活动数据到C++
     $this->get_game('Union')->Sync_Union_msg($union_id, $type);
 }
Beispiel #4
0
 public function destroy_akland_msg($type, $player_id, $monster_name)
 {
     $type = intval($type);
     $player_id = intval($player_id);
     $arr_replace = array();
     if ($type == 1) {
         #勇士我是乌拉拉2击败暗影心魔霸主,成功守护了奥克兰!
         $player_info = $this->get_data('Player')->get_player_info($player_id, array("name"));
         $arr_replace[] = array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id);
         $arr_replace[] = array('rep_type' => 7, 'txt' => $monster_name);
         $arr_replace[] = array('rep_type' => 12, 'txt' => '#1', 'rep_val' => 20055, 'rep_param' => array(1097));
         $msg = Language_Message::make_message(74801, $arr_replace, 0, '', true);
         $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 1, 1);
     } else {
         if ($type == 0) {
             #开宝箱
             $arr_replace[] = array('rep_type' => 12, 'txt' => '#1', 'rep_val' => 20055, 'rep_param' => array(1097));
             $msg = Language_Message::make_message(74802, $arr_replace, 0, '', true);
             $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 1, 1);
         } else {
             if ($type == 2) {
                 #刷新boss
                 $arr_replace[] = array('rep_type' => 7, 'txt' => $monster_name);
                 $arr_replace[] = array('rep_type' => 12, 'txt' => '#1', 'rep_val' => 20055, 'rep_param' => array(1097));
                 $msg = Language_Message::make_message(74803, $arr_replace, 0, '', true);
                 $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 1, 1);
             }
         }
     }
 }
Beispiel #5
0
 /**
  * 推送玩家获得道具、兑换、等级、名次、强化、品阶、连胜等
  * @param unknown $func_id
  * @param unknown $sub_func_id
  * @param unknown $replace_info
  * @param number $val
  */
 public function push_system_notice($player_id, $func_id, $sub_func_id, $replace_info, $val = 0, $need_broadcas = 0)
 {
     $gm = $this->get_data('Player')->get_player_info($player_id, 'gm');
     if ($gm == 1 || $gm == 2) {
         return false;
     }
     $arrPushConfig = Cache_PushUpgrade::getInstance()->get_upgrade_info($func_id, $sub_func_id);
     if (!$replace_info) {
         return false;
     }
     if (!empty($arrPushConfig)) {
         Com_Log::write('xgame.push_system_notice', "player_id={$player_id},func_id={$func_id},sub_func_id={$sub_func_id},val={$val},need_broadcas={$need_broadcas}");
         Com_Log::write('xgame.push_system_notice', var_export($replace_info, true));
         $code = $arrPushConfig['code'];
         $go_name = $arrPushConfig['go_name'];
         if ($arrPushConfig['need_broadcas'] == 99) {
             if (!$need_broadcas) {
                 return false;
             }
             $push_type = $need_broadcas;
         } else {
             if ($arrPushConfig['condition']) {
                 $arr_condition = explode(",", $arrPushConfig['condition']);
                 if (!in_array($val, $arr_condition)) {
                     return false;
                 }
             }
             $push_type = $arrPushConfig['need_broadcas'];
         }
         if (!$push_type) {
             return false;
         }
         $arr_push_type = explode(",", $push_type);
         if (empty($arr_push_type)) {
             $arr_push_type[] = $push_type;
         }
         $last_index = count($replace_info);
         foreach ($replace_info as $key => $info) {
             $rep_type = $info["rep_type"];
             $rep_val = $info["rep_val"];
             if ($go_name && !isset($replace_info[$index])) {
                 //最后前往
                 if ($rep_type == 1) {
                     $replace_info[$last_index] = $replace_info[$key];
                     $replace_info[$last_index]['txt'] = $go_name;
                     $replace_info[$last_index]['rep_underline'] = 1;
                 } else {
                     $replace_info[$last_index] = array('rep_type' => 1, 'rep_val' => $func_id, 'rep_pid' => $func_id);
                     $replace_info[$last_index]['txt'] = $go_name;
                     $replace_info[$last_index]['rep_underline'] = 1;
                 }
             }
             $replace_info[$key]['rep_color'] = "";
             if ($rep_type == 0) {
                 $name = $this->get_data('Player')->get_player_info($rep_val, 'name');
                 $replace_info[$key]['txt'] = $name;
             }
         }
         if (!$go_name) {
             $replace_info[$last_index] = array("rep_type" => 7, "txt" => "");
         }
         $go_replace_info = $replace_info[$last_index];
         $replace_info[$last_index] = array("rep_type" => 7, "txt" => "");
         foreach ($arr_push_type as $location) {
             if ($location) {
                 if ($location == 1) {
                     $replace_info[$last_index] = $go_replace_info;
                 }
                 $msg = Language_Message::make_message($code, $replace_info);
                 $this->send_system_msg($player_id, $msg, $location);
                 if ($location == 5) {
                     $this->get_game('PlayerFriend')->add_player_news($player_id, json_encode($msg));
                 }
                 $replace_info[$last_index] = array("rep_type" => 7, "txt" => "");
             }
         }
         Com_Log::write('xgame.push_system_notice', "-----------ok-------------");
         Com_Log::write('xgame.push_system_notice', var_export($replace_info, true));
         return $msg;
     }
 }
Beispiel #6
0
 /**
  * 粘在协议后的错误协议 如果有错误的话
  * @param $data
  * @return string
  */
 private function out_error($player_id, $error, $param = array())
 {
     $msg = Language_Message::make_message($error, $param);
     Protocol::input($player_id, 3, 7, 742, array(0 => array($msg)));
 }
Beispiel #7
0
 /**
  * @Purpose:
  * 更新公会任务
  * @Param $player_id 玩家ID
  * @Param $task_type 任务类型
  * @Param $target 目标
  * @Param $num 完成数量
  */
 public function async_update_union_task($player_id, $task_type, $target, $num = 1)
 {
     $player_id = intval($player_id);
     #获取玩家公会ID,验证公会信息
     $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id');
     if ($union_id > 0) {
         $is_create = false;
         #获取任务信息
         $task_info = $this->get_data('UnionBoonHall')->get_boon_hall_info($union_id, 'ubt', 'day');
         $data['task_info'] = $task_info['task_info'];
         if (!$data['task_info']) {
             /*
             #获取福利大厅等级
             $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_info = $this->get_data('UnionBoonHall')->get_boon_hall_info($union_id, 'ubtc', 'day', true);
             $data['chest_info'] = $chest_info['chest_info'];
             if ($data['chest_info'] && !is_array($data['chest_info']))
             {
             	#字段格式转换
             	$data['chest_info'] = json_decode($data['chest_info'], true);
             }
             else
             {
             	#创建宝箱数据
             	$data['chest_info'] = $this->create_chest_data($union_id, $hall_level);
             }
             
             $is_create = true;
             */
             return;
         } else {
             if (!is_array($data['task_info'])) {
                 #字段格式转换
                 $data['task_info'] = json_decode($data['task_info'], true);
             }
             #获取宝箱信息
             $chest_info = $this->get_data('UnionBoonHall')->get_boon_hall_info($union_id, 'ubtc', 'day');
             $data['chest_info'] = $chest_info['chest_info'];
             if ($data['chest_info'] && !is_array($data['chest_info'])) {
                 #字段格式转换
                 $data['chest_info'] = json_decode($data['chest_info'], true);
             } else {
                 return;
             }
         }
         $task_id = 0;
         $is_finish = false;
         $task_list = array();
         $task_type = intval($task_type);
         if ($data['task_info']['task_target'][$task_type]) {
             #更新任务进度
             if (in_array($task_type, $this->arr_type[0])) {
                 $task_id = $data['task_info']['task_target'][$task_type];
                 if ($data['task_info']['task'][$task_id] && !$data['task_info']['task'][$task_id]['finish_state']) {
                     $num = intval($num);
                     $low = $data['task_info']['task'][$task_id]['target'][0];
                     $high = $data['task_info']['task'][$task_id]['target'][1];
                     if ($num >= $low && $high <= $num) {
                         $data['task_info']['task'][$task_id]['cur_finish']++;
                         $is_finish = true;
                     }
                 }
             } else {
                 if (in_array($task_type, $this->arr_type[1])) {
                     #获取福利大厅等级
                     $hall_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'hall_level');
                     #$target = $target;
                     $task_list = $data['task_info']['task_target'][$task_type][$target];
                     if (is_array($task_list)) {
                         foreach ($task_list as $task_id) {
                             if (!empty($data['task_info']['task'][$task_id])) {
                                 if ($data['task_info']['task'][$task_id]['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) {
                                         $data['task_info']['task'][$task_id]['add_liveness'] = $task_table['add_liveness'];
                                         $data['task_info']['task'][$task_id]['need_finish'] = $task_table['times_complete'];
                                         $data['task_info']['task'][$task_id]['task_desc'] = $task_table['task_desc'];
                                     }
                                 }
                                 if ($data['task_info']['task'][$task_id]['add_liveness'] > 0) {
                                     if ($data['task_info']['task'][$task_id]['finish_state'] < 1) {
                                         $num = intval($num);
                                         $data['task_info']['task'][$task_id]['cur_finish'] += $num ? $num : 0;
                                         $is_finish = true;
                                     }
                                 }
                             }
                         }
                     } else {
                         if (!empty($data['task_info']['task'][$task_list])) {
                             if ($data['task_info']['task'][$task_list]['add_liveness'] < 1) {
                                 #获取任务配置表
                                 $task_table = $this->get_cache_table_data('task_table', array('level' => $hall_level, 'boon_task_id' => $task_list));
                                 $task_table = $task_table[0];
                                 if (!empty($task_table) && $task_table['add_liveness'] > 0 && $task_table['times_complete'] > 0) {
                                     $data['task_info']['task'][$task_list]['add_liveness'] = $task_table['add_liveness'];
                                     $data['task_info']['task'][$task_list]['need_finish'] = $task_table['times_complete'];
                                     $data['task_info']['task'][$task_list]['task_desc'] = $task_table['task_desc'];
                                 }
                             }
                             if ($data['task_info']['task'][$task_list]['add_liveness'] > 0) {
                                 if ($data['task_info']['task'][$task_list]['finish_state'] < 1) {
                                     $num = intval($num);
                                     $data['task_info']['task'][$task_list]['cur_finish'] += $num ? $num : 0;
                                     $is_finish = true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $is_chest = false;
         if ($is_finish) {
             #获取完成任务的玩家名称职业
             $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'career_type'));
             $task_state = array();
             $task_name = array();
             $task_liveness = array();
             #更新任务记录
             $arr_replace[] = array('rep_type' => 7, 'txt' => $player_info['name']);
             if (in_array($task_type, $this->arr_type[0])) {
                 if ($data['task_info']['task'][$task_id]['cur_finish'] >= $data['task_info']['task'][$task_id]['need_finish']) {
                     $data['task_info']['liveness'] += $data['task_info']['task'][$task_id]['add_liveness'];
                     $data['task_info']['task'][$task_id]['finish_state'] = 1;
                     $data['task_info']['task'][$task_id]['player_info'][] = $player_id;
                     $data['task_info']['task'][$task_id]['player_info'][] = $player_info['name'];
                     $data['task_info']['task'][$task_id]['player_info'][] = $player_info['career_type'];
                     $task_state[] = $data['task_info']['task'][$task_id]['finish_state'];
                     $task_name[] = $data['task_info']['task'][$task_id]['task_name'];
                     $task_liveness[] = $data['task_info']['task'][$task_id]['add_liveness'];
                 }
                 $arr_replace[] = array('rep_type' => 7, 'txt' => $num);
                 $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_id]['task_name']);
                 $code = 171102;
                 $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_id]['add_liveness']);
                 $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, $code, $arr_replace, 3);
             } else {
                 if (in_array($task_type, $this->arr_type[1])) {
                     #获取任务配置表
                     $func_config = $this->get_cache_table_data('func_config', $target);
                     if (is_array($task_list)) {
                         foreach ($task_list as $task_id) {
                             if ($data['task_info']['task'][$task_id]['finish_state'] == 1) {
                                 continue;
                             }
                             $code = 171104;
                             $change_code = false;
                             if ($data['task_info']['task'][$task_id]['cur_finish'] >= $data['task_info']['task'][$task_id]['need_finish']) {
                                 $data['task_info']['liveness'] += $data['task_info']['task'][$task_id]['add_liveness'];
                                 $data['task_info']['task'][$task_id]['finish_state'] = 1;
                                 $data['task_info']['task'][$task_id]['player_info'][] = $player_id;
                                 $data['task_info']['task'][$task_id]['player_info'][] = $player_info['name'];
                                 $data['task_info']['task'][$task_id]['player_info'][] = $player_info['career_type'];
                                 $code = 171103;
                                 $change_code = true;
                                 $task_state[] = $data['task_info']['task'][$task_id]['finish_state'];
                                 $task_name[] = $data['task_info']['task'][$task_id]['task_name'];
                                 $task_liveness[] = $data['task_info']['task'][$task_id]['add_liveness'];
                             }
                             $arr_replace = array();
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $player_info['name']);
                             if ($func_config) {
                                 $arr_replace[] = array('rep_type' => 7, 'txt' => $func_config['func_name']);
                             }
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_id]['task_name']);
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_id]['cur_finish']);
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_id]['need_finish']);
                             if ($change_code) {
                                 $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_id]['add_liveness']);
                             }
                             $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, $code, $arr_replace, 3);
                         }
                     } else {
                         $code = 171104;
                         $change_code = false;
                         if ($data['task_info']['task'][$task_list]['cur_finish'] >= $data['task_info']['task'][$task_list]['need_finish']) {
                             $data['task_info']['liveness'] += $data['task_info']['task'][$task_list]['add_liveness'];
                             $data['task_info']['task'][$task_list]['finish_state'] = 1;
                             $data['task_info']['task'][$task_list]['player_info'][] = $player_id;
                             $data['task_info']['task'][$task_list]['player_info'][] = $player_info['name'];
                             $data['task_info']['task'][$task_list]['player_info'][] = $player_info['career_type'];
                             $code = 171103;
                             $change_code = true;
                             $task_state[] = $data['task_info']['task'][$task_list]['finish_state'];
                             $task_name[] = $data['task_info']['task'][$task_list]['task_name'];
                             $task_liveness[] = $data['task_info']['task'][$task_list]['add_liveness'];
                         }
                         if ($func_config) {
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $func_config['func_name']);
                         }
                         $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_list]['task_name']);
                         $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_list]['cur_finish']);
                         $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_list]['need_finish']);
                         if ($change_code) {
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $data['task_info']['task'][$task_list]['add_liveness']);
                         }
                         $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, $code, $arr_replace, 3);
                     }
                 }
             }
             if (count($task_name) == count($task_liveness) && count($task_name) == count($task_state) && Com_Array::is_good_arr($task_state) && Com_Array::is_good_arr($task_name) && Com_Array::is_good_arr($task_liveness)) {
                 if (Com_Array::is_good_arr($task_name)) {
                     foreach ($task_name as $key => $name) {
                         if ($task_state[$key] == 1) {
                             #通知c++在聊天窗口显示任务完成通知
                             $arr_replace = array();
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $name, 'rep_color' => "ffb901");
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $task_liveness[$key], 'rep_color' => "ffb901");
                             $msg = Language_Message::make_message(171606, $arr_replace, 0, '', true);
                             $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
                             #增加公会记录
                             $arr_replace = array();
                             $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $name, 'rep_color' => "ffb901");
                             $arr_replace[] = array('rep_type' => 7, 'txt' => $task_liveness[$key], 'rep_color' => "ffb901");
                             $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, 1716005, $arr_replace);
                         }
                     }
                 }
             }
             /*
             $player_name = $this->get_data('Player')->get_player_info($player_id, 'name');
             $data['task_info']['record'][] = array(
             		'time' => time(),
             		'player_name' => $player_name,
             		'task_id' => $task_id,
             		'cur_finish' => $data['task_info']['task'][$task_id]['cur_finish'],
             		'need_finish' => $data['task_info']['task'][$task_id]['need_finish'],
             		'liveness' => $data['task_info']['task'][$task_id]['add_liveness'],
             );
             */
             #更新宝箱信息
             if (Com_Array::is_good_arr($data['chest_info']['chest'])) {
                 foreach ($data['chest_info']['chest'] as $chest_id => $chest) {
                     if ($data['task_info']['liveness'] >= $chest['liveness'] && $data['chest_info']['chest'][$chest_id]['state'] != 2) {
                         $data['chest_info']['chest'][$chest_id]['state'] = 1;
                         $is_chest = true;
                     }
                 }
             }
         }
         $is_commit = false;
         if (!$this->is_trans()) {
             $this->start_trans();
             $is_commit = true;
         }
         if ($is_finish || $is_create) {
             $task_info['task_info'] = json_encode($data['task_info']);
             $this->get_data('UnionBoonHall')->update_boon_hall_data($union_id, 'ubt', $task_info);
             #更新公会成就
             $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 8, $data['task_info']['liveness'], 2);
             if (is_array($task_list)) {
                 foreach ($task_list as $task_id) {
                     #更新公会引导状态
                     $this->get_game('UnionGuide')->async_trigger_union_guide($player_id, $data['task_info']['task'][$task_id]['cur_finish'], $data['task_info']['task'][$task_id]['need_finish'], 1, 1);
                 }
             } else {
                 #更新公会引导状态
                 $this->get_game('UnionGuide')->async_trigger_union_guide($player_id, $data['task_info']['task'][$task_list]['cur_finish'], $data['task_info']['task'][$task_list]['need_finish'], 1, 1);
             }
         }
         if ($is_chest || $is_create) {
             $chest_info['chest_info'] = json_encode($data['chest_info']);
             $this->get_data('UnionBoonHall')->update_boon_hall_data($union_id, 'ubtc', $chest_info);
         }
         if ($is_commit) {
             $this->commit();
         }
     }
 }
Beispiel #8
0
 /**
  * 夺宝战斗结果
  * @param unknown $player_id
  * @param unknown $battle_seq
  * @param unknown $winner_player_id
  * @param unknown $loser_player_id
  */
 public function battle_result($player_id, $battle_seq, $winner_player_id, $loser_player_id)
 {
     $battle_seq = intval($battle_seq);
     $winner_player_id = intval($winner_player_id);
     $loser_player_id = intval($loser_player_id);
     $this->start_trans();
     $grab_fail_award = "";
     $get_piece_id = "";
     $battle_result = 0;
     $grab_result = 0;
     $opponent_player_id = $winner_player_id;
     $phrase_id = 0;
     $player_info = array();
     $opponent_player_info = array();
     if ($winner_player_id == 0 && $loser_player_id == 0) {
         $battle_id_info = $this->get_data("GrabTreasure")->get_battle_id_info($battle_seq);
         $player_id = $battle_id_info['player_id'];
         $opponent_player_id = $battle_id_info['opponent_player_id'];
         $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
         $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
         if (empty($opponent_player_info)) {
             $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
         }
         Com_Log::debug_write('async_trigger_battle_test', "player_id={$player_id},{$player_info['sum_fpower']}={$opponent_player_info['sum_fpower']}");
         if ($player_info['sum_fpower'] > $opponent_player_info['sum_fpower']) {
             $winner_player_id = $player_id;
             $loser_player_id = $opponent_player_id;
             $phrase_id = 16;
         } else {
             $winner_player_id = $opponent_player_id;
             $loser_player_id = $player_id;
             $phrase_id = 17;
         }
     }
     if ($player_id == $winner_player_id) {
         $battle_result = 1;
         $opponent_player_id = $loser_player_id;
         if (empty($opponent_player_info) || empty($player_info)) {
             $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
             $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
             if (empty($opponent_player_info)) {
                 $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
             }
         }
         #抢碎片成功概率
         $rate_config = $this->get_battle_success_rate($player_info, $opponent_player_info);
         $random_get_piece_result = Com_Random::probability($rate_config['success_rate'], 100);
         #新手引导成功率100%
         $player_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($player_id, array("battle_log_id", "battle_need_piece_id", "battle_piece_quality", "quality_piece_ids", "is_guide"));
         if (intval($player_treasure_info["is_guide"]) == 1) {
             $random_get_piece_result = true;
         }
         $player_treasure_info["is_guide"] = 0;
         #抢碎片成功
         if ($random_get_piece_result) {
             $grab_result = 1;
             $quality = $player_treasure_info["battle_piece_quality"];
             $need_piece_id = $player_treasure_info["battle_need_piece_id"];
             #挑战成功加碎片
             $player_treasure_info["quality_piece_ids"][$quality][$need_piece_id] = $need_piece_id;
             #真实玩家
             if ($opponent_player_info['is_dummy'] == 0) {
                 $grab_piece_id = $need_piece_id;
                 $opponent_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($opponent_player_id, array("quality_piece_ids"));
                 #碎片存在
                 if (isset($opponent_treasure_info["quality_piece_ids"][$quality]) && !empty($opponent_treasure_info["quality_piece_ids"][$quality])) {
                     if (isset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id])) {
                         unset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id]);
                     } else {
                         $grab_piece_id = array_shift($opponent_treasure_info["quality_piece_ids"][$quality]);
                     }
                     #被抢者扣碎片
                     $re = $this->get_cross("GrabTreasure")->update_grab_treasure($opponent_player_id, $opponent_treasure_info);
                     $this->write_check($re, 5010859);
                     #抢者加碎片
                     $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info);
                     $this->write_check($re, 5010867);
                     #解除战斗中锁
                     $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id);
                     $this->write_check($re, 5010862);
                     #抢碎片日志
                     #{0}抢走了你的{1},简直不能忍!
                     $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($grab_piece_id);
                     $arr_replace = array(array('rep_type' => 0, 'rep_val' => $player_id, 'txt' => $player_info['name']), array('rep_type' => 7, 'txt' => $pieceConfig['name']));
                     $msg = Language_Message::make_message(123001, $arr_replace);
                     $add_log["player_id"] = $opponent_player_id;
                     $add_log["grab_player_id"] = $player_id;
                     $add_log["grab_piece_id"] = $grab_piece_id;
                     $add_log["quality"] = $quality;
                     $add_log["add_time"] = time();
                     $add_log['rep_content'] = $msg;
                     $add_log["is_allow_grab"] = 1;
                     $re = $this->get_cross("GrabTreasureLog")->add_grab_treasure_log($battle_seq, $add_log);
                     $this->write_check($re, 5010876);
                 } else {
                     $grab_result = 0;
                 }
             } else {
                 $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info);
                 $this->write_check($re, 5010992);
             }
             if (intval($player_treasure_info['battle_log_id']) > 0) {
                 $data = $this->get_cross('GrabTreasureLog')->get_grab_treasure_log($player_id, $player_treasure_info['battle_log_id']);
                 if (!empty($data)) {
                     $data['is_allow_grab'] = 0;
                     $re = $this->get_cross('GrabTreasureLog')->update_grab_treasure_info($player_id, $player_treasure_info['battle_log_id'], $data);
                     $this->write_check($re, 5010983);
                 }
             }
         }
         if ($grab_result == 0) {
             $need_piece_id = '';
             $grab_fail_award = $rate_config['fail_award'];
             $reward = $this->get_format_reward($grab_fail_award);
             if ($phrase_id > 0) {
                 $attachment = array();
                 foreach ($reward as $prop) {
                     $attachment[] = array("prop_id" => $prop['item_id'], "prop_num" => $prop['item_num']);
                 }
                 $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id);
                 $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 1230);
             } else {
                 $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '1230'), 1);
                 if ($re !== true) {
                     $this->write_check($re, 5011077);
                 }
             }
         }
     }
     $is_battle_lock = $this->get_cross("GrabTreasure")->get_battle_lock($opponent_player_id);
     if ($is_battle_lock) {
         $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id);
         $this->write_check($re, 5010872);
     }
     $this->commit();
     if ($battle_result == 1 && $grab_result == 0 && $phrase_id == 0) {
         $this->get_game('Reward')->add_reward_log();
     }
     if ($battle_result == 0 && $phrase_id > 0) {
         $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id);
         $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1);
     }
     #抢碎片增加日志
     if ($grab_result == 1) {
         if ($opponent_player_info['is_dummy'] == 0) {
             Log_Common::getInstance()->add_prop_log($opponent_player_id, $opponent_player_info['level'], $opponent_player_info['vip'], $opponent_player_info['privilege_level'], 1231, 11, 0, $grab_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0);
         }
         $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($need_piece_id);
         Log_Common::getInstance()->add_prop_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], 1231, 10, 0, $need_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0);
         if ($phrase_id > 0) {
             $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(18);
             $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1);
         }
     }
     $out = array('battle_result' => $battle_result, 'grab_result' => $grab_result, 'get_piece_id' => $need_piece_id, 'grab_fail_award' => $grab_fail_award);
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1040);
     #日常任务埋点
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 119, 119, 1);
     Protocol::input($player_id, 8, 12, 1230, $out);
 }
Beispiel #9
0
 /**
  * 获取战斗日志
  * @param $player_id
  * @return array
  */
 protected function get_fight_history($player_id)
 {
     $data = $this->get_data('KFDuel')->get_fight_log($player_id);
     if (empty($data)) {
         return array();
     }
     $out = array();
     $i = 0;
     $dw_configs = Cache_CrossArenaLevel::getInstance()->get_config_info();
     foreach ($data as $val) {
         if ($i > 3) {
             break;
         }
         $tmp = array('win' => $val['result'], 'msg' => array());
         if ($val['result'] == 1) {
             //你的队伍战胜了{0}的队伍,获得了{1}积分
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']), 1 => array('rep_type' => 7, 'txt' => "{$val['score']}"));
             $tmp['msg'] = Language_Message::make_message(6010104, $params);
         } elseif ($val['result'] == 0) {
             //你的队伍输给了{0}的队伍,获得了{1}积分
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']), 1 => array('rep_type' => 7, 'txt' => "{$val['score']}"));
             $tmp['msg'] = Language_Message::make_message(6010105, $params);
         }
         if ($tmp) {
             $out[] = $tmp;
             ++$i;
         }
     }
     return $out;
 }
Beispiel #10
0
 public function sync($data)
 {
     if (empty($data)) {
         return;
     }
     $data = json_decode($data, true);
     if (!isset($data['player_id'])) {
         return;
     }
     $player_id = $data['player_id'];
     $arr_update = $data['arr_update'];
     $gateway = $data['gateway'];
     //测试环境 推送到不同的gateway
     //        echo $gateway."\n";
     SynPlayer::init($player_id);
     SynPlayer::set_player($player_id);
     if (isset($arr_update['load']) && $arr_update['load'] == 1) {
         #登陆的时候加载下数据
         SynPlayer::init_syn_data(null);
         SynPlayer::set_syn_data($arr_update['init_data']);
         return;
     }
     ########################################################
     $objPlayerBase = $this->get_game('PlayerBase');
     $objFpowerCalc = $this->get_game('FpowerCalc');
     $objPlayer = $this->get_data('Player');
     $objDetail = $this->get_data('PlayerDetail');
     $objPlayerSkill = $this->get_game('PlayerSkill');
     $objPlayerAchieve = $this->get_game('PlayerAchieve');
     $objFairy = $this->get_data('Fairy');
     $objHero = $this->get_game('Hero');
     $objPlayerHero = $this->get_data('PlayerHero');
     $objPlayerWing = $this->get_game('PlayerWing');
     ########################################################
     $player_detail = null;
     $playerInfo = null;
     if (isset($arr_update['player_data'])) {
         $player_detail = $arr_update['player_data']['player_detail'];
         $playerInfo = $arr_update['player_data']['player'];
         if (isset($arr_update['player_data']['player_detail']) && empty($player_detail)) {
             $player_detail = $objDetail->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
         }
         if (isset($arr_update['player_data']['player']) && empty($playerInfo)) {
             $playerInfo = $objPlayer->get_player_info($player_id);
         }
         // Com_Log::write("sync.".$player_id,"player_data".var_export($arr_update['player_data'],true));
     }
     //Com_Log::write("sync.".$player_id,"player_detail".var_export($player_detail,true));
     //Com_Log::write("sync.".$player_id,"playerInfo".var_export($playerInfo,true));
     $cur_data = SynPlayer::get_uval();
     //        Com_Log::write('potion_hot_cnt_'.$player_id,var_export($cur_data,true));
     if (empty($cur_data)) {
         SynPlayer::init_syn_data(null);
         $init_data = $objPlayerBase->get_player_init_info($player_id);
         SynPlayer::set_syn_data($init_data);
         $cur_data = SynPlayer::get_uval();
         if (isset($arr_update['potion_dh_cnt'])) {
             $arr_update['potion_dh_cnt'] = 0;
         }
         #初次同步 如果有这些同步就置为0
         if (isset($arr_update['potion_hot_cnt'])) {
             $arr_update['potion_hot_cnt'] = 0;
         }
         if (isset($arr_update['mp_potion_cnt'])) {
             $arr_update['mp_potion_cnt'] = 0;
         }
     }
     $syn_item = array();
     $player_info = array();
     if (isset($arr_update['attr']) || isset($arr_update['fairy_info']) || isset($arr_update['hero_info'])) {
         //更新人物属性
         //            Com_Log::write('sync_player',"############################[start]##################################");
         //            Com_Log::write('sync_player',"cur_data:".var_export($cur_data,true));
         $player_info = $this->get_player_info($player_id, $playerInfo, $player_detail);
         $attr = Cache_AttrConfig::getInstance()->get_attr();
         //            Com_Log::write('sync_player',"attr:".var_export($attr,true));
         $attr_mag = array();
         $level = $cur_data[36];
         //            Com_Log::write("sync_level.".$player_id,"level:{$level}");
         foreach ($attr as $key) {
             $cur_val = $cur_data[SynPlayer::get_attr_inde($key)];
             $now_val = intval($player_info[$key]);
             //                Com_Log::write('sync_player.'.$player_id,"key:{$key} cur_val:{$cur_val} now_val:{$now_val}");
             //                echo "key:{$key} cur_val:{$cur_val} now_val:{$now_val}\n";
             if ($cur_val != $now_val) {
                 $diff_val = $now_val - $cur_val;
                 if ($level <= 20 && $diff_val < 0) {
                     //                        continue;
                 } else {
                     if ($diff_val < 0) {
                         $diff_val = $diff_val * -1;
                         $color = "FC0100";
                         $symbol = "-";
                     } else {
                         $color = "66FD34";
                         $symbol = "+";
                     }
                     if ($key != 'atk_max') {
                         $param = array(array('rep_type' => 6, 'rep_val' => $key), array('rep_type' => 7, 'rep_val' => $symbol, 'rep_color' => $color), array('rep_type' => 7, 'rep_val' => $diff_val, 'rep_color' => $color));
                         $attr_mag[] = Language_Message::make_message('10116', $param);
                     }
                 }
             }
             $syn_item[$key] = $now_val;
             //                Com_Log::write('sync_player',"############################[end]##################################");
         }
         if (!empty($attr_mag)) {
             if (isset($arr_update['exp'])) {
                 $msg_out = array(0 => $attr_mag, 1 => 2000);
             } else {
                 $msg_out = array(0 => $attr_mag, 1 => 0);
             }
             Protocol::input($player_id, 8, 7, 742, $msg_out);
         }
     }
     $update_fpower = array();
     if (isset($arr_update['wing']) || isset($arr_update['dower_info']) || isset($arr_update['hero_info']) || isset($arr_update['attr']) || isset($arr_update['fairy_info']) || isset($arr_update['skill_infos'])) {
         if (empty($player_info)) {
             $player_info = $this->get_player_info($player_id, $playerInfo, $player_detail);
         }
         Com_Log::write("player_fpower." . $player_id, "############################[start]#####################################");
         Com_Log::write("player_fpower." . $player_id, "player_info:" . var_export($player_info, true));
         Com_Log::write("player_fpower." . $player_id, "player_detail:" . var_export($player_detail, true));
         //            Com_Log::write("sync_player_fpower.".$player_id,"player_info:".var_export($player_info,true));
         //            Com_Log::write("sync_player_fpower.".$player_id,"player_detail:".var_export($player_detail,true));
         $objFpowerCalc->set_player_info($player_info);
         $objFpowerCalc->set_player_detail($player_detail);
         $player_fpower = $this->get_game('FpowerCalc')->calc_player_fpower($data['player_id']);
         $player_info['fpower'] = $update_fpower['fpower'] = $player_fpower['fpower'];
         $update_fpower['buff_fpower'] = $syn_item['buff_fpower'] = $player_fpower['buff_fpower'];
         if (isset($arr_update['attr'])) {
             $update_fpower['equip_fpower'] = $objFpowerCalc->calc_equip_fpower($player_id);
             $player_info['equip_fpower'] = $syn_item['equip_fpower'] = $update_fpower['equip_fpower'];
             $update_fpower['sq_fpower'] = $objFpowerCalc->calc_sq_fpower($player_id);
             $player_info['sq_fpower'] = $syn_item['sq_fpower'] = $update_fpower['sq_fpower'];
         }
         if (isset($arr_update['fairy_info'])) {
             $update_fpower['fairy_fpower'] = $objFpowerCalc->calc_fairy_fpower($player_id);
             $player_info['fairy_fpower'] = $syn_item['fairy_fpower'] = $update_fpower['fairy_fpower'];
         }
         if (isset($arr_update['hero_info'])) {
             $update_fpower['hero_fpower'] = $objFpowerCalc->calc_hero_fpower($player_id);
             $player_info['hero_fpower'] = $syn_item['hero_fpower'] = $update_fpower['hero_fpower'];
         }
         if (isset($arr_update['skill_infos']) || isset($arr_update['dower_info'])) {
             $update_fpower['skill_fpower'] = $objFpowerCalc->calc_skill_fpower($player_id);
             $player_info['skill_fpower'] = $syn_item['skill_fpower'] = $update_fpower['skill_fpower'];
         }
         if (isset($arr_update['wing'])) {
             $update_fpower['wing_fpower'] = $objFpowerCalc->calc_wing_fpower($player_id);
             $player_info['wing_fpower'] = $syn_item['wing_fpower'] = $update_fpower['wing_fpower'];
         }
         if ($update_fpower) {
             $update_fpower['fpower'] = $player_info['fpower'] + $player_info['sq_fpower'] + $player_info['skill_fpower'] + $player_info['equip_fpower'];
             Com_Log::write("player_fpower." . $player_id, "fpower:{$player_info['fpower']} sq_fpower:{$player_info['sq_fpower']} skill_fpower:{$player_info['skill_fpower']} equip_fpower:{$player_info['equip_fpower']}");
             $sum_fpower = $update_fpower['fpower'] + $player_info['hero_fpower'] + $player_info['fairy_fpower'] + $player_info['wing_fpower'] + $update_fpower['buff_fpower'];
             Com_Log::write("player_fpower." . $player_id, "hero_fpower:{$player_info['hero_fpower']} fairy_fpower:{$player_info['fairy_fpower']} wing_fpower:{$player_info['wing_fpower']} buff_fpower:{$update_fpower['buff_fpower']}");
             $update_fpower['sum_fpower'] = $sum_fpower;
             if ($sum_fpower > $player_info['max_sum_fpower']) {
                 $update_fpower['max_sum_fpower'] = $sum_fpower;
             }
             $yesterday_max_sum_fpower = $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, 'yesterday_max_sum_fpower');
             if (intval($yesterday_max_sum_fpower) == 0) {
                 $grab_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($player_id);
                 if (!empty($grab_treasure_info)) {
                     $yesterday_max_sum_fpower = intval($player_info['max_sum_fpower']) ? $player_info['max_sum_fpower'] : $player_info['sum_fpower'];
                     $this->get_data("PlayerDailyTime")->set_used_time($player_id, 'yesterday_max_sum_fpower', $yesterday_max_sum_fpower);
                 }
             }
             $objPlayer->update_player_info($player_id, $update_fpower);
             $syn_item['fpower'] = $update_fpower['fpower'];
             $syn_item['sum_fpower'] = $sum_fpower;
             Com_Log::write("player_fpower." . $player_id, "sum_fpower:{$sum_fpower} fpower:{$update_fpower['fpower']}");
             $this->get_data("Player")->set_player_sum_fpower($player_id, $sum_fpower);
             if ($player_info['level'] > 20) {
                 if (!isset($player_info['union_id'])) {
                     $playerInfo = $objPlayer->get_player_info($player_id);
                 }
                 $this->get_data("UnionInfo")->set_union_player_sum_fpower($player_info['union_id'], $player_id, $sum_fpower);
             }
             $objPlayerAchieve->async_trigger_achieve_target($player_id, 1, $sum_fpower, 2, $player_info['level']);
         }
         $objFpowerCalc->clear_static();
         unset($arr_update['attr']);
         Com_Log::write("player_fpower." . $player_id, "############################[end]#####################################");
     }
     if (isset($arr_update['equip_model']) || isset($arr_update['fashion_fit'])) {
         if (empty($arr_update['equip_model'])) {
             $arr_update['equip_model'] = $this->get_equip_views($player_id);
         }
         if (!isset($player_detail['fashion_fit']) || !isset($player_detail['player_settings'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('fashion_fit', 'player_settings'));
         }
         $fashion_fit = $player_detail['fashion_fit'];
         $meditation_flag = isset($player_detail['player_settings'][34]) ? $player_detail['player_settings'][34] : 0;
         if ($meditation_flag == 0) {
             if ($fashion_fit) {
                 $fashions = Cache_Fashion::getInstance()->get_fashion(array_values($fashion_fit));
                 if ($fashions) {
                     if (isset($fashion_fit[1])) {
                         $arr_update['equip_model'][3] = $fashions[$fashion_fit[1]]['equip_view'];
                     }
                     if (isset($fashion_fit[2])) {
                         $arr_update['equip_model'][0] = $fashions[$fashion_fit[2]]['equip_view'];
                     }
                 }
             }
         }
         $syn_item['equip'] = $arr_update['equip_model'];
         unset($arr_update['equip_model']);
     }
     if (isset($arr_update['meditation'])) {
         if (!isset($player_detail['player_settings'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('player_settings'));
         }
         $player_settings = $player_detail['player_settings'];
         if (isset($player_settings[37]) && $player_settings[37] == 1) {
             $syn_item['meditation_status'] = 1;
         } elseif (isset($player_settings[38]) && $player_settings[38] == 1) {
             $syn_item['meditation_status'] = 2;
         } else {
             $syn_item['meditation_status'] = 0;
         }
     }
     # 冥想功能开启状态同步
     if (isset($arr_update['meditation_open_status'])) {
         if (empty($arr_update['meditation_open_status'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('func_open'));
         } else {
             $player_detail = $arr_update['meditation_open_status'];
         }
         if (isset($player_detail['func_open']['44'])) {
             $syn_item['meditation_open_status'] = 1;
         } else {
             $syn_item['meditation_open_status'] = 0;
         }
     }
     if (isset($arr_update['equip_swallow'])) {
         $syn_item['equip_swallow'] = $arr_update['equip_swallow'];
         unset($arr_update['equip_swallow']);
     }
     if (isset($arr_update['equip_skill'])) {
         $syn_item['equip_skill'] = $arr_update['equip_skill'];
         unset($arr_update['equip_skill']);
     }
     //        $log_skill = false;
     if (isset($arr_update['skill_infos'])) {
         //Com_Log::write("skill_infos.".$player_id,"player_info:".var_export($arr_update,true));
         //Com_Log::write("skill_infos.".$player_id,"player_info:".var_export($playerInfo,true));
         //Com_Log::write("skill_infos.".$player_id,"player_deatail:".var_export($player_detail,true));
         $skill_infos = $objPlayerSkill->skill_list($player_id, $playerInfo, $player_detail);
         //            Com_Log::write('sync_skill_infos.'.$player_id,var_export($skill_infos['skill_infos'],true));
         $syn_item['skill_infos'] = $skill_infos['skill_infos'];
         //            $log_skill = true;
         unset($arr_update['skill_infos']);
     }
     if (isset($arr_update['fairy_info'])) {
         $fairy_list = $objFairy->get_player_fairy_list($player_id);
         $syn_item['fairy_info'] = array();
         if (!empty($fairy_list)) {
             foreach ($fairy_list as $keys => $val) {
                 foreach ($val['combination_list'] as $value) {
                     //获取有镶嵌的属性ID
                     if ($value['state'] > 1) {
                         $val['triggers'][] = $value['state'];
                     }
                 }
                 $syn_item['fairy_info'][] = $val;
             }
         }
         unset($arr_update['fairy_info']);
     }
     if (isset($arr_update['hero_info'])) {
         $hero_list = $this->get_data('PlayerHero')->get_fight_hero($player_id);
         if ($hero_list) {
             list($hero_id1, $hero_code1) = each($hero_list);
             if ($hero_id1) {
                 $hero_info = $this->get_game('Hero')->get_player_hero_attr($player_id, $hero_id1);
                 $syn_item['hero_info'] = $hero_info;
                 $syn_item['hero_code'] = $hero_code1;
                 $syn_item['hero_state'] = 1;
                 $syn_item['hero_level'] = $hero_info['hero_level'];
                 $syn_item['hero_fit_level'] = $hero_info['fit'];
             } else {
                 $syn_item['hero_code'] = 0;
                 $syn_item['hero_state'] = 0;
                 $syn_item['hero_info'] = array();
                 $syn_item['hero_fit_level'] = 0;
             }
             list($hero_id2, $hero_code2) = each($hero_list);
             if ($hero_id2) {
                 $after_hero_info = $this->get_game('Hero')->get_player_hero_attr($player_id, $hero_id2);
                 $syn_item['hero2_info'] = $after_hero_info;
                 $syn_item['hero2_code'] = $hero_code2;
                 $syn_item['hero2_state'] = 1;
                 $syn_item['hero2_level'] = $after_hero_info['hero_level'];
                 $syn_item['hero2_fit_level'] = $after_hero_info['fit'];
             } else {
                 $syn_item['hero2_code'] = 0;
                 $syn_item['hero2_state'] = 0;
                 $syn_item['hero2_info'] = array();
                 $syn_item['hero2_fit_level'] = 0;
             }
         } else {
             $syn_item['hero_code'] = 0;
             $syn_item['hero_state'] = 0;
             $syn_item['hero_info'] = array();
             $syn_item['hero_fit_level'] = 0;
             $syn_item['hero2_code'] = 0;
             $syn_item['hero2_state'] = 0;
             $syn_item['hero2_info'] = array();
             $syn_item['hero2_fit_level'] = 0;
         }
         unset($arr_update['hero_info']);
     }
     if (isset($arr_update['dower_info'])) {
         if (!isset($player_detail['dower_info'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('dower_info'));
         }
         $syn_item['dower_info'] = $player_detail['dower_info'];
         unset($arr_update['dower_info']);
     }
     if (isset($arr_update['hook_settings'])) {
         if (empty($arr_update['hook_settings'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('hook_settings'));
         } else {
             $player_detail = $arr_update['hook_settings'];
         }
         $syn_item['hook_settings'] = $player_detail['hook_settings'];
         unset($arr_update['hook_settings']);
     }
     if (isset($arr_update['wing'])) {
         if (!isset($player_detail['equip_wing']) || !isset($player_detail['wing_info'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('equip_wing', 'wing_info'));
         }
         if ($player_detail['equip_wing'] && isset($player_detail['wing_info'][$player_detail['equip_wing']])) {
             $wing_table_task = $objPlayerWing->get_cache_table_data('player_wing_table', array('id' => $player_detail['wing_info'][$player_detail['equip_wing']]['id'], 'level' => $player_detail['wing_info'][$player_detail['equip_wing']]['lvl']));
             $syn_item['wing'] = $wing_table_task[0]['avatar'];
             $syn_item['wing_skill_id'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][0]);
             $syn_item['wing_skill_id2'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][1]);
             $syn_item['wing_skill_id3'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][2]);
         } else {
             $syn_item['wing'] = '';
             $syn_item['wing_skill_id'] = 0;
             $syn_item['wing_skill_id2'] = 0;
             $syn_item['wing_skill_id3'] = 0;
         }
         unset($arr_update['wing']);
     }
     ##################[同步当前任务]#####################################
     if (isset($arr_update['city_escort_map_sid'])) {
         $syn_item['city_escort_map_sid'] = $arr_update['city_escort_map_sid'];
         unset($arr_update['city_escort_map_sid']);
     }
     if (isset($arr_update['city_escort_target_x'])) {
         $syn_item['city_escort_target_x'] = $arr_update['city_escort_target_x'];
         unset($arr_update['city_escort_target_x']);
     }
     if (isset($arr_update['city_escort_target_y'])) {
         $syn_item['city_escort_target_y'] = $arr_update['city_escort_target_y'];
         unset($arr_update['city_escort_target_y']);
     }
     if (isset($arr_update['city_escort_npc_sid'])) {
         $syn_item['city_escort_npc_sid'] = $arr_update['city_escort_npc_sid'];
         unset($arr_update['city_escort_npc_sid']);
     }
     if (isset($arr_update['task_id'])) {
         $syn_item['task_id'] = $arr_update['task_id'];
         unset($arr_update['task_id']);
     }
     if (isset($arr_update['task_step'])) {
         $syn_item['task_step'] = $arr_update['task_step'];
         unset($arr_update['task_step']);
     }
     if (isset($arr_update['task_start_status'])) {
         $syn_item['task_start_status'] = $arr_update['task_start_status'];
         unset($arr_update['task_start_status']);
     }
     ##################[同步当前任务]#######################################
     #########################[竞技场同步]##################################
     if (isset($arr_update['dw'])) {
         $syn_item['dw'] = $arr_update['dw'];
         unset($arr_update['dw']);
     }
     if (isset($arr_update['dw_lv'])) {
         $syn_item['dw_lv'] = $arr_update['dw_lv'];
         unset($arr_update['dw_lv']);
     }
     if (isset($arr_update['score'])) {
         $syn_item['score'] = $arr_update['score'];
         unset($arr_update['score']);
     }
     if (isset($arr_update['dw_star'])) {
         $syn_item['dw_star'] = $arr_update['dw_star'];
         unset($arr_update['dw_star']);
     }
     #########################[竞技场同步]##################################
     if (isset($arr_update['potion_dh_cnt'])) {
         #修改直接回血药剂数量
         $cur_data = SynPlayer::get_uval();
         $cur_val = intval($cur_data[SynPlayer::POTION_DH_CNT]);
         $syn_item['potion_dh_cnt'] = $cur_val + intval($arr_update['potion_dh_cnt']);
         unset($arr_update['potion_dh_cnt']);
     }
     if (isset($arr_update['potion_hot_cnt'])) {
         #修改缓慢回血药剂数量
         $cur_data = SynPlayer::get_uval();
         $cur_val = intval($cur_data[SynPlayer::POTION_HOT_CNT]);
         $syn_item['potion_hot_cnt'] = $cur_val + intval($arr_update['potion_hot_cnt']);
         unset($arr_update['potion_hot_cnt']);
     }
     if (isset($arr_update['mp_potion_cnt'])) {
         #修改回蓝药剂数量
         $cur_data = SynPlayer::get_uval();
         $cur_val = intval($cur_data[SynPlayer::MP_POTION_CNT]);
         $syn_item['mp_potion_cnt'] = $cur_val + intval($arr_update['mp_potion_cnt']);
         unset($arr_update['mp_potion_cnt']);
     }
     if (isset($arr_update['light_fairy_name'])) {
         #光女神名字
         $syn_item['light_fairy_name'] = $arr_update['light_fairy_name'];
         //            Com_Log::write('light_fairy_name_'.$player_id,$arr_update['light_fairy_name']);
         unset($arr_update['light_fairy_name']);
     }
     if (isset($arr_update['dark_fairy_name'])) {
         #按女神名字
         $syn_item['dark_fairy_name'] = $arr_update['dark_fairy_name'];
         //            Com_Log::write('dark_fairy_name'.$player_id,$arr_update['dark_fairy_name']);
         unset($arr_update['dark_fairy_name']);
     }
     if (isset($arr_update['athena_remaining_count'])) {
         #守护女神次数
         $syn_item['athena_remaining_count'] = $arr_update['athena_remaining_count'];
         unset($arr_update['athena_remaining_count']);
     }
     if (isset($arr_update['worldboss_remaining_count'])) {
         #世界boss次数
         $syn_item['worldboss_remaining_count'] = $arr_update['worldboss_remaining_count'];
         unset($arr_update['worldboss_remaining_count']);
     }
     if (isset($arr_update['had_on_swings'])) {
         #已开启翅膀
         $syn_item['had_on_swings'] = $arr_update['had_on_swings'];
         unset($arr_update['had_on_swings']);
     }
     if (isset($arr_update['trial_of_god_remaining_cnt'])) {
         #神之试炼当前剩余次数
         $syn_item['trial_of_god_remaining_cnt'] = $arr_update['trial_of_god_remaining_cnt'];
         unset($arr_update['trial_of_god_remaining_cnt']);
     }
     if (isset($arr_update['is_hidden_vip'])) {
         #vip显示状态
         $syn_item['is_hidden_vip'] = $arr_update['is_hidden_vip'];
         unset($arr_update['is_hidden_vip']);
     }
     if (isset($arr_update['mineral_remaining_count'])) {
         #抢矿剩余次数
         $syn_item['mineral_remaining_count'] = $arr_update['mineral_remaining_count'];
         unset($arr_update['mineral_remaining_count']);
     }
     if (isset($arr_update['privilege_left_time'])) {
         #vip特权剩余时间
         $syn_item['privilege_left_time'] = $arr_update['privilege_left_time'];
         unset($arr_update['privilege_left_time']);
     }
     if (isset($arr_update['kf_3vs3_remaining_count'])) {
         #跨服切磋次数
         $syn_item['kf_3vs3_remaining_count'] = $arr_update['kf_3vs3_remaining_count'];
         unset($arr_update['kf_3vs3_remaining_count']);
     }
     //毁灭奥克兰次数
     if (isset($arr_update['count_boss_oakland'])) {
         $syn_item['count_boss_oakland'] = $arr_update['count_boss_oakland'];
         unset($arr_update['count_boss_oakland']);
     }
     if (isset($arr_update['count_boss_oakland'])) {
         $syn_item['count_boss_oakland'] = $arr_update['count_boss_oakland'];
         unset($arr_update['count_boss_oakland']);
     }
     if (isset($arr_update['count_chest_oakland'])) {
         $syn_item['count_chest_oakland'] = $arr_update['count_chest_oakland'];
         unset($arr_update['count_chest_oakland']);
     }
     if (!empty($arr_update)) {
         //            Com_Log::write("sync_publish.".$player_id,var_export($arr_update,true));
         #Com_Log::write('nut','---1--'.json_encode($arr_update));
         foreach ($arr_update as $key => $val) {
             $syn_item[$key] = $val;
             #先临时这样写
             #Com_Log::write('nut','---3--'.json_encode($arr_update));
             $currency_key = Cache_Currency::get_currency_key();
             if (empty($val) && !in_array($key, $currency_key)) {
                 if (!isset($player_info[$key])) {
                     $player_info = $this->get_player_info($player_id);
                 }
                 $syn_item[$key] = $player_info[$key];
             } else {
                 $syn_item[$key] = $val;
             }
             if ($key == 'silver') {
                 if ($player_id == 1895663) {
                     Com_Log::write('xgame.p2c_part_update_tmp', json_encode($syn_item));
                 }
                 $objPlayerAchieve->async_trigger_achieve_target($player_id, 23, $syn_item[$key], 2, $player_info['level']);
                 //出发成就
             }
             if ($key == 'gold') {
                 $objPlayerAchieve->async_trigger_achieve_target($player_id, 25, $syn_item[$key], 4, $player_info['level']);
             }
         }
     }
     #Com_Log::debug_write("sync.".$player_id, "arr_update".json_encode($arr_update));
     #Com_Log::debug_write("sync.".$player_id, "player_info".json_encode($player_info));
     unset($objPlayerBase, $objFpowerCalc, $objPlayer, $objDetail, $objPlayerSkill, $objPlayerAchieve, $objFairy, $objHero, $objPlayerHero, $objPlayerWing);
     SynPlayer::set_syn_data($syn_item);
     $data = SynPlayer::get_data();
     //        if(isset($data['u'][225])){
     //            Com_Log::write('silver_'.$player_id,"silver:{$data['u'][225]}");
     //        }
     //        if($log_skill){
     //            Com_Log::write('sync_skill_infos.'.$player_id,var_export($data['m'],true));
     //            Com_Log::write('sync_skill_infos.'.$player_id,var_export($data['u'],true));
     //        }
     Protocol::input($player_id, 7, 4, 417, array(0 => $data['m'], 1 => $data['u']));
     Protocol::out($gateway);
 }
Beispiel #11
0
 /**
  * 触发公会成就任务
  * @param unknown $player_id
  */
 public function trigger_union_achieve($data)
 {
     if (empty($data)) {
         return;
     }
     $data = json_decode($data, true);
     Com_Log::log($data, 'trigger_union_achieve.log', 1);
     $player_id = $data["player_id"];
     $task_type = $data["task_type"];
     $trigger_val = $data["num"];
     $update_type = $data["update_type"];
     $union_id = $data["union_id"];
     $objUnionAchieveData = $this->get_data('UnionAchieve');
     $achieve_list = Cache_UnionAchieve::getInstance()->get_union_achieve_info(array("type" => $task_type));
     foreach ($achieve_list as $val) {
         $achieve_id = $val['sid'];
         $unionAchieveInfo = $objUnionAchieveData->get_union_achieve_list($union_id, $achieve_id);
         if ($unionAchieveInfo['state'] == 1) {
             continue;
         }
         $content = explode('|', $val['content']);
         $total_num = count($content) > 1 ? $content[1] : $content[0];
         $player_num = count($content) > 1 ? $content[0] : 0;
         //不同玩家达成
         if ($player_num > 0) {
             if ($unionAchieveInfo['player_ids']) {
                 if (in_array($player_id, $unionAchieveInfo['player_ids'])) {
                     continue;
                 }
             }
             $unionAchieveInfo['player_ids'][] = $player_id;
         }
         $unionAchieveInfo['sid'] = $achieve_id;
         $unionAchieveInfo['state'] = 0;
         if ($update_type == 1) {
             //累加
             $unionAchieveInfo['num'] += $trigger_val;
             //成就完成
             if ($unionAchieveInfo['num'] >= $total_num) {
                 $unionAchieveInfo['state'] = 1;
             }
         } else {
             if ($update_type == 2) {
                 //赋值
                 $unionAchieveInfo['num'] = $trigger_val;
                 //成就完成
                 if ($unionAchieveInfo['num'] >= $total_num) {
                     $unionAchieveInfo['state'] = 1;
                 }
             } else {
                 if ($update_type == 3) {
                     //小于等于
                     $unionAchieveInfo['num'] = $trigger_val;
                     //成就完成
                     if ($unionAchieveInfo['num'] > 0 && $unionAchieveInfo['num'] <= $total_num) {
                         $unionAchieveInfo['state'] = 1;
                     }
                 } else {
                     continue;
                 }
             }
         }
         if ($player_num) {
             $unionAchieveInfo['state'] = 0;
             if (count($unionAchieveInfo['player_ids']) >= $player_num) {
                 $unionAchieveInfo['state'] = 1;
             }
             $unionAchieveInfo['num'] = count($unionAchieveInfo['player_ids']);
         }
         $progress_task_num = 0;
         $medal_achieve_list = Cache_UnionAchieve::getInstance()->get_union_achieve_info(array("medal_id" => $val["medal_id"]));
         $medal_total_task_num = count($medal_achieve_list);
         foreach ($medal_achieve_list as $medal_task_info) {
             if ($achieve_id == $medal_task_info["sid"]) {
                 if (!$unionAchieveInfo['state']) {
                     break;
                 }
                 $progress_task_num++;
             } else {
                 $achieve_info = $objUnionAchieveData->get_union_achieve_list($union_id, $medal_task_info["sid"]);
                 if (!$achieve_info) {
                     break;
                 }
                 if ($achieve_info['state'] == 1) {
                     $progress_task_num++;
                 }
             }
         }
         $this->start_trans();
         $unionAchieveInfo["rep_time"] = time();
         $retUnionAchieve = $objUnionAchieveData->update_union_achieve($union_id, $achieve_id, $unionAchieveInfo);
         //达成勋章
         $retUnionInfo = true;
         if ($progress_task_num == $medal_total_task_num) {
             $objUnionInfoData = $this->get_data('UnionInfo');
             $UnionInfo = $objUnionInfoData->get_union_info($union_id, array("union_medal"));
             $UnionInfo['union_medal'][] = $val['medal_id'];
             Com_Log::debug_write('update_union_info', "trigger_union_achieve|unoin_id={$union_id}" . json_encode($data));
             $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $UnionInfo);
             $medal_list = Cache_UnionMedal::getInstance()->get_union_medal_info(array("sid" => $val['medal_id']));
             $medal_info = $medal_list[0];
             $arr_replace = array();
             $arr_replace[] = array('rep_type' => 7, 'txt' => $medal_info['name'], 'rep_color' => "ffb901");
             $msg = Language_Message::make_message(174902, $arr_replace);
             $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
         }
         if ($retUnionAchieve && $retUnionInfo) {
             $this->commit();
             if ($unionAchieveInfo['state'] == 1) {
                 $arr_replace = array();
                 $arr_replace[] = array('rep_type' => 7, 'txt' => $val['name'], 'rep_color' => "ffb901");
                 $msg = Language_Message::make_message(174901, $arr_replace);
                 $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
             }
             if ($progress_task_num >= $medal_total_task_num) {
                 $this->union_player_add_attr($union_id, $val['medal_id']);
             }
         } else {
             $this->rollback();
         }
         if (!IS_FRONT) {
             Protocol::out();
         }
     }
 }
Beispiel #12
0
 /**
  * 获取战斗日志
  * @param $player_id
  * @return array
  */
 protected function get_fight_history($player_id)
 {
     $data = $this->get_data('KFArena')->get_fight_log($player_id);
     if (empty($data)) {
         return array();
     }
     $out = array();
     $i = 0;
     $dw_configs = Cache_CrossArenaLevel::getInstance()->get_config_info();
     foreach ($data as $val) {
         if ($i > 3) {
             break;
         }
         $tmp = array('player_id' => $val['opponent_player_id'], 'name' => $val['opponent_name'], 'fpower' => $val['fpower'], 'win' => $val['result'], 'msg' => array());
         if ($val['result'] == 1 && $val['star'] > 0) {
             #你战胜了xxx获得一颗星
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']));
             $tmp['msg'] = Language_Message::make_message(120126, $params);
         } elseif ($val['result'] == 1 && $val['dw'] > 0) {
             #你战胜了xxxz,晋升至xxx
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']), 1 => array('rep_type' => 7, 'txt' => $dw_configs[$val['dw']]['name']));
             $tmp['msg'] = Language_Message::make_message(120127, $params);
         } elseif ($val['result'] == 1 && $val['dw'] == $this->max_dw && $val['rank'] == 0) {
             #你战胜了xxx,根据传说胜利场数,传说排名不变
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']));
             $tmp['msg'] = Language_Message::make_message(120128, $params);
         } elseif ($val['result'] == 1 && $val['dw'] == $this->max_dw && $val['rank'] > 0) {
             #你战胜了xxx,根据传说胜利场数,传说排名升至xx
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']), 1 => array('rep_type' => 7, 'txt' => "传说{$val['rank']}"));
             $tmp['msg'] = Language_Message::make_message(120129, $params);
         } elseif ($val['result'] == 0 && $val['star'] == 0 && $val['dw'] == 0 && $val['rank'] == 0) {
             #你败给了xxx改段位不掉星
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']));
             $tmp['msg'] = Language_Message::make_message(120130, $params);
         } elseif ($val['result'] == 0 && $val['star'] > 0) {
             #你失败了 失去一颗星
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']));
             $tmp['msg'] = Language_Message::make_message(120131, $params);
         } elseif ($val['result'] == 0 && $val['dw'] > 0 && $val['dw'] < $this->max_dw) {
             #你失败了 降至xx段位
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']), 1 => array('rep_type' => 7, 'txt' => $dw_configs[$val['dw']]['name']));
             $tmp['msg'] = Language_Message::make_message(120132, $params);
         } elseif ($val['result'] == 0 && $val['dw'] == $this->max_dw && $val['rank'] == 0) {
             #你失败 传说排名不变
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']));
             $tmp['msg'] = Language_Message::make_message(120133, $params);
         } elseif ($val['result'] == 0 && $val['dw'] == $this->max_dw && $val['rank'] > 0) {
             #你失败 传说排名降至xx
             $params = array(0 => array('rep_type' => 7, 'txt' => $val['opponent_name']), 1 => array('rep_type' => 7, 'txt' => "传说{$val['rank']}"));
             $tmp['msg'] = Language_Message::make_message(120134, $params);
         }
         if ($tmp) {
             $out[] = $tmp;
             ++$i;
         }
     }
     return $out;
 }
Beispiel #13
0
 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);
     }
 }
Beispiel #14
0
 /**
  * @Purpose:
  * 刷新玩家公会通缉榜运势
  * @Param $refresh_player_id 刷新玩家ID
  * @Param $player_id 玩家ID
  */
 public function refresh_fortune($refresh_player_id, $player_id)
 {
     $refresh_player_id = intval($refresh_player_id);
     $player_id = intval($player_id);
     if ($refresh_player_id == $player_id) {
         $this->throw_error('1716003');
         #不能自己刷新运势
     }
     #获取玩家公会ID,验证公会信息
     $refresh_union_id = $this->get_data('Player')->get_player_info($refresh_player_id, 'union_id');
     $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id');
     if ($union_id < 1 || $refresh_union_id < 1 || $refresh_union_id != $union_id) {
         $this->throw_error('171101');
         #未加入公会
     }
     #获取玩家通缉榜天数据
     $uwd_data = $this->get_data("UnionWanted")->get_union_wanted_daily_info($player_id, 'uwd', 'day');
     if (!$uwd_data) {
         $this->throw_error('10110');
         #数据错误
     }
     if ($uwd_data['refresh_fortune_player']) {
         $uwd_data['refresh_fortune_player'] = json_decode($uwd_data['refresh_fortune_player'], true);
         if (in_array($refresh_player_id, $uwd_data['refresh_fortune_player'])) {
             $this->throw_error('1716004');
             #已刷新过该玩家运势
         }
     }
     if ($uwd_data['refresh_fortune_times'] < 1) {
         $this->throw_error('1716001');
         #运势刷新次数不足
     }
     if ($uwd_data['fortune_star'] >= 5) {
         $this->throw_error('1716002');
         #运势已满
     }
     $uwd_data['refresh_fortune_times']--;
     $new_fortune = $this->get_fortune_star($uwd_data['fortune_star']);
     $uwd_data['fortune_star'] = $new_fortune['fortune_star'];
     $uwd_data['fortune_award_per'] = $new_fortune['fortune_award_per'];
     $uwd_data['refresh_fortune_player'][] = $refresh_player_id;
     $uwd_data['refresh_fortune_player'] = json_encode($uwd_data['refresh_fortune_player']);
     #更新运势天数据
     $this->start_trans();
     #更新玩家公会通缉榜天数据
     $this->get_data("UnionWanted")->update_union_wanted_daily_data($player_id, 'uwd', $uwd_data);
     $this->commit();
     #通知c++在聊天窗口显示刷新结果数据结构
     $refresh_player_name = $this->get_data('Player')->get_player_info($refresh_player_id, "name");
     $player_name = $this->get_data('Player')->get_player_info($player_id, "name");
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 7, 'txt' => $refresh_player_name, 'rep_color' => "ffb901");
     $arr_replace[] = array('rep_type' => 7, 'txt' => $player_name, 'rep_color' => "ffb901");
     $arr_replace[] = array('rep_type' => 7, 'txt' => $new_fortune['fortune_star'], 'rep_color' => "ffb901");
     $msg = Language_Message::make_message(171605, $arr_replace, 0, '', true);
     $this->get_game('SystemNotice')->send_system_msg($refresh_player_id, $msg, 7, 7);
 }
Beispiel #15
0
 public function CMD2_446()
 {
     $msg = Language_Message::make_message('12011');
     //        Com_Log::write('cmd_446.'.$this->_authuser['player_id'],var_export($msg,true));
     Protocol::input($this->_authuser['player_id'], 8, 7, 742, array(0 => array($msg)));
     #提示采集成功
     $this->get_game('TaskTrigger')->async_trigger_task($this->_authuser['player_id'], 10, $this->_param[0], 1);
     Protocol::input($this->_authuser['player_id'], 5, 4, 446, array('result' => 1));
     //返回一个空协议
 }
Beispiel #16
0
 /**
  * 获取战斗日志
  * @param $player_id
  * @return array
  */
 protected function get_fight_history($history)
 {
     if (empty($history)) {
         return array();
     }
     $out = array();
     $i = 0;
     foreach ($history as $val) {
         if ($i > 2) {
             break;
         }
         $params = array(0 => array('rep_type' => 7, 'txt' => $val['player_name']));
         if ($val['result'] == 1) {
             switch ($val['hard']) {
                 case 3:
                     $code = 6010148;
                     break;
                 case 2:
                     $code = 6010149;
                     break;
                 case 1:
                     $code = 6010150;
                     break;
             }
         } else {
             switch ($val['hard']) {
                 case 3:
                     $code = 6010151;
                     break;
                 case 2:
                     $code = 6010152;
                     break;
                 case 1:
                     $code = 6010153;
                     break;
             }
         }
         $tmp = Language_Message::make_message($code, $params);
         $out[] = $tmp;
     }
     return $out;
 }
Beispiel #17
0
 /**
  * 篝火加料
  * @param unknown $player_id
  * @param unknown $union_id
  * @param unknown $type 1加草 2加炭 3加薪
  */
 public function bonfire_control($player_id, $type)
 {
     $type = intval($type);
     $objPlayerData = $this->get_data('Player');
     $playerInfo = $objPlayerData->get_player_info($player_id, array("privilege_level", "ticket", "level", "exp", "union_id", "silver", "gold", "exp", "union_name", "name"));
     $union_id = intval($playerInfo['union_id']);
     //$this->get_data('UnionBonfire')->del_union_bonfire($union_id);
     if ($union_id == 0) {
         $this->throw_error('171001');
     }
     $bonfireConfig = Cache_BonfireControl::getInstance()->get_bonfire_control($type);
     if (empty($bonfireConfig)) {
         $this->throw_error('10109');
     }
     $objUnionBonfireData = $this->get_data('UnionBonfire');
     $unionBonfireInfo = $objUnionBonfireData->get_union_bonfire($union_id);
     $is_init_bonfire_info = 0;
     if (empty($unionBonfireInfo)) {
         $is_init_bonfire_info = 1;
     }
     #限制时间是否开启
     $nowtime = time();
     $activities_info = Cache_UnionActivities::getInstance()->get_union_activities_info(array("activities_id" => 1));
     if ($activities_info['open_time']) {
         $begin_time = strtotime(date("Y-m-d {$activities_info['open_time']}"));
         $end_time = $begin_time + $activities_info["activities_time"];
         if (isset($unionBonfireInfo['second_extended'])) {
             $end_time += intval($unionBonfireInfo['second_extended']);
         }
         if ($nowtime < $begin_time || $nowtime > $end_time) {
             $this->throw_error("1752001");
         }
     }
     //操作职位权限
     $objUnionPlayerData = $this->get_data('UnionPlayer');
     $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id);
     if ($unionPlayerInfo['job_id'] > $bonfireConfig['guild_job']) {
         if ($type == 2) {
             $this->throw_error('174508');
             //无权操作
         } else {
             if ($type == 3) {
                 $this->throw_error('174509');
                 //无权操作
             } else {
                 $this->throw_error('170701');
                 //无权操作
             }
         }
     }
     //可操作次数
     if ($bonfireConfig['max_frequency'] > 0) {
         if (isset($unionBonfireInfo['used_times'][$type])) {
             if ($unionBonfireInfo['used_times'][$type] >= $bonfireConfig['max_frequency']) {
                 $this->throw_error('174501');
                 //可操作次数已用完
             }
             $unionBonfireInfo['used_times'][$type] += 1;
         } else {
             $unionBonfireInfo['used_times'][$type] = 1;
         }
     }
     $item_key = Cache_FbLoot::getInstance()->get_item_key($bonfireConfig['add_cost_type']);
     //消耗货币类型是否满足
     $arr_consume = array();
     if ($item_key == "gold") {
         $ticket = 0;
         $price = $bonfireConfig['add_cost_num'];
         if ($playerInfo['ticket'] > 0) {
             if ($playerInfo['ticket'] >= $bonfireConfig['add_cost_num']) {
                 $ticket = $bonfireConfig['add_cost_num'];
                 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $bonfireConfig['add_cost_num']);
                 $bonfireConfig['add_cost_num'] = 0;
             } else {
                 $ticket = $playerInfo['ticket'];
                 $bonfireConfig['add_cost_num'] = $bonfireConfig['add_cost_num'] - $playerInfo['ticket'];
                 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $playerInfo['ticket']);
             }
         }
         $arr_consume = array('price' => $price, 'gold' => $bonfireConfig['add_cost_num'], 'ticket' => $ticket, 'count' => 1);
         #数据中心推送
     }
     $this->get_data('Player')->check_player_resource($player_id, $playerInfo, "-", $item_key, $bonfireConfig['add_cost_num']);
     //添加热度
     if ($bonfireConfig['add_heat'] > 0) {
         if (isset($unionBonfireInfo['heat'])) {
             if ($unionBonfireInfo['heat'] >= $bonfireConfig['max_heat']) {
                 $this->throw_error('174502');
                 //热度已到最大上限
             }
             if ($unionBonfireInfo['heat'] + $bonfireConfig['add_heat'] > $bonfireConfig['max_heat']) {
                 $bonfireConfig['add_heat'] = $bonfireConfig['max_heat'] - $bonfireConfig['heat'];
                 $unionBonfireInfo['heat'] = $bonfireConfig['max_heat'];
             } else {
                 $unionBonfireInfo['heat'] += $bonfireConfig['add_heat'];
             }
         } else {
             $unionBonfireInfo['heat'] = 100 + $bonfireConfig['add_heat'];
         }
     }
     //cd时间
     if ($bonfireConfig['cooldown'] > 0) {
         $cd_time = $objUnionBonfireData->get_bonfire_cd($player_id, $type);
         if ($cd_time) {
             $this->throw_error('174503');
             //cd中
         }
         $objUnionBonfireData->add_bonfire_cd($player_id, $type, $bonfireConfig['cooldown']);
     }
     //延长篝火时间
     if ($bonfireConfig['add_time'] > 0) {
         $unionBonfireInfo['second_extended'] += $bonfireConfig['add_time'];
     }
     $second_extended_used_times = 0;
     $second_extended_max_times = 0;
     if ($type == 3) {
         $second_extended_used_times = intval($unionBonfireInfo['used_times'][$type]);
         $second_extended_max_times = intval($bonfireConfig['max_frequency']);
     }
     $retBonfire = $objUnionBonfireData->update_union_bonfire($union_id, $unionBonfireInfo);
     $retPlayer = $this->get_data('Player')->update_player_resource($player_id, $playerInfo, 1745, array(), $arr_consume);
     if ($type < 3 && intval($unionBonfireInfo['heat']) >= intval($bonfireConfig['max_heat'])) {
         $use_times = -1;
     } else {
         if ($bonfireConfig['max_frequency'] == 0) {
             $use_times = 0;
         } else {
             $use_times = $bonfireConfig['max_frequency'] - intval($unionBonfireInfo["used_times"][$type]) > 0 ? $bonfireConfig['max_frequency'] - intval($unionBonfireInfo["used_times"][$type]) : -1;
         }
     }
     if ($retBonfire && $retPlayer) {
         #活动延长时间控制面板进入时间
         if ($bonfireConfig['add_time']) {
             $this->get_game('UnionActivities')->add_activities_time_interface($union_id, 4, $bonfireConfig['add_time']);
         }
         $this->commit();
         //			Protocol_Player::p2c_part_update($player_id,array('gold'=>'','silver'=>'','exp'=>''));
         $minutes_extended = $bonfireConfig['add_time'] ? $bonfireConfig['add_time'] / 60 : 0;
         if ($minutes_extended) {
             $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 19, $minutes_extended);
         }
         Protocol::input($player_id, 7, 4, 505, array($union_id, intval($bonfireConfig['add_heat']), $minutes_extended, $second_extended_used_times, $second_extended_max_times));
     } else {
         $this->rollback();
         $this->throw_error('10101');
     }
     if ($is_init_bonfire_info) {
         $activities_info = Cache_UnionActivities::getInstance()->get_union_activities_info(array("activities_id" => 1));
         $minutes_extended = $activities_info["activities_time"] ? $activities_info["activities_time"] / 60 : 0;
         $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 19, $minutes_extended);
     }
     if (in_array($type, array(2, 3))) {
         if ($type == 2) {
             $code = 174510;
             #公会【%guild name%】公会的 %player_name% 增加了公会篝火的经验倍数10%!土豪有你真幸福!
         } else {
             $code = 174506;
             #公告【%guild name%】公会的管理 %player_name% 延长了篝火的持续时间!好领导,你们公会还要人嘛?
         }
         $arr_replace = array();
         $arr_replace[] = array('rep_type' => 7, 'txt' => $playerInfo['union_name'], 'rep_color' => "e8ac44");
         $arr_replace[] = array('rep_type' => 0, 'txt' => $playerInfo['name'], 'rep_val' => $player_id, 'underLine' => 1, 'rep_color' => "fff100");
         $msg = Language_Message::make_message($code, $arr_replace);
         if ($type == 2) {
             $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
         } else {
             $this->get_game('SystemNotice')->send_system_msg(0, $msg, 1, 1);
         }
     }
     if ($use_times == -1) {
         $data = $this->get_bonfire_control($player_id, $union_id);
         if ($data) {
             Protocol::input($player_id, 8, 17, 1746, $data);
         }
     } else {
         return array(1, $type, $use_times);
     }
 }
Beispiel #18
0
 public function use_temp_vip($player_id, $item_id)
 {
     $player_id = intval($player_id);
     $item_id = intval($item_id);
     $item_set = Cache_VipReward::getInstance()->get_vip_item($item_id);
     if (empty($item_id)) {
         return false;
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('vip', 'vip_exp', 'after_hero_hole', 'name'));
     if ($item_set['vip_level'] >= $player_info['vip']) {
         $data = array('add_time' => time() + $item_set['add_time'], 'vip_level' => $item_set['vip_level'], 'state' => 1);
         if ($this->get_data('VipReward')->update_temp_vip($player_id, $data)) {
             $update_data['vip'] = $item_set['vip_level'];
             $update_data['vip_temp_time'] = $data['add_time'];
             if ($item_set['vip_level'] > 0) {
                 $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10057);
                 if ($vip_table['vip_level'] > 0 && $item_set['vip_level'] >= $vip_table['vip_level']) {
                     if ($player_info['after_hero_hole'] < 2) {
                         #直接开启全部英雄位
                         $update_data['after_hero_hole'] = 2;
                     }
                 }
             }
             if ($this->get_data('Player')->update_player_info($player_id, $update_data)) {
                 $param = array(array('rep_type' => 7, 'rep_val' => $item_set['vip_level']), array('rep_type' => 7, 'rep_val' => ceil($item_set['add_time'] / (24 * 3600))));
                 $attr_mag = array();
                 $attr_mag[] = Language_Message::make_message('80038', $param);
                 $msg_out = array(0 => $attr_mag, 1 => 2000);
                 Protocol::input($player_id, 8, 7, 742, $msg_out);
                 Protocol_Player::p2c_part_update($player_id, array('vip' => $item_set['vip_level'], 'vip_temp_time' => $item_set['add_time']));
                 #广播通知
                 $replace_info = array();
                 $replace_info[] = array('rep_type' => 7, 'txt' => $player_info['name']);
                 $replace_info[] = array('rep_type' => 7, 'txt' => $item_set['vip_level']);
                 $this->get_game('SystemNotice')->push_sys_notice($player_id, 130, 0, $replace_info, $item_set['vip_level']);
                 #vip增加背包格子数量
                 $out = $this->get_game('PlayerBag')->get_vip_bag_storage_num($player_id);
                 Protocol::input($player_id, 8, 8, 844, $out);
                 # 条件问卷查询推送
                 $this->get_game('ActivityQuestions')->get_cond_ids($player_id);
                 #更新签到奖励
                 $this->get_game('DailySign')->async_trigger_daily_sign($player_id, $item_set['vip_level']);
                 #添加日志
                 $log_data = array('player_id' => $player_id, 'channel' => 3, 'item_level' => $player_info['vip'], 'item_num' => $player_info['vip_exp'], 'amount' => 0, 'after_amount' => $player_info['vip_exp'], 'after_attr' => $update_data['vip']);
                 Log_Common::getInstance()->add_log($log_data);
                 return true;
             } else {
                 $this->throw_error(10110, 2010088);
                 return false;
             }
             return true;
         } else {
             return false;
         }
     } else {
         $this->throw_error(80037);
     }
     return true;
 }
Beispiel #19
0
 /**
  * 道具使用
  * @param $player_id
  * @param $player_prop_id
  * @param $use_num 使用数量
  * @return int
  */
 public function prop_use_by_ppid($player_id, $player_prop_id, $use_num = 1)
 {
     if ($use_num <= 0) {
         $use_num = 1;
     }
     $pdetail = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     //        Com_Log::log($pdetail,'prop_use',1);
     if (empty($pdetail) || empty($pdetail['player_prop_id'])) {
         return array('error_code' => 2, 'cooldown_msec' => 0);
         //没有这个道具
     }
     if ($pdetail['item_position'] != 1) {
         return array('error_code' => 3, 'cooldown_msec' => 0);
         //这个道具无法使用
     }
     if ($use_num > $pdetail['item_num']) {
         return array('error_code' => 3, 'cooldown_msec' => 0);
         //这个道具无法使用
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'gold'));
     if ($pdetail['prop_id'] == '52303') {
         #要扣88钻石
         $result = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', 88, 0);
         if ($result !== true) {
             return array('error_code' => 3, 'cooldown_msec' => 0);
             //这个道具无法使用
         }
         $r_52303 = true;
     } else {
         $r_52303 = false;
     }
     $prop_config = Cache_Prop::getInstance()->get_prop_info($pdetail['prop_id']);
     if (isset($prop_config['level']) && $prop_config['level'] > 0 && $player_info['level'] < $prop_config['level']) {
         $msg = Language_Message::make_message('80916');
         Protocol::input($player_id, 8, 7, 742, array(0 => array($msg)));
         #等级不足不能使用改道具
         return array('error_code' => 3, 'cooldown_msec' => 0);
         //这个道具无法使用
     }
     if ($prop_config['cooldown_time'] > 0) {
         $ttl = $this->exist_lock($player_id, $pdetail['prop_id']);
         if ($ttl) {
             return array('error_code' => 4, 'cooldown_msec' => intval($ttl));
             //还在冷却中
         }
     }
     $result = true;
     $this->start_trans();
     if ($r_52303) {
         $arr_consume = array('price' => 88, 'gold' => 88, 'ticket' => 0, 'count' => 1);
         //数据中心推送
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 409, array(), $arr_consume);
     }
     if ($prop_config['skill_sid'] && $result) {
         $result = $this->use_buff($player_id, $prop_config['skill_sid']);
         if ($result == 0) {
             $result = true;
         } else {
             $this->rollback();
             return array('error_code' => 3, 'cooldown_msec' => 0);
             //这个道具无法使用
             //                return $result;
         }
     }
     $add_reward_flag = 0;
     if ($prop_config['type'] == 2 && $prop_config['sub_type'] == 13) {
         for ($i = 0; $i < $use_num; $i++) {
             try {
                 $result = $this->get_game('Hero')->add_hero($player_id, $prop_config['loot_id']);
             } catch (Exception $e) {
                 $this->rollback();
                 return array('error_code' => 3, 'cooldown_msec' => 0);
                 //这个道具无法使用
             }
         }
     } else {
         if ($prop_config['loot_id'] && $result) {
             $result = $this->use_resource($player_id, $prop_config['loot_id'], $use_num, $pdetail['career_type'], $pdetail['bind_flag']);
             if ($result == 0) {
                 $result = true;
             } else {
                 $this->rollback();
                 return array('error_code' => 3, 'cooldown_msec' => 0);
                 //这个道具无法使用
             }
             $add_reward_flag = 1;
         }
     }
     if ($result) {
         $result = $this->get_data('PlayerProp')->update_prop_num($player_id, $pdetail, $use_num, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 409));
         //扣道具
         $pdetail['item_num'] -= $use_num;
         $this->_prop_log[] = $pdetail;
     }
     #使用临时vip道具
     if ($result && $pdetail['type'] == 2 && $pdetail['sub_type'] == 7) {
         $result = $this->get_game('VipReward')->use_temp_vip($player_id, $pdetail['prop_id']);
     }
     #使用临时vip特权道具
     if ($result && $pdetail['type'] == 2 && $pdetail['sub_type'] == 12) {
         $result = $this->get_game('VipSpecial')->use_temp_vip_special($player_id, $pdetail['prop_id']);
     }
     #使用临时首充道具
     if ($result && $pdetail['type'] == 2 && $pdetail['sub_type'] == 9) {
         $this->get_game('PlayerWing')->update_wing_activation_condition($player_id, 1);
     }
     if ($result) {
         $this->commit();
         if ($prop_config['cooldown_time'] > 0) {
             $this->add_prop_lock($player_id, $pdetail['prop_id'], $prop_config['cooldown_time']);
             //冷却
         }
         if ($add_reward_flag) {
             $this->get_game('Reward')->add_reward_log(true);
             //调用日志
             $prop_logs = $this->get_game('Reward')->get_prop_log();
             if ($prop_logs) {
                 foreach ($prop_logs as $val) {
                     $item_id = $val['prop_id'];
                     $arr_replace = array();
                     $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
                     $arr_replace[] = array('rep_type' => 2, 'rep_val' => $pdetail['prop_id']);
                     $arr_replace[] = array('rep_type' => 2, 'rep_val' => $item_id);
                     $this->get_game('SystemNotice')->push_sys_notice($player_id, 1292, 409, $arr_replace, 0, $val['need_broad_cast']);
                 }
             }
         }
         //            if($prop_config['func_id']){
         //                Protocol::input($player_id,8,7,759,array($prop_config['func_id'],$prop_config['func_params']));
         //            }
         //            Protocol_Msg::msg($player_id,80917);#提示使用成功
     } else {
         $this->rollback();
         return array('error_code' => 6, 'cooldown_msec' => 0);
         //服务器内部错误
     }
     return array('error_code' => 0, 'cooldown_msec' => intval($prop_config['cooldown_time']));
 }
Beispiel #20
0
 protected function adult_remind($player_id, $status)
 {
     if ($status == 1) {
         $msg = Language_Message::make_message('10223');
     } else {
         $msg = Language_Message::make_message('10224');
     }
     Protocol::input($player_id, 8, 7, 755, array(0 => $msg, 1 => 2));
 }
Beispiel #21
0
 public function update_login_date($player_id, $player_info = null)
 {
     $player_id = intval($player_id);
     if (is_null($player_info)) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('login_date', 'vip', 'name', 'login_time', 'level'));
     }
     //$this->get_data('Player')->update_player_info($player_id,array('is_online'=>1,'logout_time'=>time()));
     $time = time();
     $login_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'today_login_time');
     $second_last_login_time = intval($player_info['login_time']);
     # 记录倒数第二次登录的登录时间,游戏某些业务需要使用最后登录时间,但login_time会在每次登录时被重写掉,故而需要改字段
     if ($login_time == 0) {
         $this->get_data('Player')->update_player_info($player_id, array('is_online' => 1, 'login_time' => $time, 'login_date' => $player_info['login_date'] + 1, 'second_last_login_time' => $second_last_login_time));
         $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'today_login_time');
     } else {
         $this->get_data('Player')->update_player_info($player_id, array('is_online' => 1, 'login_time' => $time, 'second_last_login_time' => $second_last_login_time));
         $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'today_login_time');
     }
     #vip>=10广播
     if ($player_info['vip'] >= 10) {
         $vip_info = $this->get_data('VipReward')->get_reward_log($player_id);
         $is_hidden_vip = $vip_info['is_hidden_vip'];
         if (intval($is_hidden_vip) == 0) {
             $arr_replace = array();
             $arr_replace[] = array('rep_type' => 11, 'rep_val' => $player_info['vip']);
             $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id, 'txt' => $player_info['name']);
             $msg = Language_Message::make_message(2034, $arr_replace);
             $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, "1,2", 1);
         }
     }
     $this->get_data("Player")->add_player_online_list($player_id, $player_info['level']);
 }
Beispiel #22
0
 /**
  * 主动向指定玩家抛出异常
  * @param $player_id 玩家ID
  * @param $data 错误得id  或一个错误得数组
  * @param $is_exit 抛出异常是否终止逻辑继续执行(true:终止false:继续) 
  */
 protected function initiative_throw_error($player_id, $data, $is_exit = true)
 {
     if ($this->is_trans()) {
         $this->rollback();
     }
     Com_Lock::unLock();
     if (is_array($data)) {
         $msg = Language_Message::make_message($data['code'], $data['params'], 1, $data['content']);
     } else {
         $msg = Language_Message::make_message($data);
     }
     Com_Log::log($player_id, 'z_fb_res', 1);
     Com_Log::log(array(0 => array($msg)), 'z_fb_res', 1);
     Protocol::input($player_id, 8, 7, 742, array(0 => array($msg)));
     Protocol::out();
     if ($is_exit) {
         exit;
     }
 }
Beispiel #23
0
 /**
  *
  * @param unknown $instant_ntf 0:提前通知 1:到点通知
  * @param unknown $type_id 活动id
  * @param unknown $category 玩法类型
  */
 public function activity_send_notice($player_id, $instant_ntf, $sid)
 {
     $player_id = intval($player_id);
     $instant_ntf = intval($instant_ntf);
     $sid = intval($sid);
     #{活动名}活动10分钟后开启,请广大玩家做好准备,海量丰厚奖励等着你!
     #{活动名}活动开启了,立刻参与,活动奖励轻松获得!
     $activity_info = Cache_ActivityHall::getInstance()->get_activity_info($sid);
     if (!Com_Array::is_good_arr($activity_info)) {
         return false;
     }
     $code = $activity_info['func_id'];
     $arrPushConfig = Cache_PushUpgrade::getInstance()->get_upgrade_info($code, $instant_ntf + 1);
     if (!Com_Array::is_good_arr($arrPushConfig)) {
         return false;
     }
     $replace_info = array();
     $replace_info[] = array('rep_type' => 7, 'txt' => $activity_info['name']);
     if ($arrPushConfig['go_name']) {
         $replace_info[] = array('rep_type' => 1, 'rep_val' => $code, 'txt' => strval($arrPushConfig['go_name']));
     } else {
         $replace_info[] = array('rep_type' => 7, 'txt' => '');
     }
     $msg = Language_Message::make_message($arrPushConfig['code'], $replace_info, 0, '', true);
     $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, $arrPushConfig['need_broadcas'], 1, 2, $sid);
 }
Beispiel #24
0
 /**
  * 全服邀请
  */
 public function all_service_invite_union($player_id)
 {
     $player_id = intval($player_id);
     $playerInfo = $this->get_data('Player')->get_player_info($player_id, array("union_id", "silver", "union_name", "gold", "ticket", "level", "vip", "name", "union_job", "privilege_level"));
     if (!$playerInfo['union_id']) {
         $this->throw_error('171101');
         //没有加入公会
     }
     $union_conf = Cache_UnionBase::getInstance()->get_union_conf();
     if (empty($union_conf)) {
         $this->throw_error(10222, 5011990);
     }
     if (!isset($union_conf['world_invite'])) {
         $this->throw_error(10222, 5011993);
     }
     list($cost_currency_type, $cost_currency_value) = explode(":", $union_conf['world_invite']);
     # 消耗虚拟货币
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($playerInfo, $cost_currency_key, $cost_currency_value);
     $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     $re = $this->get_data('Player')->update_player_resource($player_id, $playerInfo, '1789', array(), $arr_consume);
     $this->write_check($re, 5012009);
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 7, 'txt' => $playerInfo['union_name']);
     $arr_replace[] = array('rep_type' => 10, 'txt' => "#1", 'rep_val' => 1703, 'rep_param' => array($playerInfo['union_id']));
     $msg = Language_Message::make_message(178901, $arr_replace, 0, '', true);
     $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 1, 1);
 }
Beispiel #25
0
 /**
  * 公会建筑升级
  */
 public function build_upgrade($player_id, $union_id, $npc_sid)
 {
     $npc_sid = intval($npc_sid);
     $union_id = intval($union_id);
     $objUnionInfoData = $this->get_data('UnionInfo');
     $unionInfo = $objUnionInfoData->get_union_info($union_id);
     $objUnionPlayerData = $this->get_data('UnionPlayer');
     $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id);
     if (empty($unionPlayerInfo)) {
         $this->throw_error('171001');
         //该玩家未加入该公会
     }
     if ($unionPlayerInfo["job_id"] > 2) {
         $this->throw_error('170701');
         //无权操作
     }
     $build_type = $this->get_game('Union')->get_build_type($npc_sid);
     if (!$build_type) {
         $this->throw_error('173601');
         //不存在该建筑
     }
     //当前建筑ID对应的Redis字段
     $redisLevelField = $build_type . "_level";
     //当前建筑等级,默认等级为1级
     $unionInfo[$redisLevelField] = intval($unionInfo[$redisLevelField]) ? $unionInfo[$redisLevelField] : 1;
     $front_upgrade_level = $unionInfo[$redisLevelField];
     $objUnionBuildConfig = Cache_UnionBuild::getInstance();
     $unionBuildLevelConfig = $objUnionBuildConfig->get_union_build_info($npc_sid, $unionInfo[$redisLevelField]);
     //1.公会资金2.经验
     if ($unionBuildLevelConfig['lvl_up_cost_type'] != 1) {
         $this->throw_error('173603');
         //该建筑不能升级
     }
     $max_level = $objUnionBuildConfig->get_union_build_max_level($build_type);
     if ($unionInfo[$redisLevelField] >= $max_level) {
         $this->throw_error('173602');
         //建筑已升级到最大等级
     }
     if (empty($unionBuildLevelConfig)) {
         $this->throw_error('10222');
         //配置错误
     }
     $unionInfo[$redisLevelField] += 1;
     if ($unionInfo[$redisLevelField] > $unionInfo['union_level']) {
         $this->throw_error('173504');
         //该建筑等级不能大于公会大厅等级
     }
     //1.公会资金2.经验
     if ($unionInfo['fund'] < $unionBuildLevelConfig['lvl_up_cost_num']) {
         $this->throw_error('173503');
     }
     $unionInfo['fund'] = "-" . $unionBuildLevelConfig['lvl_up_cost_num'];
     //更改升级后的npc_sid
     $npc_sid = $this->get_game('Union')->get_build_sid($build_type, $unionInfo[$redisLevelField]);
     $unionInfo[$build_type . '_sid'] = $npc_sid;
     $this->start_trans();
     Com_Log::debug_write('update_union_info', "build_upgrade|unoin_id={$union_id}" . json_encode($unionInfo));
     $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $unionInfo);
     if ($retUnionInfo) {
         $this->commit();
         $this->get_game('Union')->Sync_Union_msg($union_id);
     } else {
         $this->rollback();
         $this->throw_error('10101');
     }
     if ($build_type == "shop") {
         $this->get_game('UnionShop')->union_shop_upgrade($union_id, $unionInfo[$redisLevelField]);
         //公会成就商店升级
         $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 20, $unionInfo[$redisLevelField], 2);
     } else {
         if ($build_type == "hall") {
             //福利大厅
             $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 21, $unionInfo[$redisLevelField], 2);
         } else {
             if ($build_type == "wanted") {
                 //通缉
                 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 14, $unionInfo[$redisLevelField], 2);
             } else {
                 if ($build_type == "tech") {
                     //魔法科技
                     $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 22, $unionInfo[$redisLevelField], 2);
                     //魔法科技-流水日志
                     $log_data = array('player_id' => $player_id, 'channel' => 54, 'type' => 6, 'item_id' => 0, 'item_num' => $unionInfo[$redisLevelField] - $front_upgrade_level, 'amount' => $front_upgrade_level, 'after_amount' => $unionInfo[$redisLevelField], 'cmd_id' => 1732);
                     Log_Common::getInstance()->add_log($log_data);
                 }
             }
         }
     }
     //发邮件
     /* 		$phrase_id = 1000 + $unionInfo[$redisLevelField];
     		$phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id);
     		$this->get_game('UnionPlayer')->send_mail($player_id,$union_id, $phrase_config['title'], $phrase_config['content'],false); */
     //添加日志
     //%player_name% 消耗了 %s 公会资金升级了公会建筑 %d
     //广播建筑升级
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 7, 'txt' => $unionBuildLevelConfig['build_name']);
     $arr_replace[] = array('rep_type' => 7, 'txt' => $unionInfo[$redisLevelField]);
     $msg = Language_Message::make_message(171015, $arr_replace);
     $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
     $arr_replace[] = array('rep_type' => 7, 'txt' => $unionBuildLevelConfig['lvl_up_cost_num']);
     $arr_replace[] = array('rep_type' => 7, 'txt' => $unionBuildLevelConfig['build_name']);
     $objUnionBaseGame = $this->get_game('UnionBase');
     $objUnionBaseGame->sys_add_union_log($player_id, $union_id, 173604, $arr_replace);
     return array($union_id, $npc_sid, $unionInfo[$redisLevelField]);
 }
Beispiel #26
0
 private function broadcast($roles, $union_id, $player_name = '')
 {
     #广播
     $arr_replace = array();
     $role_list = explode(',', $roles);
     $player_id = 0;
     if ($player_name == '') {
         $arr_replace[] = array('rep_type' => 7, 'txt' => 3, 'rep_color' => 'ffb901');
         foreach ($role_list as $role_id) {
             $play_info = $this->get_data("Player")->get_player_info($role_id, array('name'));
             $arr_replace[] = array('rep_type' => 0, 'rep_val' => $role_id, 'txt' => $play_info['name'], 'rep_color' => 'ffb901');
             $player_id = $role_id;
         }
         $msg = Language_Message::make_message(176008, $arr_replace);
     } else {
         foreach ($role_list as $role_id) {
             $play_info = $this->get_data("Player")->get_player_info($role_id, array('name'));
             $arr_replace[] = array('rep_type' => 0, 'rep_val' => $role_id, 'txt' => $play_info['name'], 'rep_color' => 'ffb901');
             $player_id = $role_id;
         }
         $msg = Language_Message::make_message(176009, $arr_replace);
     }
     $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
     #Com_Log::write('send-box',json_encode($msg));
 }