Пример #1
0
 /**
  * 输出协议
  * @param $player_id
  */
 public static function out($player_id)
 {
     if (isset(self::$_gain_msg[$player_id]) && !empty(self::$_gain_msg[$player_id])) {
         Protocol::input($player_id, 8, 7, 740, self::$_gain_msg[$player_id]);
         unset(self::$_gain_msg[$player_id]);
     }
 }
Пример #2
0
 public static function out($player_id, $player_info = null)
 {
     if (!empty(self::$_guide_list)) {
         $out = array();
         $logs = array();
         $data = self::get_data('PlayerDetail')->get_player_detail($player_id, 'guide');
         foreach (self::$_guide_list as $guide) {
             $out[$guide['guide_id']] = array('guide_id' => $guide['guide_id'], 'step' => $guide['step']);
             $logs[$guide['guide_id']] = array('type' => 1, 'task_id' => $guide['guide_id'], 'step' => $guide['step'], 'status' => 0);
             $data[$guide['guide_id']] = 1;
         }
         $result = self::get_data('PlayerDetail')->update_player_detail($player_id, array('guide' => $data));
         if (!$result) {
             return;
         }
         if (!IS_FRONT || defined('FROM_GATEWAY')) {
             $cmd0 = 8;
         } else {
             $cmd0 = 3;
         }
         //            Com_Log::write('guide_'.$player_id,var_export($out,true));
         Protocol::input($player_id, $cmd0, 7, 787, array(0 => $out));
         if (empty($player_info) || !isset($player_info['level']) || !isset($player_info['vip'])) {
             $player_info = self::get_data('Player')->get_player_info($player_id, array('level', 'vip'));
         }
         Log_Guide::getInstance()->add_multi_guide_log($player_id, $player_info['level'], $player_info['vip'], $logs);
         self::$_guide_list = null;
     }
 }
Пример #3
0
 public function run($player_id, $s_task_id)
 {
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level'));
     $level = $player_info['level'];
     //        $task_id = $this->get_random_chain_task_id($level,0);
     $task_id = $s_task_id;
     $data = array();
     if (!empty($task_id)) {
         $arr_player_task = $this->get_game('TaskChain')->get_init_chain_val($player_id, $task_id, 1);
         $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('chain_val' => $arr_player_task['chain_val'], 'target_val' => $arr_player_task['target_val']));
         if ($result) {
             $result = $this->get_data('PlayerTask')->set_chain_task_count($player_id);
         }
         if ($result) {
             $data = $this->get_game('TaskChain')->get_chain_task_list($player_id, $arr_player_task);
             Protocol::input($player_id, 8, 10, 1025, $data);
         }
     }
     Protocol::out();
     if ($result) {
         echo 'success';
     } else {
         echo 'error';
     }
     exit;
 }
Пример #4
0
 /**
  * 道具变更下行协议
  * @param $player_id
  * @param $change_prop 二维数组    传进去player_prop的内容
  * 如果是位置变更 要加上 ['from_item_position'] 原始位置 ['from_grid'] 原始格子数
  * player_prop里面的  item_position 赋值为新的位置编号  grid 赋值为新的格子编号
  * @param $error_code 0 失败  1成功
  * @param $cmd0 3 直接返回给flash  8 通过异步返回
  * @param $flag 协议输出格式  0 直接输出  1 标志为粘包  2返回协议内容 3 附加粘包
  *
  */
 public static function prop_806($player_id, $change_prop, $func_id = 0, $error_code = 1, $cmd0 = 3, $flag = 3)
 {
     //后面三个参数不用了
     $data['type'] = 1;
     $data['result'] = $error_code;
     $data['box'] = array();
     if (!empty($change_prop)) {
         foreach ($change_prop as $prop) {
             $tmp_prop = array();
             if ($prop['item_num'] <= 0) {
                 //道具数量等于0的时候 只给位置信息就好了
                 $tmp_prop['item_position'] = $prop['item_position'];
                 $tmp_prop['grid'] = $prop['grid'];
             } else {
                 # 要求只有新发的道具的from_item_position=0,老道具都要求非0
                 $tmp_prop = $prop;
                 $tmp_prop['from_item_position'] = $prop['from_item_position'];
             }
             $data['box'][] = Struct_Prop::get_item_box_operate_struct($tmp_prop);
         }
     }
     $data['func_id'] = $func_id;
     if (!IS_FRONT) {
         Protocol::input($player_id, 8, 8, 806, $data);
         Protocol::out();
     } else {
         if (defined('FROM_GATEWAY')) {
             $cmd0 = 8;
         }
         Protocol::input($player_id, $cmd0, 8, 806, $data);
     }
 }
Пример #5
0
 /**
  * @Purpose:
  * 异步更新公会引导状态
  * @Param $player_id 玩家ID
  * @Param $cur_times 当前完成次数
  * @Param $max_times 最大完成次数
  * @Param $type 公会引导类型(1:福利2:悬赏3:巨炮4:科技5:商店6:活动)
  * @Param $sub_type 公会引导子类型(1:福利2:悬赏3:巨炮4:科技5:商店6:活动)
  */
 public function async_update_union_guide($player_id, $cur_times, $max_times, $type, $sub_type)
 {
     $player_id = intval($player_id);
     $cur_times = intval($cur_times);
     $max_times = intval($max_times);
     $type = intval($type);
     $sub_type = intval($sub_type);
     if ($player_id > 0 && $cur_times >= $max_times && $type > 0 && $sub_type > 0) {
         #获取玩家公会引导天数据
         $ug_data = $this->get_data('UnionGuide')->get_union_guide_info($player_id, 'ug', 'day');
         if ($ug_data[$type . $sub_type] != 1) {
             $ug_data[$type . $sub_type] = 1;
             $this->start_trans();
             #更新公会引导天数据
             $update_res = $this->get_data('UnionGuide')->update_union_guide_data($player_id, 'ug', $ug_data);
             if (!$update_res) {
                 $this->throw_error('10104');
             }
             $this->commit();
             #主动更新Flash面板数据
             Protocol::input($player_id, 8, 17, 1778, array($type, $sub_type, $ug_data[$type . $sub_type]));
             if (!IS_FRONT) {
                 Protocol::out();
             }
         }
     }
 }
Пример #6
0
 public function router($cmd0, $cmd1, $cmd2, $player_id, $arr_param)
 {
     global $arrParam, $arrAuthUser, $logHandler;
     $arrAuthUser['player_id'] = $player_id;
     $arrParam = $arr_param;
     $class = 'S2P_' . $cmd1;
     $include_file = ACTION_PATH . "/S2P/S2P_{$cmd1}.php";
     if (is_file($include_file)) {
         require $include_file;
         try {
             //调用对应指令函数
             $obj = new $class();
             $exec_cmd2 = 'CMD2_' . $cmd2;
             if (ECONOMY_LOG_SWITCH === TRUE) {
                 $logHandler['logger'] = new Com_Logger($cmd0, $cmd1, $cmd2, $player_id);
             }
             call_user_func_array(array($obj, $exec_cmd2), array());
             $protocols = Protocol::get_protocol();
             Protocol::out();
             Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 1, 'exec fun success', $protocols);
             if (ECONOMY_LOG_SWITCH === TRUE) {
                 $logHandler['logger']->flush_log();
             }
             exit;
         } catch (Exception $e) {
             //有异常
             $msg = json_decode($e->getMessage(), true);
             $error = "Exception: " . $e->getFile() . " line:" . $e->getLine() . " error code " . $msg['error']['code'];
             Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 0, $error);
             Protocol::input($player_id, 8, 7, 742, array(0 => array($msg['error'])));
             Protocol::out();
             exit;
         }
     }
 }
Пример #7
0
 public function doAction()
 {
     $userInfo_json = base64_decode($_POST['data']);
     $userInfo_array = json_decode($userInfo_json, true);
     $state = isset($userInfo_array['state']) ? $userInfo_array['state'] : "";
     $ips = isset($userInfo_array['ips']) ? $userInfo_array['ips'] : "";
     $data = array();
     $res = array();
     if (!empty($state) && !in_array($state, $this->state)) {
         $data['status'] = 8;
         exit;
     } else {
         $data['status'] = 0;
     }
     if ($state == 'open') {
         #开服
         #Protocol::input(0, 7, 4, 514, array('type_id'=>1,'role_id'=>0));
         #Protocol::out();
         $res['status'] = 1;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
         } else {
             $data['status'] = 0;
         }
     } elseif ($state == 'close') {
         #关服维护
         Protocol::input(0, 7, 4, 514, array('type_id' => 1, 'role_id' => 0));
         Protocol::out();
         $res['status'] = 0;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
             TenYear::getInstance();
             $objSession = TenYear::getInstance('session');
             $objSession->del_all_session();
         } else {
             $data['status'] = 0;
         }
     } elseif ('write_ip' == $state) {
         #白名单
         $res['write_ip'] = $ips;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
         } else {
             $data['status'] = 0;
         }
     } elseif ('black_id' == $state) {
         #黑名单
         $res['black_id'] = $ips;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
         } else {
             $data['status'] = 0;
         }
     }
     echo json_encode($data);
     return;
 }
Пример #8
0
 public function doAction()
 {
     $userInfo_json = base64_decode($_POST['data']);
     $userInfo_array = json_decode($userInfo_json, true);
     $ban = array();
     $result['data'] = $this->get_data('Player')->update_player_info($userInfo_array['player_id'], array('is_ban' => 3));
     $result['status'] = 1;
     Protocol::input(0, 7, 4, 514, array('type_id' => 2, 'role_id' => $userInfo_array['player_id']));
     Protocol::out();
     echo json_encode($result);
 }
Пример #9
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));
 }
Пример #10
0
 /**
  * 功能图标变更下行协议
  * @param $player_id
  * @param $func_id 
  * @param $action_type: 0关闭,1开启
  *
  */
 public static function sync_func_data($player_id, $func_id, $action_type = 0, $func_config = null)
 {
     if (empty($func_config) || !is_array($func_config)) {
         $func_config = Cache_FuncConfig::getInstance()->get_func_config_info($func_id);
     }
     if ($action_type == 0) {
         # 告知Flash关闭功能
         $out_741['funcs'][] = array('operate' => 2, 'func_id' => $func_config['func_id'], 'func_name' => $func_config['func_name'], 'open' => 1, 'pos' => $func_config['pos'], 'order' => $func_config['order']);
     } elseif ($action_type == 1) {
         # 告知Flash开启功能
         $out_741['funcs'][] = array('operate' => 1, 'func_id' => $func_config['func_id'], 'func_name' => $func_config['func_name'], 'open' => 1, 'pos' => $func_config['pos'], 'order' => $func_config['order']);
     }
     Protocol::input($player_id, 8, 7, 741, $out_741);
 }
Пример #11
0
 public function run($player_id, $s_task_id)
 {
     $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id);
     $out = array();
     $this->get_game('TaskMain')->do_guide_task($player_id, $s_task_id, 1, $arr_player_task, $out);
     $result = $this->get_data('PlayerTask')->set_task_info($player_id, $arr_player_task);
     Protocol::input($player_id, 8, 10, 1002, array(0 => $out));
     if ($result) {
         echo 'success';
     } else {
         echo 'error';
     }
     exit;
 }
Пример #12
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)));
     #提示采集成功
 }
Пример #13
0
 public static function out($func_id = 0)
 {
     if (!empty(self::$_reward)) {
         foreach (self::$_reward as $player_id => $reward) {
             $out = array('type' => 1, 'reward' => array());
             foreach ($reward as $r) {
                 if (isset($r['overlay_num']) && $r['overlay_num'] > 0) {
                     $r['item_num'] = $r['overlay_num'];
                 }
                 $out['reward'][] = Struct_Prop::get_prop_struct($r);
             }
             $out['func_id'] = $func_id;
             Protocol::input($player_id, 8, 7, 843, $out);
         }
         self::$_reward = null;
     }
 }
Пример #14
0
 public function start_task($player_id)
 {
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level'));
     $level = $player_info['level'];
     $task_id = $this->get_game('TaskChain')->get_random_chain_task_id($level, 0);
     echo "player_id;{$player_id} task_id:{$task_id}\n";
     $data = array();
     if (!empty($task_id)) {
         $arr_player_task = $this->get_game('TaskChain')->get_init_chain_val($player_id, $task_id, 1);
         $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('chain_val' => $arr_player_task['chain_val'], 'target_val' => $arr_player_task['target_val']));
         if ($result) {
             $data = $this->get_game('TaskChain')->get_chain_task_list($player_id, $arr_player_task, null, 1, 1);
             Protocol::input($player_id, 8, 10, 1025, $data);
             Protocol::out();
             return true;
         }
     }
     return false;
 }
Пример #15
0
 public function doAction()
 {
     $userInfo_json = base64_decode($_POST['data']);
     $userInfo_array = json_decode($userInfo_json, true);
     $state = isset($userInfo_array['state']) ? $userInfo_array['state'] : "";
     $data = array();
     if (!empty($state) && !in_array($state, $this->state)) {
         $data['status'] = 8;
         echo json_encode($data);
         exit;
     } else {
         $data['status'] = 0;
     }
     if ($state == 'reload') {
         #reload tables
         $data['status'] = 1;
         $data['data'] = 'ok';
         Protocol::input(0, 7, 4, 402, array(1));
         Protocol::out();
     } elseif ($state == 'memcache') {
         #清memcache 不通知前端
         $data['status'] = 1;
         $data['data'] = 'ok';
         Com_Cache::factory('setting')->flush();
     } elseif ($state == 'memcache_2') {
         #清memcache、并通知前端
         $data['status'] = 1;
         $data['data'] = 'ok';
         Com_Cache::factory('setting')->flush();
         Protocol::input(0, 7, 4, 525, array(1));
         Protocol::out();
         session_unset();
     } elseif ('reset' == $state) {
         Protocol::input(0, 7, 4, 525, array(1));
         Protocol::out();
         session_unset();
         $data['status'] = 1;
         $data['data'] = 'ok';
     }
     echo json_encode($data);
     return;
 }
Пример #16
0
 /**
  * @Purpose:
  * 微端礼包领取
  * @Param $player_id 玩家ID
  * @Param $type 微端类型(1:微端2:客户端3:网页)
  */
 public function receive_micro_terminal_bag($player_id, $type)
 {
     $player_id = intval($player_id);
     $type = intval($type);
     #获取玩家微端礼包信息;
     $data = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'micro_terminal_info');
     if ($data && $type > 0 && $type < 4) {
         if ($data[$type]['state'] == 1) {
             #获取微端礼包配置表
             $mtb_table = $this->get_cache_table_data('mtb_table', array('type' => $type));
             if (!$mtb_table) {
                 $this->throw_error('10109');
                 #配置表读取错误
             }
             $prop_list = $this->format_table_prop($mtb_table['prop_info']);
             $prop_info = $this->format_prop($prop_list);
             $data[$type]['state'] = 2;
             $this->start_trans();
             $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('micro_terminal_info' => $data));
             if (!$update_res) {
                 $this->throw_error('10104');
             }
             #道具发送
             if (Com_Array::is_good_arr($prop_info)) {
                 $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '2102', 'bind_flag' => 0), 1);
                 if ($result !== true) {
                     $this->throw_error('10104');
                 }
             }
             $this->commit();
             $this->get_game('Reward')->add_reward_log();
             if ($data[1]['state'] == 2 && $data[3]['state'] == 2) {
                 #礼包全部领完后,通知前端隐藏ICON
                 $func_data = array();
                 $func_data[0][1180] = array('operate' => 2, 'func_id' => 1180, 'open' => 0, 'guide' => 0, 'cd' => 0, 'tip' => array());
                 Protocol::input($player_id, 8, 7, 741, $func_data);
             }
             return array($type, $data[$type]['state']);
         }
     }
 }
Пример #17
0
 public function tiren()
 {
     $data = array();
     $data['data'] = array();
     $data['status'] = $this->success;
     $userInfo_array = array();
     $acc = array();
     $acc[0] = "user_account";
     $acc[1] = $_REQUEST['account'];
     $player_id = $this->get_data('Account')->get_player_id($acc);
     $result['player_id'] = $player_id["player_id"];
     $userInfo_array['ban_time'] = 0;
     $userInfo_array['is_ban'] = 3;
     $userInfo_array['player_id'] = $player_id["player_id"];
     $userInfo = Cache_GetUserInfoGM::getInstance()->update_userInfo($userInfo_array);
     $data['data'] = $userInfo_array;
     Protocol::input(0, 7, 4, 514, array('type_id' => 2, 'role_id' => $userInfo_array['player_id']));
     Protocol::out();
     echo json_encode($data);
     // 		$player_id = $this->get_data("Account")->get_player_id();
 }
Пример #18
0
 /**
  * 完成引导任务
  * @param $player_id
  * @param $guide_id
  * @return array
  */
 public function finish_guide_task($player_id, $guide_id)
 {
     $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id);
     if (empty($arr_player_task['guide_val'][$guide_id])) {
         $this->throw_error('10107');
         //参数错误
     }
     if ($arr_player_task['guide_val'][$guide_id]['task_status'] < 2) {
         $this->throw_error('10015');
         //任务还未完成
     }
     $result = true;
     $out_1002 = array();
     $index = 0;
     $this->start_trans();
     $task_guide_config = Cache_TaskGuide::getInstance()->get_task_guide($guide_id);
     if (empty($task_guide_config)) {
         $this->throw_error('10107');
         //参数错误
     }
     if ($task_guide_config['reward']) {
         $prop_info = explode('|', $task_guide_config['reward']);
         foreach ($prop_info as $v) {
             $prop = explode(':', $v);
             if ($prop[0] > 100) {
                 $reward[] = array('type' => 'prop', 'item_id' => $prop[0], 'item_num' => $prop[1]);
             } else {
                 $key = Cache_PropLoot::getInstance()->get_item_key($prop[0]);
                 if ($key != 'prop') {
                     $reward[] = array('type' => $key, 'item_id' => $prop[0], 'item_num' => $prop[1]);
                 }
             }
         }
         $params = array('cmd_id' => '1018', 'bind_flag' => 0);
         $result = $this->get_game('Reward')->send_reward($player_id, $reward, $params, 0);
         if ($result !== true) {
             if ($result == '80001') {
                 $result = "10018";
             }
             $this->throw_error($result);
         }
     }
     if ($result) {
         $target = $this->format_guide_target($arr_player_task['guide_val'][$guide_id]['target']);
         $out_1002['old'] = array('task_id' => $guide_id, 'step' => 1, 'task_status' => 3, 'task_data' => $target, 'index' => ++$index, 'cur_finish_num' => 0, 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 4, 'task_star' => 0);
         unset($arr_player_task['guide_val'][$guide_id]);
         if (!empty($task_guide_config['next_guide_id'])) {
             $o = array();
             $next_guides = explode('|', $task_guide_config['next_guide_id']);
             foreach ($next_guides as $next_guide_id) {
                 $this->do_guide_task($player_id, $next_guide_id, 1, $arr_player_task, $o);
             }
         }
         $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('guide_val' => $arr_player_task['guide_val'], 'guide_target_val' => $arr_player_task['guide_target_val']));
         //更新任务
     }
     if ($result) {
         $this->commit();
         $this->get_game('Reward')->add_reward_log(true);
         if (!empty($arr_player_task['main_val'])) {
             $current_num = intval($arr_player_task['current_num']);
             foreach ($arr_player_task['main_val'] as $key => $val) {
                 $target = $this->format_target($val['target'], $val['step_type']);
                 $out_1002[] = array('task_id' => $val['task_id'], 'step' => $val['step'], 'task_status' => $val['task_status'], 'task_data' => $target, 'index' => ++$index, 'cur_finish_num' => $current_num, 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 1, 'task_star' => 0);
             }
         }
         //支线任务的
         if (!empty($arr_player_task['daily_val'])) {
             foreach ($arr_player_task['daily_val'] as $key => $val) {
                 if ($val['task_status'] == 1 || $val['task_status'] == 2) {
                     if (empty($val['task_id'])) {
                         continue;
                     }
                     # 数据脏的时候可能没有任务ID,跳过,提高兼容
                     $target = $this->format_target($val['target'], $val['step_type']);
                     $out_1002[] = array('task_id' => $val['task_id'], 'step' => $val['step'], 'task_status' => $val['task_status'], 'task_data' => $target, 'index' => ++$index, 'cur_finish_num' => 0, 'task_seq' => $key, 'kill_npc_city_id' => $val['kill_npc_sid'], 'task_type' => 3, 'task_star' => $val['star']);
                 }
             }
         }
         if (!empty($arr_player_task['guide_val'])) {
             foreach ($arr_player_task['guide_val'] as $key => $val) {
                 if (empty($val['guide_id'])) {
                     continue;
                 }
                 $target = $this->format_guide_target($val['target']);
                 $out_1002[] = array('task_id' => $val['guide_id'], 'step' => 1, 'task_status' => $val['task_status'], 'task_data' => $target, 'index' => ++$index, 'cur_finish_num' => 0, 'task_seq' => 0, 'kill_npc_city_id' => 0, 'task_type' => 4, 'task_star' => 0);
             }
         }
         Protocol::input($player_id, 3, 10, 1002, array(0 => $out_1002));
         return array('result' => 1);
     }
     return array('result' => 0);
 }
Пример #19
0
 public function CMD2_666()
 {
     $data = $this->get_game('PlayerSkill')->test_func($this->_authuser['player_id'], $this->_param[0]);
     Protocol::input($this->_authuser['player_id'], 3, 6, 666, $data);
 }
Пример #20
0
 /**
  * 解散公会
  * @param unknown $player_id
  * @param unknown $union_id
  */
 public function dismiss_union($player_id, $union_id)
 {
     $objPlayerData = $this->get_data('Player');
     $player_info = $objPlayerData->get_player_info($player_id, array('career_type', 'level', 'union_id'));
     $union_id = $player_info['union_id'];
     $union_id = intval($union_id);
     if ($union_id < 1) {
         $this->throw_error('170303');
     }
     $objUnionInfoData = $this->get_data('UnionInfo');
     $unionInfo = $objUnionInfoData->get_union_info($union_id);
     if (empty($unionInfo)) {
         $this->throw_error('170303');
     }
     if ($unionInfo['player_num'] > 1) {
         $this->throw_error('174001');
     }
     //加锁
     if (!Com_Lock::lock('lock|union_player|player_num|union_id=' . $union_id)) {
         //系统繁忙
         $this->throw_error('170501');
     }
     $this->start_trans();
     $objUnionPlayerData = $this->get_data('UnionPlayer');
     $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id);
     //删除公会成员
     $setUnionInfo['player_num'] = 0;
     $setUnionInfo['create_player_id'] = 0;
     $setUnionInfo['create_player_name'] = '';
     $setUnionInfo['union_name'] = '';
     Com_Log::debug_write('update_union_info', "dismiss_union|unoin_id={$union_id}" . json_encode($setUnionInfo));
     $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $setUnionInfo);
     $retUnionPlayerInfo = $objUnionPlayerData->del_union_player($union_id, $player_id);
     $setPlayerInfo = array("union_id" => 0, "union_name" => "", "union_job" => 0);
     $retPlayerInfo = $this->get_data('Player')->update_player_info($player_id, $setPlayerInfo);
     $retUnionRank = $objUnionInfoData->delete_union_rank($union_id);
     //保留删除前数据
     $objUnionPlayerHisData = $this->get_data('UnionPlayerHis');
     $unionPlayerInfo['quit_time'] = time();
     $retPlayerHisInfo = $objUnionPlayerHisData->update_union_player_info($player_id, $unionPlayerInfo);
     if ($retUnionInfo && $retUnionPlayerInfo && $retPlayerInfo && $retUnionRank && $retPlayerHisInfo) {
         $this->commit();
         $this->get_game('Union')->Sync_Union_msg($union_id, -1, 2, 0, true);
     } else {
         $this->rollback();
         $this->throw_error('10101');
     }
     $update_player_detail_data['union_achieve_attr'] = array();
     $this->get_data('PlayerDetail')->update_player_detail($player_id, $update_player_detail_data);
     Protocol_Player::p2c_part_update($player_id, array('union_id' => 0, 'union_name' => '', 'union_job' => 0, 'attr' => array(), 'player_data' => array('player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']))));
     $this->get_data("PlayerDailyTime")->set_used_time($player_id, "union_player_contribute", 0);
     Protocol::input($player_id, 7, 4, 511, array($player_id, 0, 0));
     $this->get_data("Player")->add_no_union_player($player_id, $player_info['level']);
     #公会成员战力
     $this->get_data("UnionInfo")->del_union_player_sum_fpower($union_id, $player_id);
     return array(1, $union_id);
 }
Пример #21
0
 /**
  * 领取所有资源
  * @param int player_id 玩家id
  * @param int type 领取类型 1,免费;2,消耗钻石
  */
 public function get_back_all($player_id, $type)
 {
     $player_id = intval($player_id);
     if (!in_array($type, array(1, 2))) {
         //参数错误
         $this->throw_error(10107, 6010018);
     }
     $df = 0;
     $data = $this->get_data('GetBackCurrency')->get_yesterday_info($player_id, $df);
     if ($data['reward_num'] < 1) {
         //无资源可以找回
         $this->throw_error(6010109, 6010114);
     }
     if ($data['is_vip']) {
         $type = 2;
     }
     $cost_currency_value = 0;
     $reward_detail = array();
     foreach ($data['func_info'] as &$func) {
         if (1 == $func['reward_status']) {
             if (!$data['is_vip'] && 2 == $type) {
                 $value = explode(':', $func['cost_num']);
                 $cost_currency_type = $value[0];
                 $cost_currency_value += $value[1];
             }
             if (!empty($func['reward'])) {
                 $reward_array = explode("|", $func['reward']);
                 foreach ($reward_array as $reward) {
                     list($item_idx, $item_num) = explode(":", $reward);
                     if (empty($item_num)) {
                         continue;
                     }
                     if (1 == $type) {
                         $item_num = ceil($item_num / 2);
                     }
                     $reward_detail[$item_idx] += intval($item_num);
                 }
             }
             $func['reward_status'] = 2;
         }
     }
     if (!$reward_detail) {
         $this->throw_error(6010109, 6010115);
     }
     $send_reward = array();
     $this->get_game('Reward')->gen_reward_array($reward_detail, $send_reward);
     if ($cost_currency_value) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
         $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
         $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $data['reward_num'], $cost_currency_type);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     }
     $arr_up['func_info'] = $data['func_info'];
     $arr_up['reward_num'] = 0;
     $this->start_trans();
     $result = $this->get_data('GetBackCurrency')->update_player_info($player_id, $data['day'], $arr_up);
     if ($result) {
         $result = $this->get_game('Reward')->send_reward($player_id, $send_reward, array('cmd_id' => 2021));
         if ($result !== true) {
             $this->throw_error($result);
         }
     }
     if ($cost_currency_value) {
         if ($result) {
             $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2021, array(), $arr_consume);
         }
     }
     if ($result) {
         $this->commit();
         $this->get_game('Reward')->add_reward_log(true);
     } else {
         $this->rollback();
         $this->throw_error('10101', 6010116);
     }
     $data = $this->get_panel($player_id);
     Protocol::input($player_id, 8, 20, 2019, $data);
     //该死的同步次数
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130);
     return array('res' => 1);
 }
Пример #22
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)));
 }
Пример #23
0
 /**
  * 更新玩家信息
  *
  * @param array $objDataInfo
  * @return unknown
  */
 public function update_userInfo($objDataInfo)
 {
     $noclude = array('server_id', 'serverId');
     $condition = array();
     foreach ($objDataInfo as $k => $v) {
         if (!in_array($k, $noclude)) {
             $condition[$k] = $v;
         }
     }
     $result = $this->get_data('Player')->update_player_basic_info($objDataInfo['player_id'], $condition);
     if ($result) {
         $data['role_id'] = $objDataInfo['player_id'];
         $is_ban = $objDataInfo['is_ban'];
         $ban_memo = $objDataInfo['ban_memo'];
         if ($is_ban == 2) {
             $data['dead_time'] = strtotime($objDataInfo['ban_time']);
             $res['type'] = 1;
             $res['list'] = array($data);
             Protocol::input(0, 7, 4, 455, $res);
             Com_Log::write("GM_ban_info", "type:禁言" . ",player_id:" . $objDataInfo['player_id'] . ",ban_momo:" . $ban_memo . ",ban_time:" . $objDataInfo['ban_time']);
         } else {
             if ($is_ban == 3) {
                 Com_Log::write("GM_ban_info", "type:封禁" . ",player_id:" . $objDataInfo['player_id'] . ",ban_momo:" . $ban_memo . ",ban_time:" . $objDataInfo['ban_time']);
             } else {
                 if ($is_ban == 0) {
                     $data['dead_time'] = 0;
                     $res['type'] = 0;
                     $res['list'] = array($data);
                     Protocol::input(0, 7, 4, 455, $res);
                 }
             }
         }
     }
     Protocol::out();
     return $result;
 }
Пример #24
0
 public function CMD2_1159()
 {
     $lockKey = __FUNCTION__ . $this->_authuser['player_id'];
     if (!Com_Lock::lock($lockKey)) {
         //失败
         $this->check_error('1714001');
     }
     $data = $this->get_game('PlayerPVE')->get_invite_reward($this->_authuser['player_id']);
     Com_Lock::unLock($lockKey);
     Protocol::input($this->_authuser['player_id'], 3, 11, 1159, $data);
 }
Пример #25
0
 /**
  * 时装激活 激活后页面角色将变成时装模式
  */
 public function CMD2_901()
 {
     $data = $this->get_game('PlayerBase')->activate_fashion($this->_authuser['player_id'], $this->_param[0]);
     Protocol::input($this->_authuser['player_id'], 3, 9, 901, $data);
 }
Пример #26
0
 /**
  * 给索尔有名字查player_id
  */
 public function CMD2_7003()
 {
     Com_Log::write('CMD2_7003.' . $this->_authuser['player_id'], var_export($this->_param[0], true));
     $player_id = $this->get_data("Account")->get_pid_byname($this->_param[0]);
     Protocol::input($this->_authuser['player_id'], 3, 7, 7003, array(0 => intval($player_id)));
 }
Пример #27
0
 public function gain_free_reward($player_id, $plm_id)
 {
     $this->param_check_numeric(array($player_id, $plm_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     # 获取议会配置信息
     $plm_conf = Cache_MagicParliament::getInstance()->get_parliament_conf($plm_id);
     if (empty($plm_conf)) {
         $this->throw_error('100002');
         # 获取魔法议会配置失败
     }
     # 议会免费奖励领取上限
     $free_reward_gain_stint = $this->get_free_reward_gain_stint($plm_id, $plm_conf);
     # 获取玩家当日免费奖励领取次数
     $free_reward_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id']));
     # 判断上限
     if ($free_reward_num >= $free_reward_gain_stint) {
         $this->throw_error('100008');
         #  魔法议会免费领奖次数超过上限
     }
     $this->start_trans();
     # 更新免费奖励领取次数
     $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id']));
     $this->write_check($re, 3010223);
     # 发放免费奖励
     $reward = array();
     $reward_detail = $this->get_game('Reward')->get_reward_detail($plm_conf['free_reward']);
     $this->get_game('Reward')->gen_reward_array($reward_detail, $reward);
     if (!empty($reward)) {
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2506'), 1);
         $this->write_check_strict($re, 3010411);
     }
     # 记录行为日志
     $action_log = array('player_id' => $player_id, 'reg_time' => $this->current_time, 'plm_id' => $plm_id, 'action_type' => 3, 'reward_info' => json_encode($reward_detail));
     $re = $this->get_data('MagicParliament')->record_action_log($action_log);
     $this->write_check_strict($re, 3010445);
     $this->commit();
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $ret = $this->get_game('Reward')->add_reward_log(true);
     # 刷新议会信息
     $out_2503 = $this->init_magic_parliament_deatil($player_id, $plm_id);
     Protocol::input($player_id, 3, 25, 2503, $out_2503);
     # 记录行为
     Com_Log::debug_write('xgame.magic_parliament', "{$player_id}\t" . "gain_free_reward\t" . "{$plm_id}\t");
     $out_2506 = array();
     return $out_2506;
 }
Пример #28
0
 public function flush_cache()
 {
     Com_Cache::factory('setting')->flush();
     //		Com_Cache::factory("game")->flush();
     //		Com_Queued::send("process", "restart");
     $data[0] = intval(1);
     //        Protocol::input(0,7,4,402,$data);
     //        Protocol::out('192.168.1.136');
     Protocol::input(0, 7, 4, 402, $data);
     Protocol::out('192.168.1.105');
     //        Protocol::make_data($data);
     //        $raw_data = Protocol::output(7,4,402,2);
     //
     //        $server_ip = Com_System::get_client_ip();
     //
     //        $url = "http://{$server_ip}/nginx2cppsvr.do";
     //        $header = "Content-type: application/octet-stream";
     //        $ch = curl_init(); //初始化curl
     //        curl_setopt($ch, CURLOPT_URL, $url);//设置链接
     //        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息
     //        curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));//设置HTTP头
     //        curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式
     //        curl_setopt($ch, CURLOPT_POSTFIELDS, $raw_data);//POST数据
     //        curl_setopt($ch, CURLOPT_TIMEOUT,1);
     //        curl_exec($ch);
     //        curl_close($ch);
 }
Пример #29
0
 public function buff_attr($player_id, $part_update = true)
 {
     $data = $this->get_data('PlayerBuffData')->get_buff_data($player_id);
     $buff_data = array();
     if ($data) {
         $buff_sid = array();
         //            $time = time();
         foreach ($data as $val) {
             //                if(($val['save_time']+$val['duration_total']/1000) > $time){
             $buff_sid[] = $val['buff_sid'];
             //                }
         }
         if ($buff_sid) {
             $buff_data = Cache_SkillBuff::getInstance()->get_buff_data($buff_sid);
         }
     }
     $buff_attr = array();
     $buff_attr_per = array();
     $buff_exp_addition = array();
     if (!empty($buff_data)) {
         foreach ($buff_data as $val) {
             $attr_key = $this->get_attr_by_buff_type($val['param1']);
             if ($val['buff_type'] == 'mod_fight_attr') {
                 $buff_attr[$attr_key] += $val['param2'];
             }
             if ($val['buff_type'] == 'mod_fight_attr_%') {
                 $buff_attr_per[$attr_key] += $val['param2'];
             }
             if ($val['buff_type'] == 'mod_exp_%') {
                 $buff_exp_addition['exp'] += $val['param1'];
             }
         }
         //            Com_Log::write("buff_attr".$player_id,"buff_attr".var_export($buff_attr,true));
         //            Com_Log::write("buff_attr".$player_id,"buff_attr_per".var_export($buff_attr_per,true));
     }
     $result = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('buff_attr' => $buff_attr, 'buff_attr_per' => $buff_attr_per, 'buff_exp_addition' => $buff_exp_addition));
     if (!$part_update) {
         $objPlayer = $this->get_data('Player');
         $player_info = $objPlayer->get_player_info($player_id);
         $objFpowerCalc = $this->get_game('FpowerCalc');
         $objFpowerCalc->set_player_info($player_info);
         $player_fpower = $objFpowerCalc->calc_player_fpower($player_id);
         $player_info['fpower'] = $player_fpower['fpower'];
         $update_fpower['buff_fpower'] = $player_fpower['buff_fpower'];
         $update_fpower['fpower'] = $player_info['fpower'] + $player_info['sq_fpower'] + $player_info['skill_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'];
         $update_fpower['sum_fpower'] = $sum_fpower;
         $objPlayer->update_player_info($player_id, $update_fpower);
         $syn_item['buff_fpower'] = $update_fpower['buff_fpower'];
         SynPlayer::set_syn_data($syn_item);
         $data = SynPlayer::get_data();
         Protocol::input($player_id, 7, 4, 417, array(0 => $data['m'], 1 => $data['u']));
     }
     if ($result && $part_update) {
         Protocol_Player::p2c_part_update($player_id, array('attr' => ''));
     }
 }
Пример #30
0
 /**
  * 领地争夺战斗日程
  */
 public function CMD2_2606()
 {
     $data = $this->get_game('UnionGrabDomain')->get_battle_list($this->_authuser['player_id']);
     Protocol::input($this->_authuser['player_id'], 3, 26, 2606, $data);
 }