diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index a957d23..d83a780 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -498,46 +498,44 @@ function _M.buyBonusCountRpc(agent, data) return true end -local function bonusWinReward(role, bonusData, bwin, count) +local function bonusWinReward(role, bonusData, rewardType, count) count = count or 1 - local open, actId = role.activity:isOpen("BonusDouble") - local actData = csvdb["activity_ctrlCsv"][actId] - local extraCnt = role.storeData:getBonusExtraFightCount() - - local coef = 1 - if open and actData then - coef = tonumber(actData.condition2) - end - local bonusC = role.dailyData:getProperty("bonusC") - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count - role.dailyData:updateProperty({field = "bonusC", value = bonusC}) - local reward, change - reward = bonusData.reward:toNumMap() - for itemId, c in pairs(reward) do - reward[itemId] = c * count - end - for i = 1, count do - local chance = bonusData.chance:randWeight(true) - if chance[1] ~= 0 then - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] + local reward, change = {} + if rewardType == 1 or rewardType == 4 then + for k, v in pairs(bonusData.clear_reward:toNumMap()) do + reward[k] = (reward[k] or 0) + v end end - for k, v in pairs(reward) do - reward[k] = v * (coef > 1 and actData.condition or 1) - end - - if bwin then -- 满星 额外奖励 + if rewardType == 2 or rewardType == 4 then for k, v in pairs(bonusData.perfect_reward:toNumMap()) do reward[k] = (reward[k] or 0) + v end end - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) - role:checkTaskEnter("BonusPass", {id = id, count = count}) - return true, reward, change + + if rewardType == 3 then + local open, actId = role.activity:isOpen("BonusDouble") + local actData = csvdb["activity_ctrlCsv"][actId] + + reward = bonusData.reward:toNumMap() + for itemId, c in pairs(reward) do + reward[itemId] = c * count + end + for i = 1, count do + local chance = bonusData.chance:randWeight(true) + if chance[1] ~= 0 then + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] + end + end + for k, v in pairs(reward) do + reward[k] = v * (actData.condition > 1 and actData.condition or 1) + end + end + + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = bonusData.id}}) + role:checkTaskEnter("BonusPass", {id = bonusData.id, count = count}) + return reward, change end function _M.startBonusBattleRpc(agent, data) @@ -559,23 +557,24 @@ function _M.startBonusBattleRpc(agent, data) if not bonusData then return 3 end if not role:checkHangPass(bonusData.unlock) then return 4 end - local bonusC = role.dailyData:getProperty("bonusC") - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} - - local actData = csvdb["activity_ctrlCsv"][actId] - - local extraCnt = role.storeData:getBonusExtraFightCount() - local coef = 1 - if open and actData then - coef = tonumber(actData.condition2) - end - - if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end local bonusStar = role:getProperty("bonusStar") if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then - local status, reward, change = bonusWinReward(role, bonusData, nil, count) - if not status then return 10 * (reward or 0) end + local bonusC = role.dailyData:getProperty("bonusC") + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} + + local actData = csvdb["activity_ctrlCsv"][actId] + local extraCnt = role.storeData:getBonusExtraFightCount() + local coef = 1 + if open and actData then + coef = tonumber(actData.condition2) + end + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end + + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) + + local reward, change = bonusWinReward(role, bonusData, 3, count) SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) else local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) @@ -608,6 +607,7 @@ function _M.endBonusBattleRpc(agent, data) local reward, change local bonusStar = role:getProperty("bonusStar") + local oldStar = bonusStar[id] or 0 local curStar = 0 if starNum and starNum > 0 then -- 胜利扣除次数 @@ -671,12 +671,23 @@ function _M.endBonusBattleRpc(agent, data) end end local status - status, reward, change = bonusWinReward(role, bonusData, curStar >= (1 << #sweepConds) - 1) - if not status then return 10 + (reward or 0) end + local rewardType = 0 + if curStar >= (1 << #sweepConds) - 1 then -- 满星 + rewardType = 2 + if oldStar == 0 then --通关 + rewardType = 4 + end + elseif oldStar == 0 then --通关 + rewardType = 1 + end + + if rewardType ~= 0 then + reward, change = bonusWinReward(role, bonusData, rewardType) + end else - curStar = 0 + curStar = oldStar end - if curStar ~= bonusStar[id] then + if curStar ~= oldStar then bonusStar[id] = curStar role:updateProperty({field = "bonusStar", value = bonusStar}) end diff --git a/src/models/RoleBattle.lua b/src/models/RoleBattle.lua index 57c58b6..825b4bf 100644 --- a/src/models/RoleBattle.lua +++ b/src/models/RoleBattle.lua @@ -102,7 +102,7 @@ function Role:checkBattle(battleType, params) end end, pvpc = function() - for slot, hero in pairs(self:getProperty("pvpTSC")) do + for slot, hero in pairs(self:getProperty("pvpTSC").heros) do selflist[slot] = hero.type end heroscore = self:getProperty("pvpTBVC") @@ -124,7 +124,7 @@ function Role:checkBattle(battleType, params) pvph = function() for idx, team in pairs(self:getProperty("pvpTSH")) do selflist[idx] = selflist[idx] or {} - for slot, hero in pairs(team) do + for slot, hero in pairs(team.heros) do selflist[idx][slot] = hero.type end end diff --git a/src/models/RolePvp.lua b/src/models/RolePvp.lua index 3afbd69..cb3f6f9 100644 --- a/src/models/RolePvp.lua +++ b/src/models/RolePvp.lua @@ -233,7 +233,6 @@ function Role:refreshPvpMatch(score, rank, rankKey) if low < 0 then low = 0 end - print(low, heigh) local rangeIds = redisproxy:ZREVRANGE(dbKey, low, heigh) local lastRangeIds = {} for idx, one in ipairs(rangeIds) do -- libgit2 0.21.2