|
@@ -113,640 +113,638 @@ class PVPProc {
|
|
|
|
|
|
//
|
|
|
// <editor-fold defaultstate="collapsed" desc=" 旧版PVP 681x ">
|
|
|
-
|
|
|
- /**
|
|
|
- * 查找对手数量
|
|
|
- */
|
|
|
- const matchCount = 5;
|
|
|
-
|
|
|
- /**
|
|
|
- * [6810] pvp 拉取主界面信息
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- static function pvpMainInfo($req) {
|
|
|
- $mem = gMem();
|
|
|
- $uid = $req->uid;
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $pvp = new UserPVPModel($req->userInfo->game->pvp); # 设计玩家pvp数据结构
|
|
|
- $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分总榜
|
|
|
- $key_last = MemKey_GameRun::Game_PVPScoreByZone_zset_lastWeek($zoneid); # 上周积分榜
|
|
|
- $score = self::_getScore_by_uid($req, $uid); # 取玩家当前pvp积分
|
|
|
- $tsLastWeek = TimeUtil::tsWeek() - 1;
|
|
|
- $lastWeekScore = $mem->zscore($key_last, $uid);
|
|
|
- if (!in_array($tsLastWeek, $pvp->weeklyRewardRecords) # 尚未发放上周奖励
|
|
|
- && $lastWeekScore) { # 并且上周活跃
|
|
|
- $pvp->weeklyRewardRecords[] = $tsLastWeek; # 添加发奖记录
|
|
|
- $leagueid = self::GetLeagueByScore($lastWeekScore); # 上周积分所处阶段
|
|
|
- EmailProc::SendPvpLeagueReward($zoneid, $uid, $leagueid); # 阶段奖励
|
|
|
- $pvp->clearWeekData(); # 每周清理胜率数据
|
|
|
- $pvp->curMatches = self::getNewMatches($pvp, $mem, $uid, $zoneid); # 更新对手列表
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
- UserProc::updateUserInfo();
|
|
|
- }
|
|
|
- self::sendLastRankReward($req); # 发放每周上榜人员奖励
|
|
|
- self::UpdateChanlianInfo($req); # 更新蝉联数据(并发奖)
|
|
|
- $pvp->score = $score; # 插入score数据
|
|
|
- $rank = $mem->zrevrank($key, $uid); # 提取总榜排行信息
|
|
|
- $pvp->rank = (is_null($rank) ? -1 : $rank + 1);
|
|
|
- return Resp::ok($pvp); # 返回pvp数据
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param Req $req
|
|
|
- * @param type $uid
|
|
|
- */
|
|
|
- static function _getScore_by_uid($req, $uid) {
|
|
|
- if ("" == $uid) {
|
|
|
- CLog::err('"uid" is Null!');
|
|
|
- return 10;
|
|
|
- }
|
|
|
- $mem = $req->mem;
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分榜
|
|
|
- $score = $mem->zscore($key, $uid);
|
|
|
- if (!$score || $score <= 0) { # 分数异常
|
|
|
- $leagueScore = GameConfig::pvp_leaguescore_getItem(1); # 新手基础分
|
|
|
- $score = $leagueScore->minScore;
|
|
|
- $mem->zadd($key, array($uid => $score)); # 更新玩家积分
|
|
|
- $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score));
|
|
|
- }
|
|
|
- return $score;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param Req $req
|
|
|
- * @param type $uid
|
|
|
- * @param type $addValue Description
|
|
|
- */
|
|
|
- private static function _addScore_by_uid($req, $uid, $addValue) {
|
|
|
- if ($addValue <= 0) { # 防御
|
|
|
- return;
|
|
|
- }
|
|
|
- $mem = $req->mem;
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分榜
|
|
|
- $score = $mem->zscore($key, $uid);
|
|
|
- if (!$score || $score <= 0) { # 分数异常
|
|
|
- $leagueScore = GameConfig::pvp_leaguescore_getItem(1); # 新手基础分
|
|
|
- $score = $leagueScore->minScore;
|
|
|
- $mem->zadd($key, array($uid => $score)); # 重置玩家积分
|
|
|
- }
|
|
|
- $newscore = $mem->zincrby($key, $uid, $addValue); # 返回最新值
|
|
|
- $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $newscore));
|
|
|
- return $newscore;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param type $req
|
|
|
- * @param type $uid
|
|
|
- * @param type $subValue
|
|
|
- */
|
|
|
- private static function _subScore_by_uid($req, $uid, $subValue) {
|
|
|
- if ($subValue >= 0) { # 防御异常数值
|
|
|
- return;
|
|
|
- }
|
|
|
- $mem = $req->mem;
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分榜
|
|
|
- $score = $mem->zscore($key, $uid);
|
|
|
- $leagueScore = GameConfig::pvp_leaguescore_getItem(1); # 新手基础分
|
|
|
- if (!$score || $score <= 0 #
|
|
|
- || ($score + $subValue) <= $leagueScore->minScore) { # 分数异常
|
|
|
- $score = $leagueScore->minScore; # 新手基础分
|
|
|
- $mem->zadd($key, array($uid => $score)); # 重置玩家积分
|
|
|
- } else {
|
|
|
- $score = $mem->zincrby($key, $uid, $subValue); # 扣除积分并返回最新值
|
|
|
- }
|
|
|
- $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score)); # 同步记录
|
|
|
- return $score;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 发送上周上榜奖励
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- public static function sendLastRankReward($req) {
|
|
|
- $mem = gMem();
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $tsweek = TimeUtil::tsWeek();
|
|
|
- $key = MemKey_GameRun::Game_PVPRankRewardRecord_set($zoneid);
|
|
|
- if (!$mem->sismember($key, $tsweek)) { # 上周榜单尚未处理, 每周只处理一次
|
|
|
- // 上周是空的情况.
|
|
|
- $lastKey = MemKey_GameRun::Game_PVPRankRewardRecord_byWeek_str($zoneid, $tsweek - 1);
|
|
|
- $mem->sadd($key, $tsweek); # 添加处理记录
|
|
|
- $key_total = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 拉取上榜人员
|
|
|
- $uids = $mem->zrevrange($key_total, 0, 99);
|
|
|
- $rank = 0;
|
|
|
- foreach ($uids as $uid) {
|
|
|
- EmailProc::SendPvpRankReward($zoneid, $uid, ++$rank); # 发送奖励邮件
|
|
|
- }
|
|
|
- $mem->add($lastKey, $uids);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * [6819] pvp - 拉取蝉联信息
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- static function getChanlianINfo($req) {
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $key = MemKey_GameRun::Game_PVP_Chanlian_normal($zoneid);
|
|
|
- $pvpChanlian = new GamePvpChanlian(gMem()->get($key));
|
|
|
- $pvpHistory = gMem()->hgetall(MemKey_GameRun::Game_PVP_Chanlian_History_hash($zoneid));
|
|
|
- return Resp::ok(array(
|
|
|
- 'info' => $pvpChanlian,
|
|
|
- 'history' => array_values((array) $pvpHistory)
|
|
|
- ));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * [6811] pvp 挑战对手xx
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- static function pvp_PK($req) {
|
|
|
- $uid = $req->uid;
|
|
|
- $target_uid = $req->paras[0]; # 对手id
|
|
|
- $result = $req->paras[1]; # 胜负结果 0负,1胜
|
|
|
- $pvp = $req->userInfo->game->pvp;
|
|
|
- if (!property_exists($pvp->curMatches, $target_uid)//
|
|
|
- or property_exists($pvp->curMatches->$target_uid, 'killed')) { # 对手已被ko
|
|
|
- return Resp::err(ErrCode::pvp_wrongMather);
|
|
|
- }
|
|
|
- $g = glc();
|
|
|
- if (now() - $pvp->tiliTs > $g->PVP_reCover_Tili_costSec * 5) { # 检查并扣除体力
|
|
|
- $pvp->tiliTs = now() - $g->PVP_reCover_Tili_costSec * 5;
|
|
|
- }
|
|
|
- if ($pvp->tiliExtra > 0) { # 优先扣除溢出值
|
|
|
- $pvp->tiliExtra--;
|
|
|
- } else {
|
|
|
- $pvp->tiliTs += $g->PVP_reCover_Tili_costSec;
|
|
|
- if ($pvp->tiliTs > now()) {
|
|
|
- return Resp::err(ErrCode::pvp_wrongtili);
|
|
|
- }
|
|
|
- }
|
|
|
-# 发放对应奖励并记录挑战记录
|
|
|
- $score = 0;
|
|
|
- if ($result) { # 1 胜, 奖金币、积分、pvp币
|
|
|
- UserGameModel::Add_Gold($req->userInfo->game, $g->PVP_PK_Win_Gold);
|
|
|
- # × 奖励积分的公式: 获胜基础奖励积分 + 积分差距修正系数 * 积分差
|
|
|
- # 挑战胜利, 积分改为固定值.
|
|
|
- $winnerGainScore = $g->PVP_PK_Win_Score; # 本局得分
|
|
|
- $score = self::_addScore_by_uid($req, $uid, intval($winnerGainScore)); # 增加积分
|
|
|
- $pvp->pvpCoins += $g->PVP_PK_Win_PvpCoin; # 发放金币
|
|
|
- self::_subScore_by_uid($req, $target_uid, -intval($g->PVP_PK_be_defeated_score)); # 给对手扣除积分
|
|
|
- $pvp->contWin++; # 连胜记录
|
|
|
- $pvp->winTimes++; # 获胜记录
|
|
|
- $all = true; # 全部战胜标记
|
|
|
- foreach ($pvp->curMatches as $pid => &$p) {
|
|
|
- if ($pid == $target_uid) { #
|
|
|
- $p->killed = 1; # 添加ko标志
|
|
|
- if (property_exists($p, 'fog')) {
|
|
|
- $score = self::_addScore_by_uid($req, $uid, intval($winnerGainScore)); # 神秘对手, 积分翻倍(再加一遍)
|
|
|
- }
|
|
|
- }
|
|
|
- if (!property_exists($p, 'killed')) {
|
|
|
- $all = false; # 尚未全部战胜
|
|
|
- }
|
|
|
- }
|
|
|
- if ($all) { # 全部战胜之后,刷新对手
|
|
|
- $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
|
|
|
- $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
|
|
|
- }
|
|
|
- } else { # 0 挑战失败 只扣除积分
|
|
|
- # × 奖励积分的公式: 获胜基础奖励积分 + 积分差距修正系数 * 积分差
|
|
|
- # 挑战失败, 扣除固定积分
|
|
|
- $loserGainScore = $g->PVP_PK_Fail_Score;
|
|
|
- $score = self::_subScore_by_uid($req, $uid, -intval($loserGainScore)); # 扣除积分
|
|
|
- self::_addScore_by_uid($req, $target_uid, intval($g->PVP_PK_be_undefeated_score)); # 给对手发放积分
|
|
|
- $pvp->contWin = 0; # 连胜置零
|
|
|
- }
|
|
|
- if (property_exists($pvp->curMatches, $target_uid) && property_exists($pvp->curMatches->$target_uid, 'fog')) {
|
|
|
- unset($pvp->curMatches->$target_uid->fog);
|
|
|
- }
|
|
|
- $pvp->totalTimes++;
|
|
|
- $leagueid = self::GetLeagueByScore($score);
|
|
|
- if ($pvp->leagueId != $leagueid) {
|
|
|
- $pvp->leagueId = $leagueid;
|
|
|
- SystemProc::PVP_league($req->zoneid, $req->userInfo->game, $leagueid);
|
|
|
- }
|
|
|
- $pvp->actives++;
|
|
|
- $pvp->dailyPkCnt++;
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
-//todo: debuging...
|
|
|
- UserProc::updateUserInfo(); # 回写数据
|
|
|
- $ret = array(
|
|
|
- 'contWin' => $pvp->contWin,
|
|
|
- 'leagueId' => $pvp->leagueId,
|
|
|
- 'newscore' => $score, # # 返回最新积分
|
|
|
- );
|
|
|
- return Resp::ok($ret);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * [6812] pvp 刷新对手
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- static function pvp_Refresh($req) {
|
|
|
- $amt = $req->paras[0]; # 提取 params , 验证下花费
|
|
|
- $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
- $ts = now();
|
|
|
- if ($amt <= 0) { # 免费情况
|
|
|
- if ($pvp->nextRefreshTs > $ts) { # 验证时间
|
|
|
- return Resp::err(ErrCode::pvp_refresh_time);
|
|
|
- }
|
|
|
- } else { # 扣除钻石刷新的情况
|
|
|
- $priceArr = explode(',', glc()->PVP_reFresh_Match_cost); # 价格
|
|
|
- if (count($priceArr) < $pvp->dailyRefreshMatchTimes) { # 超过最大刷新次数
|
|
|
- return Resp::err(ErrCode::pvp_refresh_max);
|
|
|
- }
|
|
|
- $costCash = $priceArr[$pvp->dailyRefreshMatchTimes++]; # 查找对应的定价, 并计次
|
|
|
- if ($costCash != $amt) { # 跟预期值不一致,
|
|
|
- return Resp::err(ErrCode::pvp_refresh_cost_ilegal);
|
|
|
- }
|
|
|
- if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) {# 扣除钻石失败
|
|
|
- return Resp::err(ErrCode::notenough_cash_msg);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
|
|
|
- $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
- UserProc::updateUserInfo(); # 回写数据
|
|
|
-
|
|
|
- $ret = array(
|
|
|
- 'nextRefreshTs' => $pvp->nextRefreshTs, # # 下次免费刷新的时间戳
|
|
|
- 'dailyRefreshMatchTimes' => $pvp->dailyRefreshMatchTimes,
|
|
|
- 'curMatches' => $pvp->curMatches # # 当前对手清单
|
|
|
- );
|
|
|
- return Resp::ok($ret);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * [6813] 购买体力 v2.0 阶梯定价.
|
|
|
- * @param Req $req
|
|
|
- * @return type
|
|
|
- */
|
|
|
- static function pvp_buytili($req) {
|
|
|
- $amt = $req->paras[0]; # 验证下本次扣除的钻石数量
|
|
|
- $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
- $g = glc();
|
|
|
- $curTili = intval((now() - $pvp->tiliTs) / $g->PVP_reCover_Tili_costSec);
|
|
|
- if ($curTili > 5) {
|
|
|
- $curTili = 5;
|
|
|
- }
|
|
|
- if ($pvp->tiliExtra > 0) { # 体力溢出值大于0的时候不要购买
|
|
|
- return Resp::err(ErrCode::pvp_tili_chargenum);
|
|
|
- }
|
|
|
- $priceArr = explode(',', $g->PVP_recover_tili_cost_cash);
|
|
|
-
|
|
|
- if (count($priceArr) < $pvp->dailyBuyTiliTimes) {
|
|
|
- return Resp::err(ErrCode::pvp_tili_soldout);
|
|
|
- }
|
|
|
- $costCash = $priceArr[$pvp->dailyBuyTiliTimes++]; # 查找对应的定价, 并计次
|
|
|
- if ($costCash != $amt) { # 跟预期值不一致,
|
|
|
- return Resp::err(ErrCode::pvp_tili_cost_ilegal);
|
|
|
- }
|
|
|
- if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) { # 扣除钻石失败
|
|
|
- return Resp::err(ErrCode::notenough_cash_msg);
|
|
|
- }
|
|
|
- if ($curTili > 0) { # 增加溢出值
|
|
|
- $pvp->tiliExtra = $curTili;
|
|
|
- }
|
|
|
-
|
|
|
- $pvp->tiliTs = now() - ( 5 * $g->PVP_reCover_Tili_costSec); # 补满
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
- UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
- $ret = array(
|
|
|
- 'tiliTs' => $pvp->tiliTs,
|
|
|
- 'tiliExtra' => $pvp->tiliExtra,
|
|
|
- 'costCash' => $costCash,
|
|
|
- 'dailyBuyTiliTimes' => $pvp->dailyBuyTiliTimes,
|
|
|
- 'userCash' => $req->userInfo->game->cash
|
|
|
- );
|
|
|
- return Resp::ok($ret); # 返回
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * [6814] pvp 拉取榜单数据
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- static function pvp_getRank($req) {
|
|
|
- $maxAmt = 10; # 一次最多取10个玩家信息
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $index = $req->paras[0]; # 起始(0)
|
|
|
- $n = $req->paras[1]; # 数量, (n<=max)
|
|
|
-
|
|
|
- if ($n < 1 || $n > $maxAmt) { # 防御非法情况
|
|
|
- $n = $maxAmt;
|
|
|
- }
|
|
|
- $arr = self::getRankPlayers($req->mem, $zoneid, $index - 1, ($index + $n) - 1);
|
|
|
-
|
|
|
- $rankId = $index;
|
|
|
- $result = ObjectInit();
|
|
|
- if (count($arr)) {
|
|
|
- foreach ($arr as $key => $value) {//$value 的数据类型是array
|
|
|
- $value["uid"] = $key;
|
|
|
- $result->$rankId = $value;
|
|
|
- $rankId += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- $ret = array(
|
|
|
- 'arr' => $result
|
|
|
- );
|
|
|
- return Resp::ok($ret);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * [6815] pvp 领取活跃度奖励
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- static function pvp_drawacitverewards($req) {
|
|
|
- $rewardId = $req->paras[0]; # 提取参数
|
|
|
- $reward = GameConfig::pvp_activityreward_getItem($rewardId);
|
|
|
- if (!$reward) {
|
|
|
- return Resp::err(ErrCode::err_const_no);
|
|
|
- }
|
|
|
- $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
- if ($reward->activityNum > $pvp->actives) {
|
|
|
- return Resp::err(ErrCode::pvp_activenotenough);
|
|
|
- }
|
|
|
- $pvp->actives = 0; # 活跃记录直接清零
|
|
|
- $req->userInfo->game->pvp = $pvp; # 回写pvp数据
|
|
|
- $err = StoreProc::AddMultiItemInStore($req, $reward->reward1); # 发放奖励
|
|
|
- if ($err) {
|
|
|
- return Resp::err($err);
|
|
|
- }
|
|
|
- UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
- $ret = array(# # 返回值
|
|
|
- 'actives' => $pvp->actives, // # 最新的 活跃度值
|
|
|
- 'store' => $req->userInfo->game->store, // # 获得奖励之后的玩家仓库信息
|
|
|
- 'hero' => $req->userInfo->game->heros, // # 获得奖励之后的玩家英雄信息
|
|
|
- 'reward' => $reward->reward1,
|
|
|
- );
|
|
|
- return Resp::ok($ret);
|
|
|
- }
|
|
|
-
|
|
|
-// ---------------- 辅助函数 -----------------------
|
|
|
-
|
|
|
- /**
|
|
|
- * 清理每日计数器
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- public static function ClearDailyPkcnt($req) {
|
|
|
- $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
- $pvp->dailyPkCnt = 0;
|
|
|
- $pvp->dailyBuyTiliTimes = 0;
|
|
|
- $pvp->dailyRefreshMatchTimes = 0;
|
|
|
- $pvp->dailyMatchRecord = array($req->uid); # 屏蔽自己
|
|
|
- $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid); # added by: 李宁,2017年8月1日 11:45:41
|
|
|
- $pvp->nextRefreshTs = tsDay() * 86400 + glc()->PVP_refresh_Match_RecoverSeconds;
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新蝉联信息(并发奖,如果有)
|
|
|
- * @param Req $req
|
|
|
- */
|
|
|
- private static function UpdateChanlianInfo($req) {
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $tsWeek = TimeUtil::tsWeek();
|
|
|
- $key = MemKey_GameRun::Game_PVP_Chanlian_normal($zoneid);
|
|
|
-// $key_lastWeek = MemKey_GameRun::Game_PVPScoreByZone_zset_lastWeek($zoneid);
|
|
|
- $pvpChanlian = new GamePvpChanlian(gMem()->get($key));
|
|
|
- if ($pvpChanlian->tsWeek == $tsWeek) {
|
|
|
- return; # 已处理
|
|
|
- }
|
|
|
- $pvpChanlian->tsWeek = $tsWeek;
|
|
|
- $arr_1 = gMem()->zrevrange(MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid), 0, 0);
|
|
|
- $uid = $arr_1[0]; # 取上次第一
|
|
|
- if ($uid == $pvpChanlian->uid) { # 蝉联了
|
|
|
- $pvpChanlian->times++;
|
|
|
- if ($pvpChanlian->times == 3) { # 达到3次, 完成蝉联, 发放奖励
|
|
|
- EmailProc::SendPvpChanlianReward($zoneid, $uid); # 发放奖励
|
|
|
- $historyKey = MemKey_GameRun::Game_PVP_Chanlian_History_hash($zoneid);
|
|
|
- gMem()->hset($historyKey, $tsWeek, $pvpChanlian->userInfo); # 进入历届榜
|
|
|
- }
|
|
|
- if ($pvpChanlian->times > 3) { # 第四次蝉联的时候
|
|
|
- $pvpChanlian->times -= 3; # 循环蝉联计数信息
|
|
|
- }
|
|
|
- } else { # 替换掉上一届
|
|
|
- $arr = self::GetPlayerInfosForPVP(gMem(), $zoneid, array($uid => 100)); # 提取玩家信息
|
|
|
- $pvpChanlian->userInfo = $arr[$uid]; # 更新蝉联玩家信息
|
|
|
- $pvpChanlian->uid = $uid; # 玩家ID
|
|
|
- $pvpChanlian->times = 1; # 首次
|
|
|
- }
|
|
|
- gMem()->set($key, $pvpChanlian); # 回写数据
|
|
|
- }
|
|
|
-
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 查找对手数量
|
|
|
+// */
|
|
|
+// const matchCount = 5;
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * [6810] pvp 拉取主界面信息
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// static function pvpMainInfo($req) {
|
|
|
+// $mem = gMem();
|
|
|
+// $uid = $req->uid;
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $pvp = new UserPVPModel($req->userInfo->game->pvp); # 设计玩家pvp数据结构
|
|
|
+// $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分总榜
|
|
|
+// $key_last = MemKey_GameRun::Game_PVPScoreByZone_zset_lastWeek($zoneid); # 上周积分榜
|
|
|
+// $score = self::_getScore_by_uid($req, $uid); # 取玩家当前pvp积分
|
|
|
+// $tsLastWeek = TimeUtil::tsWeek() - 1;
|
|
|
+// $lastWeekScore = $mem->zscore($key_last, $uid);
|
|
|
+// if (!in_array($tsLastWeek, $pvp->weeklyRewardRecords) # 尚未发放上周奖励
|
|
|
+// && $lastWeekScore) { # 并且上周活跃
|
|
|
+// $pvp->weeklyRewardRecords[] = $tsLastWeek; # 添加发奖记录
|
|
|
+// $leagueid = self::GetLeagueByScore($lastWeekScore); # 上周积分所处阶段
|
|
|
+// EmailProc::SendPvpLeagueReward($zoneid, $uid, $leagueid); # 阶段奖励
|
|
|
+// $pvp->clearWeekData(); # 每周清理胜率数据
|
|
|
+// $pvp->curMatches = self::getNewMatches($pvp, $mem, $uid, $zoneid); # 更新对手列表
|
|
|
+// $req->userInfo->game->pvp = $pvp;
|
|
|
+// UserProc::updateUserInfo();
|
|
|
+// }
|
|
|
+// self::sendLastRankReward($req); # 发放每周上榜人员奖励
|
|
|
+// self::UpdateChanlianInfo($req); # 更新蝉联数据(并发奖)
|
|
|
+// $pvp->score = $score; # 插入score数据
|
|
|
+// $rank = $mem->zrevrank($key, $uid); # 提取总榜排行信息
|
|
|
+// $pvp->rank = (is_null($rank) ? -1 : $rank + 1);
|
|
|
+// return Resp::ok($pvp); # 返回pvp数据
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// *
|
|
|
+// * @param Req $req
|
|
|
+// * @param type $uid
|
|
|
+// */
|
|
|
+// static function _getScore_by_uid($req, $uid) {
|
|
|
+// if ("" == $uid) {
|
|
|
+// CLog::err('"uid" is Null!');
|
|
|
+// return 10;
|
|
|
+// }
|
|
|
+// $mem = $req->mem;
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分榜
|
|
|
+// $score = $mem->zscore($key, $uid);
|
|
|
+// if (!$score || $score <= 0) { # 分数异常
|
|
|
+// $leagueScore = GameConfig::pvp_leaguescore_getItem(1); # 新手基础分
|
|
|
+// $score = $leagueScore->minScore;
|
|
|
+// $mem->zadd($key, array($uid => $score)); # 更新玩家积分
|
|
|
+// $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score));
|
|
|
+// }
|
|
|
+// return $score;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// *
|
|
|
+// * @param Req $req
|
|
|
+// * @param type $uid
|
|
|
+// * @param type $addValue Description
|
|
|
+// */
|
|
|
+// private static function _addScore_by_uid($req, $uid, $addValue) {
|
|
|
+// if ($addValue <= 0) { # 防御
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// $mem = $req->mem;
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分榜
|
|
|
+// $score = $mem->zscore($key, $uid);
|
|
|
+// if (!$score || $score <= 0) { # 分数异常
|
|
|
+// $leagueScore = GameConfig::pvp_leaguescore_getItem(1); # 新手基础分
|
|
|
+// $score = $leagueScore->minScore;
|
|
|
+// $mem->zadd($key, array($uid => $score)); # 重置玩家积分
|
|
|
+// }
|
|
|
+// $newscore = $mem->zincrby($key, $uid, $addValue); # 返回最新值
|
|
|
+// $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $newscore));
|
|
|
+// return $newscore;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// *
|
|
|
+// * @param type $req
|
|
|
+// * @param type $uid
|
|
|
+// * @param type $subValue
|
|
|
+// */
|
|
|
+// private static function _subScore_by_uid($req, $uid, $subValue) {
|
|
|
+// if ($subValue >= 0) { # 防御异常数值
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// $mem = $req->mem;
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 积分榜
|
|
|
+// $score = $mem->zscore($key, $uid);
|
|
|
+// $leagueScore = GameConfig::pvp_leaguescore_getItem(1); # 新手基础分
|
|
|
+// if (!$score || $score <= 0 #
|
|
|
+// || ($score + $subValue) <= $leagueScore->minScore) { # 分数异常
|
|
|
+// $score = $leagueScore->minScore; # 新手基础分
|
|
|
+// $mem->zadd($key, array($uid => $score)); # 重置玩家积分
|
|
|
+// } else {
|
|
|
+// $score = $mem->zincrby($key, $uid, $subValue); # 扣除积分并返回最新值
|
|
|
+// }
|
|
|
+// $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score)); # 同步记录
|
|
|
+// return $score;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 发送上周上榜奖励
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// public static function sendLastRankReward($req) {
|
|
|
+// $mem = gMem();
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $tsweek = TimeUtil::tsWeek();
|
|
|
+// $key = MemKey_GameRun::Game_PVPRankRewardRecord_set($zoneid);
|
|
|
+// if (!$mem->sismember($key, $tsweek)) { # 上周榜单尚未处理, 每周只处理一次
|
|
|
+// // 上周是空的情况.
|
|
|
+// $lastKey = MemKey_GameRun::Game_PVPRankRewardRecord_byWeek_str($zoneid, $tsweek - 1);
|
|
|
+// $mem->sadd($key, $tsweek); # 添加处理记录
|
|
|
+// $key_total = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 拉取上榜人员
|
|
|
+// $uids = $mem->zrevrange($key_total, 0, 99);
|
|
|
+// $rank = 0;
|
|
|
+// foreach ($uids as $uid) {
|
|
|
+// EmailProc::SendPvpRankReward($zoneid, $uid, ++$rank); # 发送奖励邮件
|
|
|
+// }
|
|
|
+// $mem->add($lastKey, $uids);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * [6819] pvp - 拉取蝉联信息
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// static function getChanlianINfo($req) {
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $key = MemKey_GameRun::Game_PVP_Chanlian_normal($zoneid);
|
|
|
+// $pvpChanlian = new GamePvpChanlian(gMem()->get($key));
|
|
|
+// $pvpHistory = gMem()->hgetall(MemKey_GameRun::Game_PVP_Chanlian_History_hash($zoneid));
|
|
|
+// return Resp::ok(array(
|
|
|
+// 'info' => $pvpChanlian,
|
|
|
+// 'history' => array_values((array) $pvpHistory)
|
|
|
+// ));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * [6811] pvp 挑战对手xx
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// static function pvp_PK($req) {
|
|
|
+// $uid = $req->uid;
|
|
|
+// $target_uid = $req->paras[0]; # 对手id
|
|
|
+// $result = $req->paras[1]; # 胜负结果 0负,1胜
|
|
|
+// $pvp = $req->userInfo->game->pvp;
|
|
|
+// if (!property_exists($pvp->curMatches, $target_uid)//
|
|
|
+// or property_exists($pvp->curMatches->$target_uid, 'killed')) { # 对手已被ko
|
|
|
+// return Resp::err(ErrCode::pvp_wrongMather);
|
|
|
+// }
|
|
|
+// $g = glc();
|
|
|
+// if (now() - $pvp->tiliTs > $g->PVP_reCover_Tili_costSec * 5) { # 检查并扣除体力
|
|
|
+// $pvp->tiliTs = now() - $g->PVP_reCover_Tili_costSec * 5;
|
|
|
+// }
|
|
|
+// if ($pvp->tiliExtra > 0) { # 优先扣除溢出值
|
|
|
+// $pvp->tiliExtra--;
|
|
|
+// } else {
|
|
|
+// $pvp->tiliTs += $g->PVP_reCover_Tili_costSec;
|
|
|
+// if ($pvp->tiliTs > now()) {
|
|
|
+// return Resp::err(ErrCode::pvp_wrongtili);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//# 发放对应奖励并记录挑战记录
|
|
|
+// $score = 0;
|
|
|
+// if ($result) { # 1 胜, 奖金币、积分、pvp币
|
|
|
+// UserGameModel::Add_Gold($req->userInfo->game, $g->PVP_PK_Win_Gold);
|
|
|
+// # × 奖励积分的公式: 获胜基础奖励积分 + 积分差距修正系数 * 积分差
|
|
|
+// # 挑战胜利, 积分改为固定值.
|
|
|
+// $winnerGainScore = $g->PVP_PK_Win_Score; # 本局得分
|
|
|
+// $score = self::_addScore_by_uid($req, $uid, intval($winnerGainScore)); # 增加积分
|
|
|
+// $pvp->pvpCoins += $g->PVP_PK_Win_PvpCoin; # 发放金币
|
|
|
+// self::_subScore_by_uid($req, $target_uid, -intval($g->PVP_PK_be_defeated_score)); # 给对手扣除积分
|
|
|
+// $pvp->contWin++; # 连胜记录
|
|
|
+// $pvp->winTimes++; # 获胜记录
|
|
|
+// $all = true; # 全部战胜标记
|
|
|
+// foreach ($pvp->curMatches as $pid => &$p) {
|
|
|
+// if ($pid == $target_uid) { #
|
|
|
+// $p->killed = 1; # 添加ko标志
|
|
|
+// if (property_exists($p, 'fog')) {
|
|
|
+// $score = self::_addScore_by_uid($req, $uid, intval($winnerGainScore)); # 神秘对手, 积分翻倍(再加一遍)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (!property_exists($p, 'killed')) {
|
|
|
+// $all = false; # 尚未全部战胜
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if ($all) { # 全部战胜之后,刷新对手
|
|
|
+// $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
|
|
|
+// $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
|
|
|
+// }
|
|
|
+// } else { # 0 挑战失败 只扣除积分
|
|
|
+// # × 奖励积分的公式: 获胜基础奖励积分 + 积分差距修正系数 * 积分差
|
|
|
+// # 挑战失败, 扣除固定积分
|
|
|
+// $loserGainScore = $g->PVP_PK_Fail_Score;
|
|
|
+// $score = self::_subScore_by_uid($req, $uid, -intval($loserGainScore)); # 扣除积分
|
|
|
+// self::_addScore_by_uid($req, $target_uid, intval($g->PVP_PK_be_undefeated_score)); # 给对手发放积分
|
|
|
+// $pvp->contWin = 0; # 连胜置零
|
|
|
+// }
|
|
|
+// if (property_exists($pvp->curMatches, $target_uid) && property_exists($pvp->curMatches->$target_uid, 'fog')) {
|
|
|
+// unset($pvp->curMatches->$target_uid->fog);
|
|
|
+// }
|
|
|
+// $pvp->totalTimes++;
|
|
|
+// $leagueid = self::GetLeagueByScore($score);
|
|
|
+// if ($pvp->leagueId != $leagueid) {
|
|
|
+// $pvp->leagueId = $leagueid;
|
|
|
+// SystemProc::PVP_league($req->zoneid, $req->userInfo->game, $leagueid);
|
|
|
+// }
|
|
|
+// $pvp->actives++;
|
|
|
+// $pvp->dailyPkCnt++;
|
|
|
+// $req->userInfo->game->pvp = $pvp;
|
|
|
+////todo: debuging...
|
|
|
+// UserProc::updateUserInfo(); # 回写数据
|
|
|
+// $ret = array(
|
|
|
+// 'contWin' => $pvp->contWin,
|
|
|
+// 'leagueId' => $pvp->leagueId,
|
|
|
+// 'newscore' => $score, # # 返回最新积分
|
|
|
+// );
|
|
|
+// return Resp::ok($ret);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * [6812] pvp 刷新对手
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// static function pvp_Refresh($req) {
|
|
|
+// $amt = $req->paras[0]; # 提取 params , 验证下花费
|
|
|
+// $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
+// $ts = now();
|
|
|
+// if ($amt <= 0) { # 免费情况
|
|
|
+// if ($pvp->nextRefreshTs > $ts) { # 验证时间
|
|
|
+// return Resp::err(ErrCode::pvp_refresh_time);
|
|
|
+// }
|
|
|
+// } else { # 扣除钻石刷新的情况
|
|
|
+// $priceArr = explode(',', glc()->PVP_reFresh_Match_cost); # 价格
|
|
|
+// if (count($priceArr) < $pvp->dailyRefreshMatchTimes) { # 超过最大刷新次数
|
|
|
+// return Resp::err(ErrCode::pvp_refresh_max);
|
|
|
+// }
|
|
|
+// $costCash = $priceArr[$pvp->dailyRefreshMatchTimes++]; # 查找对应的定价, 并计次
|
|
|
+// if ($costCash != $amt) { # 跟预期值不一致,
|
|
|
+// return Resp::err(ErrCode::pvp_refresh_cost_ilegal);
|
|
|
+// }
|
|
|
+// if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) {# 扣除钻石失败
|
|
|
+// return Resp::err(ErrCode::notenough_cash_msg);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
|
|
|
+// $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
|
|
|
+// $req->userInfo->game->pvp = $pvp;
|
|
|
+// UserProc::updateUserInfo(); # 回写数据
|
|
|
+//
|
|
|
+// $ret = array(
|
|
|
+// 'nextRefreshTs' => $pvp->nextRefreshTs, # # 下次免费刷新的时间戳
|
|
|
+// 'dailyRefreshMatchTimes' => $pvp->dailyRefreshMatchTimes,
|
|
|
+// 'curMatches' => $pvp->curMatches # # 当前对手清单
|
|
|
+// );
|
|
|
+// return Resp::ok($ret);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * [6813] 购买体力 v2.0 阶梯定价.
|
|
|
+// * @param Req $req
|
|
|
+// * @return type
|
|
|
+// */
|
|
|
+// static function pvp_buytili($req) {
|
|
|
+// $amt = $req->paras[0]; # 验证下本次扣除的钻石数量
|
|
|
+// $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
+// $g = glc();
|
|
|
+// $curTili = intval((now() - $pvp->tiliTs) / $g->PVP_reCover_Tili_costSec);
|
|
|
+// if ($curTili > 5) {
|
|
|
+// $curTili = 5;
|
|
|
+// }
|
|
|
+// if ($pvp->tiliExtra > 0) { # 体力溢出值大于0的时候不要购买
|
|
|
+// return Resp::err(ErrCode::pvp_tili_chargenum);
|
|
|
+// }
|
|
|
+// $priceArr = explode(',', $g->PVP_recover_tili_cost_cash);
|
|
|
+//
|
|
|
+// if (count($priceArr) < $pvp->dailyBuyTiliTimes) {
|
|
|
+// return Resp::err(ErrCode::pvp_tili_soldout);
|
|
|
+// }
|
|
|
+// $costCash = $priceArr[$pvp->dailyBuyTiliTimes++]; # 查找对应的定价, 并计次
|
|
|
+// if ($costCash != $amt) { # 跟预期值不一致,
|
|
|
+// return Resp::err(ErrCode::pvp_tili_cost_ilegal);
|
|
|
+// }
|
|
|
+// if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) { # 扣除钻石失败
|
|
|
+// return Resp::err(ErrCode::notenough_cash_msg);
|
|
|
+// }
|
|
|
+// if ($curTili > 0) { # 增加溢出值
|
|
|
+// $pvp->tiliExtra = $curTili;
|
|
|
+// }
|
|
|
+//
|
|
|
+// $pvp->tiliTs = now() - ( 5 * $g->PVP_reCover_Tili_costSec); # 补满
|
|
|
+// $req->userInfo->game->pvp = $pvp;
|
|
|
+// UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
+// $ret = array(
|
|
|
+// 'tiliTs' => $pvp->tiliTs,
|
|
|
+// 'tiliExtra' => $pvp->tiliExtra,
|
|
|
+// 'costCash' => $costCash,
|
|
|
+// 'dailyBuyTiliTimes' => $pvp->dailyBuyTiliTimes,
|
|
|
+// 'userCash' => $req->userInfo->game->cash
|
|
|
+// );
|
|
|
+// return Resp::ok($ret); # 返回
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * [6814] pvp 拉取榜单数据
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// static function pvp_getRank($req) {
|
|
|
+// $maxAmt = 10; # 一次最多取10个玩家信息
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $index = $req->paras[0]; # 起始(0)
|
|
|
+// $n = $req->paras[1]; # 数量, (n<=max)
|
|
|
+//
|
|
|
+// if ($n < 1 || $n > $maxAmt) { # 防御非法情况
|
|
|
+// $n = $maxAmt;
|
|
|
+// }
|
|
|
+// $arr = self::getRankPlayers($req->mem, $zoneid, $index - 1, ($index + $n) - 1);
|
|
|
+//
|
|
|
+// $rankId = $index;
|
|
|
+// $result = ObjectInit();
|
|
|
+// if (count($arr)) {
|
|
|
+// foreach ($arr as $key => $value) {//$value 的数据类型是array
|
|
|
+// $value["uid"] = $key;
|
|
|
+// $result->$rankId = $value;
|
|
|
+// $rankId += 1;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $ret = array(
|
|
|
+// 'arr' => $result
|
|
|
+// );
|
|
|
+// return Resp::ok($ret);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * [6815] pvp 领取活跃度奖励
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// static function pvp_drawacitverewards($req) {
|
|
|
+// $rewardId = $req->paras[0]; # 提取参数
|
|
|
+// $reward = GameConfig::pvp_activityreward_getItem($rewardId);
|
|
|
+// if (!$reward) {
|
|
|
+// return Resp::err(ErrCode::err_const_no);
|
|
|
+// }
|
|
|
+// $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
+// if ($reward->activityNum > $pvp->actives) {
|
|
|
+// return Resp::err(ErrCode::pvp_activenotenough);
|
|
|
+// }
|
|
|
+// $pvp->actives = 0; # 活跃记录直接清零
|
|
|
+// $req->userInfo->game->pvp = $pvp; # 回写pvp数据
|
|
|
+// $err = StoreProc::AddMultiItemInStore($req, $reward->reward1); # 发放奖励
|
|
|
+// if ($err) {
|
|
|
+// return Resp::err($err);
|
|
|
+// }
|
|
|
+// UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
+// $ret = array(# # 返回值
|
|
|
+// 'actives' => $pvp->actives, // # 最新的 活跃度值
|
|
|
+// 'store' => $req->userInfo->game->store, // # 获得奖励之后的玩家仓库信息
|
|
|
+// 'hero' => $req->userInfo->game->heros, // # 获得奖励之后的玩家英雄信息
|
|
|
+// 'reward' => $reward->reward1,
|
|
|
+// );
|
|
|
+// return Resp::ok($ret);
|
|
|
+// }
|
|
|
+//
|
|
|
+//// ---------------- 辅助函数 -----------------------
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 清理每日计数器
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// public static function ClearDailyPkcnt($req) {
|
|
|
+// $pvp = new UserPVPModel($req->userInfo->game->pvp);
|
|
|
+// $pvp->dailyPkCnt = 0;
|
|
|
+// $pvp->dailyBuyTiliTimes = 0;
|
|
|
+// $pvp->dailyRefreshMatchTimes = 0;
|
|
|
+// $pvp->dailyMatchRecord = array($req->uid); # 屏蔽自己
|
|
|
+// $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid); # added by: 李宁,2017年8月1日 11:45:41
|
|
|
+// $pvp->nextRefreshTs = tsDay() * 86400 + glc()->PVP_refresh_Match_RecoverSeconds;
|
|
|
+// $req->userInfo->game->pvp = $pvp;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 更新蝉联信息(并发奖,如果有)
|
|
|
+// * @param Req $req
|
|
|
+// */
|
|
|
+// private static function UpdateChanlianInfo($req) {
|
|
|
+// $zoneid = $req->zoneid;
|
|
|
+// $tsWeek = TimeUtil::tsWeek();
|
|
|
+// $key = MemKey_GameRun::Game_PVP_Chanlian_normal($zoneid);
|
|
|
+//// $key_lastWeek = MemKey_GameRun::Game_PVPScoreByZone_zset_lastWeek($zoneid);
|
|
|
+// $pvpChanlian = new GamePvpChanlian(gMem()->get($key));
|
|
|
+// if ($pvpChanlian->tsWeek == $tsWeek) {
|
|
|
+// return; # 已处理
|
|
|
+// }
|
|
|
+// $pvpChanlian->tsWeek = $tsWeek;
|
|
|
+// $arr_1 = gMem()->zrevrange(MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid), 0, 0);
|
|
|
+// $uid = $arr_1[0]; # 取上次第一
|
|
|
+// if ($uid == $pvpChanlian->uid) { # 蝉联了
|
|
|
+// $pvpChanlian->times++;
|
|
|
+// if ($pvpChanlian->times == 3) { # 达到3次, 完成蝉联, 发放奖励
|
|
|
+// EmailProc::SendPvpChanlianReward($zoneid, $uid); # 发放奖励
|
|
|
+// $historyKey = MemKey_GameRun::Game_PVP_Chanlian_History_hash($zoneid);
|
|
|
+// gMem()->hset($historyKey, $tsWeek, $pvpChanlian->userInfo); # 进入历届榜
|
|
|
+// }
|
|
|
+// if ($pvpChanlian->times > 3) { # 第四次蝉联的时候
|
|
|
+// $pvpChanlian->times -= 3; # 循环蝉联计数信息
|
|
|
+// }
|
|
|
+// } else { # 替换掉上一届
|
|
|
+// $arr = self::GetPlayerInfosForPVP(gMem(), $zoneid, array($uid => 100)); # 提取玩家信息
|
|
|
+// $pvpChanlian->userInfo = $arr[$uid]; # 更新蝉联玩家信息
|
|
|
+// $pvpChanlian->uid = $uid; # 玩家ID
|
|
|
+// $pvpChanlian->times = 1; # 首次
|
|
|
+// }
|
|
|
+// gMem()->set($key, $pvpChanlian); # 回写数据
|
|
|
+// }
|
|
|
//
|
|
|
// <editor-fold defaultstate="collapsed" desc=" 辅助 函数 ">
|
|
|
-
|
|
|
- /**
|
|
|
- * 依据积分获得所在阶段的id
|
|
|
- * @param type $curScore
|
|
|
- * @return int
|
|
|
- */
|
|
|
- private static function GetLeagueByScore($curScore) {
|
|
|
- foreach (GameConfig::pvp_leaguescore() as $id => $lg) {
|
|
|
- isEditor() and $lg = new sm_pvp_leaguescore;
|
|
|
- if ($lg->maxScore >= $curScore && $lg->minScore <= $curScore) {
|
|
|
- return $id;
|
|
|
- }
|
|
|
- }
|
|
|
- return 1; # 找不到对应所属阶段的时候,返回 默认值 1
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取对手匹配结果
|
|
|
- * @param UserPVPModel $pvp
|
|
|
- * @param CRedisutil $mem
|
|
|
- * @param type $uid
|
|
|
- * @param type $zoneid
|
|
|
- */
|
|
|
- private static function getNewMatches($pvp, $mem, $uid, $zoneid) {
|
|
|
- $arr = array();
|
|
|
- $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
|
|
|
- self::findmatcher($zoneid, $key, $uid, $pvp, $arr); # 积分榜查找
|
|
|
- if (count($arr) < self::matchCount) { # 如果没有凑足人数,战斗力候补来源,
|
|
|
- $keyfp = MemKey_GameRun::Game_FightPowerRank_zset($zoneid);
|
|
|
- self::findmatcher($zoneid, $keyfp, $uid, $pvp, $arr); # 从战斗力榜找
|
|
|
- }
|
|
|
- if (count($arr) < self::matchCount) { # 再不行, 准备机器人吧
|
|
|
-// todo: 这里引入gm对手数据,
|
|
|
- CLog::err('PVP刷对手数量不足, 赶快考虑加入机器人.', 'PVP');
|
|
|
- }
|
|
|
- $ret = self::GetPlayerInfosForPVP($mem, $zoneid, $arr);
|
|
|
- $keys = array_keys($ret);
|
|
|
- $k = $keys[0];
|
|
|
- $v = $ret[$k];
|
|
|
- $v['fog'] = true;
|
|
|
- $ret[$k] = $v;
|
|
|
-// var_dump($v);
|
|
|
-// echoLine(JsonUtil::encode($ret[$k]));
|
|
|
- return $ret;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查找匹配的对手
|
|
|
- * @param type $zoneid
|
|
|
- * @param type $key
|
|
|
- * @param type $uid
|
|
|
- * @param UserPVPModel $pvp
|
|
|
- * @param type $arr
|
|
|
- */
|
|
|
- private static function findmatcher($zoneid, $key, $uid, &$pvp, &$arr) {
|
|
|
- $mem = gMem();
|
|
|
- $rank = $mem->zrevrank($key, $uid); # 直接查排名
|
|
|
- $zlen = $mem->zlen($key); # 数据长度
|
|
|
- $i = 0; # 计数器
|
|
|
- $b = false; # 上下标志位
|
|
|
- while (count($arr) < self::matchCount && $i < 50) { # 找够数量为止,或者查找超过100个位置, 跳出查找
|
|
|
- $index = $rank + ($b ? - $i : $i);
|
|
|
-// todo: 这里引入连胜/连负修正系数.
|
|
|
- $b = !$b;
|
|
|
- if ($b) { # 变化查找方向
|
|
|
- $i++; #
|
|
|
- }
|
|
|
- if ($index < 0 || $index >= $zlen) { # 跳过不合理位置
|
|
|
- continue;
|
|
|
- }
|
|
|
- $back = $mem->zrevrange($key, $index, $index, true); # 取1个人
|
|
|
- if (count($back) <= 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $us = array_keys($back);
|
|
|
- $d_uid = $us[0];
|
|
|
- if ($d_uid == $uid) { # 避开自己
|
|
|
- continue;
|
|
|
- }
|
|
|
- $user = $mem->get(MemKey_User::Info($zoneid, $d_uid));
|
|
|
- if (null == $user) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $fp = HeroProc::CalcTeamFightPower($zoneid, $d_uid, $user);
|
|
|
- if ($fp > 0) {
|
|
|
-// $pvp->dailyMatchRecord
|
|
|
- if (!in_array($d_uid, $pvp->dailyMatchRecord)) { # 已经匹配过的对手不在出现
|
|
|
- $arr[$d_uid] = $back[$d_uid];
|
|
|
- $pvp->dailyMatchRecord[] = $d_uid;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取榜单玩家
|
|
|
- * @param Credisutil $mem
|
|
|
- * @param int $zoneid
|
|
|
- * @param int $start
|
|
|
- * @param int $stop
|
|
|
- * @return type
|
|
|
- */
|
|
|
- private static function getRankPlayers($mem, $zoneid, $start, $stop) {
|
|
|
- $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
|
|
|
- $retUidsWithScore = $mem->zrevrange($key, $start, $stop, true);
|
|
|
- return self::GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 拉取玩家信息-pvp模块专用信息
|
|
|
- * @param CredisUtil $mem
|
|
|
- * @param type $zoneid
|
|
|
- * @param type $retUidsWithScore
|
|
|
- * @return type
|
|
|
- */
|
|
|
- private static function GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore) {
|
|
|
-// var_dump($retUidsWithScore);
|
|
|
- $retUids = array_keys($retUidsWithScore);
|
|
|
- $keysOfUserInfo = array_map(function($u)use($zoneid) {
|
|
|
- return MemKey_User::Info($zoneid, $u);
|
|
|
- }, $retUids);
|
|
|
- $arrUserInfos = $mem->getMulti($keysOfUserInfo);
|
|
|
- $arr = ArrayInit();
|
|
|
- $i = 0;
|
|
|
- foreach ($arrUserInfos as $userGameInfo) {
|
|
|
- isEditor() && $userGameInfo = new UserGameModel;
|
|
|
- $uid = $retUids[$i++];
|
|
|
-// $sharedHeroId = $userGameInfo->heros->firendSupportHeroUID;
|
|
|
- $team = JsonUtil::decode('{"teamLeader": 0,"heros":{}}');
|
|
|
- $teamConfig = JsonUtil::decode($userGameInfo->heroTeamConfig);
|
|
|
- if ($teamConfig && $teamConfig->curUseTeamID > 0) {
|
|
|
- $heros = ObjectInit();
|
|
|
- $teamid = $teamConfig->curUseTeamID;
|
|
|
- $heros_uid = $teamConfig->teamDic->$teamid->heros;
|
|
|
- $m = 0;
|
|
|
- foreach ($heros_uid as $heroid) {
|
|
|
- $m++;
|
|
|
- $heros->$m = $heroid ? self::getHeroInfoForShare($userGameInfo, $heroid) : null;
|
|
|
- }
|
|
|
- $team = array(
|
|
|
- 'teamLeader' => $teamConfig->teamDic->$teamid->teamLeader,
|
|
|
- 'heros' => $heros
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- $pvp = StlUtil::array2class(array('contWin' => '', 'totalTimes' => '', 'winTimes' => '', 'leagueId' => ''));
|
|
|
- CommUtil::loadObject($userGameInfo->pvp, $pvp); # 提取pvp数据
|
|
|
- $arr[$uid] = array(
|
|
|
- 'img' => $userGameInfo->img,
|
|
|
- 'imgBorderId' => $userGameInfo->imgBorderId,
|
|
|
-// 'sharedHero' => self::getHeroInfoForShare($userGameInfo, $sharedHeroId),
|
|
|
- 'lastLoginTs' => isset($userGameInfo->lastLogin) ? $userGameInfo->lastLogin : 0,
|
|
|
- 'nickname' => $userGameInfo->name,
|
|
|
- 'pvp' => $pvp,
|
|
|
- 'score' => $retUidsWithScore[$uid],
|
|
|
- 'level' => $userGameInfo->level,
|
|
|
- 'uid' => $uid,
|
|
|
- 'heroTeamConfig' => $team # 战队配置
|
|
|
- );
|
|
|
- }
|
|
|
- if (count($arr) <= 0) {
|
|
|
- $arr = null;
|
|
|
- }
|
|
|
- return $arr;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 提取英雄信息以供其他人使用
|
|
|
- * @param type $userInfo
|
|
|
- * @param type $heroId
|
|
|
- * @return UserHeroModel
|
|
|
- */
|
|
|
- public static function getHeroInfoForShare($userInfo, $heroId) {
|
|
|
- if ($heroId) {
|
|
|
- $heroInfo = $userInfo->heros->collectHeros->$heroId;
|
|
|
- } else { // todo: 暂定如果没有设置共享英雄,默认取集合中第一个英雄, 征询策划是否修订规则
|
|
|
- $coll = $userInfo->heros->collectHeros;
|
|
|
- $keys = array_keys((array) $coll);
|
|
|
- if (count($keys) <= 0) {
|
|
|
- return null; // 暴力跳过, 防止出现更大的错误
|
|
|
- }
|
|
|
- $heroId = $keys[0];
|
|
|
- $heroInfo = $userInfo->heros->collectHeros->$heroId;
|
|
|
- }
|
|
|
-// 额外将英雄的装备数据替换为实例数据
|
|
|
- self::getArmor($userInfo, $heroInfo, 'weapon');
|
|
|
- self::getArmor($userInfo, $heroInfo, 'armor');
|
|
|
- self::getArmor($userInfo, $heroInfo, 'ring');
|
|
|
- return $heroInfo;
|
|
|
- }
|
|
|
-
|
|
|
- private static function getArmor($userInfo, $hero, $armor) {
|
|
|
- if (isset($hero->equip->$armor)) {
|
|
|
- if (property_exists($hero->equip->$armor, 'itemuid')) {
|
|
|
- $armorid = $hero->equip->$armor->itemuid;
|
|
|
- if ($armorid > 0 && isset($userInfo->store->equipment->$armorid)) {
|
|
|
- $hero->equip->$armor = $userInfo->store->equipment->$armorid;
|
|
|
- return; # 找到后直接跳出
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $hero->equip->$armor = null;
|
|
|
- }
|
|
|
-
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 依据积分获得所在阶段的id
|
|
|
+// * @param type $curScore
|
|
|
+// * @return int
|
|
|
+// */
|
|
|
+// private static function GetLeagueByScore($curScore) {
|
|
|
+// foreach (GameConfig::pvp_leaguescore() as $id => $lg) {
|
|
|
+// isEditor() and $lg = new sm_pvp_leaguescore;
|
|
|
+// if ($lg->maxScore >= $curScore && $lg->minScore <= $curScore) {
|
|
|
+// return $id;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return 1; # 找不到对应所属阶段的时候,返回 默认值 1
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取对手匹配结果
|
|
|
+// * @param UserPVPModel $pvp
|
|
|
+// * @param CRedisutil $mem
|
|
|
+// * @param type $uid
|
|
|
+// * @param type $zoneid
|
|
|
+// */
|
|
|
+// private static function getNewMatches($pvp, $mem, $uid, $zoneid) {
|
|
|
+// $arr = array();
|
|
|
+// $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
|
|
|
+// self::findmatcher($zoneid, $key, $uid, $pvp, $arr); # 积分榜查找
|
|
|
+// if (count($arr) < self::matchCount) { # 如果没有凑足人数,战斗力候补来源,
|
|
|
+// $keyfp = MemKey_GameRun::Game_FightPowerRank_zset($zoneid);
|
|
|
+// self::findmatcher($zoneid, $keyfp, $uid, $pvp, $arr); # 从战斗力榜找
|
|
|
+// }
|
|
|
+// if (count($arr) < self::matchCount) { # 再不行, 准备机器人吧
|
|
|
+//// todo: 这里引入gm对手数据,
|
|
|
+// CLog::err('PVP刷对手数量不足, 赶快考虑加入机器人.', 'PVP');
|
|
|
+// }
|
|
|
+// $ret = self::GetPlayerInfosForPVP($mem, $zoneid, $arr);
|
|
|
+// $keys = array_keys($ret);
|
|
|
+// $k = $keys[0];
|
|
|
+// $v = $ret[$k];
|
|
|
+// $v['fog'] = true;
|
|
|
+// $ret[$k] = $v;
|
|
|
+//// var_dump($v);
|
|
|
+//// echoLine(JsonUtil::encode($ret[$k]));
|
|
|
+// return $ret;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 查找匹配的对手
|
|
|
+// * @param type $zoneid
|
|
|
+// * @param type $key
|
|
|
+// * @param type $uid
|
|
|
+// * @param UserPVPModel $pvp
|
|
|
+// * @param type $arr
|
|
|
+// */
|
|
|
+// private static function findmatcher($zoneid, $key, $uid, &$pvp, &$arr) {
|
|
|
+// $mem = gMem();
|
|
|
+// $rank = $mem->zrevrank($key, $uid); # 直接查排名
|
|
|
+// $zlen = $mem->zlen($key); # 数据长度
|
|
|
+// $i = 0; # 计数器
|
|
|
+// $b = false; # 上下标志位
|
|
|
+// while (count($arr) < self::matchCount && $i < 50) { # 找够数量为止,或者查找超过100个位置, 跳出查找
|
|
|
+// $index = $rank + ($b ? - $i : $i);
|
|
|
+//// todo: 这里引入连胜/连负修正系数.
|
|
|
+// $b = !$b;
|
|
|
+// if ($b) { # 变化查找方向
|
|
|
+// $i++; #
|
|
|
+// }
|
|
|
+// if ($index < 0 || $index >= $zlen) { # 跳过不合理位置
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// $back = $mem->zrevrange($key, $index, $index, true); # 取1个人
|
|
|
+// if (count($back) <= 0) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// $us = array_keys($back);
|
|
|
+// $d_uid = $us[0];
|
|
|
+// if ($d_uid == $uid) { # 避开自己
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// $user = $mem->get(MemKey_User::Info_hash($zoneid, $d_uid));
|
|
|
+// if (null == $user) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// $fp = HeroProc::CalcTeamFightPower($zoneid, $d_uid, $user);
|
|
|
+// if ($fp > 0) {
|
|
|
+//// $pvp->dailyMatchRecord
|
|
|
+// if (!in_array($d_uid, $pvp->dailyMatchRecord)) { # 已经匹配过的对手不在出现
|
|
|
+// $arr[$d_uid] = $back[$d_uid];
|
|
|
+// $pvp->dailyMatchRecord[] = $d_uid;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取榜单玩家
|
|
|
+// * @param Credisutil $mem
|
|
|
+// * @param int $zoneid
|
|
|
+// * @param int $start
|
|
|
+// * @param int $stop
|
|
|
+// * @return type
|
|
|
+// */
|
|
|
+// private static function getRankPlayers($mem, $zoneid, $start, $stop) {
|
|
|
+// $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
|
|
|
+// $retUidsWithScore = $mem->zrevrange($key, $start, $stop, true);
|
|
|
+// return self::GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 拉取玩家信息-pvp模块专用信息
|
|
|
+// * @param CredisUtil $mem
|
|
|
+// * @param type $zoneid
|
|
|
+// * @param type $retUidsWithScore
|
|
|
+// * @return type
|
|
|
+// */
|
|
|
+// private static function GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore) {
|
|
|
+//// var_dump($retUidsWithScore);
|
|
|
+// $retUids = array_keys($retUidsWithScore);
|
|
|
+// $keysOfUserInfo = array_map(function($u)use($zoneid) {
|
|
|
+// return MemKey_User::Info_hash($zoneid, $u);
|
|
|
+// }, $retUids);
|
|
|
+// $arrUserInfos = $mem->getMulti($keysOfUserInfo);
|
|
|
+// $arr = ArrayInit();
|
|
|
+// $i = 0;
|
|
|
+// foreach ($arrUserInfos as $userGameInfo) {
|
|
|
+// isEditor() && $userGameInfo = new UserGameModel;
|
|
|
+// $uid = $retUids[$i++];
|
|
|
+//// $sharedHeroId = $userGameInfo->heros->firendSupportHeroUID;
|
|
|
+// $team = JsonUtil::decode('{"teamLeader": 0,"heros":{}}');
|
|
|
+// $teamConfig = JsonUtil::decode($userGameInfo->heroTeamConfig);
|
|
|
+// if ($teamConfig && $teamConfig->curUseTeamID > 0) {
|
|
|
+// $heros = ObjectInit();
|
|
|
+// $teamid = $teamConfig->curUseTeamID;
|
|
|
+// $heros_uid = $teamConfig->teamDic->$teamid->heros;
|
|
|
+// $m = 0;
|
|
|
+// foreach ($heros_uid as $heroid) {
|
|
|
+// $m++;
|
|
|
+// $heros->$m = $heroid ? self::getHeroInfoForShare($userGameInfo, $heroid) : null;
|
|
|
+// }
|
|
|
+// $team = array(
|
|
|
+// 'teamLeader' => $teamConfig->teamDic->$teamid->teamLeader,
|
|
|
+// 'heros' => $heros
|
|
|
+// );
|
|
|
+// }
|
|
|
+//
|
|
|
+// $pvp = StlUtil::array2class(array('contWin' => '', 'totalTimes' => '', 'winTimes' => '', 'leagueId' => ''));
|
|
|
+// CommUtil::loadObject($userGameInfo->pvp, $pvp); # 提取pvp数据
|
|
|
+// $arr[$uid] = array(
|
|
|
+// 'img' => $userGameInfo->img,
|
|
|
+// 'imgBorderId' => $userGameInfo->imgBorderId,
|
|
|
+//// 'sharedHero' => self::getHeroInfoForShare($userGameInfo, $sharedHeroId),
|
|
|
+// 'lastLoginTs' => isset($userGameInfo->lastLogin) ? $userGameInfo->lastLogin : 0,
|
|
|
+// 'nickname' => $userGameInfo->name,
|
|
|
+// 'pvp' => $pvp,
|
|
|
+// 'score' => $retUidsWithScore[$uid],
|
|
|
+// 'level' => $userGameInfo->level,
|
|
|
+// 'uid' => $uid,
|
|
|
+// 'heroTeamConfig' => $team # 战队配置
|
|
|
+// );
|
|
|
+// }
|
|
|
+// if (count($arr) <= 0) {
|
|
|
+// $arr = null;
|
|
|
+// }
|
|
|
+// return $arr;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 提取英雄信息以供其他人使用
|
|
|
+// * @param type $userInfo
|
|
|
+// * @param type $heroId
|
|
|
+// * @return UserHeroModel
|
|
|
+// */
|
|
|
+// public static function getHeroInfoForShare($userInfo, $heroId) {
|
|
|
+// if ($heroId) {
|
|
|
+// $heroInfo = $userInfo->heros->collectHeros->$heroId;
|
|
|
+// } else { // todo: 暂定如果没有设置共享英雄,默认取集合中第一个英雄, 征询策划是否修订规则
|
|
|
+// $coll = $userInfo->heros->collectHeros;
|
|
|
+// $keys = array_keys((array) $coll);
|
|
|
+// if (count($keys) <= 0) {
|
|
|
+// return null; // 暴力跳过, 防止出现更大的错误
|
|
|
+// }
|
|
|
+// $heroId = $keys[0];
|
|
|
+// $heroInfo = $userInfo->heros->collectHeros->$heroId;
|
|
|
+// }
|
|
|
+//// 额外将英雄的装备数据替换为实例数据
|
|
|
+// self::getArmor($userInfo, $heroInfo, 'weapon');
|
|
|
+// self::getArmor($userInfo, $heroInfo, 'armor');
|
|
|
+// self::getArmor($userInfo, $heroInfo, 'ring');
|
|
|
+// return $heroInfo;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private static function getArmor($userInfo, $hero, $armor) {
|
|
|
+// if (isset($hero->equip->$armor)) {
|
|
|
+// if (property_exists($hero->equip->$armor, 'itemuid')) {
|
|
|
+// $armorid = $hero->equip->$armor->itemuid;
|
|
|
+// if ($armorid > 0 && isset($userInfo->store->equipment->$armorid)) {
|
|
|
+// $hero->equip->$armor = $userInfo->store->equipment->$armorid;
|
|
|
+// return; # 找到后直接跳出
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $hero->equip->$armor = null;
|
|
|
+// }
|
|
|
// </editor-fold>
|
|
|
//
|
|
|
// </editor-fold>
|