Commit 55c7c172ba60d62ced6971b76704d73d8673f6cc
1 parent
23847cc0
奖励副本 新机制
Showing
3 changed files
with
62 additions
and
52 deletions
Show diff stats
src/actions/HangAction.lua
... | ... | @@ -498,46 +498,44 @@ function _M.buyBonusCountRpc(agent, data) |
498 | 498 | return true |
499 | 499 | end |
500 | 500 | |
501 | -local function bonusWinReward(role, bonusData, bwin, count) | |
501 | +local function bonusWinReward(role, bonusData, rewardType, count) | |
502 | 502 | count = count or 1 |
503 | - local open, actId = role.activity:isOpen("BonusDouble") | |
504 | - local actData = csvdb["activity_ctrlCsv"][actId] | |
505 | - local extraCnt = role.storeData:getBonusExtraFightCount() | |
506 | - | |
507 | - local coef = 1 | |
508 | - if open and actData then | |
509 | - coef = tonumber(actData.condition2) | |
510 | - end | |
511 | - local bonusC = role.dailyData:getProperty("bonusC") | |
512 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
513 | - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end | |
514 | - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | |
515 | - role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | |
516 | 503 | |
517 | - local reward, change | |
518 | - reward = bonusData.reward:toNumMap() | |
519 | - for itemId, c in pairs(reward) do | |
520 | - reward[itemId] = c * count | |
521 | - end | |
522 | - for i = 1, count do | |
523 | - local chance = bonusData.chance:randWeight(true) | |
524 | - if chance[1] ~= 0 then | |
525 | - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | |
504 | + local reward, change = {} | |
505 | + if rewardType == 1 or rewardType == 4 then | |
506 | + for k, v in pairs(bonusData.clear_reward:toNumMap()) do | |
507 | + reward[k] = (reward[k] or 0) + v | |
526 | 508 | end |
527 | 509 | end |
528 | 510 | |
529 | - for k, v in pairs(reward) do | |
530 | - reward[k] = v * (coef > 1 and actData.condition or 1) | |
531 | - end | |
532 | - | |
533 | - if bwin then -- 满星 额外奖励 | |
511 | + if rewardType == 2 or rewardType == 4 then | |
534 | 512 | for k, v in pairs(bonusData.perfect_reward:toNumMap()) do |
535 | 513 | reward[k] = (reward[k] or 0) + v |
536 | 514 | end |
537 | 515 | end |
538 | - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
539 | - role:checkTaskEnter("BonusPass", {id = id, count = count}) | |
540 | - return true, reward, change | |
516 | + | |
517 | + if rewardType == 3 then | |
518 | + local open, actId = role.activity:isOpen("BonusDouble") | |
519 | + local actData = csvdb["activity_ctrlCsv"][actId] | |
520 | + | |
521 | + reward = bonusData.reward:toNumMap() | |
522 | + for itemId, c in pairs(reward) do | |
523 | + reward[itemId] = c * count | |
524 | + end | |
525 | + for i = 1, count do | |
526 | + local chance = bonusData.chance:randWeight(true) | |
527 | + if chance[1] ~= 0 then | |
528 | + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | |
529 | + end | |
530 | + end | |
531 | + for k, v in pairs(reward) do | |
532 | + reward[k] = v * (actData.condition > 1 and actData.condition or 1) | |
533 | + end | |
534 | + end | |
535 | + | |
536 | + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = bonusData.id}}) | |
537 | + role:checkTaskEnter("BonusPass", {id = bonusData.id, count = count}) | |
538 | + return reward, change | |
541 | 539 | end |
542 | 540 | |
543 | 541 | function _M.startBonusBattleRpc(agent, data) |
... | ... | @@ -559,23 +557,24 @@ function _M.startBonusBattleRpc(agent, data) |
559 | 557 | if not bonusData then return 3 end |
560 | 558 | if not role:checkHangPass(bonusData.unlock) then return 4 end |
561 | 559 | |
562 | - local bonusC = role.dailyData:getProperty("bonusC") | |
563 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
564 | - | |
565 | - local actData = csvdb["activity_ctrlCsv"][actId] | |
566 | - | |
567 | - local extraCnt = role.storeData:getBonusExtraFightCount() | |
568 | - local coef = 1 | |
569 | - if open and actData then | |
570 | - coef = tonumber(actData.condition2) | |
571 | - end | |
572 | - | |
573 | - if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end | |
574 | 560 | |
575 | 561 | local bonusStar = role:getProperty("bonusStar") |
576 | 562 | if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then |
577 | - local status, reward, change = bonusWinReward(role, bonusData, nil, count) | |
578 | - if not status then return 10 * (reward or 0) end | |
563 | + local bonusC = role.dailyData:getProperty("bonusC") | |
564 | + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
565 | + | |
566 | + local actData = csvdb["activity_ctrlCsv"][actId] | |
567 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
568 | + local coef = 1 | |
569 | + if open and actData then | |
570 | + coef = tonumber(actData.condition2) | |
571 | + end | |
572 | + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end | |
573 | + | |
574 | + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | |
575 | + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | |
576 | + | |
577 | + local reward, change = bonusWinReward(role, bonusData, 3, count) | |
579 | 578 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) |
580 | 579 | else |
581 | 580 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) |
... | ... | @@ -608,6 +607,7 @@ function _M.endBonusBattleRpc(agent, data) |
608 | 607 | local reward, change |
609 | 608 | |
610 | 609 | local bonusStar = role:getProperty("bonusStar") |
610 | + local oldStar = bonusStar[id] or 0 | |
611 | 611 | local curStar = 0 |
612 | 612 | if starNum and starNum > 0 then |
613 | 613 | -- 胜利扣除次数 |
... | ... | @@ -671,12 +671,23 @@ function _M.endBonusBattleRpc(agent, data) |
671 | 671 | end |
672 | 672 | end |
673 | 673 | local status |
674 | - status, reward, change = bonusWinReward(role, bonusData, curStar >= (1 << #sweepConds) - 1) | |
675 | - if not status then return 10 + (reward or 0) end | |
674 | + local rewardType = 0 | |
675 | + if curStar >= (1 << #sweepConds) - 1 then -- 满星 | |
676 | + rewardType = 2 | |
677 | + if oldStar == 0 then --通关 | |
678 | + rewardType = 4 | |
679 | + end | |
680 | + elseif oldStar == 0 then --通关 | |
681 | + rewardType = 1 | |
682 | + end | |
683 | + | |
684 | + if rewardType ~= 0 then | |
685 | + reward, change = bonusWinReward(role, bonusData, rewardType) | |
686 | + end | |
676 | 687 | else |
677 | - curStar = 0 | |
688 | + curStar = oldStar | |
678 | 689 | end |
679 | - if curStar ~= bonusStar[id] then | |
690 | + if curStar ~= oldStar then | |
680 | 691 | bonusStar[id] = curStar |
681 | 692 | role:updateProperty({field = "bonusStar", value = bonusStar}) |
682 | 693 | end | ... | ... |
src/models/RoleBattle.lua
... | ... | @@ -102,7 +102,7 @@ function Role:checkBattle(battleType, params) |
102 | 102 | end |
103 | 103 | end, |
104 | 104 | pvpc = function() |
105 | - for slot, hero in pairs(self:getProperty("pvpTSC")) do | |
105 | + for slot, hero in pairs(self:getProperty("pvpTSC").heros) do | |
106 | 106 | selflist[slot] = hero.type |
107 | 107 | end |
108 | 108 | heroscore = self:getProperty("pvpTBVC") |
... | ... | @@ -124,7 +124,7 @@ function Role:checkBattle(battleType, params) |
124 | 124 | pvph = function() |
125 | 125 | for idx, team in pairs(self:getProperty("pvpTSH")) do |
126 | 126 | selflist[idx] = selflist[idx] or {} |
127 | - for slot, hero in pairs(team) do | |
127 | + for slot, hero in pairs(team.heros) do | |
128 | 128 | selflist[idx][slot] = hero.type |
129 | 129 | end |
130 | 130 | end | ... | ... |
src/models/RolePvp.lua
... | ... | @@ -233,7 +233,6 @@ function Role:refreshPvpMatch(score, rank, rankKey) |
233 | 233 | if low < 0 then |
234 | 234 | low = 0 |
235 | 235 | end |
236 | - print(low, heigh) | |
237 | 236 | local rangeIds = redisproxy:ZREVRANGE(dbKey, low, heigh) |
238 | 237 | local lastRangeIds = {} |
239 | 238 | for idx, one in ipairs(rangeIds) do | ... | ... |