|
|
@@ -16,7 +16,7 @@
|
|
|
--
|
|
|
-- 战斗:
|
|
|
-- 挑战一次依次走 CG_COMBAT_BEGIN(COMBAT_TYPE39~43); 仅首场校验次数/道具并请求跨服
|
|
|
--- 扣次在 C2N_CanFight; onFightEnd 链式 nextCombatType 打满 5 族或 3 胜
|
|
|
+-- 扣次在 C2N_CanFight; onFightEnd 链式 nextCombatType 打满 5 族或 3 胜, 整场结束发 fightReward
|
|
|
-- 机器人: combatBegin; 真人: MiddleCommonLogic_CombatBegin_LW
|
|
|
--
|
|
|
-- 文件结构:
|
|
|
@@ -275,7 +275,7 @@ local function sendMatchListGC(human, myScore, opponentList)
|
|
|
net.body = opp.body or 0
|
|
|
net.power = opp.power
|
|
|
net.score = opp.score
|
|
|
- net.serverId = opp.serverId or 0
|
|
|
+ net.serverId = BaiZhanChengShenDefine.ToClientServerId(opp.serverId, opp.isRobot)
|
|
|
end
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
end
|
|
|
@@ -463,31 +463,66 @@ local function getRankReward(rank)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+-- 道具列表转日志串 itemId:cnt,...
|
|
|
+local function formatAwardList(awardList)
|
|
|
+ if not awardList or #awardList < 1 then
|
|
|
+ return ""
|
|
|
+ end
|
|
|
+ local parts = {}
|
|
|
+ for i, item in ipairs(awardList) do
|
|
|
+ parts[i] = string.format("%s:%s", item[1] or 0, item[2] or 0)
|
|
|
+ end
|
|
|
+ return table.concat(parts, ",")
|
|
|
+end
|
|
|
+
|
|
|
-- 整场挑战结束发放道具奖励(读 excel fightReward: 1=胜 2=负)
|
|
|
-local function grantFightReward(human, atkWin)
|
|
|
+-- combatInfo.rewardItem 供 GC_COMBAT_FINISH 展示, 参考 BattleLogic.onFightEnd
|
|
|
+local function grantFightReward(human, atkWin, combatInfo)
|
|
|
if not human or not human.db then return end
|
|
|
local rewardId = atkWin and BaiZhanChengShenDefine.BZCS_FIGHT_REWARD_WIN_ID
|
|
|
or BaiZhanChengShenDefine.BZCS_FIGHT_REWARD_LOSE_ID
|
|
|
local fightReward = BzcsConfig.fightReward
|
|
|
local cfg = fightReward and fightReward[rewardId]
|
|
|
if not cfg or not cfg.awardList or not next(cfg.awardList) then
|
|
|
- BzcsLog.logAction("fight_reward_miss", string.format("uuid=%s rewardId=%s", human.db._id, rewardId))
|
|
|
+ BzcsLog.logAction("fight_reward_miss", string.format(
|
|
|
+ "uuid=%s atkWin=%s rewardId=%s", human.db._id, atkWin and 1 or 0, rewardId
|
|
|
+ ))
|
|
|
return
|
|
|
end
|
|
|
+ if combatInfo then
|
|
|
+ combatInfo.rewardItem = {}
|
|
|
+ end
|
|
|
local awardList = {}
|
|
|
for i, itemInfo in ipairs(cfg.awardList) do
|
|
|
- awardList[i] = {itemInfo[1], itemInfo[2]}
|
|
|
+ local itemID = itemInfo[1]
|
|
|
+ local itemCnt = itemInfo[2]
|
|
|
+ awardList[i] = {itemID, itemCnt}
|
|
|
+ if combatInfo then
|
|
|
+ combatInfo.rewardItem[i] = {itemID, itemCnt}
|
|
|
+ end
|
|
|
+ BagLogic.addItem(human, itemID, itemCnt, LOGTAG)
|
|
|
end
|
|
|
- BagLogic.addItemList(human, awardList, LOGTAG)
|
|
|
BzcsLog.logAction("fight_reward", string.format(
|
|
|
- "uuid=%s rewardId=%s itemCnt=%s", human.db._id, rewardId, #awardList
|
|
|
+ "uuid=%s atkWin=%s rewardId=%s itemCnt=%s items=%s",
|
|
|
+ human.db._id, atkWin and 1 or 0, rewardId, #awardList, formatAwardList(awardList)
|
|
|
))
|
|
|
end
|
|
|
|
|
|
-- 发周期结算邮件(排名写入正文)
|
|
|
local function sendMail(mailId, receiverUuid, itemArray, rank)
|
|
|
local mailCfg = MailExcel.mail[mailId]
|
|
|
- if not mailCfg then return end
|
|
|
+ if not mailCfg then
|
|
|
+ BzcsLog.logAction("reward_mail_miss", string.format(
|
|
|
+ "uuid=%s rank=%s mailId=%s", receiverUuid or "", rank or 0, mailId or 0
|
|
|
+ ))
|
|
|
+ return
|
|
|
+ end
|
|
|
+ if not itemArray or not next(itemArray) then
|
|
|
+ BzcsLog.logAction("reward_mail_empty", string.format(
|
|
|
+ "uuid=%s rank=%s mailId=%s", receiverUuid or "", rank or 0, mailId
|
|
|
+ ))
|
|
|
+ return
|
|
|
+ end
|
|
|
local content = mailCfg.content
|
|
|
if rank then
|
|
|
if rank > BaiZhanChengShenDefine.BZCS_RANK_MAX then
|
|
|
@@ -496,6 +531,10 @@ local function sendMail(mailId, receiverUuid, itemArray, rank)
|
|
|
content = Util.format(content, rank)
|
|
|
end
|
|
|
MailManager.add(MailManager.SYSTEM, receiverUuid, mailCfg.title, content, itemArray, mailCfg.senderName or "GM")
|
|
|
+ BzcsLog.logAction("reward_mail_ok", string.format(
|
|
|
+ "uuid=%s rank=%s mailId=%s itemCnt=%s items=%s",
|
|
|
+ receiverUuid, rank or 0, mailId, #itemArray, formatAwardList(itemArray)
|
|
|
+ ))
|
|
|
end
|
|
|
|
|
|
-- 批量发奖队列(分批发邮件, 失败重试)
|
|
|
@@ -506,13 +545,26 @@ local function createRewardQueue()
|
|
|
local maxNum = math.min(self.insertMaxNum, #self.playerArray)
|
|
|
for _ = 1, maxNum do
|
|
|
local info = table.remove(self.playerArray)
|
|
|
- local ok, err = pcall(sendMail, BaiZhanChengShenDefine.BZCS_AWARD_MAIL_ID, info[1], getRankReward(info[2]), info[2])
|
|
|
- if not ok then
|
|
|
- if not self.repeatTb[info[1]] or self.repeatTb[info[1]] < self.repeatMaxTimes then
|
|
|
- q:add(info)
|
|
|
- self.repeatTb[info[1]] = (self.repeatTb[info[1]] or 0) + 1
|
|
|
+ local uuid, rank = info[1], info[2]
|
|
|
+ local itemArray = getRankReward(rank)
|
|
|
+ if not itemArray then
|
|
|
+ BzcsLog.logAction("reward_cfg_miss", string.format("uuid=%s rank=%s", uuid or "", rank or 0))
|
|
|
+ else
|
|
|
+ local ok, err = pcall(sendMail, BaiZhanChengShenDefine.BZCS_AWARD_MAIL_ID, uuid, itemArray, rank)
|
|
|
+ if not ok then
|
|
|
+ local retry = (self.repeatTb[uuid] or 0) + 1
|
|
|
+ if retry <= self.repeatMaxTimes then
|
|
|
+ self.repeatTb[uuid] = retry
|
|
|
+ q:add(info)
|
|
|
+ BzcsLog.logAction("reward_mail_fail", string.format(
|
|
|
+ "uuid=%s rank=%s retry=%s err=%s", uuid, rank, retry, err
|
|
|
+ ))
|
|
|
+ else
|
|
|
+ BzcsLog.logAction("reward_mail_giveup", string.format(
|
|
|
+ "uuid=%s rank=%s retry=%s err=%s", uuid, rank, retry, err
|
|
|
+ ))
|
|
|
+ end
|
|
|
end
|
|
|
- BzcsLog.logAction("reward_mail_fail", string.format("uuid=%s rank=%s err=%s", info[1], info[2], err))
|
|
|
end
|
|
|
end
|
|
|
if #self.playerArray > 0 then
|
|
|
@@ -625,7 +677,6 @@ local function challengeFinish(human, cache)
|
|
|
oppName = cache.defName or "",
|
|
|
scoreChange = scoreChange,
|
|
|
})
|
|
|
- grantFightReward(human, atkWin)
|
|
|
|
|
|
human.bzcs_Battle_Cache = nil
|
|
|
end
|
|
|
@@ -745,7 +796,7 @@ function BZCS_WarReport(human)
|
|
|
local r = list[total - j + 1]
|
|
|
local net = msgRet.reportList[j]
|
|
|
net.warType = r.warType or 0
|
|
|
- net.oppServerId = r.oppServerId or 0
|
|
|
+ net.oppServerId = BaiZhanChengShenDefine.ToClientServerId(r.oppServerId, 0)
|
|
|
net.oppName = r.oppName or ""
|
|
|
net.scoreChange = r.scoreChange or 0
|
|
|
end
|
|
|
@@ -840,7 +891,7 @@ local function fillBzcsRankNet(net, info)
|
|
|
net.headFrame = info.headFrame or 0
|
|
|
net.power = info.power or 0
|
|
|
net.score = info.score or BaiZhanChengShenDefine.BZCS_INIT_SCORE
|
|
|
- net.serverId = info.serverId or 0
|
|
|
+ net.serverId = BaiZhanChengShenDefine.ToClientServerId(info.serverId, info.isRobot or 0)
|
|
|
net.uuid = info.uuid or ""
|
|
|
end
|
|
|
|
|
|
@@ -923,6 +974,7 @@ function C2N_IssueReward(msg)
|
|
|
if not rewardList or #rewardList == 0 then
|
|
|
return
|
|
|
end
|
|
|
+ BzcsLog.logAction("reward_issue_ns", string.format("cnt=%s svr=%s", #rewardList, Config.SVR_INDEX))
|
|
|
local q = createRewardQueue()
|
|
|
for _, info in ipairs(rewardList) do
|
|
|
q:add({info[1], info[2]})
|
|
|
@@ -1035,6 +1087,8 @@ function onFightEnd(human, result, combatType, cbParam, combatInfo)
|
|
|
cache.defW = cache.defW + 1
|
|
|
end
|
|
|
|
|
|
+ combatInfo.defender.name = cache.defName
|
|
|
+
|
|
|
local seriesOver = cache.atkW >= BaiZhanChengShenDefine.BZCS_WIN_TARGET
|
|
|
or cache.defW >= BaiZhanChengShenDefine.BZCS_WIN_TARGET
|
|
|
or cache.raceIdx >= BaiZhanChengShenDefine.BZCS_RACE_CNT
|
|
|
@@ -1045,6 +1099,9 @@ function onFightEnd(human, result, combatType, cbParam, combatInfo)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
+ -- 整场结束: 发挑战奖励并写入 combatInfo.rewardItem(GC_COMBAT_FINISH 展示)
|
|
|
+ local atkWin = cache.atkW >= BaiZhanChengShenDefine.BZCS_WIN_TARGET
|
|
|
+ grantFightReward(human, atkWin, combatInfo)
|
|
|
challengeFinish(human, cache)
|
|
|
end
|
|
|
|