private function get_redis_key($week_offset = 0) { $time = $this->current_time - $week_offset * 7 * 86400; $week_date = Com_Util::get_next_week_day($time, false); # 每周周日 $redis_key = $this->week_fame_sorted_set . "|" . $week_date; Com_Log::write('xgame.magic_parliament', "get_redis_key: time={$time}|get_reids_key:{$redis_key}"); return $redis_key; }
public function get_questionnaire_info($questionnaire_id) { if (empty($questionnaire_id)) { return false; } $sql = "select * from activity_questionnaire where questionnaire_id = {$questionnaire_id}"; $key = $this->get_cache_key(array('questionnaire_id' => $questionnaire_id), $this->prefix_activity_questionnaire_master); Com_Log::write('xgame.questionnaire', "get_start_plane:============:{$key}"); return $this->select_one($sql, $this->get_cache_key(array('questionnaire_id' => $questionnaire_id), $this->prefix_activity_questionnaire_master)); }
public function doAction() { $this->arrData = $this->_parseData; if ($this->veritySig()) { $step = $this->arrData['step']; $cmd = $this->arrData['cmd']; switch ($step) { case 1: $result = $this->award(); break; case 2: if ($cmd == "check_award") { $result = $this->check_award(); } else { if ($cmd == "award") { $result = $this->award(); } } break; case 3: $result = $this->check(); break; case 4: $result = $this->award(); break; default: $result = json_encode(array("ret" => 103, "msg" => "请求参数错误,缺少step")); break; } } else { $result = json_encode(array("ret" => 103, "msg" => "请求参数错误:签名不一致")); } //记录发放奖励的流水号 if (json_decode($result, true)['ret'] == 0) { $billno = $this->arrData['billno']; # 奖励流水号 $openid = $this->arrData['openid']; # 玩家openid $step = $this->arrData['step']; # 步骤号 $contractid = $this->arrData['contractid']; # 任务id $payitem = $this->arrData['payitem']; # 道具礼包id $cmd = $this->arrData['cmd']; $data = array("msg" => json_decode($result, true)['msg'], "zoneid" => json_decode($result, true)['zoneid'], "step" => $step, "contractid" => $contractid, "payitem" => $payitem, "cmd" => $cmd, "billno" => $billno, "time" => time()); $objTask = $this->get_game('TencentTaskMarket'); $ret = $objTask->set_tencent_bill_record($openid . ":" . $step, $data); if (!$ret) { Com_Log::write("TencentTaskMarket", "billno stored failed!" . json_encode($data)); } } echo $result; }
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)); }
/** * 更新公告 * @param int $player_id * @param array $arr_notice_detail * @return int */ public function update_system_notice($id, $arr_notice_detail) { $updateSql = "update system_notice set "; $update = array(); foreach ($arr_notice_detail as $field => $value) { if ($field == 'id') { continue; } if (is_array($value)) { $arr_notice_detail[$field] = json_encode($value); } $update[] = "{$field} = '" . ($arr_notice_detail[$field] ? $arr_notice_detail[$field] : $value) . "'"; } $updateSql = $updateSql . implode(",", $update) . " where id = {$id}"; Com_Log::debug_write('crontab_system_notice', json_encode($updateSql)); return $this->query($updateSql); }
public static function output() { if (DEBUG == 2) { foreach (self::$_log as $path => $arrLog) { $arrLog['content'] .= "===============================\n\n"; if ($arrLog['type']) { file_put_contents(self::$_path . '/' . $path, $arrLog['content'], FILE_APPEND); } else { if (!file_exists(self::$_path . '/' . $path)) { mkdir(self::$_path . '/' . $path); } file_put_contents(self::$_path . '/' . $path . '/' . date('YmdH'), $arrLog['content'], FILE_APPEND); } } self::$_log = array(); } }
/** * 发送聊天信息到37wan接口 * @param $params * @return int errno -3(接口超时),-2(签名验证错误),-1(参数错误),1(推送成功) */ public function report_msg($params) { $params = json_decode($params, true); $player_id = $params[3]; $player_info = $this->get_player_info($player_id); if ($params[0] != 0) { $dpf_player_info = $this->get_player_info($params[0]); } else { // $params[0] 为0的时候,是在世界或者公会聊天 $dpf_player_info['name'] = 'world'; } $post_data = array('game_key' => $this->game_key, 'server_id' => SERVER_ID, 'time' => $params[1], 'login_account' => $player_info['user_account'], 'actor' => $player_info['name'], 'to_login_account' => $params[0], 'to_actor' => $dpf_player_info['name'], 'content' => urlencode($params[2]), 'ip' => $player_info['client_ip']); $sign = $this->make_sign($post_data); $post_data['sign'] = $sign; $result = Com_TencentDataUpload::getInstance()->send_data($post_data, $this->api_url); echo '-------Upload data to 37wan-----status code-----' . $result; if ($result != 1) { //推送不成功,日志打印错误信息 Com_Log::write('uploadDataError', 'Upload data to 37wan failed! Errorcode' . $result); } }
protected function parser_dispatch() { $passport_key = SERVER_KEY; # 需要自行与平台约定 $timeExpire = 300; $arrData = $_REQUEST; if (empty($_REQUEST["action"]) || empty($_REQUEST["verify"])) { $this->throw_error(3, 'param lack.'); #缺少参数 } elseif (!in_array($_REQUEST["action"], $this->_actions)) { $this->throw_error(-1, 'param error.'); #参数错误 } unset($arrData['action'], $arrData["verify"]); # 不参与签名算法 ksort($arrData); $strAuth = ""; foreach ($arrData as $key => $value) { if (empty($strAuth)) { $strAuth .= $key . "=" . $value; } else { $strAuth .= "&" . $key . "=" . $value; } } $strAuth .= $passport_key; $strAuthMd5 = md5($strAuth); if ($strAuthMd5 != $_REQUEST["verify"]) { Com_Log::write('xgame.game_api', "sorted query string:\t{$strAuth}\tmd5sum:\t{$strAuthMd5}"); $this->throw_error(1, 'verify code error.'); # 校验码错误 } elseif (time() - intval($_REQUEST["timestamp"]) > $timeExpire) { $this->throw_error(2, 'request timeout.'); # 超时 } $this->_action = ucfirst($_REQUEST["action"]) . 'Action'; $this->_command = isset($_REQUEST['command']) ? $_REQUEST['command'] : 'doAction'; $this->_parseData = $arrData; # 无用的 }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $userInfo_array = json_decode($userInfo_json, true); Com_Log::write('xgame.questionnaire', json_encode($userInfo_array)); if ($userInfo_array['activity']['topic']) { foreach ($userInfo_array['activity']['topic'] as $key => $val) { $userInfo_array['activity']['topic'][$key]['topicContent'] = trim($val['topicContent']); $userInfo_array['activity']['topic'][$key]['topicOptions'] = json_decode($val['topicOptions'], true); } } $reward_info = array('base_reward' => $userInfo_array['activity']['reward'][0]['reward'], 'extra_reward' => $userInfo_array['activity']['reward'][0]['good_reward'], 'answer_reward' => $userInfo_array['activity']['reward'][0]['answer_reward']); $update_data = array('questionnaire_id' => $userInfo_array['activity']['id'], 'questionnaire_type' => $userInfo_array['activity']['questioninvType'], 'questionnaire_name' => $userInfo_array['activity']['name'], 'content' => serialize($userInfo_array['activity']['topic']), 'reward' => json_encode($reward_info), 'start_time' => $userInfo_array['activity']['questioninvStartTime'], 'stop_time' => $userInfo_array['activity']['questioninvEndTime'], 'start_level' => $userInfo_array['activity']['questioninvStartLevel'], 'end_level' => $userInfo_array['activity']['questioninvEndLevel'], 'start_vip' => $userInfo_array['activity']['questioninvStartVip'], 'end_vip' => $userInfo_array['activity']['questioninvEndVip'], 'start_charge_time' => $userInfo_array['activity']['questioninvStartPayTime'], 'end_charge_time' => $userInfo_array['activity']['questioninvEndPayTime'], 'charge_status' => $userInfo_array['activity']['activityBehavier'], 'start_word' => $userInfo_array['activity']['startMess'], 'end_word' => $userInfo_array['activity']['endMess'], 'status' => $userInfo_array['activity']['status']); foreach ($update_data as $k => $v) { $update_data[$k] = addslashes($v); } $result = $this->get_data('ActivityQuestions')->add_questionnaire($update_data); if ($result) { echo json_encode(array('status' => 1, 'data' => "success")); } else { echo json_encode(array('status' => 0, 'data' => 'fail')); } }
/** * 异常处理回调函数 */ protected function failure_callback($e) { $msg = "Mongo Exception: " . $e->getFile() . " line:" . $e->getLine() . " " . $e->getMessage(); #$msg = "Mongo Error: " . $e->getMessage(); Com_Log::write('mongo.error', $msg); }
public static function print_stack_trace($log_file_name, $endline = "\n") { $trace = debug_backtrace(); $num = 0; $ans = 'message:' . $endline . 'stact trace back :' . $endline; foreach ($trace as $line) { if ($num > 3) { break; } $ans .= '#' . $num . ' ' . $line['file'] . '[' . $line['line'] . '] '; if ($line['type'] == '->' || $line['type'] == '::') { $ans .= $line['class'] . $line['type'] . $line['function'] . '()'; } else { $ans .= $line['function'] . '()'; } if (!empty($line['args'])) { $ans .= $endline . 'parameters:' . $endline . print_r($line['args'], true); } if (!empty($line['object'])) { $ans .= $endline . 'object:' . $endline . print_r($line['object'], true); } $ans .= $endline; $num++; } if ($log_file_name == null) { return $ans; } else { Com_Log::write($log_file_name, $ans); } }
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; }
public function close() { if (!$this->_isExit) { $this->_isExit = true; //锁组件被启动 自动解锁 if (defined('LOCKRUN')) { Com_Lock::unLock(); } $this->push_cache(); $this->session_close(); $this->cache_close(); $this->db_close(); // if(IS_FRONT){ // Com_Log::log("action={$_POST['action']}|command={$_POST['command']}\ninclude files=".var_export(get_included_files(), true), 'corefile', 1); // } //DEBUG组件被启动 自动输出 if (defined('LOGRUN')) { Com_Log::output(); } if (IS_FRONT) { ob_end_flush(); } // global $scriptStartTime; // if($scriptStartTime){ // save_xhprof(); // } } }
public function payback() { $result = $this->objTencent->verityToken($this->auth, $this->script_name); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay2',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND); if ($result['ret'] != 0) { return $result; } $senddata = explode('*', $this->auth['payitem']); $goodsid = $senddata[0]; $price = (int) $senddata[1]; $num = (int) $senddata[2]; /** 所有道具 */ $payGoods = $this->objTencent->payGoods(); if (empty($payGoods[$goodsid])) { return array('ret' => 1, 'msg' => '道具不存在' . $goodsid); } /** @var is_double 是否双倍 */ //$this->is_double = (int) $payGoods[$goodsid]['double']; /** @var $is_cash 是否钻石充值 */ $this->is_cash = (int) $payGoods[$goodsid]['is_cash']; $cash = $price * $num; $this->cash = $cash; // 档次 $this->price = $price; // Token缓存 $tokenKey = $this->objTencent->tokenTable . ':pay:' . $this->player_id; $tokenField = $goodsid; $buy_info_json = $this->redis()->hash_get($tokenKey, $tokenField); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay3',$this->player_id,$this->auth,json_decode($buy_info_json,'array')),true)."\n",FILE_APPEND); $this->redis()->hash_delete($tokenKey, $tokenField); if ($buy_info_json) { $buy_info = json_decode($buy_info_json, 'array'); if ($buy_info['token'] != $this->auth['token']) { return array('ret' => 3, 'msg' => 'token不存在'); } $timeout = $this->objTencent->tokenTypes['pay']['timeout']; if (time() > $timeout + $buy_info['create_time']) { return array('ret' => 2, 'msg' => 'token已过期'); } //charge log $insertData = array('uid' => $this->player_id, 'passport' => $this->auth['openid'], 'tokentype' => 'pay', 'token' => $this->auth['token'], 'create_time' => $buy_info['create_time'], 'content' => $buy_info['url_params'], 'senddata' => $this->auth['payitem'], 'verity_time' => time()); $objPlayerCharge = $this->get_data('PlayerCharge'); $arrCharge = $objPlayerCharge->get_charge_info($this->auth['billno']); if (!empty($arrCharge)) { return array('ret' => 2, 'msg' => '订单号已经存在'); } $arrPlayer = $this->get_data('Player')->get_player_info($this->player_id, array('gold', 'level', 'vip', 'privilege_level', 'qq_blue_points')); $b_gold = $arrPlayer['gold']; #改变之前的钻石 if ($tokenField == 18) { #$this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'qq_blue_points', $cash); } else { $this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'gold', $cash); } $iGold = $cash * 10; $this->start_trans(); $result = $this->get_data('Player')->update_player_resource($this->player_id, $arrPlayer, 111, array('is_pay' => 1)); if ($result) { $after = $arrPlayer['gold']; $result = $objPlayerCharge->add_charge($this->player_id, $this->auth['billno'], $this->auth['openid'], $arrPlayer['level'], $cash, $cash, $b_gold, $after); } if ($result) { $this->commit(); Log_Charge::getInstance()->add_charge_log($this->player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $this->auth['billno'], $cash, $cash, $arrPlayer['gold'], $b_gold); $data['status'] = 0; if ($tokenField != 18) { # 充值回馈活动,蛋疼的次数埋点 $this->get_game('PlayerFunc')->sync_func_tips($this->player_id, 1260); #vip升级 $this->get_game('VipReward')->vip_upgrade($this->player_id, $cash); #新服活动 $pub_day = $this->get_data('NewServerActivity')->get_server_day(); if ($pub_day <= 7) { $this->get_game('NewServerActivity')->add_sign($this->player_id, $pub_day, $cash); } } } else { $this->rollback(); return array('ret' => 1, 'msg' => '充值失败'); } } else { return array('ret' => 1, 'msg' => '充值失败'); } ############################################################################### # 充值成功,上报数据,上报字段信息: # modifyfee是充值金额,上报单位为Q分,1Q币=100Q分 # modifycoin对应为玩家充值变化的钻石数 # totalcoin对应充值完成之后,玩家总钻石数 # level为玩家等级 $arrData = $this->auth; $platform = $arrData['platform']; $serverId = $arrData['serverid']; $openid = $arrData['openid']; $playerid = $this->player_id; $level = $arrPlayer['level']; $modifycoin = $after - $b_gold; $chargeData = array('modifyfee' => $cash * 10, 'modifycoin' => $modifycoin, 'totalcoin' => $after, 'level' => $level); Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid); if (!($res = Com_TencentDataUpload::getInstance()->recharge_data_upload($chargeData))) { Com_Log::write("uploadDataError", "recharge_data_upload failed!"); } ############################################################################### //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay4',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND); return array('ret' => 0, 'msg' => 'OK'); }
/** * 更新玩家信息 * * @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; }
public function wing_equip_swallow($type, $player_id, $player_prop_id, $swallow_equips, $onekey = 0) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); $this->param_check_numeric(array($type, $player_id), 0); if (empty($swallow_equips)) { $this->throw_error('10107'); } # 参数错误 $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'career_type')); $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key()); # 1515展示协议返回数据,1515协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充 $out_1515 = array('player_ppid' => $player_prop_id, 'swallow_ppids' => $swallow_equips, 'item_struct' => array()); $swallow_equips = explode(':', $swallow_equips); $swallow_equips = array_filter($swallow_equips); $player_prop_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id); $before_player_prop_info = $player_prop_info; if (empty($player_prop_info)) { $this->throw_error('80013'); //玩家没有该装备! } if (Com_Util::is_first_charge_item($player_prop_info['prop_id'])) { if (!empty($type)) { # 实际吞噬 $this->throw_error('81106'); # 首充装备不允许吞噬 } else { $message = array('texts' => array(array('code' => 81106, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许吞噬 $out_1515['swallow_ppids'] = ""; return $out_1515; } } # 计算吞噬属性最大等级 $swallow_lv_max = $this->get_we_swallow_lv_max($player_prop_info['vocation_limit'], $player_detail); $swallow_config_max = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($swallow_lv_max); if (empty($swallow_config_max)) { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } $player_prop_details = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, $swallow_equips); if (empty($player_prop_details)) { $this->throw_error('80024'); //未选择有效的被吞噬装备 } # 被吞噬装备信息 $before_swallow_info = empty($player_prop_info['we_swallow_info']) ? array() : $player_prop_info['we_swallow_info']; $player_prop_id_slave = ""; $item_id_slave = ""; $onekey_prop_list = array(); # 保存允许一键吞噬的装备ID列表 foreach ($swallow_equips as $pprop_id) { if (!empty($type)) { # 实际吞噬 if (empty($player_prop_details[$pprop_id])) { $this->throw_error('80013'); # 玩家没有该装备! } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $this->throw_error('81107'); # 首充装备不允许被吞噬 } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { $this->throw_error('80044'); # 装备品质未达到被吞噬要求 } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $this->throw_error('80045'); # 装备已达到最大吞噬等级 } } else { # 非实际吞噬 if (!empty($onekey)) { # 一键勾选 if (empty($player_prop_details[$pprop_id])) { continue; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { continue; } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { continue; } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { continue; } } else { # 单项勾选,单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环 if (empty($player_prop_details[$pprop_id])) { $message = array('texts' => array(array('code' => 80013, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 玩家没有该装备! break; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $message = array('texts' => array(array('code' => 81107, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许被吞噬 break; } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { $message = array('texts' => array(array('code' => 80044, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 装备品质未达到被吞噬要求 break; } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $message = array('texts' => array(array('code' => 80045, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 装备已达到最大吞噬等级 break; } } } $player_prop_id_slave .= "{$pprop_id}:"; $item_id_slave .= $player_prop_details[$pprop_id]['prop_id'] . ":"; $onekey_prop_list[] = $pprop_id; # 计算增加属性值 && 修正经验值 $add_swallow_exp = self::$swallow_quality_to_exp_map[$player_prop_details[$pprop_id]['quality']] * (1 + intval($player_prop_details[$pprop_id]['level'] / 5) / 4); if (isset($player_prop_info['we_swallow_info'])) { $player_prop_info['we_swallow_info']['swallow_exp'] += $add_swallow_exp; } else { $player_prop_info['we_swallow_info'] = array('swallow_lv' => 0, 'swallow_exp' => $add_swallow_exp, 'swallow_attr' => array()); } } # 根据吞噬属性的exp,刷新吞噬属性的lv if (!empty($player_prop_info['we_swallow_info'])) { $swallow_config = Cache_Forge::getInstance()->get_we_swallow_config_by_exp($player_prop_info['we_swallow_info']['swallow_exp']); if (!empty($swallow_config)) { $player_prop_info['we_swallow_info']['swallow_lv'] = min($swallow_config['swallow_lv'], $swallow_lv_max); # 根据最大lv,修正经验值 if ($player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $player_prop_info['we_swallow_info']['swallow_exp'] = $swallow_config_max['swallow_exp'] - 1; } } else { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } } # 根据吞噬等级,计算吞噬加成附加属性 $we_swallow_revise_info = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($player_prop_info['we_swallow_info']['swallow_lv']); if (empty($we_swallow_revise_info)) { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } foreach ($player_prop_info['addition_attr'] as $attr_key => $attr_val) { $attr_val = ceil($attr_val * $we_swallow_revise_info['attr_revise_ratio'] / 10000) + $we_swallow_revise_info[$attr_key]; $player_prop_info['we_swallow_info']['swallow_attr'][$attr_key] = $attr_val; } if (empty($type)) { # 修正被吞噬的装备列表,去除吞噬属性达到上限及之后的其它装备 $out_1515['swallow_ppids'] = empty($onekey_prop_list) ? "" : implode(":", $onekey_prop_list); $out_1515['item_struct'] = Struct_Prop::get_prop_struct($player_prop_info); if (empty($out_1515['swallow_ppids']) && !empty($onekey)) { # 没有能被吞噬的装备 $message = array('texts' => array(array('code' => 80046, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 没有可以被吞噬的装备 } return $out_1515; } $out_1516 = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => array())); $this->start_trans(); # 更新吞噬信息 $re = $this->get_data('PlayerProp')->update_player_prop($player_prop_info, array('we_swallow_info' => $player_prop_info['we_swallow_info'], 'we_swallow_version' => $this->we_swallow_version)); $this->write_check($re, 3010177); # 扣除被吞噬装备 foreach ($player_prop_details as $k => $v) { $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $v, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 1516)); $this->write_check($re, 3010182); } # 刷新玩家翅膀战力与镶嵌装备的附加属性及战力 if ($player_prop_info['item_position'] == $this->wing_pos) { $wing_attr = $player_detail['wing_info'][$player_prop_info['vocation_limit']]; # 修正缓存的翅膀装备吞噬信息 $wing_attr['equipment'][$player_prop_info['sub_type']]['we_swallow_info'] = $player_prop_info['we_swallow_info']; $wing_attr['equip_attr'] = $this->get_game('PlayerWing')->get_wing_equip_attr($wing_attr['equipment']); # 减去吞噬之前的战力 Struct_Prop::get_item_additions($before_player_prop_info); $wing_attr['fight'] -= $before_player_prop_info['fpower']; $wing_attr['equipment_fight'] -= $before_player_prop_info['fpower']; if ($wing_attr['fight'] < 0) { $wing_attr['fight'] = 0; } if ($wing_attr['equipment_fight'] < 0) { $wing_attr['equipment_fight'] = 0; } # 加上吞噬之后的战力 $player_prop_info_cp = $player_prop_info; Struct_Prop::get_item_additions($player_prop_info_cp); $wing_attr['fight'] += $player_prop_info_cp['fpower']; $wing_attr['equipment_fight'] += $player_prop_info_cp['fpower']; # 更新wing_info $player_detail['wing_info'][$player_prop_info['vocation_limit']] = $wing_attr; $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $player_detail['wing_info'])); $this->write_check($re, 3010242); #更新翅膀排行 if ($player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight'] > 0) { $wing_fight = $player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight']; $this->get_data('RankList')->update_wing_rank($player_id, $player_prop_info['vocation_limit'], $wing_fight); } } $this->commit(); # 成就相关埋 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 39, $player_prop_info['we_swallow_info']['swallow_lv'], 8); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_info['player_prop_id'], 'item_id_master' => $player_prop_info['prop_id'], 'item_type' => $player_prop_info['type'], 'item_sub_type' => $player_prop_info['sub_type'], 'item_quality' => $player_prop_info['quality'], 'item_level' => $player_prop_info['level'], 'item_star_level' => $player_prop_info['star_level'], 'player_prop_id_slave' => rtrim($player_prop_id_slave, ":"), 'item_id_slave' => rtrim($item_id_slave, ":"), 'before_swallow_info' => $before_swallow_info, 'after_swallow_info' => $player_prop_info['we_swallow_info'], 'before_swallow_lv' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_lv'], 'after_swallow_lv' => $player_prop_info['we_swallow_info']['swallow_lv'], 'before_swallow_exp' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_exp'], 'after_swallow_exp' => $player_prop_info['we_swallow_info']['swallow_exp']); Log_Forge::getInstance()->add_log($log_info, 'we_swallow'); # 通知翅膀属性变更 if ($player_prop_info['item_position'] == $this->wing_pos) { #同步翅膀属性 $str = $this->get_game('PlayerWing')->get_activation_wing_interface($player_id, $player_detail['wing_info']); Protocol_Player::p2c_part_update($player_id, array('had_on_swings' => $str, 'wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])))); } # 通知道具变更806 $ndata = array(); $ndata[] = $player_prop_info; foreach ($player_prop_details as $key => &$val) { $val['item_num'] -= 1; $out_1516[1]['grid_list'][] = $val['grid']; $ndata[] = $val; } Protocol_Prop::prop_806($player_id, $ndata); # 刷装备1506[翅膀装备强化面板]与1514[可吞噬道具列表] $out_1506 = $this->get_game('PlayerWing')->equipment_intensify_panel($player_id, 4); $out_1514 = $this->get_wing_equips_for_swallow($player_id, $player_prop_id); Protocol::input($player_id, 3, 15, 1506, $out_1506); Protocol::input($player_id, 3, 15, 1514, $out_1514); # 记录行为 Com_Log::write('xgame.forge_we_swallow', "{$player_id}\t" . "we_swallow\t" . "{$type}\t" . "{$player_prop_id}\t" . implode(",", $swallow_equips)); return $out_1516; }
public function query($str) { if (!$str || !$this->connect()) { return false; } if ($this->queryid) { $this->free(); } if ($this->trans && !$this->realTrans) { $this->start_trans(true); } $this->querystr = $str; $this->queryid = @mysql_query($this->querystr, $this->linkid); if (!$this->queryid) { $this->errstr = mysql_error(); if ($_POST['debug'] && SERVER_ID == 1 && $this->errstr) { echo '数据执行错误,请稍后重试!<br><br>'; echo '<font color="#ffffff">' . "sql: " . $this->querystr . '</font><br>'; echo '<font color="#ffffff">' . "mysql error: " . $this->errstr . '</font>'; } $error_front = IS_FRONT ? 1 : 0; $error_db = $this->database; $error_debug = ''; $error_file = $_SERVER['SCRIPT_FILENAME']; file_put_contents(LOG_PATH . '/mysqlerror.log', "[" . date("Y-m-d H:i:s") . "]errno:" . mysql_errno() . ";error:{$this->errstr};sql:{$this->querystr};File:{$error_file};Front:{$error_front};DB:{$error_db};debug:{$error_debug}\n", FILE_APPEND); if ($this->errstr == 'MySQL server has gone away') { $this->close(); if (!IS_FRONT) { Com_Log::log('MySQL server has gone away, reTry to query' . $str, 'mysqlgoneaway', 1); return $this->query($str); } } else { if (!IS_FRONT && $this->ping()) { // 后端进程则PING后再试一次 $this->queryid = mysql_query($this->querystr, $this->linkid); if ($this->queryid) { return $this->queryid; } } } return false; } return $this->queryid; }
/** * 添加多种资源 资源是指 黄金 钻石 等这些资源 * @param $player_id 用户id * @param $level 用户等级 * @param $vip_level vip等级 * @param $cmd_id cmd2 指令 * @param $data array('type',item_id,item_num,amount) 具体含义 参照 add_resource_log 里的 $item * @param $arr_consume array('price',gold,ticket,count) or array() 同 Data/Player.php update_player_resource 里的 $arr_consume * @return bool */ public function add_multi_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $data, $arr_consume = array()) { $arr_async = array(); if (Com_Array::is_arr2($data)) { foreach ($data as $param) { if ($param['item_num'] > 0) { $this->add_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $param['type'], $param['item_id'], $param['item_num'], $param['amount'], $param['front_attr'], $param['after_attr']); } $key = Cache_Currency::getInstance()->get_key($param['item_id']); if (isset($param['is_async']) && $param['is_async'] == 0) { #这时候是不推送的 做不推送的操作 具体啥操作 待定 } else { if ($param['type'] == 1) { $arr_async[$key] = $param['amount'] + $param['item_num']; } elseif ($param['type'] == 2) { $arr_async[$key] = $param['amount'] - $param['item_num']; ############################################################################### # 道具消费,上报数据 if (OPERATOR_ID == 82) { $playerData = TenYear::getInstance("Data_player")->get_player_info($player_id, array("session_id")); $arrUpload = TenYear::getInstance("Game_online")->get_session($playerData['session_id']); $platform = $arrUpload['platform']; $serverId = $arrUpload['server_id']; $openid = $arrUpload['openid']; Com_TencentDataUpload::getInstance()->init($platform, $serverId, $player_id, $openid); $arr_consume_upload = array("level" => $level, "itemid" => $data['item_id'], "itemtype" => $data['type'], "itemcnt" => $data['item_num']); if (!($res = Com_TencentDataUpload::getInstance()->consume_data_upload($arr_consume_upload))) { Com_Log::write("uploadDataError", "consume_data_upload failed!"); } } ############################################################################### } } } } else { if ($data['item_num'] > 0) { $this->add_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $data['type'], $data['item_id'], $data['item_num'], $data['amount'], $data['front_attr'], $data['after_attr']); } $key = Cache_Currency::getInstance()->get_key($data['item_id']); if (isset($data['is_async']) && $data['is_async'] == 0) { #检查否同步前端 #这时候是不推送的 做不推送的操作 具体啥操作 待定 } else { if ($data['type'] == 1) { $arr_async[$key] = $data['amount'] + $data['item_num']; } elseif ($data['type'] == 2) { $arr_async[$key] = $data['amount'] - $data['item_num']; } } } if ($arr_consume) { $params['act'] = $cmd_id; $params['level'] = $level; $params['price'] = $arr_consume['price']; $params['gold'] = $arr_consume['gold']; $params['black_gold'] = $arr_consume['ticket']; $params['count'] = $arr_consume['count']; $params['time'] = time(); Com_DataCenter::getInstance()->publish_data($player_id, 'prop', $params); } # 先注释了 if ($arr_async) { Protocol_Player::p2c_part_update($player_id, $arr_async); #同步资 } return true; }
public function CMD2_517() { $params = array(); $params['type'] = $this->_param[0]; $params['id'] = $this->_param[1]; $params['timeout'] = $this->_param[2]; $params['param1'] = $this->_param[3]; $params['param2'] = $this->_param[4]; $params['param3'] = $this->_param[5]; $params['param4'] = $this->_param[6]; $data = $this->get_game('PlayerFunc')->start_time($params); Protocol::input($this->_authuser['player_id'], 5, 4, 517, $data); if ($this->_param[0] == 755) { $this->get_game('Adlut')->do_timer($this->_param[1]); } Com_Log::write('516---send-log', json_encode($params)); }
/** * 给索尔有名字查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))); }
/** * @Purpose: * 更新玩家英雄redis,sql字段 * @Method Name: update_player_hero() * @Parameter: $player_id 玩家ID * @Parameter: $hero_id 英雄ID * @Parameter: $arr 更新字段 * @Return: 是否成功 */ public function update_player_hero($player_id, $hero_id, $arr, $all_field, $cmd = 0) { if (!is_array($all_field)) { return FALSE; } list($hero_player, $value) = explode("|", $hero_id); if ($player_id != $hero_player) { Com_Log::debug_write('hero_update', 'cmd : ' . $cmd . ' ; player_id : ' . $player_id . ' ; hero_id : ' . $hero_id); return FALSE; } $player_Key = $this->getKeys($this->keyPrefix, array('player_id' => $player_id)); $player_set_data = array(); foreach ($all_field as $key => $value) { if (isset($this->arrField[$key])) { $player_set_data[$key] = $value; } } $player_set_data = json_encode($player_set_data); $res = 0; if ($this->is_trans()) { if ($player_set_data) { $res = $this->set_redis_pre_action(null, array($this->Redis, 'hash_set'), array($player_Key, array($hero_id => $player_set_data))); } } else { if ($player_set_data) { $res = $this->Redis->hash_set($player_Key, array($hero_id => $player_set_data)); } } return $res > 0 ? TRUE : FALSE; }
/** * 恢复公会 * @param unknown $player_id * @param unknown $union_id */ public function restore_union($player_id, $union_id) { $objPlayerData = $this->get_data('Player'); $playerInfo = $objPlayerData->get_player_info($player_id, array("union_id", "name")); if (intval($playerInfo['union_id']) > 0) { $this->throw_error('170301'); //已加入过公会 } $objUnionInfoData = $this->get_data('UnionInfo'); $unionInfo = $objUnionInfoData->get_union_info($union_id); if (!$unionInfo) { $this->throw_error('170303'); //该公会未创建 } //公会成员 $unionPlayer = array(); $unionPlayer['player_id'] = $player_id; $unionPlayer['job_id'] = 1; $unionPlayer['total_dedicate'] = 0; //总贡献 $unionPlayer['rep_time'] = time(); $unionPlayer['add_time'] = time(); $unionPlayer['quit_time'] = 0; $objUnionPlayerData = $this->get_data('UnionPlayer'); $retUnionPlayerInfo = $objUnionPlayerData->update_union_player_info($union_id, $player_id, $unionPlayer); //公会人数 $unionInfo['create_player_id'] = $player_id; $unionInfo['create_player_name'] = $playerInfo["name"]; $unionInfo['player_num'] = "+1"; Com_Log::debug_write('update_union_info', "restore_union|unoin_id={$union_id}" . json_encode($unionInfo)); $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $unionInfo); $setPlayerInfo = array("union_id" => $union_id, "union_name" => $unionInfo['union_name'], "union_job" => $unionPlayer['job_id']); $retPlayerInfo = $this->get_data('Player')->update_player_info($player_id, $setPlayerInfo); if ($retUnionPlayerInfo && $retPlayerInfo && $retUnionInfo) { $this->commit(); $this->get_game('Union')->Sync_Union_msg($union_id); Protocol_Player::p2c_part_update($player_id, array('union_id' => $union_id, 'union_name' => $unionInfo['union_name'], 'union_job' => $unionPlayer['job_id'])); } else { $this->rollback(); $this->throw_error('10101'); } return array(1, $union_id); }
public function create_sql($table, $data) { $content = ''; if (Com_Array::is_arr2($data)) { $content = "insert into " . $table; $i = 0; foreach ($data as $key => $value) { $value = $this->get_pub_data($value); if ($i == 0) { $content .= "(`" . implode("`,`", array_keys($value)) . "`) values"; } $content .= "('" . implode("','", $value) . "'),"; $i++; } $content = rtrim($content, ',') . ";\n"; } else { if (is_array($data)) { $data = $this->get_pub_data($data); $content = 'insert into ' . $table . "(`" . implode("`,`", array_keys($data)) . "`) values('" . implode("','", $data) . "');\n"; Com_Log::write('game_log', $content); } } return $content; }
public function update_vip_special_info($player_id, $data) { $player_id = intval($player_id); if (!$player_id) { return false; } if (!is_array($data) || empty($data)) { return false; } $redis = $this->redis(); $hash = $this->get_adcache_key($player_id); $setData = array(); $incData = array(); foreach ($data as $key => $value) { if (is_array($value)) { $setData[$key] = json_encode($value); } else { $svalue = (string) $value; if ($svalue[0] == '+' || $svalue[0] == '-') { $incData[$key] = intval($value); } else { $setData[$key] = $value; } } } if (!empty($setData)) { $this->redis()->hash_set($hash, $setData); } if (!empty($incData)) { foreach ($incData as $field => $value) { $this->redis()->hash_incr($hash, $field, $value); } } return true; #下面的事务有问题待查 if ($this->is_trans()) { Com_Log::write("nut", '--------1'); if (!empty($setData)) { $this->redis()->hash_set($hash, $setData); } if (!empty($incData)) { foreach ($incData as $field => $value) { $this->redis()->hash_incr($hash, $field, $value); } } $arrResults = $redis->commit(); if (!empty($arrResults)) { foreach ($arrResults as $result) { if ($result === false) { return false; } } } } else { Com_Log::write("nut", '--------2'); $redis->start_trans(true); if (!empty($setData)) { #$redis->hash_set($hash, $setData); } if (!empty($incData)) { foreach ($incData as $field => $value) { #$redis->hash_incr($hash, $field, $value); } } return true; $arrResults = $redis->commit(); if (!empty($arrResults)) { foreach ($arrResults as $result) { if ($result === false) { return false; } } } } return true; }
/** * 英雄战斗力计算 * @param $player_id 玩家ID * @param $hero_attr 英雄属性 * @param $fit_level 合体等级 * @param $rune_list 符文列表 * @param $attr_per 属性百分比 * @param $skill_list 技能列表 add by chengt * @param $union_attr 公会科技 * */ public function calc_fight($player_id, $hero_attr, $fit_level, $rune_list, $attr_per, $skill_list, $union_attr = false, $remote = array(), $remote_player = array()) { $life = $hero_attr['life']; $def = $hero_attr['def']; $attack = $hero_attr['attack']; #星级属性百分比加成 $life += intval($life * ($attr_per / 10000)); $def += intval($def * ($attr_per / 10000)); $attack += intval($attack * ($attr_per / 10000)); #战斗力计算前加上潜能属性 $life += $hero_attr['potential_life']; $attack += $hero_attr['potential_attack']; $def += $hero_attr['potential_def']; #合体属性加成 $life += $hero_attr['fit_life']; $def += $hero_attr['fit_def']; $attack += $hero_attr['fit_attack']; #合体属性百分比加成 if (Com_Array::is_good_arr($hero_attr['fit_attr_per'])) { $life += intval($life * ($hero_attr['fit_attr_per']['hp_per'] / 10000)); $def += intval($def * ($hero_attr['fit_attr_per']['arm_per'] / 10000)); $attack += intval($attack * ($hero_attr['fit_attr_per']['atk_per'] / 10000)); } #技能百分比加成 $life += intval($life * ($hero_attr['skill_life'] / 100)); $def += intval($def * ($hero_attr['skill_def'] / 100)); $attack += intval($attack * ($hero_attr['skill_attack'] / 100)); #成长值百分比加成 $attr_table = $this->get_hero_attr_table($hero_attr['hero_code']); $life += intval($life * $this->calc_grow_attar($hero_attr['grow_rate'], $attr_table['grow'])); $def += intval($def * $this->calc_grow_attar($hero_attr['grow_rate'], $attr_table['grow'])); $attack += intval($attack * $this->calc_grow_attar($hero_attr['grow_rate'], $attr_table['grow'])); if ($union_attr === false) { #获取英雄公会科技属性加成 $objPlayerDetail = $this->get_data('PlayerDetail'); // if(!empty($remote_player)){ // $objPlayerDetail->set_remote($remote_player); // } $union_attr = $objPlayerDetail->get_player_detail($player_id, 'union_hero_attr'); // $objPlayerDetail->clear_remote(); // unset($objPlayerDetail); } $hero_fight = 0; #公会科技加成 if (!empty($union_attr)) { // Com_Log::write("hero_calc_fight.".$player_id,"union_attr:".var_export($union_attr,true)); $union_fight = Formula_Fpower::calc_fpower($union_attr); $hero_fight += $union_fight; // Com_Log::write("hero_calc_fight.".$player_id,"union_fight:".var_export($union_fight,true)); } if (isset($hero_attr['fit_other_attr']) && Com_Array::is_good_arr($hero_attr['fit_other_attr'])) { $hero_attr['fit_other_attr']['hp'] = $life; $hero_attr['fit_other_attr']['arm'] = $def; $hero_attr['fit_other_attr']['atk_min'] = $attack; } else { $hero_attr['fit_other_attr'] = array('hp' => $life, 'arm' => $def, 'atk_min' => $attack); } // $fit_level = $fit_level - 1 < 0 ? 0 : $fit_level - 1; // $extra_fight_ratio = 1 + ($fit_level) / 9/* + $rune_level * 0.05*/; // Com_Log::write("hero_calc_fight.".$player_id,"fit_other_attr:".var_export($hero_attr['fit_other_attr'],true)); $fit_other_fight = Formula_Fpower::calc_fpower($hero_attr['fit_other_attr']); $hero_fight += $fit_other_fight; // Com_Log::write("hero_calc_fight.".$player_id,"extra_fight_ratio:".var_export($extra_fight_ratio,true)); Com_Log::write("hero_calc_fight." . $player_id, "fit_other_fight:" . var_export($fit_other_fight, true)); // $all_fight = intval($hero_fight * $extra_fight_ratio); $all_fight = $hero_fight; $rune_list = Com_FmtData::cus_json_decode($rune_list); if (Com_Array::is_good_arr($rune_list)) { $objPlayerProp = $this->get_data('PlayerProp'); // if(!empty($remote)){ // $objPlayerProp->set_remote($remote_player); // } foreach ($rune_list as $nune_data) { if ($nune_data['state'] == 2) { $arr_prop_detail = $objPlayerProp->get_player_prop_detail($player_id, $nune_data['id']); $rune_fight = intval(Formula_SkillFpower::$hero_run[$arr_prop_detail['quality']]); $all_fight += $rune_fight; // Com_Log::write("hero_calc_fight.".$player_id,"rune_fight:".var_export($rune_fight,true)); } } // $objPlayerProp->clear_remote(); // unset($objPlayerProp); } if ($skill_list) { if (is_string($skill_list)) { $skill_list = json_decode($skill_list, true); } foreach ($skill_list as $val) { if ($val['state'] > 0) { $skill_fight = intval(Formula_SkillFpower::$hero_skill[$val['lvl']]); $all_fight += $skill_fight; // Com_Log::write("hero_calc_fight.".$player_id,"skill_fight:".var_export($skill_fight,true)); } } } return $all_fight; }
/** * @Purpose: * 开启公会活动 * @Param $player_id 玩家ID * @Param $activities_id 活动ID */ public function open_activities($player_id, $activities_id) { $player_id = intval($player_id); #获取玩家公会ID,验证公会信息 $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id'); if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } $activities_id = intval($activities_id); #获取公会活动配置表 $activities_table = $this->get_cache_table_data('activities_table', array('activities_id' => $activities_id)); if (!$activities_table) { $this->throw_error('10109'); //配置表读取错误 } #获取公会等级 $union_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'union_level'); if (empty($union_level) || $union_level < $activities_table['union_level']) { $this->throw_error('1752007'); #公会等级不足 } #获取玩家公会职务 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $job = $player_data['job_id']; #获取公会活动天数据 $uad_data = $this->get_data('UnionActivities')->get_union_activities_daily_info($union_id, 'uad', 'day'); if ($uad_data['activities_info'] && !is_array($uad_data['activities_info'])) { $uad_data['activities_info'] = json_decode($uad_data['activities_info'], true); } if ($uad_data['open_times'] && !is_array($uad_data['open_times'])) { $uad_data['open_times'] = json_decode($uad_data['open_times'], true); } #获取公会资金 $union_coin = $this->get_data('UnionInfo')->get_union_info($union_id, 'fund'); if ($activities_table['expend_coin'] > $union_coin) { $this->throw_error('1752002'); #公会资金不足 } $activities_table['open_job'] = explode("|", $activities_table['open_job']); $is_open_job = false; if (Com_Array::is_good_arr($activities_table['open_job'])) { if (in_array($job, $activities_table['open_job'])) { $is_open_job = true; } } if (isset($uad_data['activities_info'][$activities_id]['state']) && $uad_data['activities_info'][$activities_id]['state'] != 0 || $activities_table['open_way'] != 1 || !$is_open_job || $uad_data['open_times'][$activities_id] >= $activities_table['open_times']) { $this->throw_error('1752001'); #不能开启活动 } #开启活动 $time = time(); $uad_data['activities_info'][$activities_id]['fb_id'] = $activities_table['fb_id']; $uad_data['activities_info'][$activities_id]['activities_type'] = $activities_table['activities_type']; $uad_data['activities_info'][$activities_id]['state'] = 1; $uad_data['activities_info'][$activities_id]['open_time'] = $time; $uad_data['activities_info'][$activities_id]['close_time'] = $time + $activities_table['activities_time']; $update_uad['activities_info'] = json_encode($uad_data['activities_info']); $uad_data['open_times'][$activities_id]++; $update_uad['open_times'] = json_encode($uad_data['open_times']); if ($activities_table['expend_coin']) { #$update_field['fund'] = $union_coin - $activities_table['expend_coin']; $update_field['fund'] = "-" . $activities_table['expend_coin']; } $this->start_trans(); #更新活动天数据 $this->get_data('UnionActivities')->update_union_activities_daily_data($union_id, 'uad', $update_uad); #更新公会资金 if ($activities_table['expend_coin']) { Com_Log::debug_write('update_union_info', "UnionActivities|unoin_id={$union_id}" . json_encode($update_field)); $update_res = $this->get_data('UnionInfo')->update_union_info($union_id, $update_field); if (!$update_res) { $this->throw_error('10104'); } } $this->commit(); #同步活动数据到C++ $this->get_game('Union')->Sync_Union_msg($union_id, $activities_table['activities_type']); if ($uad_data['activities_info'][$activities_id]['activities_type'] == 1) { #公会任务触发 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 9091); #更新公会成就任务 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 13, 1, 1); } else { if ($uad_data['activities_info'][$activities_id]['activities_type'] == 2) { #公会任务触发 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9092_2'); } } #公告发2遍 for ($times = 0; $times < 2; $times++) { #通知c++在聊天窗口显示活动开启通知 $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'career_type')); $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id, 'underLine' => 1, 'rep_color' => "fff100"); $arr_replace[] = array('rep_type' => 9, 'txt' => '#1', 'rep_val' => 176, 'rep_param' => array(intval($uad_data['activities_info'][$activities_id]['activities_type'])), 'underLine' => 1, 'rep_color' => "cd4040"); $msg = Language_Message::make_message($activities_table['code'], $arr_replace, 0, '', true); $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, '7,9', 7, 1, 0, 1, $player_info['career_type']); } $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id, 'underLine' => 1, 'rep_color' => "fff100"); $arr_replace[] = array('rep_type' => 7, 'txt' => ''); $msg = Language_Message::make_message($activities_table['code'], $arr_replace); $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 2, 7); #增加公会记录 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $activities_table['expend_coin'], 'rep_color' => "ffb901"); $arr_replace[] = array('rep_type' => 7, 'txt' => $activities_table['activities_name'], 'rep_color' => "ffb901"); $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, 1752005, $arr_replace); }
/** * 如果玩家没有出序章 在遇到C++服务器重启的时候 重置这写玩家的任务 */ public function reset_task() { Com_Log::write('x_reset', "=============================[start]========================="); $keys = Com_AdCache::factory('player')->keys("data|player:*"); if (!empty($keys)) { $syndata['city_id'] = 2100; $syndata['city_x'] = 3382; $syndata['city_y'] = 3538; $role_init_data = array(); foreach ($keys as $key) { $player_info = Com_AdCache::factory('player')->hash_get($key, array('player_id', 'level', 'vip', 'map_id', 'career_type')); // if($player_info['player_id'] != 980564) continue; if ($player_info['level'] >= 10) { continue; } Com_Log::write('x_reset', "player_id:{$player_info['player_id']}"); if (!isset($role_init_data[$player_info['career_type']]) && empty($role_init_data[$player_info['career_type']])) { $role_init_data[$player_info['career_type']] = Cache_RoleAttrInit::getInstance()->get_role_attr_init($player_info['career_type']); } if ($player_info['map_id'] == 2100 && $player_info['level'] < 10) { $this->init_set_task($player_info['player_id'], explode(":", $role_init_data[$player_info['career_type']]['default_task_id'])); // $this->get_data('PlayerTaskLog')->del_player_task_log($player_info['player_id']); $syndata['level'] = 1; $level_exp = Cache_RoleExp::getInstance()->get_role_exp(1); $syndata['level_exp'] = intval($level_exp['need_exp']); $syndata['exp'] = 0; $this->get_data('Player')->update_player_info($player_info['player_id'], $syndata); $update_fields = $this->get_game('PlayerSkill')->extend_set($player_info['player_id'], $player_info['career_type'], 1, false); $update_fields['guide'] = ''; try { $update_fields['wing_info'] = $this->get_game('PlayerWing')->create_player_wing($player_info['player_id'], false); $update_fields['equip_wing'] = 0; } catch (Exception $e) { Com_Log::write('reset_del', "del wing error ##" . var_export($e, true)); } $this->get_data('PlayerDetail')->update_player_detail($player_info['player_id'], $update_fields); try { $this->get_game('Fairy')->set_fairy_state_interface($player_info['player_id']); } catch (Exception $e) { Com_Log::write('reset_del', "del fairy error ##" . var_export($e, true)); } $props = $this->get_data('PlayerProp')->get_player_all_prop($player_info['player_id']); if ($props) { foreach ($props as $ppid => $val) { Com_Log::write('reset_del', "del prop player_id:{$player_info['player_id']} ##" . var_export($val, true)); $result = $this->get_data('PlayerProp')->delete_player_prop($player_info['player_id'], $val, true, array('cmd_id' => 107, 'level' => $player_info['level'], 'vip' => $player_info['vip'])); if (!$result) { Com_Log::write('reset_del', "del prop error ##" . var_export($val, true)); } } } } } } Com_Log::write('x_reset', "=============================[end]========================="); }
/** * 夺宝战斗结果 * @param unknown $player_id * @param unknown $battle_seq * @param unknown $winner_player_id * @param unknown $loser_player_id */ public function battle_result($player_id, $battle_seq, $winner_player_id, $loser_player_id) { $battle_seq = intval($battle_seq); $winner_player_id = intval($winner_player_id); $loser_player_id = intval($loser_player_id); $this->start_trans(); $grab_fail_award = ""; $get_piece_id = ""; $battle_result = 0; $grab_result = 0; $opponent_player_id = $winner_player_id; $phrase_id = 0; $player_info = array(); $opponent_player_info = array(); if ($winner_player_id == 0 && $loser_player_id == 0) { $battle_id_info = $this->get_data("GrabTreasure")->get_battle_id_info($battle_seq); $player_id = $battle_id_info['player_id']; $opponent_player_id = $battle_id_info['opponent_player_id']; $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); if (empty($opponent_player_info)) { $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); } Com_Log::debug_write('async_trigger_battle_test', "player_id={$player_id},{$player_info['sum_fpower']}={$opponent_player_info['sum_fpower']}"); if ($player_info['sum_fpower'] > $opponent_player_info['sum_fpower']) { $winner_player_id = $player_id; $loser_player_id = $opponent_player_id; $phrase_id = 16; } else { $winner_player_id = $opponent_player_id; $loser_player_id = $player_id; $phrase_id = 17; } } if ($player_id == $winner_player_id) { $battle_result = 1; $opponent_player_id = $loser_player_id; if (empty($opponent_player_info) || empty($player_info)) { $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); if (empty($opponent_player_info)) { $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); } } #抢碎片成功概率 $rate_config = $this->get_battle_success_rate($player_info, $opponent_player_info); $random_get_piece_result = Com_Random::probability($rate_config['success_rate'], 100); #新手引导成功率100% $player_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($player_id, array("battle_log_id", "battle_need_piece_id", "battle_piece_quality", "quality_piece_ids", "is_guide")); if (intval($player_treasure_info["is_guide"]) == 1) { $random_get_piece_result = true; } $player_treasure_info["is_guide"] = 0; #抢碎片成功 if ($random_get_piece_result) { $grab_result = 1; $quality = $player_treasure_info["battle_piece_quality"]; $need_piece_id = $player_treasure_info["battle_need_piece_id"]; #挑战成功加碎片 $player_treasure_info["quality_piece_ids"][$quality][$need_piece_id] = $need_piece_id; #真实玩家 if ($opponent_player_info['is_dummy'] == 0) { $grab_piece_id = $need_piece_id; $opponent_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($opponent_player_id, array("quality_piece_ids")); #碎片存在 if (isset($opponent_treasure_info["quality_piece_ids"][$quality]) && !empty($opponent_treasure_info["quality_piece_ids"][$quality])) { if (isset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id])) { unset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id]); } else { $grab_piece_id = array_shift($opponent_treasure_info["quality_piece_ids"][$quality]); } #被抢者扣碎片 $re = $this->get_cross("GrabTreasure")->update_grab_treasure($opponent_player_id, $opponent_treasure_info); $this->write_check($re, 5010859); #抢者加碎片 $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info); $this->write_check($re, 5010867); #解除战斗中锁 $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id); $this->write_check($re, 5010862); #抢碎片日志 #{0}抢走了你的{1},简直不能忍! $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($grab_piece_id); $arr_replace = array(array('rep_type' => 0, 'rep_val' => $player_id, 'txt' => $player_info['name']), array('rep_type' => 7, 'txt' => $pieceConfig['name'])); $msg = Language_Message::make_message(123001, $arr_replace); $add_log["player_id"] = $opponent_player_id; $add_log["grab_player_id"] = $player_id; $add_log["grab_piece_id"] = $grab_piece_id; $add_log["quality"] = $quality; $add_log["add_time"] = time(); $add_log['rep_content'] = $msg; $add_log["is_allow_grab"] = 1; $re = $this->get_cross("GrabTreasureLog")->add_grab_treasure_log($battle_seq, $add_log); $this->write_check($re, 5010876); } else { $grab_result = 0; } } else { $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info); $this->write_check($re, 5010992); } if (intval($player_treasure_info['battle_log_id']) > 0) { $data = $this->get_cross('GrabTreasureLog')->get_grab_treasure_log($player_id, $player_treasure_info['battle_log_id']); if (!empty($data)) { $data['is_allow_grab'] = 0; $re = $this->get_cross('GrabTreasureLog')->update_grab_treasure_info($player_id, $player_treasure_info['battle_log_id'], $data); $this->write_check($re, 5010983); } } } if ($grab_result == 0) { $need_piece_id = ''; $grab_fail_award = $rate_config['fail_award']; $reward = $this->get_format_reward($grab_fail_award); if ($phrase_id > 0) { $attachment = array(); foreach ($reward as $prop) { $attachment[] = array("prop_id" => $prop['item_id'], "prop_num" => $prop['item_num']); } $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id); $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 1230); } else { $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '1230'), 1); if ($re !== true) { $this->write_check($re, 5011077); } } } } $is_battle_lock = $this->get_cross("GrabTreasure")->get_battle_lock($opponent_player_id); if ($is_battle_lock) { $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id); $this->write_check($re, 5010872); } $this->commit(); if ($battle_result == 1 && $grab_result == 0 && $phrase_id == 0) { $this->get_game('Reward')->add_reward_log(); } if ($battle_result == 0 && $phrase_id > 0) { $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id); $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1); } #抢碎片增加日志 if ($grab_result == 1) { if ($opponent_player_info['is_dummy'] == 0) { Log_Common::getInstance()->add_prop_log($opponent_player_id, $opponent_player_info['level'], $opponent_player_info['vip'], $opponent_player_info['privilege_level'], 1231, 11, 0, $grab_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0); } $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($need_piece_id); Log_Common::getInstance()->add_prop_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], 1231, 10, 0, $need_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0); if ($phrase_id > 0) { $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(18); $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1); } } $out = array('battle_result' => $battle_result, 'grab_result' => $grab_result, 'get_piece_id' => $need_piece_id, 'grab_fail_award' => $grab_fail_award); $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1040); #日常任务埋点 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 119, 119, 1); Protocol::input($player_id, 8, 12, 1230, $out); }
public function get_daily_task_step_type_list($player_level, $number) { if ($number <= 0) { return false; } # 首先确定等级区间 $min_level = 0; $sql = "select distinct min_level from task_daily_cond order by min_level desc"; $records = $this->select_all($sql, $this->get_cache_key(array('task_daily_cond' => 1, 'sort' => 'desc'), $this->prefix_task_daily_cond)); foreach ($records as $record) { if ($player_level >= $record['min_level']) { $min_level = $record['min_level']; break; } } #$sql = "select * from task_daily_cond where min_level <= $player_level and max_level >= $player_level"; $sql = "select * from task_daily_cond where min_level = {$min_level}"; $type_list = $this->select_all($sql, $this->get_cache_key(array('min_level' => $min_level), $this->prefix_task_daily_cond)); # 列表结构转为哈希结构,为了使用哈希结构方便判断某种任务类型是否允许重复 $type_hash = array(); $type_weight_hash = array(); # 任务权重哈希,随机取task_step_type用 $task_flag_hash = array(); # 记录每一类task_flag,用来随机一个 foreach ($type_list as $index => $type_info) { $type_hash[$type_info['task_step_type']] = $type_info; if (empty($type_info['task_flag'])) { $type_weight_hash[$type_info['task_step_type']] = $type_info['rand_weight']; } else { $task_flag_hash[$type_info['task_flag']][$type_info['task_step_type']] = $type_info['rand_weight']; } } $rand_type_list = array(); # 随机的类型列表 # -------------------------------------------------------------------- # 先从非空task_flag下,每类task_flag选一个 # -------------------------------------------------------------------- if (!empty($task_flag_hash)) { foreach ($task_flag_hash as $tf => $ti) { $rand_type = Com_Random::get_probability_key($ti); $rand_type_list[] = $rand_type; } } # -------------------------------------------------------------------- # 再从为空task_flag下,按权重随机缺少的个数 # -------------------------------------------------------------------- $need_number = $number - count($rand_type_list); if ($need_number <= 0) { $rand_type_list = array_slice($rand_type_list, 0, $number); } else { $i = 1; while ($i++ <= $need_number) { $rand_type = Com_Random::get_probability_key($type_weight_hash); if (empty($type_hash[$rand_type]['allow_repeat'])) { # 该类型不允许重复 unset($type_weight_hash[$rand_type]); # 去重 } if (!empty($rand_type)) { # 当$type_weight_hash消耗完时,会返回false $rand_type_list[] = $rand_type; } } } $real_number = count($rand_type_list); # 实际包含的类型计数 # 对于偶发性的刷新到很多同类型的任务的问题添加调试日志 Com_Log::write('xgame.debug', "Daily task debug in " . __CLASS__ . ":\t{$player_level}\t{$number}\t{$real_number}\t" . json_encode($task_flag_hash) . "\t" . json_encode($type_weight_hash) . "\t" . json_encode($rand_type_list)); return array($rand_type_list, $real_number); }
public function compose($player_id, $target_id, $comp_type, $comp_sub_type, $auto_buy, $onekey) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); # 参数校验,comp_sub_type允许为0 $this->param_check_numeric(array($player_id, $target_id, $comp_type, $comp_sub_type), 0); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level'))); # 一键合成不允许自动购买 if ($onekey) { $auto_buy = 0; } # 获取具体合成信息 $comp_info = Cache_ItemCompose::getInstance()->get_item_compose_info_by_target_id($target_id); if (empty($comp_info)) { $this->throw_error('90002'); # 没有配置该道具的合成信息 } $comp_type = $comp_info['comp_type']; $comp_sub_type = $comp_info['comp_sub_type']; /** 由于前端问题,传参此处可能报异常,反正这两个参数不实用,故忽略 if ($comp_info['comp_type'] != $comp_type || $comp_info['comp_sub_type'] != $comp_sub_type) { $this->throw_error('90003'); # 合成参数异常 } **/ # 检查消耗情况 $cost_material_info_hash = array(); # 消耗材料信息哈希,为了方便一次性查找所有消耗材料的持有数 for ($i = 1; $i <= 5; $i++) { if (!empty($comp_info['m' . $i . '_id']) && !empty($comp_info['m' . $i . '_amount'])) { $cost_material_info_hash[$comp_info['m' . $i . '_id']] = $comp_info['m' . $i . '_amount']; } } # -------------------------------------------------------------------- # 计算可一键合成的产物数量 # -------------------------------------------------------------------- $onekey_num_list = array(); # 每项材料可以满足合成条件几次 if (!empty($cost_material_info_hash)) { $material_hold_nums = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, array_keys($cost_material_info_hash)); foreach ($cost_material_info_hash as $m_id => $m_amount) { $onekey_num_list[$m_id] = intval($material_hold_nums[$m_id] / $m_amount); } } $onekey_num = min($onekey_num_list); # 木桶原理,能一键合成的产物数由最少材料项决定 if ($onekey) { if (empty($onekey_num)) { $this->throw_error('90004'); # 合成所需材料不足 } $onekey_num = min($onekey_num, intval($player_info['silver'] / $comp_info['cost'])); # 木桶原理,能一键合成的产物数还由玩家持有货币决定 if (empty($onekey_num)) { $this->throw_error('10113'); # 金币不足 } } else { if (empty($onekey_num) && empty($auto_buy)) { $this->throw_error('90004'); # 合成所需材料不足 } $onekey_num = 1; # 非一键合成一次只允许合成一件 } $this->start_trans(); # 消耗虚拟货币 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $comp_info['cost'] * $onekey_num, 1, 1); # 消耗材料 $arr_logs = array(); $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2202); foreach ($cost_material_info_hash as $m_id => $m_amount) { $hold_num = !empty($material_hold_nums[$m_id]) ? $material_hold_nums[$m_id] : 0; if (!empty($auto_buy) && $hold_num < $m_amount) { # 一定是单次合成 # 获取正确的单价 $price_info = $this->get_game('Shop')->shortcut_purchase_interface($m_id, 1); if (empty($price_info['item_price'])) { $this->throw_error('130001'); # 商城没有出售该道具 } # 策划价格配置多项时,选其中一项 list($cur_idx, $cur_val) = each($price_info['item_price']); $price = $cur_val; $cost_currency_key = Cache_Currency::getInstance()->get_key($cur_idx); $cost_currency_value = intval($cur_val * ($m_amount - $hold_num)); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cur_idx); if ($hold_num > 0) { # 该方法在道具不足时会报错,无需外层再判断是否道具足够 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $material_hold_nums[$m_id], $arr_logs, 0, $log_param); $this->write_check($re, 3010156); } # 若有购买缺少材料,记录虚假商城购买日志 if ($cost_currency_value > 0) { $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $m_id, intval($m_amount - $hold_num), $cur_idx, $cost_currency_value, 2202); } } else { # 可能单次,可能一键 # 该方法在道具不足时会报错,无需外层再判断是否道具足够 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $m_amount * $onekey_num, $arr_logs, 0, $log_param); $this->write_check($re, 3010161); } } # TODO: 数据中心推送 $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2202'); $this->write_check($re, 3010167); #--------------------------------------------------------------------- # 按概率计算成功次数 #--------------------------------------------------------------------- $success_num = 0; for ($i = 1; $i <= $onekey_num; $i++) { if (Com_Random::probability($comp_info['succ_rate'], 10000)) { # 成功 $success_num += 1; } } if ($success_num) { # 成功 # 发送道具 $reward[] = array('type' => 'prop', 'item_id' => $target_id, 'item_num' => $success_num); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 2202)); #send_reward失败时,会返回各种失败情况的错误码 $this->write_check_strict($re, 3010173); } # 记录合成日志 $this->commit(); # -------------------------------------------------------------------- # 通知道具变更,粘包806 # -------------------------------------------------------------------- $this->get_game('Reward')->add_reward_log(); # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志 if (!empty($arr_logs) && is_array($arr_logs)) { $ndata = array(); foreach ($arr_logs as $key => $val) { $ndata[] = $val; } Protocol_Prop::prop_806($player_id, $ndata); } # -------------------------------------------------------------------- # 刷新2201协议 # -------------------------------------------------------------------- $data_2201 = $this->get_compose_info($player_id, $comp_type, $comp_sub_type); Protocol::input($player_id, 3, 22, 2201, $data_2201); # 记录行为 Com_Log::write('xgame.compose', "{$player_id}\t" . "{$target_id}\t" . "{$auto_buy}\t" . "{$onekey}\t" . "{$onekey_num}\t" . "{$success_num}\t"); # 日常任务埋点,宝石合成才触发,考虑宝石种类可能包含多种,不方便使用$arr_logs[0]['type'] == 3 && $arr_logs[0]['sub_type'] == 6类似条件 #if ($comp_type == $this->comp_type_for_gem) { # 改为任意合成都算 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 109, 109, $onekey_num); #} #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 12, $onekey_num); # -------------------------------------------------------------------- # 公告 # -------------------------------------------------------------------- $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 70), array('rep_type' => 2, 'rep_val' => $target_id)); $prop_info = Cache_Prop::getInstance()->get_prop_info($target_id); $this->get_game('SystemNotice')->push_sys_notice($player_id, 70, 0, $replace_info, 0, $prop_info['need_broad_cast']); $out_2202 = array('result' => 1); return $out_2202; }