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; }
/** * @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(); } } } }
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; } } }
/** * 道具变更下行协议 * @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); } }
public function sync($data) { $arr_account = file_get_contents(CACHE_PATH . "/server3.txt"); $arr_account = json_decode($arr_account, true); $player_id = $data['player_id']; $user_account = $data['user_account']; if (!$player_id || !$user_account) { return; } if (isset($arr_account[$user_account])) { if ($arr_account[$user_account]['level'] >= 55) { // 生成奖励邮件附件信息 $attachment = array(); $attachment[] = array("prop_id" => 95015, "prop_num" => 1); // 邮件发送 $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(8005); $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 108); $this->write_check($re); Protocol::out(); } if ($arr_account[$user_account]['sum_fpower'] >= 80000) { // 生成奖励邮件附件信息 $attachment = array(); $attachment[] = array("prop_id" => 95014, "prop_num" => 1); // 邮件发送 $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(8006); $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 108); $this->write_check($re); Protocol::out(); } } }
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; }
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); }
/** * @Purpose: * 通知C++新一天的优先公会活动 */ public function refresh_new_union_activities_p2c() { #获取公会ID列表 $union_id_list = $this->get_data('UnionInfo')->get_all_union_id(); if (Com_Array::is_good_arr($union_id_list)) { foreach ($union_id_list as $union_id => $val) { #同步活动数据到C++ $this->get_game('Union')->Sync_Union_msg($union_id, 0); Protocol::out(); } } }
public function add_timer($player_id) { $params['type'] = 755; $params['id'] = $player_id; $params['timeout'] = $this->_timer_len; #10秒钟过期时间 $params['param1'] = 0; $params['param2'] = 0; $params['param3'] = 0; $params['param4'] = 0; Com_Log::write("do_timeer." . $player_id, "send:" . $player_id); Protocol::input(0, 7, 4, 516, $params); Protocol::out(); }
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; }
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; }
public function add_sign($player_id, $day, $gold_num) { if ($day > 7) { return false; } $activity_player = $this->get_data('NewServerActivity')->get_player_info($player_id, array('sign_info', 'extra_rewards_status', 'retro_num', 'buy_info')); if (isset($activity_player['sign_info'][$day])) { $activity_player['sign_info'][$day]['recharge_num'] += $gold_num; $activity_player['sign_info'][$day]['recharge_left_num'] += $gold_num; } else { $activity_player['sign_info'][$day] = array('recharge_num' => $gold_num, 'recharge_left_num' => $gold_num); } $up_arr = array('player_id' => $player_id, 'sign_info' => $activity_player['sign_info']); $this->get_data('NewServerActivity')->update_player_info($player_id, $up_arr); $data = $this->get_sign_panel($player_id); Protocol::input($player_id, 8, 23, 2305, $data); Protocol::out(); # 新服活动,蛋疼的数字埋点 $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1250); }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $userInfo_array = json_decode($userInfo_json, true); $show_type = 1; $content = addslashes($userInfo_array['notice']['text']); $start_time = $userInfo_array['notice']['begin_time']; $end_time = $userInfo_array['notice']['end_time']; $interval = $userInfo_array['notice']['exec_time']; $location = $userInfo_array['notice']['type']; $id = $userInfo_array['notice']['tid']; $vip = '0'; $result = $this->get_game('SystemNotice')->add_system_notice($id, $show_type, $location, $content, $start_time, $end_time, $interval, $vip); $data = array(); $data['status'] = 0; if ($result) { $data['status'] = 1; Protocol::out(); } echo json_encode($data); }
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(); }
/** * 触发公会成就任务 * @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(); } } }
/** * 主动向指定玩家抛出异常 * @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; } }
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); }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $arrData = json_decode($userInfo_json, true); $strAccount = isset($arrData["user_account"]) ? trim($arrData["user_account"]) : ""; #账号 $strOrderId = isset($arrData["order_id"]) ? trim($arrData["order_id"]) : ""; #订单号 $iGameMoney = isset($arrData["game_money"]) ? intval($arrData["game_money"]) : 0; #充值黄金 $iUMoney = isset($arrData["u_money"]) ? floatval($arrData["u_money"]) : 0; #充值U币(可以理解为人民币) $serverId = isset($arrData['server_id']) ? $arrData['server_id'] : 0; $player_id = isset($arrData['player_id']) ? $arrData['player_id'] : 0; $type = isset($arrData['type']) ? $arrData['type'] : 1; #1充值 2赠送3仅仅刷新VIP if (intval($iGameMoney) <= 0) { echo json_encode(array('status' => 0, 'data' => '充值金额有误')); exit; } if (!in_array($type, array(1, 2, 3))) { echo json_encode(array('status' => 8, 'data' => '类型错误')); #类型错误 exit; } if (!empty($strAccount)) { $player_id = $this->get_data('Account')->get_pid_byaccount($strAccount, true, $serverId); } if (empty($player_id)) { echo json_encode(array('status' => 0, 'data' => '账户不存在')); exit; } $objPlayerCharge = $this->get_data('PlayerCharge'); if ($type == 1) { $strOrderId = "gm" . time(); // $arrCharge = $objPlayerCharge->get_charge_info($strOrderId); // if(!empty($arrCharge)){ // echo json_encode(array('status'=>0, 'data'=>'订单不存在')); // exit; // } } $objPlayerData = $this->get_data('Player'); $arrPlayer = $objPlayerData->get_player_info($player_id, array('gold', 'level', 'vip', 'privilege_level')); $b_gold = $arrPlayer['gold']; #改变之前的钻石 // $iGold = $arrPlayer['gold']; // $player_level = $arrPlayer['level']; $result = false; #$this->get_data('Player')->check_player_resource($player_id, $player_info, '+', 'gold', $iGameMoney); $this->start_trans(); $iGold = $iGameMoney * 10; /* if ($iGameMoney) { $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 525); } */ $result = $objPlayerData->update_player_info($player_id, array('gold' => "+" . $iGold)); if ($result) { $after = $arrPlayer['gold'] + $iGold; if ($type == 1) { //充值 $result = $objPlayerCharge->add_charge($player_id, $strOrderId, $strAccount, $arrPlayer['level'], $iGold, $iGameMoney, $b_gold, $after); } else { //赠送 $result = $objPlayerCharge->add_present($player_id, $iGameMoney); } if ($type == 2) { //计入充值活动 $player_charge_dummy_info = array(); $player_charge_dummy_info["order_id"] = "gmorder" . time(); $player_charge_dummy_info["player_id"] = $player_id; $player_charge_dummy_info["user_account"] = $strAccount; $player_charge_dummy_info["player_level"] = $arrPlayer['level']; $player_charge_dummy_info["front_gold"] = $b_gold; $player_charge_dummy_info["gold"] = $iGold; $player_charge_dummy_info["after_gold"] = $after; $player_charge_dummy_info["u_money"] = $iGameMoney; $player_charge_dummy_info["add_time"] = time(); $player_charge_dummy_info["active"] = 0; $player_charge_dummy_info["active2"] = 0; $player_charge_dummy_info["active3"] = 0; $player_charge_dummy_info["active4"] = 0; $player_charge_dummy_info["active5"] = 0; $result = $this->get_data("Event")->insert_into_player_charge_dummy($player_charge_dummy_info); } } if ($result) { $this->commit(); if ($type == 1) { //充值记录 Log_Charge::getInstance()->add_charge_log($player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $strOrderId, $iGold, $iUMoney, $arrPlayer['gold'], $b_gold); } else { Log_Common::getInstance()->add_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], 100, 1, 2, $iGold, $arrPlayer['gold']); } // $logs[] = array('type'=>1,'item_id'=>2,'item_num'=>$iGold,'amount'=>$arrPlayer['gold']); // Log_Common::getInstance()->add_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'],$arrPlayer['privilege_level'], 100, 1, 2, $iGold, $arrPlayer['gold']); // Log_Common::getInstance()->add_multi_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'],$arrPlayer['privilege_level'], 100, $logs); $data['status'] = 1; $data['data']['success'][] = $player_id; #同步更新面板数据 Protocol_Player::p2c_part_update($player_id, array('gold' => $iGold + $arrPlayer['gold'])); #vip升级 if ($type == 3) { #不参加 首次充值 $this->get_game('VipReward')->vip_upgrade($player_id, $iGold); } else { $this->get_game('VipReward')->vip_upgrade($player_id, $iGold); } #新服活动 if ($type < 3) { $pub_day = $this->get_data('NewServerActivity')->get_server_day(); if ($pub_day <= 7) { $this->get_game('NewServerActivity')->add_sign($player_id, $pub_day, $iGold); } } } else { $this->rollback(); $data['status'] = 0; } echo json_encode($data); define("FROM_GATEWAY", true); $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260); Protocol::out(); return; }
public function player_upgrade_fame($data) { if (empty($data)) { return false; } $data = json_decode($data, true); $player_id = $data['player_id']; $fame = $data['fame']; $old_fame_level = intval($data['fame_level']); $fame_level_exp = $data['fame_level_exp']; $level = $data['level']; $vip = $data['vip']; $privilege_level = $data['privilege_level']; $logs = array(); // Com_Log::write('xgame.player_fame_upgrade',var_export($data,true)); $update = array(); $max_level = Cache_PlayerFame::getInstance()->get_fame_max_level(); if ($old_fame_level >= $max_level) { return false; } $level = $this->get_update_fame_level($old_fame_level, $fame, $logs); $this->start_trans(); $update['fame'] = $level['fame'] < 0 ? 0 : $level['fame']; $update['fame_level'] = $level['fame_level']; $update['fame_level_exp'] = $level['fame_level_exp']; // Com_Log::write('xgame.player_fame_upgrade',"update"); // Com_Log::write('xgame.player_fame_upgrade',var_export($update,true)); $ret_attr = true; if ($update['fame_level'] > $old_fame_level) { $level_config = Cache_PlayerFame::getInstance()->get_player_fame_info($update['fame_level']); $fame_attr = array(); $fame_attr['atk_min'] = $level_config['atk_min']; $fame_attr['hp'] = $level_config['max_hp']; $fame_attr['arm'] = $level_config['arm']; $update_player_detail_data['fame_attr'] = $fame_attr; $obj_player_detail = $this->get_data('PlayerDetail'); $ret_attr = $obj_player_detail->update_player_detail($player_id, $update_player_detail_data); } $result = $this->get_data('Player')->update_player_info($player_id, $update); if ($result && $ret_attr) { $this->commit(); if ($logs) { Log_Common::getInstance()->add_multi_resource_log($player_id, $level, $vip, $privilege_level, 103, $logs); } $arr_player['fame'] = $update['fame']; $arr_player['fame_level'] = $update['fame_level']; $arr_player['fame_level_exp'] = $update['fame_level_exp']; $arr_player['fame_attr'] = array(); $arr_player['attr'] = array(); Protocol_Player::p2c_part_update($player_id, $arr_player); if ($update['fame_level'] > $old_fame_level) { if ($update['fame_level'] > 1) { #{玩家名}的声望达到了{声望名},真是厉害! $level_config = Cache_PlayerFame::getInstance()->get_player_fame_info($update['fame_level']); $replace_info = array(); $replace_info[] = array('rep_type' => 0, 'rep_val' => $player_id); $replace_info[] = array('rep_type' => 7, 'txt' => $level_config['title']); $this->get_game('SystemNotice')->push_sys_notice($player_id, 15, 0, $replace_info, $update['fame_level']); #升级提示 $hero_list = $level_config['hero_sid'] ? explode("|", $level_config['hero_sid']) : array(); $notice = array(); $notice['lvl'] = $level_config['lvl']; $notice['fame'] = $level_config['exp']; $notice['atk_min'] = $level_config['atk_min']; $notice['max_hp'] = $level_config['max_hp']; $notice['arm'] = $level_config['arm']; $notice['wing_lvl'] = intval($level_config['wing_lvl']); $notice['fairy_lvl'] = intval($level_config['fairy_lvl']); $notice['hero_list'] = $hero_list; $notice['title'] = $level_config['title']; Protocol::input($player_id, 8, 7, 747, $notice); if (!IS_FRONT) { Protocol::out(); } // Com_Log::debug_write('player_upgrade_fame', "player_id={$player_id}".json_encode($notice)); } } return false; } else { $this->rollback(); } return $update; }
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); }
/** * 更新玩家信息 * * @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; }
/** * 更新玩家信息 * * @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[0] = array($objDataInfo['player_id']); $data[1] = strtotime($objDataInfo['ban_time']); Protocol::input(0, 7, 4, 455, $data); } Protocol::out(); return $result; }
/** * 429: 天梯战斗结算奖励 * @note 注意,C++请求该方法时传入的player_id=0[玩家下线离开仍然要有战斗结果,即结果与挑战发起方无关],不能用plaeyr_id做二次验证,只能用战斗序号验证 * @note 考虑到天梯挑战的战斗结果与当事人发起挑战后的其它游戏行为无关,即当发起挑战后,无论当事人有任何游戏行为, * @note 该场战斗仍然客观进行中,结果都必须结算,而ladder_id已经可以唯一确认一场天梯挑战 * @note 当$winner_player_id == 0 && $loser_player_id == 0时,表示玩家异常操作,刷新或下线,PHP后端自行结算战斗奖励及结果 * @param $player_id * @param $battle_seq * @param $winner_player_id * @param $loser_player_id * @return bool */ public function finish_challenge_battle($player_id, $battle_seq, $winner_player_id, $loser_player_id) { # 记录行为 Com_Log::write('xgame.challenge', "{$player_id}\t" . "finish_challenge_battle\tstart\t" . "{$battle_seq}\t" . "{$winner_player_id}\t" . "{$loser_player_id}\t"); $this->current_time = time(); # 后台进程调用的方法需要重置当前时间 # 获取挑战日志 $battle_log = $this->get_data('Challenge')->get_challenge_battle_log($battle_seq); if (empty($battle_log) || $battle_log['battle_status'] == 1) { $this->throw_error('120102'); # 天梯战斗结果验证异常,或战斗序号错误 } # 挑战双方player_id $player_id = $battle_log['player_id']; $tgt_player_id = $battle_log['tgt_player_id']; $mon_offset = $battle_log['mon_offset']; $reward_buff_type = $battle_log['reward_buff_type']; $reward_buff_offset = $battle_log['reward_buff_offset']; $fight_with_monster = $mon_offset ? 1 : 0; # 是否挑战怪物标识 $exception_flag = 0; # 异常标识 $player_info = $this->get_data('Player')->get_player_info($player_id); # 挑战方一定是玩家,可先获取其玩家信息 # -------------------------------------------------------------------- # 初始化奖励信息:1.怪物额外奖励;2.挑战奖励;3.reward buff额外奖励 # -------------------------------------------------------------------- $currency_index = Cache_Currency::getInstance()->get_index(); $reward_detail_monster = array(); $reward_detail_buff = array(); # ---------------------------------------------------------------- # 获取排名信息 $player_rank_info = $this->get_data('Challenge')->get_player_challenge_rank_info($player_id); $player_rank_before = $player_rank_info['rank']; # 发起方战前排名,本人在虚拟天梯榜时,值为0 $player_cstatus_before = $player_rank_info['challenge_status']; # 发起方战前天梯状态 $player_frank_before = $player_rank_info['fake_rank']; # 发起方战前虚假排名 $player_frank_after = $player_rank_info['fake_rank']; # 发起方战后虚假排名[挑战怪物,则玩家cstatus<=2,虚假排名不会变;挑战玩家,虚假排名可能变化] $fight_with_dummy = 0; # 是否与虚拟榜虚假玩家战斗 if ($mon_offset) { $tgt_player_rank_info = array(); # 对手为怪物时,值为false $tgt_player_rank_before = 0; # 被挑战方战前排名[挑战怪物,则为0,怪物没有天梯排名] } else { $tgt_player_rank_info = $this->get_data('Challenge')->get_player_challenge_rank_info($tgt_player_id); # 对手为虚拟玩家时,值为false $tgt_player_rank_before = empty($tgt_player_rank_info) ? 0 : $tgt_player_rank_info['rank']; # 被挑战方战前排名[挑战虚拟玩家,则为0,虚拟玩家没有天梯排名;挑战真实玩家,则为真实玩家排名] } # ---------------------------------------------------------------- $this->start_trans(); # 玩家挑战怪物,正常情况:只传回玩家ID,怪物ID不传,异常情况[掉线或刷新]: 玩家ID与怪物ID都传0 if (!empty($mon_offset)) { if ($winner_player_id == 0 && $loser_player_id == 0) { # 异常战斗行为处理:包括玩家下线及刷新等 $battle_result = 1; $exception_flag = 1; } else { if ($player_id != $winner_player_id && $player_id != $loser_player_id) { $this->throw_error('120102'); # 天梯战斗结果验证异常 } $battle_result = $player_id == $winner_player_id ? 1 : 0; # 挑战结果 } # TODO: 此处有高并发问题隐患,当过了此处验证时,另一玩家已经挑战完该怪物并清空该怪物,下面的排位移动将出问题 $monster_info = $this->get_data('Challenge')->get_challenge_monster_info($mon_offset); if (empty($mon_offset) || empty($monster_info)) { $this->throw_error('120102'); # 天梯战斗结果验证异常 } # 发放怪物额外奖励[输了怪物奖励折半] $ladder_element_info = Cache_Ladder::getInstance()->get_element_info_by_double_type(2, $tgt_player_id); if (empty($ladder_element_info)) { $this->throw_error('120108'); } $coeff_monster = $battle_result == 1 ? 1 : 0.5; $reward_detail_monster = $this->get_game('Reward')->get_reward_detail($ladder_element_info['reward'], $coeff_monster); # 若胜利,清除该偏移量位置上的怪物,玩家取代怪物位置,怪物后直到玩家之前的所有玩家向后推移1位 if ($battle_result) { # 清除怪物 $re = $this->get_data('Challenge')->delete_challenge_monster_info($mon_offset); $this->write_check($re, 3010666); if (empty($player_rank_before)) { # 本人在虚假天梯榜,显示排名3001,假设mon_offset=2997,则打完后,本人排名为2997,实际2997-2999变为2998-3000,实际3000移出真实榜 $player_rank_info['rank'] = $mon_offset; $player_rank_info['is_in_battle'] = 0; # 战斗状态变更 $player_rank_info['challenge_status'] = 1; # 移入真实天梯榜 $player_rank_info['mod_date'] = $this->current_time; $need_update_player_rank_info = array(0 => $player_rank_info); # 怪物后第一位一直到边界值排位的前一位正常处理 $need_modify_rank = array(); for ($i = $mon_offset; $i < $this->challenge_partition_boundary; $i++) { # 这部分玩家排位后移1位, $need_modify_rank[] = $i; } list($player_info_list, $player_pid_list) = $this->get_data('Challenge')->get_player_list_by_rank($need_modify_rank); foreach ($player_info_list as $rank => $rank_info) { $rank_info['rank'] += 1; $rank_info['mod_date'] = $this->current_time; $need_update_player_rank_info[] = $rank_info; } # 边界值排位的玩家额外处理【即真实天梯榜最后一名额外处理,需移出真实天梯榜】 list($player_info_list, $player_pid_list) = $this->get_data('Challenge')->get_player_list_by_rank($this->challenge_partition_boundary); foreach ($player_info_list as $rank => $rank_info) { $rank_info['rank'] = 0; $rank_info['challenge_status'] = 2; $rank_info['mod_date'] = $this->current_time; $need_update_player_rank_info[] = $rank_info; } # 更新 foreach ($need_update_player_rank_info as $rank_info) { $re = $this->get_data('Challenge')->update_challenge_rank_info($rank_info); $this->write_check($re, 3010701); } } elseif ($player_rank_before > $mon_offset) { # 本人在正常天梯榜,只有往前打怪才移动排名,往后打排名不变,只清除怪物 $player_rank_info['rank'] = $mon_offset; $player_rank_info['is_in_battle'] = 0; # 战斗状态变更 $player_rank_info['mod_date'] = $this->current_time; $need_update_player_rank_info = array(0 => $player_rank_info); $need_modify_rank = array(); for ($i = $mon_offset; $i <= $player_rank_before - 1; $i++) { # 这部分玩家排位后移1位 $need_modify_rank[] = $i; } list($player_info_list, $player_pid_list) = $this->get_data('Challenge')->get_player_list_by_rank($need_modify_rank); foreach ($player_info_list as $rank => $rank_info) { $rank_info['rank'] += 1; $rank_info['mod_date'] = $this->current_time; $need_update_player_rank_info[] = $rank_info; } # 更新 foreach ($need_update_player_rank_info as $rank_info) { $re = $this->get_data('Challenge')->update_challenge_rank_info($rank_info); $this->write_check($re, 3010726); } #$this->handle_challenge_rank_refer_achieve($player_id, $player_rank_info['rank']); } # 公会任务触发 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 1050); } else { # 若失败,排名不变 # 更新怪物战斗状态 $monster_info['is_in_battle'] = 0; $re = $this->get_data('Challenge')->update_challenge_monster_info($monster_info); $this->write_check($re, 3010737); } } else { # 玩家挑战玩家 if ($winner_player_id == 0 && $loser_player_id == 0) { # 异常战斗行为处理:包括玩家下线及刷新等 # 连败时的战力加成处理 if ($player_info['challenge_cont_lose'] > 0) { $ability_add_info = Cache_Ladder::getInstance()->get_ability_add_info($player_info['challenge_cont_lose']); if (empty($ability_add_info)) { $this->throw_error('120106'); # 没有连胜或连败的加成配置信息 } $player_info['sum_fpower'] = $player_info['sum_fpower'] * (1 + intval($ability_add_info['ability_add'] / 100)); } $tgt_player_info = $this->get_data('Player')->get_player_info($tgt_player_id); $battle_result = $player_info['sum_fpower'] >= $tgt_player_info['sum_fpower'] ? 1 : 0; # 挑战结果 $exception_flag = 1; } else { if ($player_id != $winner_player_id && $player_id != $loser_player_id || $tgt_player_id != $winner_player_id && $tgt_player_id != $loser_player_id) { $this->throw_error('120102'); # 天梯战斗结果验证异常 } $battle_result = $player_id == $winner_player_id ? 1 : 0; # 挑战结果 } if (!empty($tgt_player_rank_before)) { # 真实天梯对手才需要更新 # 若胜利,取二者较前排名【不交换排名是因为向后挑战时排名不变更】 if ($battle_result) { if (empty($player_rank_before)) { # 本人在虚假天梯榜时,将对方移出真实天梯榜,取而代之,也可用$player_rank_info['challenge_status'] == 2||3判断 $player_rank_info['rank'] = $tgt_player_rank_before; $player_rank_info['challenge_status'] = 1; # 移入真实天梯榜 $tgt_player_rank_info['rank'] = 0; $tgt_player_rank_info['challenge_status'] = 2; # 移出真实天梯榜 } else { $player_rank_info['rank'] = min($player_rank_before, $tgt_player_rank_before); $tgt_player_rank_info['rank'] = max($player_rank_before, $tgt_player_rank_before); } $player_rank_info['mod_date'] = $tgt_player_rank_info['mod_date'] = $this->current_time; #$this->handle_challenge_rank_refer_achieve($player_id, $player_rank_info['rank']); # 公会任务触发 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 1050); } else { # 若失败,排名不变 # do nothing } # 更新玩家战斗状态 $player_rank_info['is_in_battle'] = $tgt_player_rank_info['is_in_battle'] = 0; $re = $this->get_data('Challenge')->update_challenge_rank_info($player_rank_info); $this->write_check($re, 3010799); $re = $this->get_data('Challenge')->update_challenge_rank_info($tgt_player_rank_info); $this->write_check($re, 3010801); } else { # 虚拟天梯对手,由于虚拟玩家未实际进入天梯,故此时不更新虚拟玩家天梯信息[包含两类:1初始进入时即进入虚假天梯榜,2初始进入真实天梯榜,但被其它玩家打出真实天梯榜] if ($battle_result) { $fake_rank = $player_rank_info['fake_rank']; foreach ($player_rank_info['fake_rank_list'] as $rank => $rank_info) { if ($rank_info['player_id'] == $tgt_player_id) { $tgt_player_rank = $rank_info['rank']; break; } } if ($fake_rank > $tgt_player_rank) { # 向排名较前的人挑战则交换,否则不交换 $player_rank_info['fake_rank'] = $tgt_player_rank; $player_rank_info['fake_rank_list'][$fake_rank]['player_id'] = $tgt_player_id; $player_rank_info['fake_rank_list'][$tgt_player_rank]['player_id'] = $player_id; $player_rank_info['mod_date'] = $this->current_time; } # 公会任务触发 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 1050); } $player_rank_info['fake_battle_num'] += 1; # 战斗次数加1 if ($player_rank_info['fake_battle_num'] >= $this->challenge_req_fake_battle_num) { $player_rank_info['challenge_status'] = 2; # 天梯状态置为2 } $player_rank_info['is_in_battle'] = 0; $re = $this->get_data('Challenge')->update_challenge_rank_info($player_rank_info); $this->write_check($re, 3010828); $player_frank_after = $player_rank_info['fake_rank']; # 发起方战前后假排名 $fight_with_dummy = 1; # 是否与虚拟榜虚假玩家战斗 } } $this->handle_challenge_battle_refer_achieve($player_id, $battle_result); $this->handle_challenge_battle_refer_union_achieve($player_id, $battle_result); # -------------------------------------------------------------------- # 玩家挑战怪物 | 玩家挑战玩家 | 玩家下线等异常操作,以下是共同逻辑 # -------------------------------------------------------------------- # -------------------------------------------------------------------- # 连胜连败处理 # -------------------------------------------------------------------- if ($battle_result) { $player_info['challenge_cont_win'] += 1; $player_info['challenge_cont_lose'] = 0; } else { $player_info['challenge_cont_win'] = 0; $player_info['challenge_cont_lose'] += 1; } # -------------------------------------------------------------------- # 挑战奖励 # -------------------------------------------------------------------- $coeff = 1; # 连胜连败加成系数 if ($battle_result == 0) { # 若失败,奖励减半 $coeff = 0.5; } else { # 若成功,考虑连胜加成 if ($player_info['challenge_cont_win'] > 0) { $award_add_info = Cache_Ladder::getInstance()->get_award_add_info($player_info['challenge_cont_win']); if (empty($award_add_info)) { $this->throw_error('120106'); # 没有连胜或连败的加成配置信息 } $coeff = 1 + $award_add_info['award_add'] / 100; } } $award_battle_info = Cache_Ladder::getInstance()->get_ladder_award_battle_info($player_info['level']); if (empty($award_battle_info) || empty($award_battle_info['reward_base'])) { $this->throw_error('120121'); # 没有经验奖励配置信息 } # 挑战奖励要求加成绝对值,不使用加成比率 #$reward_detail_battle = $this->get_game('Reward')->get_reward_detail_other_way($award_battle_info['reward_base'], $award_battle_info['reward_add']); $reward_detail_battle = $this->get_game('Reward')->get_reward_detail($award_battle_info['reward_base']); if (!empty($award_battle_info['reward_add'])) { $add_info_array = explode("|", $award_battle_info['reward_add']); foreach ($add_info_array as $add_info) { list($item_id, $item_value) = explode(":", $add_info); if (isset($reward_detail_battle[$item_id])) { $reward_detail_battle[$item_id] += $item_value * ($player_info['level'] - $award_battle_info['level']); } } } $reward_string_battle = $this->get_game('Reward')->get_reward_string_by_reward_detail($reward_detail_battle); $reward_detail_battle_correct = $this->get_game('Reward')->get_reward_detail($reward_string_battle, $coeff); # 处理连胜连败加成 # -------------------------------------------------------------------- # 发放额外奖励buff的奖励并清空该偏移量位置上的reward_buff[无论输赢都清空buff,但输的时候buff奖励折半] # -------------------------------------------------------------------- $reward_buff_info = $this->get_data('Challenge')->get_challenge_reward_buff($player_id); if (!empty($reward_buff_type) && !empty($reward_buff_offset) && !empty($reward_buff_info)) { $ladder_element_info = Cache_Ladder::getInstance()->get_element_info_by_double_type(1, $reward_buff_type); if (empty($ladder_element_info)) { $this->throw_error('120108'); } $coeff_buff = $battle_result == 1 ? 1 : 0.5; $reward_detail_buff = $this->get_game('Reward')->get_reward_detail($ladder_element_info['reward'], $coeff_buff); if (isset($reward_detail_buff[$this->need_correct_item])) { # 部分奖励资源需要根据玩家等级修正 $element_correct_info = Cache_Ladder::getInstance()->get_element_correct_info($player_info['level'], $this->need_correct_item_id); if (empty($element_correct_info)) { $this->throw_error('120125'); # 天梯奖励元素修正表配置为空 } $correct_detail = explode("|", $element_correct_info['reward_correct']); foreach ($correct_detail as $correct_info) { list($item_idx, $item_num) = explode(":", $correct_info); if ($item_idx == $this->need_correct_item_id) { $reward_detail_buff[$this->need_correct_item_id] = $item_num; break; } } } for ($i = 1; $i <= $this->challenge_reward_buff_stint; $i++) { if ($reward_buff_info['buff' . $i . '_offset'] == $reward_buff_offset) { $reward_buff_info['buff' . $i . '_offset'] = 0; $reward_buff_info['buff' . $i . '_type'] = 0; break; } } $re = $this->get_data('Challenge')->update_challenge_reward_buff($reward_buff_info); $this->write_check($re, 3010923); } # 更新连胜连败信息 $update_fields = array('challenge_cont_win' => $player_info['challenge_cont_win'], 'challenge_cont_lose' => $player_info['challenge_cont_lose']); $re = $this->get_data('Player')->update_player_info($player_id, $update_fields); $this->write_check($re, 3010932); $item_keys = Cache_Currency::getInstance()->get_key(); # 统一发放奖励 $reward = array(); $this->get_game('Reward')->gen_reward_array($reward_detail_battle_correct, $reward); $this->get_game('Reward')->gen_reward_array($reward_detail_buff, $reward); $this->get_game('Reward')->gen_reward_array($reward_detail_monster, $reward); if (!empty($reward)) { if ($exception_flag == 1) { # 异常情况下发邮件 # 生成奖励邮件附件信息 $attachment = array(); $reward_detail = $this->get_game('Reward')->get_reward_detail_by_reward($reward); foreach ($reward_detail as $item_idx => $item_num) { $attachment[] = array("prop_id" => $item_idx, "prop_num" => $item_num); } # 邮件发送 $phrase_id = $battle_result ? 14 : 15; $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id); $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 429); } else { $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '429')); $this->write_check_strict($re, 3010943); } } # 更新挑战日志 $battle_log = array('battle_seq' => $battle_seq, 'player_id' => $player_id, 'tgt_player_id' => $tgt_player_id, 'battle_status' => 1, 'battle_result' => $battle_result); $re = $this->get_data('Challenge')->update_challenge_battle_log($battle_log); $this->write_check($re, 3010955); # 记录挑战MYSQL日志 $player_rank_after = $player_rank_info['rank']; # 发起方战后排名 $challenge_log_info = array('player_id' => $player_id, 'tgt_player_id' => $tgt_player_id, 'reg_date' => $this->current_time, 'battle_seq' => $battle_seq, 'player_rank_before' => $player_rank_before, 'player_rank_after' => $player_rank_after, 'player_fake_rank_before' => $player_frank_before, 'player_fake_rank_after' => $player_frank_after, 'tgt_player_rank_before' => $tgt_player_rank_before, 'fight_with_monster' => $fight_with_monster, 'fight_with_dummy' => $fight_with_dummy, 'challenge_status_after' => $player_rank_info['challenge_status'], 'status' => $battle_result); $re = $this->get_data('Challenge')->record_challenge_log($challenge_log_info); $this->write_check($re, 3010975); # 系统公告与广播信息只对应挑战发起方,包括获取天梯第一名和天梯连胜 $replace_info1 = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 1050), array('rep_type' => 0, 'rep_val' => $tgt_player_id)); $replace_info2 = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 1050), array('rep_type' => 7, 'txt' => $player_info['challenge_cont_win'])); # 挑战发起者胜利 && 挑战发起者战前与战后排名不一致[因为胜利,所以排名一定是提高] && 挑战发起者战后排名是第一名 if ($battle_result && $player_rank_before != $player_rank_info['rank'] && $player_rank_info['rank'] == 1) { $this->get_game('SystemNotice')->push_sys_notice($player_id, 1050, 2, $replace_info1, $player_rank_info['rank']); # 排名第一 } $this->get_game('SystemNotice')->push_sys_notice($player_id, 1050, 1, $replace_info2, $player_info['challenge_cont_win']); # 连胜 $this->commit(); # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更 $this->get_game('Reward')->add_reward_log(); #if ($exception_flag == 0) { # 战斗超时时,也是走异常结算逻辑,但却需要推送结算协议给前端 $reward_string = $this->get_game('Reward')->get_reward_string_by_reward_detail($reward_detail_battle_correct); # 挑战奖励通用字符串 # 合并$reward_detail_monster和$reward_detail_buff $extra_reward_array = array(); if (!empty($reward_detail_monster)) { foreach ($reward_detail_monster as $item_idx => $item_num) { $extra_reward_array[$item_idx] += $item_num; } } if (!empty($reward_detail_buff)) { foreach ($reward_detail_buff as $item_idx => $item_num) { $extra_reward_array[$item_idx] += $item_num; } } $extra_string = $this->get_game('Reward')->get_reward_string_by_reward_detail($extra_reward_array); $player_rank_before_display = $this->get_display_rank($player_rank_before, $player_cstatus_before, $player_frank_before); # 发起方战前显示排名 $player_rank_after_display = $this->get_display_rank($player_rank_info['rank'], $player_rank_info['challenge_status'], $player_rank_info['fake_rank']); # 发起方战后显示排名 $data = array('result' => $battle_result, 'reward' => $reward_string, 'extra_reward' => $extra_string, 'rank' => $player_rank_after_display, 'raw_rank' => $player_rank_before_display); # 推送FLASH结果与奖励信息 Protocol::input($player_id, 8, 12, 1203, $data); #} # 日常任务埋点 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 102, 102, 1); #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 7, 1); # 记录行为 Com_Log::write('xgame.challenge', "{$player_id}\t" . "finish_challenge_battle\tend\t" . "{$battle_seq}\t" . "{$winner_player_id}\t" . "{$loser_player_id}\t"); #Protocol::input($player_id,7,4,429,array(null)); # C++不需要下行 $protocols = Protocol::get_protocol(); Protocol::out(GATEWAY_IP); # 异步处理时,推送协议需要手动调用out执行 return null; }
public function fix_chain_task($player_id) { $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id, array('chain_val', 'target_val')); $chain_val = $arr_player_task['chain_val']; if (empty($chain_val)) { return true; } $step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($chain_val['task_id'], $chain_val['task_step']); if ($step_config['step_type'] != $chain_val['step_type']) { $arr_player_task = $this->get_init_chain_val($player_id, $chain_val['task_id'], $chain_val['task_step']); $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_chain_task_list($player_id, $arr_player_task); Protocol::input($player_id, 8, 10, 1025, $data); Protocol::out(); } } }
public function notice_wechat_auth_status($player_id) { if (empty($player_id)) { $this->throw_error('10107'); //参数错误! } $out_1903 = array('result' => 0); # 获取认证日志 $auth_reward_log = $this->get_data('AuthReward')->get_player_auth_reward_log($player_id, 2); # 是否已经通过微信认证 if (empty($auth_reward_log['auth_status'])) { # 若未通过认证 # 记录日志 $auth_reward_log = array('player_id' => $player_id, 'auth_type' => 2, 'phone_number' => 0, 'verify_code' => 0, 'sms_session_id' => 0, 'expire_at' => 0, 'mod_date' => $this->current_time, 'auth_status' => 1, 'reward_status' => 0); $re = $this->get_data('AuthReward')->record_player_auth_reward_log($auth_reward_log); $this->write_check($re, 3010260); $out_1903['result'] = 1; } else { # 若已通过认证 $out_1903['result'] = 2; } # 告知Flash认证状态 Protocol::input($player_id, 8, 19, 1903, $out_1903); # 由于该方法由平台API调用,故需要手动输出协议,另外,由于该请求由平台发起,故需要手动指定client_ip为默认网关 Protocol::out(GATEWAY_IP); # 记录行为 Com_Log::write('xgame.authreward', "{$player_id}\t" . "notice_wechat_auth_status\t" . "{$out_1903['result']}\t"); return 0; # 返回平台处理状态 }
public function update_player_vip($player_id, $level) { if ($level < 0 || $level > 10) { echo "等级错误"; return; } $objPlayer = TenYear::getInstance('Data_Player'); $objPlayer->update_player_info($player_id, array('vip' => $level)); SynPlayer::set_syn_data(array('vip' => $level)); $data = SynPlayer::get_data(); Protocol::input($player_id, 7, 4, 417, array(0 => $data['m'], 1 => $data['u'])); $out = TenYear::getInstance('Game_PlayerBag')->get_vip_bag_storage_num($player_id); Protocol::input($player_id, 8, 8, 844, $out); Protocol::out(); echo "添加成功"; }
public function do_sys_set_data($data) { if (empty($data)) { return; } $data = json_decode($data, true); Com_Log::log($data, 'like_news.log', 1); $friend_id = intval($data['friend_id']); $objlike = $this->get_data('PlayerLike'); $objfrined = $this->get_data('PlayerFriend'); $objtips = $this->get_data('NewsTips'); $objplayer = $this->get_data('Player'); $friend_basic_info = $objplayer->get_player_info($friend_id, array('vip', 'level_exp', 'name', 'like_times')); $like_max_times = $this->like_default_times; #vip点赞与被点赞总次数增加 if (intval($friend_basic_info['vip']) > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($friend_basic_info['vip'], 10069); $like_max_times = $this->like_default_times + $vip_set['max_times']; } $friend_data = $objfrined->get_player_friend($friend_id, array('like_times')); #今日点赞与被点次数 if ($friend_data['like_times']['today_times'] + $friend_data['like_times']['today_like_friend_times'] >= $like_max_times) { return false; } $friend_add_exp = $this->add_default_exp; $this->start_trans(); #被点赞今日次数增加 $friend_data['like_times']['upts'] = time(); $friend_data['like_times']['today_times'] += 1; $friend_ret = $objfrined->update_player_friend($friend_id, $friend_data); if (!$friend_ret) { return false; } #被点赞总次数增加 $friend_basic_info['like_times'] += 1; $ret_friend_basic = $objplayer->update_player_info($friend_id, $friend_basic_info); if (!$ret_friend_basic) { return false; } #被点赞奖励消息详细 $language_config = Cache_Language::getInstance()->get_language_info(71612); $content = sprintf($language_config['content'], $friend_add_exp); $content = "<FONT COLOR='#c6c6c6'> {$content}</FONT>"; $set_like_data = array('news_id' => $data['news_id'], 'player_id' => $data['player_id'], 'exp' => $friend_add_exp, 'name' => $data['name'], 'content' => $content, 'create_time' => time()); $sid = $data['news_id'] . $data['player_id']; $ret_like = $objlike->update_like_data_by_likeid($friend_id, $sid, $set_like_data); if (!$ret_like) { return false; } #被点赞奖励提醒数量更新 $set_tips_data = $objtips->get_player_newstips($friend_id, self::$_like_tips_type); $set_tips_data['num'] += 1; $ret_tips = $objtips->update_player_tips($friend_id, self::$_like_tips_type, $set_tips_data); if (!$ret_tips) { return false; } $this->commit(); #提醒被点赞数量 $objtips->push_player_tips($friend_id, self::$_like_tips_type); if (!IS_FRONT) { Protocol::out(); } return true; }
private function creat_auth_code($player_id, $vip_level) { $rand_num = intval(rand(10000000, 99999999)); if ($vip_level == 6 || $vip_level == 10) { $save_data = array(); $vip_auth = $this->get_data('VipReward')->get_vip_auth_reward($player_id); if (empty($vip_auth) || !isset($vip_auth[$vip_level])) { $save_data[$vip_level] = json_encode(array('code' => $rand_num, 'status' => 1)); if ($this->get_data('VipReward')->update_vip_auth_reward($player_id, $save_data)) { #发邮件 $this->send_mail_to_player($player_id, $vip_level); Protocol::out(); } else { return false; } } } }
/** * 预处理队列回调方法 * @param $data */ public function do_async_trigger_mail($data) { if (empty($data)) { return; } $data = json_decode($data, true); try { $this->trigger_mail($data); Protocol::out(); //输出协议 } catch (Exception $e) { echo $e->getMessage(); } }
public function trigger_random_task($player_id, $target_type, $target_id, $add_num, $arr_player_task = null) { // Com_Log::write("trigger_random_task.".$player_id,"target_type:{$target_type} target_id:{$target_id} add_num:{$add_num}"); if (is_null($arr_player_task) || !isset($arr_player_task['random_val'])) { $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id, array('random_val', 'random_refresh_time')); } $up = false; if (!empty($arr_player_task['random_val'])) { #加了个判断 foreach ($arr_player_task['random_val'] as $val) { $random_task_config = Cache_TaskRandom::getInstance()->get_task_random_info($val['task_id']); if ($random_task_config['type'] == $target_type && $target_id == $random_task_config['condition']) { $arr_player_task['random_val'][$val['task_id']]['cur_num'] += $add_num; if ($arr_player_task['random_val'][$val['task_id']]['cur_num'] >= $random_task_config['comp_times']) { $arr_player_task['random_val'][$val['task_id']]['task_status'] = 2; $arr_player_task['random_val'][$val['task_id']]['cur_num'] = $random_task_config['comp_times']; } $up = true; } } if ($up) { $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('random_val' => $arr_player_task['random_val'])); if ($result) { $data = $this->get_game('TaskRandom')->get_task_random_list($player_id, $arr_player_task); if (!IS_FRONT || defined('FROM_GATEWAY')) { $cmd0 = 8; } else { $cmd0 = 3; } // Com_Log::write("trigger_random_task.".$player_id,var_export($data,true)); Protocol::input($player_id, $cmd0, 10, 1022, $data); Protocol::out(); } } } }