|
@@ -47,11 +47,10 @@ class PVPProc {
|
|
|
|
|
|
/**
|
|
|
* [6803] 挑战 - 查询对手信息 等级、头像、昵称、战队信息(言灵师,等级,星级,武器,技能,言灵)
|
|
|
- * @param req $req
|
|
|
*/
|
|
|
- public static function GetChallengeAdversaryInfo($req) {
|
|
|
- $targetUID = $req->paras[0]; # 参数: 对手的UID
|
|
|
- $uinfo = UserProc::getUserInfo($req->zoneid, $targetUID); # 读取玩家信息
|
|
|
+ public static function GetChallengeAdversaryInfo() {
|
|
|
+ $targetUID = req()->paras[0]; # 参数: 对手的UID
|
|
|
+ $uinfo = UserProc::getUserInfo(req()->zoneid, $targetUID); # 读取玩家信息
|
|
|
if (null == $uinfo) {
|
|
|
Err(ErrCode::user_no_err);
|
|
|
}
|
|
@@ -59,7 +58,6 @@ class PVPProc {
|
|
|
|
|
|
$heros = new \stdClass();
|
|
|
$curTeamId = $team->curUseTeamID;
|
|
|
- $arr_nil = array();
|
|
|
foreach ($team->teamDic->$curTeamId->heros as $i => $hid) {
|
|
|
if ($hid > 0) {
|
|
|
$n_hid = $hid - 10000;
|
|
@@ -86,13 +84,11 @@ class PVPProc {
|
|
|
|
|
|
/**
|
|
|
* [6804] 挑战 - 记录挑战结果
|
|
|
- * @param req $req
|
|
|
*/
|
|
|
- static function LogChallengeInfo($req) {
|
|
|
- // 参数: 对手uid,对手昵称,对手头像, 对战结果, 胜利者的留言(失败时无法留言"")
|
|
|
- list($targetUID, $name, $headImg, $win, $msg) = $req->paras;
|
|
|
- $key_mine = MemKey_User::OffensiveLog_zset($req->zoneid, $req->uid);
|
|
|
- $key_target = MemKey_User::DefensiveLog_zset($req->zoneid, $targetUID);
|
|
|
+ static function LogChallengeInfo() {
|
|
|
+ list($targetUID, $name, $headImg, $win, $msg) = req()->paras; // 参数: 对手uid,对手昵称,对手头像, 对战结果, 胜利者的留言(失败时无法留言"")
|
|
|
+ $key_mine = MemKey_User::OffensiveLog_zset(req()->zoneid, req()->uid);
|
|
|
+ $key_target = MemKey_User::DefensiveLog_zset(req()->zoneid, $targetUID);
|
|
|
$ts = now(); # 记录时间戳
|
|
|
gMem()->zadd($key_mine, array(# # 组装被挑战对手信息
|
|
|
JsonUtil::encode(array(
|
|
@@ -106,36 +102,33 @@ class PVPProc {
|
|
|
gMem()->zremrangebyrank($key_mine, self::maxLogCount, -1); # 保留50条数据
|
|
|
gMem()->zadd($key_target, array(# # 组装挑战者信息
|
|
|
JsonUtil::encode(array(
|
|
|
- 'uid' => $req->uid,
|
|
|
- 'name' => $req->userInfo->game->baseInfo->name,
|
|
|
- 'headImg' => $req->userInfo->game->baseInfo->headImg,
|
|
|
+ 'uid' => req()->uid,
|
|
|
+ 'name' => req()->userInfo->game->baseInfo->name,
|
|
|
+ 'headImg' => req()->userInfo->game->baseInfo->headImg,
|
|
|
'win' => !my_null_default($win, false),
|
|
|
'msg' => my_null_default($msg, ""),
|
|
|
'ts' => $ts
|
|
|
)) => $ts));
|
|
|
- gMem()->zremrangebyrank($key_target, self::maxLogCount, -1); # 保留50条数据
|
|
|
+ gMem()->zremrangebyrank($key_target, self::maxLogCount, -1); # 保留50条数据
|
|
|
// 暂无发放奖励流程
|
|
|
- // 更新每日任务
|
|
|
- TaskProc::OnRankChalenge();
|
|
|
+ TaskProc::OnRankChalenge(); // 更新每日任务
|
|
|
UserProc::updateUserInfo();
|
|
|
- // 返回
|
|
|
return Resp::ok(); # 返回成功
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [6805] 挑战 - 拉取挑战记录
|
|
|
- * @param req $req
|
|
|
*/
|
|
|
- static function GetChagllengeLog($req) {
|
|
|
+ static function GetChagllengeLog() {
|
|
|
// 参数:无
|
|
|
- $key_off = MemKey_User::OffensiveLog_zset($req->zoneid, $req->uid);
|
|
|
- $key_def = MemKey_User::DefensiveLog_zset($req->zoneid, $req->uid);
|
|
|
+ $key_off = MemKey_User::OffensiveLog_zset(req()->zoneid, req()->uid);
|
|
|
+ $key_def = MemKey_User::DefensiveLog_zset(req()->zoneid, req()->uid);
|
|
|
// 拉取自己的挑战记录
|
|
|
$offLog = gMem()->zrange($key_off, 0, self::maxLogCount);
|
|
|
$defLog = gMem()->zrange($key_def, 0, self::maxLogCount);
|
|
|
// Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
|
|
|
// if (!CommUtil::isPropertyExists($req->userInfo->game->privateState, "lastCheckDefLog")) {
|
|
|
- $req->userInfo->game->privateState->lastCheckDefLog_ts = now(); # 记录时间戳
|
|
|
+ req()->userInfo->game->privateState->lastCheckDefLog_ts = now(); # 记录时间戳
|
|
|
// }
|
|
|
UserProc::updateUserInfo(); # 回写数据
|
|
|
// 记录拉取时间戳(在主界面有个未读消息条数显示, 需要靠最后拉取时间戳对比, 时间戳之后的消息是未读消息)
|
|
@@ -162,27 +155,25 @@ class PVPProc {
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * [6820] 竞技商店 主界面
|
|
|
- * @param req $req
|
|
|
+ * [6820] 竞技商店 主界面
|
|
|
*/
|
|
|
- public static function pvpShopMain($req) {
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp); # PVP信息
|
|
|
+ public static function pvpShopMain() {
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp); # PVP信息
|
|
|
if ($pvp->shopRefreshTs < now()) { # 检查刷新时间<now => 刷新商品列表
|
|
|
$pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval; # 更新刷新时间
|
|
|
$pvp->curShopItems = GameConfig::pvp_shop(); # 重刷道具
|
|
|
- $req->userInfo->game->pvp = $pvp; # 回写
|
|
|
+ req()->userInfo->game->pvp = $pvp; # 回写
|
|
|
UserProc::updateUserInfo();
|
|
|
}
|
|
|
return Resp::ok($pvp); // 返回
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [6821] 竞技 商店 购买道具
|
|
|
- * @param req $req
|
|
|
+ * [6821] 竞技 商店 购买道具
|
|
|
*/
|
|
|
- public static function pvpShopBuy($req) {
|
|
|
- $index = $req->paras[0]; # 参数:道具索引(typeId)
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp); # PVP 数据
|
|
|
+ public static function pvpShopBuy() {
|
|
|
+ $index = req()->paras[0]; # 参数:道具索引(typeId)
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp); # PVP 数据
|
|
|
my_Assert(CommUtil::isPropertyExists($pvp->curShopItems, $index), ErrCode::err_innerfault); # 没有找到改商品
|
|
|
// isEditor() && $citem = new \sm_pvp_shop();
|
|
|
$citem = $pvp->curShopItems->$index; # 查询物品数据
|
|
@@ -192,24 +183,23 @@ class PVPProc {
|
|
|
my_Assert($pvp->pvpCoins > $citem->price, ErrCode::pvp_coinnotenough); # pvp币不足
|
|
|
$citem->sold += 1; # 设置已售罄/已购买标志
|
|
|
$pvp->pvpCoins -= $citem->price; # 扣除竞技币
|
|
|
- StoreProc::AddMultiItemInStore($req, $citem->goods); // 发放道具
|
|
|
- $req->userInfo->game->pvp = $pvp; // 回写数据
|
|
|
+ StoreProc::AddMultiItemInStore(req(), $citem->goods); // 发放道具
|
|
|
+ req()->userInfo->game->pvp = $pvp; // 回写数据
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok(array('pvp' => $pvp, 'store' => $req->userInfo->game->store)); # 返回
|
|
|
+ return Resp::ok(array('pvp' => $pvp, 'store' => req()->userInfo->game->store)); # 返回
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [6822] 竞技 商店 刷新道具
|
|
|
- * @param req $req
|
|
|
+ * [6822] 竞技 商店 刷新道具
|
|
|
*/
|
|
|
- public static function pvpShopRefresh($req) {
|
|
|
+ public static function pvpShopRefresh() {
|
|
|
// 扣除刷新消耗
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp);
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
|
|
|
$costCash = glc()->PVP_shop_refresh_cash;
|
|
|
- my_Assert(Data_UserGame::Consume_Cash($req->userInfo->game->baseInfo, $costCash), ErrCode::notenough_cash_msg);
|
|
|
+ my_Assert(Data_UserGame::Consume_Cash(req()->userInfo->game->baseInfo, $costCash), ErrCode::notenough_cash_msg);
|
|
|
// $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval; # 更新刷新时间
|
|
|
$pvp->curShopItems = GameConfig::pvp_shop(); # 重刷道具
|
|
|
- $req->userInfo->game->pvp = $pvp; # 回写
|
|
|
+ req()->userInfo->game->pvp = $pvp; # 回写
|
|
|
UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
return Resp::ok($pvp); # 返回
|
|
|
}
|
|
@@ -240,23 +230,22 @@ class PVPProc {
|
|
|
|
|
|
/**
|
|
|
* [6810] 竞技场 拉取主界面信息
|
|
|
- * @param Req $req
|
|
|
*/
|
|
|
- static function pvpMainInfo($req) {
|
|
|
- $uid = $req->uid; # 快速访问UID
|
|
|
- $zoneid = $req->zoneid; # 快速访问zoneid
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp); # 设计玩家pvp数据结构
|
|
|
+ static function pvpMainInfo() {
|
|
|
+ $uid = req()->uid; # 快速访问UID
|
|
|
+ $zoneid = req()->zoneid; # 快速访问zoneid
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp); # 设计玩家pvp数据结构
|
|
|
$pvp->refreshDailyData(); # 刷新免费挑战次数
|
|
|
$seasonId = self::GetCurSeasonID(); # 当前赛季ID
|
|
|
$key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
|
|
|
|
|
|
$score = self::_getScore_by_uid($uid, $key); # 玩家积分
|
|
|
$rank = self::_getRank_by_uid($uid, $key); # 玩家排名
|
|
|
- $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, $req->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
|
|
|
+ $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, req()->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
|
|
|
$numNewLog = 0; // todo: 真正查询是否有新战报
|
|
|
$matches = self::getNewMatches($pvp, $uid, $zoneid); # 获得新的匹配对手
|
|
|
$pvp->sendRewardEmail($zoneid, $uid, $seasonId); # 发奖励邮件
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
+ req()->userInfo->game->pvp = $pvp;
|
|
|
UserProc::updateUserInfo();
|
|
|
$ret = array(# # 组装 返回值结构
|
|
|
'score' => $score, # # 自己的积分
|
|
@@ -272,17 +261,16 @@ class PVPProc {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [6811] 竞技场 刷新对手
|
|
|
- * @param Req $req
|
|
|
+ * [6811] 竞技场 刷新对手
|
|
|
*/
|
|
|
- static function pvp_Refresh($req) {
|
|
|
+ static function pvp_Refresh() {
|
|
|
// 刷新无花费, 间隔时间3秒(客户端控制得了)
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp);
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
|
|
|
$ts = now();
|
|
|
my_Assert($pvp->nextRefreshTs < $ts, ErrCode::pvp_refresh_time); # 验证时间间隔
|
|
|
- $pvp->curMatches = self::getNewMatches($pvp, $req->uid, $req->zoneid);
|
|
|
+ $pvp->curMatches = self::getNewMatches($pvp, req()->uid, req()->zoneid);
|
|
|
$pvp->nextRefreshTs = now(3);
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
+ req()->userInfo->game->pvp = $pvp;
|
|
|
UserProc::updateUserInfo(); # 回写数据
|
|
|
$ret = array(
|
|
|
'curMatches' => my_null_default($pvp->curMatches, array()), # # 当前对手清单
|
|
@@ -292,15 +280,14 @@ class PVPProc {
|
|
|
|
|
|
/**
|
|
|
* [6812] 竞技场 挑战对手xx
|
|
|
- * @param Req $req
|
|
|
*/
|
|
|
- static function pvp_PK($req) {
|
|
|
- $uid = $req->uid;
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $baseInfo = $req->userInfo->game->baseInfo;
|
|
|
- list($target_uid, $result, $target_name, $target_HeadImg) = $req->paras; # 对手id,胜负结果 0负,1胜
|
|
|
+ static function pvp_PK() {
|
|
|
+ $uid = req()->uid;
|
|
|
+ $zoneid = req()->zoneid;
|
|
|
+ $baseInfo = req()->userInfo->game->baseInfo;
|
|
|
+ list($target_uid, $result, $target_name, $target_HeadImg) = req()->paras; # 对手id,胜负结果 0负,1胜
|
|
|
|
|
|
- $pvp = $req->userInfo->game->pvp;
|
|
|
+ $pvp = req()->userInfo->game->pvp;
|
|
|
|
|
|
if ($pvp->freeFightTickets > 0) { # 有免费挑战票,先扣除免费的
|
|
|
$pvp->freeFightTickets -= 1;
|
|
@@ -333,7 +320,7 @@ class PVPProc {
|
|
|
TaskProc::OnPvPWinN($pvp->totalWin);
|
|
|
TaskProc::OnPvPScoreN($R_A);
|
|
|
}
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
+ req()->userInfo->game->pvp = $pvp;
|
|
|
TaskProc::OnPvp(); # 每日PVP挑战即可
|
|
|
UserProc::updateUserInfo(); # 回写数据
|
|
|
// 写挑战记录
|
|
@@ -357,76 +344,64 @@ class PVPProc {
|
|
|
|
|
|
/**
|
|
|
* [6813] 竞技场 设置防守队伍
|
|
|
- * @param req $req
|
|
|
*/
|
|
|
- public static function pvp_setTeam($req) {
|
|
|
- $heros = $req->paras[0]; # para: 新阵容
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp);
|
|
|
+ public static function pvp_setTeam() {
|
|
|
+ $heros = req()->paras[0]; # para: 新阵容
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
|
|
|
my_Assert(is_array($heros), ErrCode::paras_err); # 参数检查
|
|
|
$pvp->defTeam = $heros; # 更新阵容
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
+ req()->userInfo->game->pvp = $pvp;
|
|
|
UserProc::updateUserInfo(); # 回存数据
|
|
|
return Resp::ok($pvp); # 返回
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [6814] 购买挑战票
|
|
|
- * @param Req $req
|
|
|
- * @return type
|
|
|
+ * [6814] 购买挑战票
|
|
|
+ * @return Resp
|
|
|
*/
|
|
|
- static function pvp_buyticket($req) {
|
|
|
- $amt = $req->paras[0]; # 购买数量
|
|
|
- # 检查并扣除消耗
|
|
|
- # 增加挑战票
|
|
|
- # 回存数据
|
|
|
- # 返回
|
|
|
+ static function pvp_buyticket() {
|
|
|
+ $amt = req()->paras[0]; # 购买数量
|
|
|
my_Assert($amt > 0, ErrCode::paras_err); # 数量>0
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp);
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
|
|
|
$g = glc();
|
|
|
$costCash = $g->PVP_pk_ticket_price * $amt; # 计算消耗钻石
|
|
|
my_Assert($costCash > 0, ErrCode::pvp_ticket_cost_ilegal); # 定价数据异常
|
|
|
+ my_Assert(Data_UserGame::Consume_Cash(req()->userInfo->game->baseInfo, $costCash), ErrCode::notenough_cash_msg); # 扣除钻石失败
|
|
|
|
|
|
- if (!Data_UserGame::Consume_Cash($req->userInfo->game->baseInfo, $costCash)) { # 扣除钻石失败
|
|
|
- return Resp::err(ErrCode::notenough_cash_msg);
|
|
|
- }
|
|
|
$pvp->fightTicket += $amt; # 发放挑战票
|
|
|
- $req->userInfo->game->pvp = $pvp;
|
|
|
+ req()->userInfo->game->pvp = $pvp;
|
|
|
UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
$ret = array(
|
|
|
'fightTicket' => $pvp->fightTicket,
|
|
|
'costCash' => $costCash,
|
|
|
- 'userCash' => $req->userInfo->game->baseInfo->cash
|
|
|
+ 'userCash' => req()->userInfo->game->baseInfo->cash
|
|
|
);
|
|
|
return Resp::ok($ret); # 返回
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [6815] 竞技场 拉取榜单数据
|
|
|
- * @param Req $req
|
|
|
+ * [6815] 竞技场 拉取榜单数据
|
|
|
*/
|
|
|
- static function pvp_getRank($req) {
|
|
|
+ static function pvp_getRank() {
|
|
|
$maxAmt = 10; # 一次最多取10个玩家信息
|
|
|
- $zoneid = $req->zoneid;
|
|
|
- $index = $req->paras[0]; # 起始(0)
|
|
|
- $n = $req->paras[1]; # 数量, (n<=max)
|
|
|
- #
|
|
|
+ $zoneid = req()->zoneid;
|
|
|
+ list($index, $n) = req()->paras; # 起始(0), 数量(n<=max)
|
|
|
if ($n < 1 || $n > $maxAmt) { # 防御非法情况
|
|
|
$n = $maxAmt;
|
|
|
}
|
|
|
- $arr = self::getRankPlayers($zoneid, $index - 1, ($index + $n) - 1);
|
|
|
-//
|
|
|
+ $arr = self::getRankPlayers($zoneid, $index - 1, ($index + $n) - 1); // 上榜玩家
|
|
|
$rankId = $index;
|
|
|
$result = ObjectInit();
|
|
|
if (count($arr)) {
|
|
|
- foreach ($arr as $key => $value) {// $value 的数据类型是array
|
|
|
+ foreach ($arr as $key => $value) { // $value 的数据类型是array
|
|
|
$value["uid"] = $key;
|
|
|
$result->$rankId = $value;
|
|
|
$rankId += 1;
|
|
|
}
|
|
|
}
|
|
|
$key_rank = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, self::GetCurSeasonID());
|
|
|
- $myRank = self::_getRank_by_uid($req->uid, $key_rank);
|
|
|
- $myScore = self::_getScore_by_uid($uid, $key_rank);
|
|
|
+ $myRank = self::_getRank_by_uid(req()->uid, $key_rank);
|
|
|
+ $myScore = self::_getScore_by_uid(req()->uid, $key_rank);
|
|
|
$ret = array(
|
|
|
'dic' => $result,
|
|
|
'myRank' => $myRank,
|
|
@@ -436,21 +411,20 @@ class PVPProc {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [6816] 竞技场 查看战报
|
|
|
- * @param Req $req
|
|
|
+ * [6816] 竞技场 查看战报
|
|
|
*/
|
|
|
- static function pvp_getFightLogs($req) {
|
|
|
+ static function pvp_getFightLogs() {
|
|
|
// 提取主动挑战+被挑战记录
|
|
|
// 更新下刷新时间
|
|
|
// 返回
|
|
|
// 参数:无
|
|
|
- $key_off = MemKey_User::PVP_OffensiveLog_zset($req->zoneid, $req->uid);
|
|
|
- $key_def = MemKey_User::PVP_DefensiveLog_zset($req->zoneid, $req->uid);
|
|
|
+ $key_off = MemKey_User::PVP_OffensiveLog_zset(req()->zoneid, req()->uid);
|
|
|
+ $key_def = MemKey_User::PVP_DefensiveLog_zset(req()->zoneid, req()->uid);
|
|
|
// 拉取自己的挑战记录
|
|
|
$offLog = gMem()->zrange($key_off, 0, self::maxLogCount); # 主动挑战数据
|
|
|
$defLog = gMem()->zrange($key_def, 0, self::maxLogCount); # 防守数据
|
|
|
// Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
|
|
|
- $pvp = new Info_UserPVP($req->userInfo->game->pvp); # 玩家竞技场数据
|
|
|
+ $pvp = new Info_UserPVP(req()->userInfo->game->pvp); # 玩家竞技场数据
|
|
|
$pvp->lastCheckDefLog_ts = now(); # 记录时间戳
|
|
|
UserProc::updateUserInfo(); # 回写数据
|
|
|
array_walk($offLog, function (&$i) { # 解码一下
|