Commit cbefef4cd764789602681bb034a4822fbe6946f5

Authored by zhouhaihai
2 parents ebeefd34 d93ec42c

Merge branch 'develop' into cn/develop

* develop: (24 commits)
  天赋系统属性加成改为百分比
  传递 count
  bug
  支付bug
  充值 整理
  奖励关卡 满星奖励
  光环相关buff
  奖励副本 完成
  编队增加战术字段
  编队整理 增加 tactics战术
  光环
  bug
  bug
  多队挂机,天赋道具合成
  修改调用位置
  新的 buff 效果
  删除等级
  天赋技能
  被动触发
  冒险 buff 类型 34 35
  ...
src/GlobalVar.lua
... ... @@ -126,6 +126,7 @@ ItemId = {
126 126 HeroFC = {700, 701, 702, 703}, --通用角色碎片
127 127 AdvKey = 80, -- 冒险钥匙
128 128 BoxKey = 60, -- 拆解工具
  129 + AdvPower = 4701, -- 拾荒体力
129 130 }
130 131  
131 132 TimeReset = {
... ...
src/ProtocolCode.lua
... ... @@ -99,6 +99,7 @@ actionCodes = {
99 99 Hero_unlockPoolRpc = 222,
100 100 Hero_changeCrown = 223,
101 101 Hero_drawHeroExtraRewardNtf = 224,
  102 + Hero_itemComposeRpc = 225,
102 103  
103 104 Hang_startRpc = 251,
104 105 Hang_checkRpc = 252,
... ... @@ -217,9 +218,8 @@ actionCodes = {
217 218 Activity_actCalendaTaskRpc = 655,
218 219 Activity_actPaySignRpc = 656,
219 220  
220   - Radio_listRpc = 700, -- 获取电台讨伐任务列表
221   - Radio_startQuestRpc = 701,
222   - Radio_finishQuestRpc = 702,
  221 + Radio_startQuestRpc = 700,
  222 + Radio_finishQuestRpc = 701,
223 223 }
224 224  
225 225 rpcResponseBegin = 10000
... ...
src/RedisKeys.lua
... ... @@ -12,6 +12,8 @@ R_RUNE = "role:%d:rune:%d" -- 符文详细信息
12 12 R_EMAIL = "role:%d:emailIds" --邮件列表
13 13 R_EMAIL_ITEM = "email:%d:%d" --邮件
14 14 R_STORE = "role:%d:store" -- 商店
  15 +R_ORDERS = "role:%d:orders" -- 订单
  16 +R_ORDER = "order:%d:%d"
15 17  
16 18  
17 19 -- rank
... ...
src/actions/AdvAction.lua
... ... @@ -247,13 +247,14 @@ function _M.startHangRpc(agent, data)
247 247 info.format.heros[slot] = heroId
248 248 end
249 249 info.time = skynet.timex() + adv_idle_time --挂机时间
  250 + info.duration = adv_idle_time
250 251 info.campId = campId
251 252 info.index = index
252 253  
253 254 -- 没有在战斗 用team来挂机了 把team清掉
254   - if not role:getAdvData():isRunning() then
255   - role:updateProperty({field = "advTeam", value = {}})
256   - end
  255 + --if not role:getAdvData():isRunning() then
  256 + -- role:updateProperty({field = "advTeam", value = {}})
  257 + --end
257 258 role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time})
258 259 role:changeUpdates({{type = "advHang", field = chapterId, value = info}})
259 260  
... ... @@ -265,6 +266,16 @@ function _M.startHangRpc(agent, data)
265 266 return true
266 267 end
267 268  
  269 +local function addHeroFaith(role, heroId, exp)
  270 + local hero = role.heros[heroId]
  271 + if not hero then
  272 + return
  273 + end
  274 +
  275 + hero:addHeroFaith(exp)
  276 + return hero:getProperty("faith")
  277 +end
  278 +
268 279 function _M.quickHangRpc(agent, data)
269 280 local role = agent.role
270 281 local msg = MsgPack.unpack(data)
... ... @@ -332,7 +343,7 @@ function _M.endHangRpc(agent, data)
332 343 end
333 344 adv_idle_time = adv_idle_time * 60
334 345  
335   - local reward, isFull, change
  346 + local reward, isFull, change, heroFaithMap
336 347 if skynet.timex() >= info.time then
337 348 -- 最新需求加成取消
338 349 --[[
... ... @@ -361,6 +372,14 @@ function _M.endHangRpc(agent, data)
361 372  
362 373 if not maxCampsite then return end
363 374 ]]
  375 + -- 增加英雄信赖
  376 + local exp = info.duration / 60
  377 + heroFaithMap = {}
  378 + for _, heroId in pairs(info.format.heros) do
  379 + local curFaith = addHeroFaith(role, heroId, exp)
  380 + heroFaithMap[heroId] = curFaith
  381 + end
  382 +
364 383 local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
365 384  
366 385 local idleReward = totalReward:toNumMap()
... ... @@ -388,7 +407,7 @@ function _M.endHangRpc(agent, data)
388 407  
389 408 role:checkTaskEnter("AdvHang", {})
390 409  
391   - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull}))
  410 + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap}))
392 411 return true
393 412 end
394 413  
... ... @@ -508,25 +527,8 @@ function _M.useItemRpc(agent, data)
508 527 adv:cost({[itemId] = count}, {log = {desc = "useItem", int1 = itemId, int2 = count}})
509 528 adv:backUse({[itemId] = count})
510 529 end
511   -
512   - if itemId == 5020 then
513   - role:finishGuide(53)
514   - end
515   - adv:checkAchievement(adv.AchievType.UseItem, count, itemId)
516   - adv:mylog({desc = "useItem", int1 = itemId, int2 = count})
517   -
518   - role:log("mission_pick_use", {
519   - mission_threadid = adv.chapterId, -- 大地图ID
520   - mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称
521   - mission_id = adv.level, -- 关卡ID
522   - item_id = itemId, -- 道具ID
523   - mission_pick_use_num = count, -- 道具使用量
524   - mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志
525   - })
526   -
527   - for i = 1, count do
528   - adv:doActive(itemData.effect, target) -- target
529   - end
  530 +
  531 + adv:useItem(itemId, count, target)
530 532  
531 533 adv:afterRound()
532 534 adv:saveDB()
... ...
src/actions/DinerAction.lua
... ... @@ -609,10 +609,10 @@ function _M.refreshTaskRpc( agent, data )
609 609 local role = agent.role
610 610 local msg = MsgPack.unpack(data)
611 611  
612   - local cost = {[ItemId.Diamond] = 40}
613   - if not role:checkItemEnough(cost) then
614   - return 1
615   - end
  612 + --local cost = {[ItemId.Diamond] = 40}
  613 + --if not role:checkItemEnough(cost) then
  614 + -- return 1
  615 + --end
616 616  
617 617 local orders = json.decode(role.dinerData:getProperty("order"))
618 618  
... ...
src/actions/GmAction.lua
... ... @@ -402,24 +402,23 @@ function _M.advl(role, pms)
402 402 return "成功"
403 403 end
404 404  
405   -table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"})
406   -function _M.advcl(role, pms)
407   - local exp = tonum(pms.pm1)
408   - local advData = role:getAdvData()
  405 +-- table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"})
  406 +-- function _M.advcl(role, pms)
  407 +-- local exp = tonum(pms.pm1)
  408 +-- local advData = role:getAdvData()
409 409  
410   - if not advData.chapterId then
411   - return "先随便开启一关"
412   - end
413   - advData.battle.player:addExp(exp)
414   - advData:saveDB()
415   - role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender})
  410 +-- if not advData.chapterId then
  411 +-- return "先随便开启一关"
  412 +-- end
  413 +-- advData.battle.player:addExp(exp)
  414 +-- advData:saveDB()
  415 +-- role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender})
416 416  
417   - return "成功"
418   -end
  417 +-- return "成功"
  418 +-- end
419 419  
420 420 table.insert(helpDes, {"挂机清除" , "idlec"})
421 421 function _M.idlec(role, pms)
422   - role:updateProperty({field = "hangTeam", value = {}})
423 422 role:updateProperty({field = "hangInfo", value = {}})
424 423 role:updateProperty({field = "hangBag", value = {}})
425 424 role:mylog("gm_action", {desc = "idlec", key1 = pms.sender})
... ...
src/actions/HangAction.lua
... ... @@ -315,6 +315,7 @@ function _M.roleFormatRpc(agent , data)
315 315 local msg = MsgPack.unpack(data)
316 316 local index = msg.index -- 阵容索引
317 317 local title = msg.title -- 阵容名称
  318 + local tactics = msg.tactics -- 战术
318 319 local team = {}
319 320 for slot, heroId in pairs(msg.heros) do
320 321 if not role.heros[heroId] then
... ... @@ -346,6 +347,9 @@ function _M.roleFormatRpc(agent , data)
346 347 team.leader = msg.leader
347 348 team.supports = supports
348 349 team.title = title
  350 + if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then
  351 + team.tactics = msg.tactics
  352 + end
349 353  
350 354 role:setTeamFormat(index, team)
351 355  
... ... @@ -459,36 +463,6 @@ function _M.quickRpc(agent , data)
459 463 return true
460 464 end
461 465  
462   -function _M.bonusFormatRpc(agent , data)
463   - local role = agent.role
464   - local msg = MsgPack.unpack(data)
465   - local bTeam = role:getProperty("bTeam")
466   - for slot, heroId in pairs(msg.heros) do
467   - if not role.heros[heroId] then
468   - return
469   - end
470   - end
471   - local supports = {}
472   - for slot, support in pairs(msg.supports) do
473   - if slot ~= 1 and slot ~= 2 then return end
474   - local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
475   - if level <= 0 then return end
476   - supports[slot] = support
477   - end
478   - if not checkLeader(msg.heros, msg.leader) then return end
479   -
480   - table.clear(bTeam)
481   - bTeam.heros = {}
482   - for slot, heroId in pairs(msg.heros) do
483   - bTeam.heros[slot] = heroId
484   - end
485   - bTeam.leader = msg.leader
486   - bTeam.supports = supports
487   -
488   - role:updateProperty({field = "bTeam", value = bTeam})
489   - SendPacket(actionCodes.Hang_bonusFormatRpc, '')
490   - return true
491   -end
492 466  
493 467 function _M.buyBonusCountRpc(agent, data)
494 468 local role = agent.role
... ... @@ -524,10 +498,53 @@ function _M.buyBonusCountRpc(agent, data)
524 498 return true
525 499 end
526 500  
  501 +local function bonusWinReward(role, bonusData, bwin, count)
  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 +
  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]
  526 + end
  527 + end
  528 +
  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 -- 满星 额外奖励
  534 + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do
  535 + reward[k] = (reward[k] or 0) + v
  536 + end
  537 + 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
  541 +end
  542 +
527 543 function _M.startBonusBattleRpc(agent, data)
528 544 local role = agent.role
529 545 local msg = MsgPack.unpack(data)
530 546 local id = msg.id
  547 + local count = msg.count or 1
531 548  
532 549 local open, actId = role.activity:isOpen("BonusDouble")
533 550  
... ... @@ -542,9 +559,6 @@ function _M.startBonusBattleRpc(agent, data)
542 559 if not bonusData then return 3 end
543 560 if not role:checkHangPass(bonusData.unlock) then return 4 end
544 561  
545   - local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
546   - if not next(bTeam) then return 5 end
547   -
548 562 local bonusC = role.dailyData:getProperty("bonusC")
549 563 bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
550 564  
... ... @@ -555,15 +569,24 @@ function _M.startBonusBattleRpc(agent, data)
555 569 if open and actData then
556 570 coef = tonumber(actData.condition2)
557 571 end
  572 +
  573 + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end
558 574  
559   - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end
560   -
  575 + local bonusStar = role:getProperty("bonusStar")
  576 + 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
  579 + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change}))
  580 + else
  581 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  582 + if not next(bTeam) then return 5 end
  583 + role.__bonusBattleCache = {
  584 + key = tostring(math.random()),
  585 + id = id,
  586 + }
  587 + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
  588 + end
561 589  
562   - role.__bonusBattleCache = {
563   - key = tostring(math.random()),
564   - id = id,
565   - }
566   - SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
567 590 return true
568 591 end
569 592  
... ... @@ -574,14 +597,7 @@ function _M.endBonusBattleRpc(agent, data)
574 597 local key = msg.key
575 598 local starNum = msg.starNum
576 599 if not role.__bonusBattleCache then return 1 end
577   - local open, actId = role.activity:isOpen("BonusDouble")
578   - local actData = csvdb["activity_ctrlCsv"][actId]
579   - local extraCnt = role.storeData:getBonusExtraFightCount()
580   -
581   - local coef = 1
582   - if open and actData then
583   - coef = tonumber(actData.condition2)
584   - end
  600 +
585 601  
586 602 if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
587 603 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
... ... @@ -590,24 +606,79 @@ function _M.endBonusBattleRpc(agent, data)
590 606 local bonusData = csvdb["bonus_battleCsv"][id]
591 607  
592 608 local reward, change
  609 +
  610 + local bonusStar = role:getProperty("bonusStar")
  611 + local curStar = 0
593 612 if starNum and starNum > 0 then
594 613 -- 胜利扣除次数
595   - local bonusC = role.dailyData:getProperty("bonusC")
596   - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
597   - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 3 end
598   - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1
599   - role.dailyData:updateProperty({field = "bonusC", value = bonusC})
600   -
601   - reward = bonusData.reward:toNumMap()
602   - local chance = bonusData.chance:randWeight(true)
603   - if chance[1] ~= 0 then
604   - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
  614 +
  615 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  616 + local herosInfo = role:getTeamHerosInfo(bTeam.heros)
  617 +
  618 + local check = {}
  619 + -- 1 通关
  620 + check[1] = function(_)
  621 + return true
  622 + end
  623 + -- 2 阵亡人数 <= N
  624 + check[2] = function(_, cond)
  625 + return msg.info.dead and msg.info.dead <= cond
605 626 end
606   - for k, v in pairs(reward) do
607   - reward[k] = v * (coef > 1 and actData.condition or 1)
  627 + -- 3 全员存活
  628 + check[3] = function(_)
  629 + return msg.info.dead and msg.info.dead == 0
608 630 end
609   - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}})
610   - role:checkTaskEnter("BonusPass", {id = id})
  631 + -- 4 指定种族 >= N
  632 + check[4] = function(_, cond)
  633 + local count = 0
  634 + for _, one in pairs(herosInfo) do
  635 + local heroData = csv["unitCsv"][one.type]
  636 + if heroData.camp == cond then
  637 + count = count + 1
  638 + end
  639 + end
  640 + return count >= cond
  641 + end
  642 + -- 5 指定职业 >= N
  643 + check[5] = function(_, cond)
  644 + local count = 0
  645 + for _, one in pairs(herosInfo) do
  646 + local heroData = csv["unitCsv"][one.type]
  647 + if heroData.job == cond then
  648 + count = count + 1
  649 + end
  650 + end
  651 + return count >= cond
  652 + end
  653 + -- 6 含有指定角色
  654 + check[6] = function(_, cond)
  655 + for _, one in pairs(herosInfo) do
  656 + if one.type == cond then
  657 + return true
  658 + end
  659 + end
  660 + return false
  661 + end
  662 + -- 7 通关耗时 <= X 秒 msg.info.atime
  663 + check[7] = function(_, cond)
  664 + return msg.info.atime and msg.info.atime <= cond
  665 + end
  666 + curStar = 0
  667 + local sweepConds = bonusData.sweep_condition:toTableArray(true)
  668 + for i, cond in ipairs(sweepConds) do
  669 + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
  670 + curStar = curStar + (1 << (i - 1))
  671 + end
  672 + end
  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
  676 + else
  677 + curStar = 0
  678 + end
  679 + if curStar ~= bonusStar[id] then
  680 + bonusStar[id] = curStar
  681 + role:updateProperty({field = "bonusStar", value = bonusStar})
611 682 end
612 683  
613 684 role:checkBattle("bonus", {
... ... @@ -711,4 +782,4 @@ function _M.selectTeamRpc(agent, data)
711 782 return true
712 783 end
713 784  
714   -return _M
715 785 \ No newline at end of file
  786 +return _M
... ...
src/actions/HeroAction.lua
... ... @@ -143,74 +143,45 @@ function _M.talentRpc(agent, data)
143 143 local hero = role.heros[msg.id]
144 144 if not hero then return 1 end
145 145  
146   - local index = msg.index -- 第几个天赋
147   - local need = {[0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1}
148   - if not need[index] then return 2 end
149   -
150 146 local talent = hero:getProperty("talent")
  147 + local heroCfgId = hero:getProperty("type")
151 148 local curStage = talent:getv(0, 1)
152   - local curData = csvdb["unit_talentCsv"][curStage]
153   - if not curData then return 4 end
  149 + local curLevel = talent:getv(1, 1)
  150 + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage]
  151 + if not curData then return 1 end
154 152 local oldSkillLv = hero:getSkillLevel(1)
155 153  
156 154  
157 155 local cost = {}
158   - if index == 0 then
159   - --是否进阶
160   - local max = true
161   - for i = 1, 4 do
162   - if talent:getv(i, 0) < #curData then
163   - max = false
164   - break
165   - end
166   - end
167   - if max then
168   - talent = talent:setv(0, curStage + 1)
169   - for i = 1, 4 do
170   - talent = talent:setv(i, 0)
171   - end
172   - else
173   - return 12
174   - end
  156 + if curLevel == #curData then
  157 + talent = talent:setv(0, curStage + 1)
  158 + talent = talent:setv(1, 1)
175 159 else
176   -
177   - local level = talent:getv(index, 0)
178   - if level >= #curData then return 5 end
  160 + if curLevel > #curData then return 2 end
179 161  
180   - local talentData = curData[level]
181   - if not talentData then return end
  162 + local talentData = curData[curLevel]
  163 + if not talentData then return 3 end
182 164  
183   - if talentData.lvRequire > hero:getProperty("level") then return 6 end
  165 + if talentData.lvRequire > hero:getProperty("level") then return 4 end
184 166  
185 167 cost = talentData.money:toNumMap()
186   - local cost2 = talentData.cost:toNumMap()
187   - for k,v in pairs(cost2) do
188   - cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v
189   - end
190   - if not role:checkItemEnough(cost) then return 6 end
  168 + if not role:checkItemEnough(cost) then return 5 end
191 169 role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}})
192   - talent = talent:incrv(index, 1)
193   -
194   -
195   - local aheadLevel = 0
196   - for i = 1, talent:getv(0, 1) - 1 do
197   - aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i]
198   - end
199   - aheadLevel = aheadLevel + talent:getv(index, 0)
200   -
201   - role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel})
  170 + talent = talent:setv(1, curLevel + 1)
202 171 end
  172 + curStage = talent:getv(0, 1)
  173 + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage})
203 174  
204 175 hero:updateProperty({field = "talent", value = talent})
205 176  
206 177 role:log("hero_talent", {
207 178 hero_id = hero:getProperty("type"), --英雄ID
208   - hero_talent_id = index, --天赋ID
  179 + hero_talent_id = curStage, --天赋ID
209 180 hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
210 181 hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级
211 182 hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级
212 183 })
213   - hero:mylog({desc = "talent", int1 = index, int2 = talent:getv(index, 0)})
  184 + hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)})
214 185  
215 186 SendPacket(actionCodes.Hero_talentRpc, '')
216 187 return true
... ... @@ -641,6 +612,7 @@ function _M.getResetRewardRpc(agent, data)
641 612 local level = hero:getProperty("level")
642 613 local breakL = hero:getProperty("breakL")
643 614 local talent = hero:getProperty("talent")
  615 + local heroCfgId = hero:getProperty("type")
644 616  
645 617 local tmpLevel = level
646 618 if level <= 1 and talent == "" then return end
... ... @@ -669,32 +641,18 @@ function _M.getResetRewardRpc(agent, data)
669 641 end
670 642  
671 643 local stage = talent:getv(0, 1)
672   - local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
  644 + local curTalentLvl = talent:getv(1, 1)
  645 + --local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
673 646  
674   - local talentCostIds = globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp]
675 647 while stage > 0 do
676   - local curData = csvdb["unit_talentCsv"][stage]
677   - for level = math.max(table.unpack(tlevel)), 1, -1 do
678   - local add = 0
679   - for i = 1, 4 do
680   - if tlevel[i] == level then
681   - add = add + 1
682   - tlevel[i] = tlevel[i] - 1
683   - end
684   - end
685   - local talentData = curData[level - 1]
  648 + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][stage]
  649 + for lvl = 1, curTalentLvl - 1 do
  650 + local talentData = curData[lvl]
686 651 for itemId, count in pairs(talentData.money:toNumMap()) do
687   - reward[itemId] = (reward[itemId] or 0) + count * add
688   - end
689   - for idx , count in pairs(talentData.cost:toNumMap()) do
690   - reward[talentCostIds[idx]] = (reward[talentCostIds[idx]] or 0) + count * add
  652 + reward[itemId] = (reward[itemId] or 0) + count
691 653 end
692 654 end
693 655 stage = stage - 1
694   - curData = csvdb["unit_talentCsv"][stage]
695   - if curData then
696   - tlevel = {#curData, #curData, #curData, #curData}
697   - end
698 656 end
699 657  
700 658 local equip = hero:getProperty("equip")
... ... @@ -1080,4 +1038,23 @@ function _M.changeCrown(agent, data)
1080 1038 return true
1081 1039 end
1082 1040  
  1041 +function _M.itemComposeRpc(agent, data)
  1042 + local role = agent.role
  1043 + local msg = MsgPack.unpack(data)
  1044 +
  1045 + local itemId = msg.id
  1046 + local count = msg.count
  1047 + if not csvdb["itemCsv"][itemId] then return 1 end
  1048 + local config = csvdb["item_processCsv"][itemId]
  1049 + if not config then return 2 end
  1050 +
  1051 + local cost = config.cost:toNumMap()
  1052 + if not role:checkItemEnough(cost) then return 2 end
  1053 + role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}})
  1054 + role:award({[itemId] = count}, {log = {desc = "itemCompose"}})
  1055 +
  1056 + SendPacket(actionCodes.Hero_itemComposeRpc, "")
  1057 + return true
  1058 +end
  1059 +
1083 1060 return _M
... ...
src/actions/PvpAction.lua
... ... @@ -50,6 +50,9 @@ function _M.formatCommonRpc(agent , data)
50 50 end
51 51 pvpTC.leader = msg.leader
52 52 pvpTC.supports = supports
  53 + if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then
  54 + pvpTC.tactics = msg.tactics
  55 + end
53 56  
54 57 role:savePvpCTeam(pvpTC)
55 58 SendPacket(actionCodes.Pvp_formatCommonRpc, '')
... ... @@ -92,6 +95,9 @@ function _M.formatHighRpc(agent , data)
92 95 curTeam.heros = team.heros
93 96 curTeam.leader = team.leader
94 97 curTeam.supports = supports
  98 + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then
  99 + curTeam.tactics = team.tactics
  100 + end
95 101  
96 102 table.insert(pvpTH, curTeam)
97 103 end
... ... @@ -462,6 +468,10 @@ function _M.startBattleHRpc(agent, data)
462 468 curTeam.heros = team.heros
463 469 curTeam.leader = team.leader
464 470 curTeam.supports = supports
  471 + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then
  472 + curTeam.tactics = team.tactics
  473 + end
  474 +
465 475  
466 476 table.insert(pvpTH, curTeam)
467 477 end
... ...
src/actions/RadioAction.lua
1 1 local _M = {}
2 2  
3   -function _M.listRpc(agent, data)
4   - local role = agent.role
5   - local roleId = role:getProperty("id")
6   - local now = skynet.timex()
7   - local result = {}
8   -
  3 +-- 获取英雄大成功率
  4 +local function getHeroCoef(hero, condition)
  5 + -- 基础概率
  6 + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20}
  7 + local rare = hero:getRare()
  8 + local result = 0
  9 + for _, it in ipairs(condition:toTableArray(true)) do
  10 + local type = it[1]
  11 + local value = it[2]
  12 + local add = it[3]
  13 + if type == 1 then -- 种族加成
  14 + if hero:getCamp() == value then
  15 + result = result + add
  16 + end
  17 + elseif type == 2 then -- 定位加成
  18 + if hero:getPosition() == value then
  19 + result = result + add
  20 + end
  21 + end
  22 + end
9 23  
10   - SendPacket(actionCodes.Email_listRpc, MsgPack.pack({list = result}))
11   - return true
  24 + return result + (rareMap[rare] or 0)
12 25 end
13 26  
14   --- 获取英雄大成功率
15   -local function getHeroCoef()
16   - return 0
  27 +local function getQuestMax(role)
  28 + local count = 0
  29 + for _, carbonId in ipairs(globalCsv.crusade_team_unlock or {}) do
  30 + if role:checkHangPass(carbonId) then
  31 + count = count + 1
  32 + end
  33 + end
  34 +
  35 + return count + (globalCsv.cursade_team_count_initial or 0)
17 36 end
18 37  
19 38 function _M.startQuestRpc(agent, data)
... ... @@ -22,11 +41,67 @@ function _M.startQuestRpc(agent, data)
22 41 local id = msg.id
23 42 local heros = msg.heros
24 43 local result = {}
  44 + local radioTask = role:getProperty("radioTask")
  45 + if table.numbers(radioTask) >= getQuestMax(role) then
  46 + return 1
  47 + end
25 48 -- check id
  49 + local config = csvdb["crusadeCsv"][id]
  50 + if not config then return 2 end
  51 + if not role:checkHangPass(config.unlock) then return 3 end
  52 + if radioTask[id] then return 4 end
26 53 -- check hero
  54 + --1=指定等级=人数
  55 + --2=指定稀有度=人数
  56 + --3=人数
  57 + local needHeroCnt = 0
  58 + local lvlMap = {}
  59 + local rareMap = {}
  60 + for _, it in ipairs(config.condition:toTableArray(true)) do
  61 + local type = it[1]
  62 + if type == 1 then
  63 + lvlMap[1] = it[2]
  64 + lvlMap[2] = it[3]
  65 + elseif type == 2 then
  66 + rareMap[1] = it[2]
  67 + rareMap[2] = it[3]
  68 + elseif type == 3 then
  69 + needHeroCnt = it[2]
  70 + end
  71 + end
  72 + for _, heroId in ipairs(heros) do
  73 + local hero = role.heros[heroId]
  74 + if hero then
  75 + needHeroCnt = needHeroCnt - 1
  76 + if next(lvlMap) then
  77 + if hero:getProperty("level") >= lvlMap[1] then
  78 + lvlMap[2] = lvlMap[2] - 1
  79 + if lvlMap[2] <= 0 then
  80 + lvlMap = {}
  81 + end
  82 + end
  83 + end
  84 + if next(rareMap) then
  85 + if hero:getRare() >= rareMap[1] then
  86 + rareMap[2] = rareMap[2] - 1
  87 + end
  88 + if rareMap[2] <= 0 then
  89 + rareMap = {}
  90 + end
  91 + end
  92 + end
  93 + end
  94 + if needHeroCnt > 0 or next(rareMap) or next(lvlMap) then
  95 + return 5
  96 + end
27 97 -- start quest, set finish time
  98 + local taskData = {}
  99 + taskData["time"] = skynet.timex() + config.time
  100 + taskData["heros"] = heros
  101 + radioTask[id] = taskData
  102 + role:updateProperty({field="radioTask", value=radioTask, notNotify=true})
28 103  
29   - SendPacket(actionCodes.Email_listRpc, MsgPack.pack({list = result}))
  104 + SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData}))
30 105 return true
31 106 end
32 107  
... ... @@ -34,13 +109,56 @@ function _M.finishQuestRpc(agent, data)
34 109 local role = agent.role
35 110 local msg = MsgPack.unpack(data)
36 111 local id = msg.id
37   - local result = {}
38 112 -- check finish time
  113 + local radioTask = role:getProperty("radioTask")
  114 + local task = radioTask[id]
  115 + if not task then return 1 end
  116 + if skynet.timex() < task.time then return 2 end
39 117 -- check id
  118 + local config = csvdb["crusadeCsv"][id]
  119 + if not config then return 3 end
  120 + local carbonData = csvdb["idle_battleCsv"][config.unlock]
  121 + if not carbonData then return 4 end
40 122 -- get heros
  123 + local totalCoef = 0
  124 + local exp = config.time / 60
  125 + heroFaithMap = {}
  126 + for _, heroId in ipairs(task.heros) do
  127 + local hero = role.heros[heroId]
  128 + if hero then
  129 + totalCoef = totalCoef + getHeroCoef(hero, config.success)
  130 + -- 增加英雄信赖
  131 + hero:addHeroFaith(exp)
  132 + heroFaithMap[heroId] = hero:getProperty("faith")
  133 + end
  134 + end
41 135 -- send award
  136 + local bigSuccess = false
  137 + local result = math.randomInt(0, 100)
  138 + if result < totalCoef then
  139 + bigSuccess = true
  140 + end
  141 + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear
  142 + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear
  143 + local itemReward = config.item_clear_special:toNumMap()
  144 + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
  145 + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
  146 + if bigSuccess then
  147 + for key, value in pairs(itemReward) do
  148 + itemReward[key] = math.ceil(1.5 * value)
  149 + end
  150 + end
  151 +
  152 + local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}})
  153 +
  154 + radioTask[id] = nil
  155 + role:updateProperty({field="radioTask", value=radioTask, notNotify = true})
42 156  
43   - SendPacket(actionCodes.Email_listRpc, MsgPack.pack({list = result}))
  157 + local msg = role:packReward(r, change)
  158 + msg["big"] = bigSuccess
  159 + msg["id"] = id
  160 + msg["heroFaith"] = heroFaithMap
  161 + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg))
44 162 return true
45 163 end
46 164  
... ...
src/actions/RoleAction.lua
... ... @@ -291,7 +291,7 @@ function _M.loginRpc( agent, data )
291 291  
292 292  
293 293 -- 玩家登陆做的一些操作
294   - role:saveHangTeam()
  294 + role:updateHangTeamInfo()
295 295 role:savePvpCTeam()
296 296 role:savePvpHTeam()
297 297  
... ...
src/actions/StoreAction.lua
1 1 local _M = {}
2 2  
3   -local serverId = tonumber(skynet.getenv("servId"))
4 3 local md5 = require "md5"
5 4  
6   -local function makeOrder(role, rechargeId)
7   - local roleId = role:getProperty("id")
8   - local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
9   - if not rechargeData then
10   - skynet.error("recharge id not exist", rechargeId)
11   - return ""
12   - end
13   - local limit = rechargeData.limit
14   - local rechargeRecord = role:getProperty("payR") or {}
15   - if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then
16   - skynet.error(string.format("recharge id:%d count over limit, user id:%d", rechargeId, roleId))
17   - return ""
18   - end
19   -
20   - local orderId = redisproxy:hincrby("autoincrement_set", "order", 1)
21   - local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId)
22   - local orderKey = string.format("order:%d:%d", roleId, orderId)
23   - redisproxy:del(orderKey)
24   - local order = require("models.Order").new({
25   - key = orderKey,
26   - order = partnerOrderId,
27   - rechargeId = rechargeId,
28   - })
29   - order:create()
30   - redisproxy:sadd(string.format("role:%d:orders", roleId), partnerOrderId)
31   - return partnerOrderId
32   -end
33   -
34 5 -- 入口在正式服关闭 -- mock 充值
35 6 function _M.rechargeRpc(agent , data)
36 7 local role = agent.role
... ... @@ -41,7 +12,7 @@ function _M.rechargeRpc(agent , data)
41 12 local roleId = role:getProperty("id")
42 13  
43 14 --创建订单号
44   - local partnerOrderId = makeOrder(role, id)
  15 + local partnerOrderId = role:getPurchaseOrder(id)
45 16 SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId }))
46 17  
47 18  
... ... @@ -115,7 +86,7 @@ function _M.googleRechargeRpc(agent, data)
115 86  
116 87 role.ignoreHeartbeat = true
117 88 --创建订单号
118   - local partnerOrderId = makeOrder(role, id)
  89 + local partnerOrderId = role:getPurchaseOrder(id)
119 90 -- 签名
120 91 -- local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075"
121 92 local secret_key = "8920e9dcf0cb4ebca87393ce48021ead"
... ... @@ -143,7 +114,7 @@ function _M.myCardRechargeRpc(agent, data)
143 114  
144 115 role.ignoreHeartbeat = true
145 116 --创建订单号
146   - local partnerOrderId = makeOrder(role, id)
  117 + local partnerOrderId = role:getPurchaseOrder(id)
147 118 -- 签名
148 119 local secret_key = "48759e07540f46d9af17ec82669b4272"
149 120 local need = {
... ... @@ -169,7 +140,7 @@ function _M.iosRechargeRpc(agent, data)
169 140  
170 141 role.ignoreHeartbeat = true
171 142 --创建订单号
172   - local partnerOrderId = makeOrder(role, id)
  143 + local partnerOrderId = role:getPurchaseOrder(id)
173 144 -- 签名
174 145 local secret_key = "9647d2efe1074c73b9ac19af4337a70e"
175 146 local need = {
... ... @@ -193,43 +164,15 @@ function _M.purchaseOrderResult(agent, data)
193 164  
194 165 role.ignoreHeartbeat = false
195 166  
196   - local partnerOrderStr = msg.order
197   - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
198   - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) })
199   - if not orderObject:load() then
200   - -- 订单不存在
201   - skynet.error("cancelPurchaseRpc", string.format("order %s not exist", partnerOrderStr))
202   - return true
203   - end
204   -
205   - if msg.status == "success" then
206   - orderObject:setProperty("transactionId", msg.platformOrder or "")
207   - local rechargeId = orderObject:getProperty("rechargeId")
208   - local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
209   -
210   - role:log("setOrder", {
211   - order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
212   - item_id = rechargeId, -- 道具id
213   - item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
214   - item_name = dataSet.title, -- 购买的道具名
215   - item_number = 1, -- 购买的道具数量
216   - item_level = 1, -- 购买的道具等级
217   - order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
218   - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
219   - order_type = role:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0
220   - order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
221   - })
222   -
223   - return true
224   - end
  167 + local status = {
  168 + fail = true,
  169 + success = true
  170 + }
225 171  
226   - if orderObject:getProperty("finishTime") > 0 then
227   - return true
  172 + local partnerOrderStr = msg.order
  173 + if partnerOrderStr then
  174 + role:updatePurchaseOrder(partnerOrderStr, msg.platformOrder, status[msg.status] and msg.status or "unknown")
228 175 end
229   -
230   - orderObject:setProperty("status", msg.status)
231   -
232   - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
233 176 return true
234 177 end
235 178  
... ...
src/actions/TowerAction.lua
... ... @@ -8,36 +8,6 @@ local MsgPack = MsgPack
8 8 local _M = {}
9 9  
10 10  
11   -function _M.roleFormatRpc(agent , data)
12   - local role = agent.role
13   - local msg = MsgPack.unpack(data)
14   - local towerTeam = role:getProperty("towerF")
15   - for slot, heroId in pairs(msg.heros) do
16   - if not role.heros[heroId] then
17   - return
18   - end
19   - end
20   - local supports = {}
21   - for slot, support in pairs(msg.supports) do
22   - if slot ~= 1 and slot ~= 2 then return end
23   - local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
24   - if level <= 0 then return end
25   - supports[slot] = support
26   - end
27   - table.clear(towerTeam)
28   - towerTeam.heros = {}
29   - for slot, heroId in pairs(msg.heros) do
30   - towerTeam.heros[slot] = heroId
31   - end
32   - towerTeam.leader = msg.leader
33   - towerTeam.supports = supports
34   -
35   -
36   - role:updateProperty({field = "towerF", value = towerTeam})
37   - SendPacket(actionCodes.Tower_roleFormatRpc, '')
38   - return true
39   -end
40   -
41 11  
42 12 local function getUpdateTime(lastCount, lastTime)
43 13 local nextCount, nextTime = lastCount, skynet.timex()
... ...
src/adv/Adv.lua
... ... @@ -102,6 +102,9 @@ function Adv:initByChapter(params)
102 102 self.cacheUnlock = self.cacheUnlock or {}
103 103 self.shopStatus = self.shopStatus or {}
104 104 self.support = self.support or {}
  105 + if self.battle then
  106 + self.battle:overBattle()
  107 + end
105 108 self.battle = nil -- 清掉 老的 battle
106 109 self.logid = self.owner:getActionUcode()
107 110  
... ... @@ -211,7 +214,7 @@ function Adv:saveDB(notNotify)
211 214 advInfo.logid = self.logid
212 215 advInfo.maps = {}
213 216  
214   - self.battle:saveDB()
  217 + self.battle:saveDB(advInfo)
215 218  
216 219 for id , map in ipairs(self.maps) do
217 220 advInfo.maps[id] = map:getDB()
... ... @@ -468,6 +471,11 @@ function Adv:initBattle(notDb)
468 471 if notDb and self.level ~= 1 then
469 472 self.battle.player:attrChangeCondBuffCheck(1)
470 473 end
  474 +
  475 + -- 初始化
  476 + if notDb then
  477 + self.battle:newBattle()
  478 + end
471 479 end
472 480  
473 481 function Adv:triggerPassive(condType, params)
... ... @@ -936,7 +944,7 @@ end
936 944  
937 945 -- log long1 字段被征用!!!
938 946 -- 在冒险中获得的物品都发放在冒险背包内
939   -function Adv:award(gift, params)
  947 +function Adv:award(gift, params, backRewardParams)
940 948 params = params or {}
941 949 local tgift = {}
942 950 if type(gift) == "string" then
... ... @@ -948,6 +956,8 @@ function Adv:award(gift, params)
948 956 end
949 957 local items = self.owner:getProperty("advItems")
950 958 local oldItems = items
  959 +
  960 + local autoUse = {}
951 961 for itemId, count in pairs(tgift) do
952 962 if count > 0 then
953 963 local buffAdd = self.battle.player:getRewardChange(itemId)
... ... @@ -956,41 +966,45 @@ function Adv:award(gift, params)
956 966 self:checkAchievement(Adv.AchievType.GetItem, count, itemId)
957 967 end
958 968 tgift[itemId] = count
959   - local origin = items:getv(itemId, 0)
960   - local nums = origin + count
961   -
962   - if csvdb["adv_artifactCsv"][itemId] then -- 获得神器
963   - self:awardArtifact(itemId, params)
964   - if not self.owner:checkOverGuide(55) then
965   - self.owner:saveGuide(55,1,true)
966   - end
  969 + if globalCsv.adv_auto_useItem[itemId] and count > 0 then
  970 + autoUse[itemId] = count
967 971 else
968   - if nums <= 0 then
969   - items = items:delk(itemId)
970   - nums = 0
  972 + local origin = items:getv(itemId, 0)
  973 + local nums = origin + count
  974 +
  975 + if csvdb["adv_artifactCsv"][itemId] then -- 获得神器
  976 + self:awardArtifact(itemId, params)
  977 + if not self.owner:checkOverGuide(55) then
  978 + self.owner:saveGuide(55,1,true)
  979 + end
971 980 else
972   - items = items:setv(itemId, nums)
973   - end
  981 + if nums <= 0 then
  982 + items = items:delk(itemId)
  983 + nums = 0
  984 + else
  985 + items = items:setv(itemId, nums)
  986 + end
974 987  
975   - if itemId == 16 and not self.owner:checkOverGuide(51,4) then
976   - self.owner:saveGuide(51,4)
977   - end
978   - if params.log then
979   - local log = clone(params.log)
980   - if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then
981   - print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback())
  988 + if itemId == 16 and not self.owner:checkOverGuide(51,4) then
  989 + self.owner:saveGuide(51,4)
982 990 end
983   - log["cint1"] = itemId
984   - log["cint2"] = math.abs(count)
985   - log["cint3"] = self.chapterId
986   - log["long1"] = self.level
987   - if count >= 0 then
988   - self.owner:mylog("in_adv", log)
  991 + if params.log then
  992 + local log = clone(params.log)
  993 + if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then
  994 + print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback())
  995 + end
  996 + log["cint1"] = itemId
  997 + log["cint2"] = math.abs(count)
  998 + log["cint3"] = self.chapterId
  999 + log["long1"] = self.level
  1000 + if count >= 0 then
  1001 + self.owner:mylog("in_adv", log)
  1002 + else
  1003 + self.owner:mylog("out_adv", log)
  1004 + end
989 1005 else
990   - self.owner:mylog("out_adv", log)
  1006 + print("addAdvItem no log ", debug.traceback())
991 1007 end
992   - else
993   - print("addAdvItem no log ", debug.traceback())
994 1008 end
995 1009 end
996 1010 end
... ... @@ -1001,10 +1015,48 @@ function Adv:award(gift, params)
1001 1015 if tgift[ItemId.OldCoin] then
1002 1016 self.battle.player:attrChangeCondBuffCheck(0)
1003 1017 end
  1018 +
  1019 + if backRewardParams then
  1020 + self:backReward(tgift, backRewardParams)
  1021 + end
  1022 +
  1023 + if next(autoUse) then
  1024 + for itemId, count in pairs(autoUse) do
  1025 + self:useItem(itemId, count)
  1026 + end
  1027 + self:backUse(autoUse, 1)
  1028 + end
1004 1029 return tgift
1005 1030 end
1006 1031  
1007 1032  
  1033 +function Adv:useItem(itemId, count, target)
  1034 + local itemData = csvdb["adv_itemCsv"][itemId]
  1035 + if not itemData then return end
  1036 +
  1037 + if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end
  1038 +
  1039 + if itemId == 5020 then
  1040 + self.owner:finishGuide(53)
  1041 + end
  1042 +
  1043 + self:checkAchievement(self.AchievType.UseItem, count, itemId)
  1044 + self:mylog({desc = "useItem", int1 = itemId, int2 = count})
  1045 +
  1046 + self.owner:log("mission_pick_use", {
  1047 + mission_threadid = self.chapterId, -- 大地图ID
  1048 + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称
  1049 + mission_id = self.level, -- 关卡ID
  1050 + item_id = itemId, -- 道具ID
  1051 + mission_pick_use_num = count, -- 道具使用量
  1052 + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志
  1053 + })
  1054 +
  1055 + for i = 1, count do
  1056 + self:doActive(itemData.effect, target) -- target
  1057 + end
  1058 +end
  1059 +
1008 1060 -- 消耗物品 优先冒险背包 --check 只是检查够不够
1009 1061 function Adv:cost(item, params, check)
1010 1062 local items = self.owner:getProperty("advItems")
... ... @@ -1040,7 +1092,9 @@ local function clickOut(self, room, block, params, isExit)
1040 1092 end
1041 1093  
1042 1094 if #self.mapStack > 1 then -- 处于夹层中
  1095 + local oldMapIdx = self:getCurMapIdx()
1043 1096 table.remove(self.mapStack) --退出夹层
  1097 + self.battle:iLayerChange(oldMapIdx)
1044 1098 self:backLayer(-1)
1045 1099 else --处于底层
1046 1100  
... ... @@ -1071,11 +1125,10 @@ local function clickOut(self, room, block, params, isExit)
1071 1125 self.battle.player:triggerPassive(Passive.DOWN_LAYER)
1072 1126  
1073 1127 if curFloorData then
1074   - self:backReward(self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}))
  1128 + self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {})
1075 1129 end
1076 1130 local isHaveRelay = self:isHaveRelay(self.level)
1077 1131  
1078   - self.owner:getProperty("advTeam").player = self.battle.player:getDB() -- 临时缓存住 battle 的player
1079 1132 if isHaveRelay and not self.isRelay then
1080 1133 self:initByChapter({
1081 1134 chapterId = self.chapterId,
... ... @@ -1255,7 +1308,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1255 1308 skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id))
1256 1309 end
1257 1310 end
1258   - self:backReward(self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}), {roomId = room.roomId, blockId = block.blockId})
  1311 + self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId})
1259 1312 end,
1260 1313 [2] = function() --获得冒险buff
1261 1314 local layer = effect[3] or 1
... ... @@ -1419,14 +1472,12 @@ local function clickDrop(self, room, block, params)
1419 1472 if not self.battle or not self.battle.player then return end
1420 1473 self.battle.player:triggerPassive(Passive.CLICK_DROP)
1421 1474  
1422   - local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}})
1423   - -- local reward = self:award({[5801] = 1})
1424   - -- 获取绷带的引导
  1475 + local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}, {roomId = room.roomId, blockId = block.blockId})
  1476 +
1425 1477 if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then
1426 1478 self.owner:saveGuide(53,2)
1427 1479 end
1428 1480 block:clear()
1429   - self:backReward(reward, {roomId = room.roomId, blockId = block.blockId})
1430 1481 return true
1431 1482 end
1432 1483  
... ... @@ -1447,7 +1498,7 @@ local function clickTrader(self, room, block, params)
1447 1498 local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100)
1448 1499 if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够
1449 1500 self:backCost({[goodsData.currency] = costCount})
1450   - local reward = self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}})
  1501 + self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {})
1451 1502 if goodsData.restrict == 1 then
1452 1503 self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1
1453 1504 elseif goodsData.restrict == 2 then
... ... @@ -1459,7 +1510,6 @@ local function clickTrader(self, room, block, params)
1459 1510 buyCount = buyCount + 1
1460 1511 self:checkTask(Adv.TaskType.Shop, 1, block.event.id)
1461 1512 self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id)
1462   - self:backReward(reward)
1463 1513  
1464 1514 if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then
1465 1515 block:clear()
... ... @@ -1501,7 +1551,7 @@ local function clickClick(self, room, block, params)
1501 1551 local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true)
1502 1552 reward[item[1]] = (reward[item[1]] or 0) + item[2]
1503 1553 end
1504   - self:backReward(self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}), {roomId = room.roomId, blockId = block.blockId})
  1554 + self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}, {roomId = room.roomId, blockId = block.blockId})
1505 1555 end,
1506 1556 [3] = function()
1507 1557 for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do
... ... @@ -1521,6 +1571,7 @@ local function clickClick(self, room, block, params)
1521 1571 end
1522 1572  
1523 1573 local function clickLayer(self, room, block, params)
  1574 + local oldMapIdx = self:getCurMapIdx()
1524 1575 if block.event.mapIdx then
1525 1576 table.insert(self.mapStack, block.event.mapIdx) --进入夹层
1526 1577 else
... ... @@ -1536,6 +1587,7 @@ local function clickLayer(self, room, block, params)
1536 1587 self.maps[mapIdx]:initBattleAfter()
1537 1588 self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId)
1538 1589 end
  1590 + self.battle:iLayerChange(oldMapIdx)
1539 1591 self:backLayer(1)
1540 1592 return true
1541 1593 end
... ... @@ -1842,23 +1894,31 @@ end
1842 1894  
1843 1895 -- 地图上物品变化
1844 1896 function Adv:mapItemChange(ctype)
  1897 + local blocks = {}
  1898 + for roomId, room in pairs(self:getCurMap().rooms) do
  1899 + for blockId, block in pairs(room.blocks) do
  1900 + table.insert(blocks, block)
  1901 + end
  1902 + end
  1903 + self:blockDropChange(ctype, blocks)
  1904 +end
  1905 +
  1906 +function Adv:blockDropChange(ctype, blocks)
1845 1907 local clist = csvdb["transform_itemCsv"][ctype]
1846 1908 if clist then
1847   - for roomId, room in pairs(self:getCurMap().rooms) do
1848   - for blockId, block in pairs(room.blocks) do
1849   - if block:getEventType() == AdvEventType.Drop and block.event.item then
1850   - local id = block.event.item[1]
1851   - local count = block.event.item[2]
1852   - local changeTo = nil
1853   - if clist[id] then
1854   - changeTo = {clist[id].toId, math.ceil(count * clist[id].num)}
1855   - elseif clist[-1] then
1856   - changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)}
1857   - end
1858   - if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
1859   - block.event.item = changeTo
1860   - self:backBlockChange(roomId, blockId, ctype)
1861   - end
  1909 + for _, block in ipairs(blocks) do
  1910 + if block:getEventType() == AdvEventType.Drop and block.event.item then
  1911 + local id = block.event.item[1]
  1912 + local count = block.event.item[2]
  1913 + local changeTo = nil
  1914 + if clist[id] then
  1915 + changeTo = {clist[id].toId, math.ceil(count * clist[id].num)}
  1916 + elseif clist[-1] then
  1917 + changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)}
  1918 + end
  1919 + if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
  1920 + block.event.item = changeTo
  1921 + self:backBlockChange(block.room.roomId, block.blockId, ctype)
1862 1922 end
1863 1923 end
1864 1924 end
... ... @@ -1887,8 +1947,9 @@ function Adv:enemyDead(enemy, escape)
1887 1947 else
1888 1948 self:scoreChange(AdvScoreType.Kill, monsterData.advScore)
1889 1949 end
1890   - local changeV = self.battle.player:addExp(monsterData.exp)
1891   - self:backDead(enemyId, changeV)
  1950 + -- local changeV = self.battle.player:addExp(monsterData.exp)
  1951 + -- self:backDead(enemyId, changeV)
  1952 + self:backDead(enemyId)
1892 1953  
1893 1954 local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK)
1894 1955 if toClick then
... ... @@ -1989,10 +2050,13 @@ end
1989 2050 function Adv:pushBackEvent(btype, params)
1990 2051 table.insert(self.backEvents, {btype = btype, params = params})
1991 2052 end
1992   -
  2053 +--[=[
  2054 +tag
  2055 +1 自动拾取
  2056 +--]=]
1993 2057 function Adv:backReward(items, params)
1994 2058 params = params or {}
1995   - self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId})
  2059 + self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId, tag = params.tag})
1996 2060 end
1997 2061  
1998 2062 -- if is player enemyId is nil
... ... @@ -2009,8 +2073,8 @@ function Adv:backBlockChange(roomId, blockId, itemChangeType)
2009 2073 self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId, itemChangeType = itemChangeType})
2010 2074 end
2011 2075  
2012   -function Adv:backDead(enemyId, exp)
2013   - self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId, exp = exp})
  2076 +function Adv:backDead(enemyId)
  2077 + self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId})
2014 2078 end
2015 2079  
2016 2080 function Adv:backTrap()
... ... @@ -2033,8 +2097,12 @@ function Adv:backCost(items)
2033 2097 self:pushBackEvent(AdvBackEventType.Cost, {items = items})
2034 2098 end
2035 2099  
2036   -function Adv:backUse(items)
2037   - self:pushBackEvent(AdvBackEventType.Use, {items = items})
  2100 +--[=[
  2101 +tag
  2102 +1 自动使用
  2103 +--]=]
  2104 +function Adv:backUse(items, tag)
  2105 + self:pushBackEvent(AdvBackEventType.Use, {items = items, tag = tag})
2038 2106 end
2039 2107  
2040 2108  
... ... @@ -2044,21 +2112,11 @@ function Adv:scoreChange(scoreType, score)
2044 2112 end
2045 2113  
2046 2114 function Adv:getScore()
2047   - self.score[AdvScoreType.Level] = math.floor(self.score[AdvScoreType.Level] or 0)
2048   - self.score[AdvScoreType.Task] = math.floor(self.score[AdvScoreType.Task] or 0)
2049   - self.score[AdvScoreType.Kill] = math.floor(self.score[AdvScoreType.Kill] or 0)
2050   - self.score[AdvScoreType.KillBoss] = math.floor(self.score[AdvScoreType.KillBoss] or 0)
2051   - self.score[AdvScoreType.ItemBack] = math.floor(self.score[AdvScoreType.ItemBack] or 0)
2052   - self.score[AdvScoreType.Event] = math.floor(self.score[AdvScoreType.Event] or 0)
2053   - self.score[AdvScoreType.Story] = math.floor(self.score[AdvScoreType.Story] or 0)
2054   -
2055   - return self.score[AdvScoreType.Level]
2056   - + self.score[AdvScoreType.Task]
2057   - + self.score[AdvScoreType.Kill]
2058   - + self.score[AdvScoreType.KillBoss]
2059   - + self.score[AdvScoreType.ItemBack]
2060   - + self.score[AdvScoreType.Event]
2061   - + self.score[AdvScoreType.Story]
  2115 + local allScore = 0
  2116 + for _, score in pairs(self.score) do
  2117 + allScore = allScore + math.floor(score)
  2118 + end
  2119 + return allScore
2062 2120 end
2063 2121  
2064 2122 function Adv:popBackEvents()
... ...
src/adv/AdvBattle.lua
... ... @@ -8,6 +8,7 @@ function Battle:ctor(adv)
8 8 self.isNewPlayer = false
9 9 self.enemys = {} --怪
10 10 self.builds = {} -- 建筑
  11 + self.auras = {} -- 光环
11 12 self.cachePassiveEvent = {}
12 13 self:initPlayer()
13 14 self:initEnemys()
... ... @@ -67,17 +68,17 @@ function Battle:initPlayer()
67 68 local advAddAttrs = self.adv.owner:getAdvLvAddAttrs()
68 69  
69 70 player = {}
70   - player.level = 1
71   - if self.adv.level ~= 1 then
72   - local relayData = self.adv:isHaveRelay()
73   - if relayData then
74   - player.level = relayData.level
75   - end
76   - end
77   - player.exp = 0
  71 + -- player.level = 1
  72 + -- if self.adv.level ~= 1 then
  73 + -- local relayData = self.adv:isHaveRelay()
  74 + -- if relayData then
  75 + -- player.level = relayData.level
  76 + -- end
  77 + -- end
  78 + -- player.exp = 0
78 79 player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100)
79 80 player.spMax = player.sp
80   - player.growth = {}
  81 + -- player.growth = {}
81 82 player.passives = {}
82 83  
83 84 for slot, heroId in pairs(advTeam.heros) do
... ... @@ -100,8 +101,8 @@ function Battle:initPlayer()
100 101 player[attrName] = (player[attrName] or 0) + hero[attrName]
101 102 end
102 103 player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1)
103   - player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1)
104   - player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1)
  104 + -- player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1)
  105 + -- player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1)
105 106 end
106 107  
107 108 player.hpMax = player.hp or 0
... ... @@ -198,8 +199,10 @@ function Battle:addEnemy(room, block, mapIdx, init)
198 199 end
199 200  
200 201 for _, buff in ipairs(buffs) do
201   - enemy:addBuff(buff)
  202 + player:addBuff(buff)
202 203 end
  204 + -- 新生成的怪 加上 已有的光环buff
  205 + player:checkAuraBuff(self:checkDiffAuraBuff({}, self:getAurasByMap()))
203 206 end
204 207 end
205 208 return player
... ... @@ -347,6 +350,8 @@ function Battle:afterRound()
347 350  
348 351 self.player:triggerPassive(Passive.AFTER_ROUND)
349 352  
  353 + self:checkAura()
  354 +
350 355 if self.player.isDead then
351 356 self.adv:over(false, nil, -2)
352 357 end
... ... @@ -435,8 +440,116 @@ function Battle:initMapEffect(ilayer)
435 440 end
436 441  
437 442  
  443 +-- 夹层 进入退出 接口 清理玩家身上的老光环 添加新的光环
  444 +function Battle:iLayerChange(oldMapIdx)
  445 + local auras = self:getActiveAuras()
  446 + local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras)
  447 + local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras)
  448 + self.player:checkAuraBuff(playerBuffs)
  449 + for _, enemy in pairs(self.player:getTeam(2)) do
  450 + enemy:checkAuraBuff(enemyBuffs)
  451 + end
  452 + self:setMapAuras(auras)
  453 +end
  454 +
  455 +-- 新的 关卡 关闭旧的战斗模块 清理 玩家身上的光环效果
  456 +function Battle:overBattle()
  457 + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), {})
  458 + self.player:checkAuraBuff(buffs)
  459 + self.adv.owner:getProperty("advTeam").player = self.player:getDB() -- 临时缓存住 battle 的player
  460 +end
  461 +
  462 +-- 初始化 新的 关卡
  463 +function Battle:newBattle()
  464 + local auras = self:getActiveAuras()
  465 + local buffs = self:checkDiffAuraBuff({}, auras)
  466 + self:setMapAuras(auras)
  467 +end
  468 +
  469 +-- 过了回合 检查光环
  470 +function Battle:checkAura()
  471 + local auras = self:getActiveAuras()
  472 + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras)
  473 + self.player:checkAuraBuff(buffs)
  474 + for _, enemy in pairs(self.player:getTeam(2)) do
  475 + enemy:checkAuraBuff(buffs)
  476 + end
  477 + self:setMapAuras(auras)
  478 +end
  479 +
  480 +-- 查找差异buff
  481 +function Battle:checkDiffAuraBuff(oldAuras, newAuras)
  482 + local auras = {}
  483 + for aurasId , count in pairs(oldAuras) do
  484 + auras[aurasId] = -count
  485 + end
  486 + for aurasId , count in pairs(newAuras) do
  487 + auras[aurasId] = (auras[aurasId] or 0) + count
  488 + end
  489 +
  490 + local buffs = {}
  491 + for aurasId , count in pairs(auras) do
  492 + local auraData = csvdb["adv_map_haloCsv"][aurasId]
  493 + if auraData then
  494 + for _, effect in ipairs(auraData.effect:toTableArray(true)) do
  495 + temp = buffs
  496 + for i = 1, #effect do
  497 + temp[effect[i]] = temp[effect[i]] or {}
  498 + temp = temp[effect[i]]
  499 + end
  500 + temp.count = (temp.count or 0) + count
  501 + if newAuras[aurasId] then
  502 + -- 加上 未消失标记
  503 + temp.exist = true
  504 + end
  505 + end
  506 + end
  507 + end
  508 + return buffs
  509 +end
  510 +
  511 +-- 获取所有生效的 光环
  512 +function Battle:getActiveAuras()
  513 + local auras = {}
  514 + for _, one in pairs(self.player:getAuras()) do
  515 + auras[one] = (auras[one] or 0) + 1
  516 + end
  517 + for _, enemy in pairs(self.player:getTeam(2)) do
  518 + for _, one in pairs(enemy:getAuras()) do
  519 + auras[one] = (auras[one] or 0) + 1
  520 + end
  521 + end
  522 + for _, build in pairs(self:getBuilds()) do
  523 + for _, one in pairs(build:getAuras()) do
  524 + auras[one] = (auras[one] or 0) + 1
  525 + end
  526 + end
  527 + return auras
  528 +end
  529 +
  530 +function Battle:setMapAuras(auras)
  531 + self.auras[self.adv:getCurMapIdx()] = auras
  532 +end
  533 +
  534 +function Battle:getAurasByMap(mapIdx)
  535 + mapIdx = mapIdx or self.adv:getCurMapIdx()
  536 + local auras = self.auras[mapIdx] or {}
  537 + return auras
  538 +end
  539 +
  540 +function Battle:getBuilds()
  541 + local team = {}
  542 + for _, build in pairs(self.builds[self.adv:getCurMapIdx()]) do
  543 + if not build.isDead and not build.lock then -- 已经翻开的
  544 + table.insert(team, build)
  545 + end
  546 + end
  547 + return team
  548 +end
  549 +
  550 +
438 551 --写入数据
439   -function Battle:saveDB()
  552 +function Battle:saveDB(advInfo)
440 553 for idx, mapEnemys in pairs(self.enemys) do
441 554 for _, enemy in ipairs(mapEnemys) do
442 555 local block = self.adv:getBlock(enemy.roomId, enemy.blockId, idx)
... ... @@ -453,6 +566,7 @@ function Battle:saveDB()
453 566 end
454 567 end
455 568 end
  569 + advInfo.auras = self.auras
456 570 end
457 571  
458 572 return Battle
459 573 \ No newline at end of file
... ...
src/adv/AdvBlock.lua
... ... @@ -48,6 +48,8 @@ function Block:updateEvent(event, isInit)
48 48 end
49 49 end
50 50 end
  51 + local oldet = self:getEventType()
  52 +
51 53 self.event = event
52 54 if not isInit and self.event then
53 55 -- 判断下类型是不是错的
... ... @@ -58,18 +60,49 @@ function Block:updateEvent(event, isInit)
58 60 end
59 61 self:randomEvent()
60 62 end
  63 + self:quickDrop()
  64 +
  65 + if not isInit and self.isOpen then
  66 + local newet = self:getEventType()
  67 + if oldet ~= newet then
  68 + local em = {}
  69 + if oldet then
  70 + em[oldet] =1
  71 + end
  72 + if newet then
  73 + em[newet] =1
  74 + end
  75 +
  76 + local player = self.room.map.adv.battle.player
  77 + player:attrChangeCondBuffCheck(4, em)
  78 + for _, monster in pairs(player:getTeam(2)) do
  79 + monster:attrChangeCondBuffCheck(4, em)
  80 + end
  81 + end
  82 + end
61 83 end
62 84  
63 85 function Block:clear()
64   - if self:getEventType() == AdvEventType.Trap then
  86 + local et = self:getEventType()
  87 + if et == AdvEventType.Trap then
65 88 self.trapId = self.event.id
66   - elseif self:getEventType() == AdvEventType.Build then
  89 + elseif et == AdvEventType.Build then
67 90 local build = self.room.map.adv.battle:getBuild(self.room.roomId, self.blockId, self.room.map.mapIdx)
68 91 if build then
69 92 build.isDead = true
70 93 end
71 94 end
72 95 self.event = nil
  96 +
  97 +
  98 + if et then
  99 + local em = {[et] = 1}
  100 + local player = self.room.map.adv.battle.player
  101 + player:attrChangeCondBuffCheck(4, em)
  102 + for _, monster in pairs(player:getTeam(2)) do
  103 + monster:attrChangeCondBuffCheck(4, em)
  104 + end
  105 + end
73 106 end
74 107  
75 108  
... ... @@ -90,8 +123,10 @@ function Block:randomEvent()
90 123 enemy:triggerPassive(Passive.BORN_ONCE)
91 124  
92 125 adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
  126 + adv.battle.player:attrChangeCondBuffCheck(3, enemy:getClassify())
93 127 for _, monster in pairs(adv.battle.player:getTeam(2)) do
94   - adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
  128 + monster:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
  129 + monster:attrChangeCondBuffCheck(3, enemy:getClassify())
95 130 end
96 131 end
97 132 randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster]
... ... @@ -208,6 +243,13 @@ function Block:randomEvent()
208 243 e:addBuff(buffId)
209 244 end
210 245 end
  246 + elseif data.target == 4 then
  247 + local enemys = self.room.map.adv:getCurMap():openBlocksIsMonsterByRoom(self.room.roomId)
  248 + for _, e in ipairs(enemys) do
  249 + for _, buffId in ipairs(buffs) do
  250 + e:addBuff(buffId)
  251 + end
  252 + end
211 253 end
212 254  
213 255 if data.specialEff ~= "" then
... ... @@ -263,10 +305,35 @@ function Block:open()
263 305 local adv = map.adv
264 306 self.isOpen = true
265 307 self:randomEvent()
  308 + self:quickDrop()
  309 +
  310 + local et = self:getEventType()
  311 + if et then
  312 + local em = {[et] = 1}
  313 + local player = self.room.map.adv.battle.player
  314 + player:attrChangeCondBuffCheck(4, em)
  315 + for _, monster in pairs(player:getTeam(2)) do
  316 + monster:attrChangeCondBuffCheck(4, em)
  317 + end
  318 + end
266 319 return true
267 320 end
268 321  
  322 +function Block:quickDrop()
  323 + if self:getEventType() == AdvEventType.Drop and self.event.item then
  324 + local itemId, count = table.unpack(self.event.item)
  325 + if globalCsv.adv_auto_collect[itemId] then
  326 + self.room.map.adv:award({[itemId] = count}, {log = {desc = "clickDrop"}}, {roomId = self.room.roomId, blockId = self.blockId, tag = 1})
  327 + self:clear()
  328 + end
  329 + end
  330 +end
  331 +
269 332 function Block:getObstacle()
  333 + if self:isMonster() then
  334 + local enemy = self.room.map.adv.battle:getEnemy(self.room.roomId, self.blockId)
  335 + return enemy:getObstacle()
  336 + end
270 337 local data = self:getEventData()
271 338 if not data then return 0 end
272 339 return data.obstacle or 0
... ...
src/adv/AdvBuff.lua
... ... @@ -20,7 +20,7 @@ Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效)
20 20 Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff
21 21 Buff.CHANGE_DROP = 18 -- 转换掉落
22 22 Buff.BATTLE_PASSIVE = 19 -- 切换为战斗中的被动技
23   -Buff.EXP_ADD = 20 -- 增加exp(每回合)
  23 +-- Buff.EXP_ADD = 20 -- 增加exp(每回合)
24 24 Buff.DONT_DEFEND = 21 -- 不看守地板 -- 怪周围点半可点击
25 25 Buff.SHOW_DANGER = 22 -- 扫雷 展示地上怪物和陷阱数量的标记
26 26 Buff.SHOW_MONSTER_POS = 23 -- 蓝臂章训练场 感知
... ... @@ -34,6 +34,10 @@ Buff.Buff_EFFECT_CHANGE = 30 -- 改变 buff 效果
34 34 Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物
35 35 Buff.SNEAK = 32 --潜行
36 36 Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用
  37 +Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效
  38 +Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 0 - 1
  39 +Buff.DISABLE_AURA = 36 -- 禁用光环
  40 +Buff.GET_AURA = 37 -- 获得光环
37 41  
38 42  
39 43 --角色一些属性的变化
... ... @@ -87,13 +91,24 @@ local function commonAttCond(_Buff, attrName)
87 91 if buff then
88 92 effectCount = buff.layer
89 93 end
  94 + elseif self.buffData.effectValue4 == 3 then
  95 + local classify = tonumber(self.buffData.effectValue5) -- 怪标签
  96 + local enemy = self.owner.battle.player:getTeam(2)
  97 + for _, one in pairs(enemy) do
  98 + if one.isClassify and one:isClassify(classify) then
  99 + effectCount = effectCount + 1
  100 + end
  101 + end
  102 + elseif self.buffData.effectValue4 == 4 then
  103 + local eventType = tonumber(self.buffData.effectValue5) -- event 类型
  104 + effectCount = #self.owner.battle.adv:getCurMap():getEventTypeAllMap(eventType)
90 105 end
91 106 return self.buffData.effectValue2 * effectCount
92 107 end
93 108  
94 109 _Buff.getEffectBy = function(self)
95 110 local cond = nil
96   - if self.buffData.effectValue4 == 2 then
  111 + if self.buffData.effectValue4 == 2 or self.buffData.effectValue4 == 3 or self.buffData.effectValue4 == 4 then
97 112 cond = tonumber(self.buffData.effectValue5)
98 113 end
99 114 return self.buffData.effectValue4, attrName, cond
... ... @@ -302,18 +317,30 @@ local BuffFactory = {
302 317 end
303 318 end,
304 319  
305   - [Buff.EXP_ADD] = function(_Buff)
306   - _Buff._afterRound = function(self)
307   - local value = self:effect()
308   - self.owner.battle.player:addExp(value)
  320 + -- [Buff.EXP_ADD] = function(_Buff)
  321 + -- _Buff._afterRound = function(self)
  322 + -- local value = self:effect()
  323 + -- self.owner.battle.player:addExp(value)
  324 + -- end
  325 + -- _Buff._effectValue = function(self)
  326 + -- -- 经验值
  327 + -- return self.buffData.effectValue1 * self.layer
  328 + -- end
  329 + -- end,
  330 +
  331 + [Buff.DISABLE_BUFF] = function(_Buff)
  332 + _Buff._effectValue = function(self)
  333 + return self.buffData.effectValue1
309 334 end
  335 + end,
  336 +
  337 + [Buff.DISABLE_AURA] = function(_Buff)
310 338 _Buff._effectValue = function(self)
311   - -- 经验值
312   - return self.buffData.effectValue1 * self.layer
  339 + return self.buffData.effectValue1
313 340 end
314 341 end,
315 342  
316   - [Buff.DISABLE_BUFF] = function(_Buff)
  343 + [Buff.GET_AURA] = function(_Buff)
317 344 _Buff._effectValue = function(self)
318 345 return self.buffData.effectValue1
319 346 end
... ... @@ -378,6 +405,14 @@ local BuffFactory = {
378 405 self.layer = self.buffData.effectValue1
379 406 end
380 407 end,
  408 + [Buff.GET_PASSIVE] = function( _Buff )
  409 + _Buff._init = function(self)
  410 + self.owner:addPassive({id = self.buffData.effectValue1})
  411 + end
  412 + _Buff._endBuff = function(self)
  413 + self.owner:delPassiveById(self.buffData.effectValue1)
  414 + end
  415 + end
381 416 }
382 417  
383 418 -- 同样的返回 effectValue1, effectValue2 * self.layer 类型的buff
... ... @@ -439,7 +474,18 @@ function Buff:initNew(release, data)
439 474 end
440 475 end
441 476  
442   -function Buff:createAfter()
  477 +function Buff:createAfter(layer)
  478 + layer = layer or 1
  479 + local otype, maxLayer = self:getOverlay()
  480 + if otype then
  481 + self.layer = layer
  482 + if maxLayer ~= 0 then
  483 + self.layer = math.min(maxLayer, self.layer)
  484 + end
  485 + else
  486 + self.layer = 1
  487 + end
  488 +
443 489 if self._init then
444 490 self:_init()
445 491 end
... ... @@ -626,12 +672,13 @@ function Buff:getOverlay()
626 672 end
627 673  
628 674 -- 叠加
629   -function Buff:overlay(releaser, data)
  675 +function Buff:overlay(releaser, data, layer)
630 676 local otype, maxLayer = self:getOverlay()
631 677 if self.isDel or not otype then -- 新获得的 (不可叠加相当于新获得的)
632   - self.isDel = false
633 678 self:endBuff()
  679 + self.isDel = false
634 680 self:initNew(releaser, data)
  681 + self:createAfter(layer)
635 682 else
636 683 -- 重置回合 次数
637 684 self.roundSpace = 0
... ... @@ -644,7 +691,7 @@ function Buff:overlay(releaser, data)
644 691  
645 692 self.release = releaser or self.release
646 693 -- 叠加层数
647   - self.layer = self.layer + 1
  694 + self.layer = self.layer + layer
648 695 if maxLayer ~= 0 then
649 696 self.layer = math.min(maxLayer, self.layer)
650 697 end
... ... @@ -655,14 +702,32 @@ function Buff:overlay(releaser, data)
655 702 end
656 703  
657 704 -- 扣减层数
658   -function Buff:uncover()
659   - if self.layer <= 1 then
  705 +function Buff:uncover(layer, isAura)
  706 + layer = layer or 1
  707 + local oldLayer = self.layer
  708 +
  709 + self.layer = self.layer - layer
  710 +
  711 + if self.layer <= 0 then
660 712 self.isDel = true
661 713 end
662 714  
663   - self.layer = self.layer - 1
664   - if self._uncover then
665   - self:_uncover()
  715 + if isAura then
  716 + if layer == -1 then
  717 + self.layer = 0
  718 + self.isDel = true
  719 + else
  720 + self.layer = math.max(1, self.layer)
  721 + self.isDel = false
  722 + end
  723 + end
  724 +
  725 + if self.isDel then return end
  726 +
  727 + if oldLayer ~= self.layer then
  728 + if self._uncover then
  729 + self:_uncover()
  730 + end
666 731 end
667 732 end
668 733  
... ...
src/adv/AdvMap.lua
... ... @@ -256,7 +256,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
256 256  
257 257 if status then
258 258 if isPlayer then
259   - self.adv.battle:triggerPassive(Passive.OPEN_BLOCK)
  259 + self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId})
260 260 self.adv.owner:checkTaskEnter("AdvOpenBlock")
261 261  
262 262 -- 潜行检查
... ... @@ -272,8 +272,8 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
272 272 if not ignoreBack then
273 273 self.adv:backBlockChange(roomId, blockId)
274 274 end
275   -
276 275 end
  276 + return status
277 277 end
278 278  
279 279 function Map:openBlocksBySize(roomId, blockId, size, isPlayer, ignoreBack)
... ... @@ -292,6 +292,41 @@ function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack)
292 292 end
293 293 end
294 294  
  295 +function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack)
  296 + local room = self.rooms[roomId]
  297 + if not room then return end
  298 +
  299 + local allBlock = {}
  300 + for blockId, block in pairs(room.blocks) do
  301 + if block:isMonster() and not block.isOpen then
  302 + table.insert(allBlock, blockId)
  303 + end
  304 + end
  305 +
  306 + local enemys = {}
  307 + local openBlock = function(blockId)
  308 + if self:openBlock(roomId, blockId, isPlayer, ignoreBack) then
  309 + local e = self.adv.battle:getEnemy(roomId, blockId)
  310 + if e then
  311 + table.insert(enemys, e)
  312 + end
  313 + end
  314 + end
  315 +
  316 + if not count or count == -1 or count >= len(allBlock) then
  317 + for _, blockId in ipairs(allBlock) do
  318 + openBlock(blockId)
  319 + end
  320 + else
  321 + for i = 1, count do
  322 + local idx = math.randomInt(1, len(allBlock))
  323 + openBlock(allBlock[idx])
  324 + table.remove(allBlock, idx)
  325 + end
  326 + end
  327 + return enemys
  328 +end
  329 +
295 330 function Map:openAllBlocks(isPlayer, ignoreBack)
296 331 for roomId, room in pairs(self.rooms) do
297 332 self:openBlocksByRoom(room.roomId, isPlayer, ignoreBack)
... ... @@ -309,6 +344,22 @@ function Map:getRBByPos(c, r)
309 344 end
310 345 end
311 346  
  347 +function Map:getDistance(froomId, fblockId, troomId, tblockId)
  348 + local distance = -1
  349 + local room1 = self.rooms[froomId]
  350 + local room2 = self.rooms[troomId]
  351 + if room1 and room2 then
  352 + local block1 = room1[fblockId]
  353 + local block2 = room2[tblockId]
  354 + if block1 and block2 then
  355 + local c1, r1 = room1:tranLtoG(block1.col, block1.row)
  356 + local c2, r2 = room2:tranLtoG(block2.col, block2.row)
  357 + distance = math.max(math.abs(c1 - c2), math.abs(r1 - r2))
  358 + end
  359 + end
  360 + return distance
  361 +end
  362 +
312 363 function Map:getAroundBlocks(room, block)
313 364 local blocks = {}
314 365 local range = {1, -1}
... ... @@ -412,6 +463,18 @@ function Map:getEnemysBySize(roomId, blockId, size)
412 463 return enemys
413 464 end
414 465  
  466 +function Map:getEventTypeAllMap(eventType)
  467 + local blocks = {}
  468 + if not eventType then return blocks end
  469 + for roomId, room in pairs(self.rooms) do
  470 + for blockId, block in pairs(room.blocks) do
  471 + if block.isOpen and block:getEventType() == eventType then
  472 + table.insert(blocks, block)
  473 + end
  474 + end
  475 + end
  476 + return blocks
  477 +end
415 478 -----------------------------随机地图-----------------------------
416 479  
417 480 -- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入
... ...
src/adv/AdvPassive.lua
... ... @@ -7,6 +7,8 @@ Filter.HP_LOW = 4 -- 血量&lt;value%
7 7 Filter.BUFF_BY_TYPE = 5 -- 指定类型buff
8 8 Filter.BUFF_BY_ID = 6 -- 指定id的buff
9 9 Filter.CAMP = 7 -- 玩家是指定阵营
  10 +Filter.RANGE = 8 -- 筛选范围 (触发是地块)
  11 +Filter.CLASSIFY = 9 -- 标签
10 12  
11 13 local FilterFactory = {}
12 14 FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter)
... ... @@ -46,6 +48,21 @@ FilterFactory[Filter.CAMP] = function (_Filter)
46 48 end
47 49 end
48 50  
  51 +FilterFactory[Filter.RANGE] = function (_Filter)
  52 + _Filter._execute = function (self, target, params)
  53 + if self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then
  54 + local distance = self.owner.battle.adv:getCurMap():getDistance(self.owner.roomId, self.owner.blockId, params.roomId, params.blockId)
  55 + return distance ~= -1 and distance <= self.value
  56 + end
  57 + return false
  58 + end
  59 +end
  60 +
  61 +FilterFactory[Filter.CLASSIFY] = function (_Filter)
  62 + _Filter._execute = function (self, target)
  63 + return target.isClassify and target:isClassify(self.value)
  64 + end
  65 +end
49 66  
50 67 function Filter:ctor(params)
51 68 self.owner = params.owner
... ... @@ -79,7 +96,7 @@ function Filter:execute(params)
79 96 return
80 97 end
81 98 if self:_execute(target) then
82   - return self:_execute(target)
  99 + return self:_execute(target, params)
83 100 end
84 101 end
85 102  
... ... @@ -120,6 +137,7 @@ Passive.GET_BUFF = 28 --获得指定buff
120 137 Passive.OPEN_BLOCK = 29 --翻开格子
121 138 Passive.OPEN_MONSTER = 30 --翻开怪物
122 139 Passive.PLAYER_BUFF = 31 --玩家获得buff
  140 +
123 141 Passive.PLAYER_BUFF_CLASSIFY = 35 -- 获得指定标签的buff
124 142  
125 143 -- 不同的开启条件
... ... @@ -442,6 +460,7 @@ end
442 460  
443 461 --3=翻开自己所在格子
444 462 function Passive:effect3(value)
  463 + if not self.owner.roomId or not self.owner.blockId then return end
445 464 if value == 0 then
446 465 self.owner.battle.adv:getCurMap():openBlock(self.owner.roomId, self.owner.blockId)
447 466 elseif value > 0 then
... ... @@ -494,7 +513,7 @@ function Passive:effect8(dropId)
494 513 skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId))
495 514 end
496 515 local item = dropData["range"]:randWeight(true)
497   - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId})
  516 + self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId})
498 517  
499 518 end
500 519  
... ... @@ -509,7 +528,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max)
509 528 return
510 529 end
511 530 if not cond then return end
512   - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId})
  531 + self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId})
513 532 end
514 533  
515 534 --10=战斗额外掉落次数
... ... @@ -561,5 +580,22 @@ function Passive:effect14(value, triggerPms, enemyId)
561 580 end
562 581 end
563 582  
  583 +--15=翻开房间内的count 个怪 并且增加一个buff
  584 +function Passive:effect15(count, triggerPms, buffId)
  585 + local roomId = self.owner.roomId
  586 + if not roomId then return end
  587 + local enemys = self.owner.battle.adv:getCurMap():openBlocksIsMonsterByRoom(roomId, count)
  588 + for _, e in ipairs(enemys) do
  589 + e:addBuff(buffId)
  590 + end
  591 +end
  592 +
  593 +--16=转变 value 范围内的掉落物 为 id count
  594 +function Passive:effect16(value, triggerPms, changeType)
  595 + if not self.owner.roomId or not self.owner.blockId then return end
  596 + local blocks = self.owner.battle.adv:getCurMap():getBlocksBySize(self.owner.roomId, self.owner.blockId, value)
  597 + self.owner.battle.adv:blockDropChange(changeType, blocks)
  598 +end
  599 +
564 600  
565 601 return Passive
566 602 \ No newline at end of file
... ...
src/adv/AdvPlayer.lua
... ... @@ -90,6 +90,12 @@ end
90 90 function BaseObject:clear()
91 91 self.buffs = {}
92 92 self.passives = {}
  93 + if self:is("Enemy") then
  94 + self.battle.player:attrChangeCondBuffCheck(3, self:getClassify())
  95 + for _, monster in pairs(self.battle.player:getTeam(2)) do
  96 + monster:attrChangeCondBuffCheck(3, self:getClassify())
  97 + end
  98 + end
93 99 end
94 100  
95 101 function BaseObject:addPassive(params)
... ... @@ -137,7 +143,21 @@ function BaseObject:getDisablePassiveCount()
137 143 return count
138 144 end
139 145  
140   -function BaseObject:addBuff(buffId, releaser)
  146 +function BaseObject:getDisableAuraCount()
  147 + local count
  148 + for _, buff in ipairs(self.buffs) do
  149 + if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then
  150 + if buff:effect() == 0 then
  151 + return 0
  152 + end
  153 + count = (count or 0) + buff:effect()
  154 + end
  155 + end
  156 + return count
  157 +end
  158 +
  159 +function BaseObject:addBuff(buffId, releaser, layer)
  160 + layer = layer or 1
141 161 local buffData = csvdb["adv_map_buffCsv"][buffId]
142 162 if not buffData then return end
143 163 for _, buff in ipairs(self.buffs) do
... ... @@ -151,7 +171,7 @@ function BaseObject:addBuff(buffId, releaser)
151 171 local oldBuff = self:getBuffById(buffId)
152 172 if oldBuff then
153 173 if not oldBuff:checkKeep() then return end
154   - oldBuff:overlay(releaser, {}) -- 叠加
  174 + oldBuff:overlay(releaser, {}, layer) -- 叠加
155 175 else
156 176 -- 不能保持的buff 也加不上去
157 177 if not Buff.checkKeep({
... ... @@ -161,10 +181,11 @@ function BaseObject:addBuff(buffId, releaser)
161 181 }) then return end
162 182 local buff = Buff.create(self, releaser, {id = buffId})
163 183 table.insert(self.buffs, buff)
164   - buff:createAfter()
  184 + buff:createAfter(layer)
165 185 end
166 186 self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId})
167 187 self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify})
  188 + self:attrChangeCondBuffCheck(2, buffId)
168 189 return true
169 190 end
170 191  
... ... @@ -217,6 +238,44 @@ end
217 238 function BaseObject:reSetSpMax()
218 239 end
219 240  
  241 +function BaseObject:checkAuraBuff(buffs)
  242 +end
  243 +
  244 +function BaseObject:getAuras()
  245 + local disable = self:getDisableAuraCount()
  246 + local auras = {}
  247 + local function addAura(one)
  248 + if disable > 0 then
  249 + disable = disable - 1
  250 + else
  251 + table.insert(auras, one)
  252 + end
  253 + end
  254 + if self:is("Enemy") then
  255 + local halo = csvdb["event_monsterCsv"][self.monsterId].halo
  256 + if halo then
  257 + for _, one in ipairs(halo:toArray(true, "=")) do
  258 + addAura(one)
  259 + end
  260 + end
  261 + elseif self:is("Build") then
  262 + local halo = csvdb["event_buildingCsv"][self.id].halo
  263 + if halo then
  264 + for _, one in ipairs(halo:toArray(true, "=")) do
  265 + addAura(one)
  266 + end
  267 + end
  268 + end
  269 +
  270 + for _, buff in ipairs(self.buffs) do
  271 + if not buff:isHide() and buff:getType() == Buff.GET_AURA then
  272 + addAura(buff:effect())
  273 + end
  274 + end
  275 +
  276 + return auras
  277 +end
  278 +
220 279  
221 280 -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类
222 281 function BaseObject:getCommonBuffEffect(bType, otherCond)
... ... @@ -417,7 +476,7 @@ function BaseObject:hurt(value, releaser, params)
417 476 if self.hp == 0 then
418 477 self:triggerPassive(Passive.SELF_DEAD)
419 478 for _, team in ipairs(self:getTeam(1, true)) do
420   - team:triggerPassive(Passive.TEAM_DEAD)
  479 + team:triggerPassive(Passive.TEAM_DEAD, {trigger = self})
421 480 end
422 481  
423 482 if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then
... ... @@ -505,6 +564,50 @@ function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock)
505 564 return team
506 565 end
507 566  
  567 +function BaseObject:attrChangeCondBuffCheck(etype, cond)
  568 + local effect = {}
  569 + if etype == 3 then
  570 + if type(cond) ~= "string" then
  571 + return
  572 + end
  573 + local temp = cond:toArray(true, " ")
  574 + cond = {}
  575 + for _, one in pairs(temp) do
  576 + cond[one] = 1
  577 + end
  578 + elseif etype == 4 then
  579 + if not cond then
  580 + cond = {}
  581 + end
  582 + if type(cond) == "number" then
  583 + cond = {[cond] = 1}
  584 + end
  585 + end
  586 + for _, buff in ipairs(self.buffs) do
  587 + if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then
  588 + local _et, _attr, _co = buff:getEffectBy()
  589 + if etype == _et then
  590 + if etype == 3 or etype == 4 then
  591 + if cond[_co] then
  592 + effect[_attr] = 1
  593 + end
  594 + else
  595 + if (not _co or _co == cond) then
  596 + effect[_attr] = 1
  597 + end
  598 + end
  599 + end
  600 + end
  601 + end
  602 + for attrName, _ in pairs(effect) do
  603 + if attrName == "hp" then
  604 + self:reSetHpMax()
  605 + else
  606 + self:reSetAttr(attrName)
  607 + end
  608 + end
  609 +end
  610 +
508 611 function BaseObject:getDB()
509 612 local db = {}
510 613 db.hp = self.hp
... ... @@ -557,6 +660,51 @@ function Enemy:isEnemy()
557 660 return true
558 661 end
559 662  
  663 +function Enemy:getObstacle()
  664 + local obstacle = csvdb["event_monsterCsv"][self.monsterId].obstacle
  665 + if obstacle == 0 and self:hadBuff(Buff.OBSTACLE_CHANGE) then
  666 + obstacle = 1
  667 + end
  668 + return obstacle
  669 +end
  670 +
  671 +function Enemy:isClassify(check)
  672 + local classify = self:getClassify()
  673 + return classify and classify:sismember(check, " ")
  674 +end
  675 +
  676 +function Enemy:getClassify()
  677 + return csvdb["event_monsterCsv"][self.monsterId].classify
  678 +end
  679 +
  680 +-- 0=所有 1=怪物 2=玩家
  681 +function Enemy:checkAuraBuff(buffs)
  682 + local needBuffs = {}
  683 +
  684 + for buffId, info in pairs(buffs[0] or {}) do
  685 + needBuffs[buffId] = needBuffs[buffId] or {}
  686 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  687 + needBuffs[buffId].exist = info.exist
  688 + end
  689 +
  690 + for buffId, info in pairs(buffs[1] or {}) do
  691 + needBuffs[buffId] = needBuffs[buffId] or {}
  692 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  693 + needBuffs[buffId].exist = info.exist
  694 + end
  695 +
  696 + for buffId, info in pairs(needBuffs) do
  697 + if info.count < 0 then
  698 + local buff = self:getBuffById(buffId)
  699 + if buff then
  700 + buff:uncover(info.exist and -info.count or -1, true)
  701 + end
  702 + elseif count > 0 then
  703 + self:addBuff(buffId, nil, info.count)
  704 + end
  705 + end
  706 +end
  707 +
560 708 function Enemy:kill()
561 709 self:hurt(self.hp, self.battle.player, {hurtType = 5})
562 710 end
... ... @@ -569,44 +717,44 @@ end
569 717  
570 718 function Player:initData(data)
571 719 Player.super.initData(self, data)
572   - self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr
  720 + -- self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr
573 721 self.growth = data.growth
574   - self.exp = data.exp or 0
  722 + -- self.exp = data.exp or 0
575 723 self.sp = data.sp or 100
576 724 self.spMax = data.spMax or 100
577 725 self._spMax = data._spMax or 100
578 726 end
579 727  
580   -function Player:addExp(value)
581   - -- buff 经验加成
582   - local up = self:getCommonBuffEffect(Buff.EXP_UP)
583   - value = math.ceil((value + up[0]) * (1 + up[1]))
584   -
585   - if value <= 0 then return end
586   - local newExp = self.exp + value
587   - local level = self.level
588   - if level >= #csvdb["adv_levelCsv"] then return end
589   - while true do
590   - local curData = csvdb["adv_levelCsv"][level]
591   - if newExp < curData.exp then break end
592   - level = level + 1
593   - newExp = newExp - curData.exp
594   - if level >= #csvdb["adv_levelCsv"] then break end
595   - end
596   - local delta = level - self.level
597   -
598   - self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value})
599   -
600   - if delta > 0 then
601   - for attr, _ in pairs(AdvAttsEnum) do
602   - self:addBaseAttr(attr, self.growth[attr] * delta, 0, true)
603   - end
604   - self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta})
605   - end
606   - self.level = level
607   - self.exp = newExp
608   - return value
609   -end
  728 +-- function Player:addExp(value)
  729 +-- -- buff 经验加成
  730 +-- local up = self:getCommonBuffEffect(Buff.EXP_UP)
  731 +-- value = math.ceil((value + up[0]) * (1 + up[1]))
  732 +
  733 +-- if value <= 0 then return end
  734 +-- local newExp = self.exp + value
  735 +-- local level = self.level
  736 +-- if level >= #csvdb["adv_levelCsv"] then return end
  737 +-- while true do
  738 +-- local curData = csvdb["adv_levelCsv"][level]
  739 +-- if newExp < curData.exp then break end
  740 +-- level = level + 1
  741 +-- newExp = newExp - curData.exp
  742 +-- if level >= #csvdb["adv_levelCsv"] then break end
  743 +-- end
  744 +-- local delta = level - self.level
  745 +
  746 +-- self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value})
  747 +
  748 +-- if delta > 0 then
  749 +-- for attr, _ in pairs(AdvAttsEnum) do
  750 +-- self:addBaseAttr(attr, self.growth[attr] * delta, 0, true)
  751 +-- end
  752 +-- self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta})
  753 +-- end
  754 +-- self.level = level
  755 +-- self.exp = newExp
  756 +-- return value
  757 +-- end
610 758 --vtype 0/1 值/%
611 759 function Player:addBaseAttr(attr, value, vtype, ignoreBack)
612 760 local attrName = attr
... ... @@ -696,7 +844,6 @@ end
696 844 function Player:addBuff(buffId, releaser)
697 845 local status = Player.super.addBuff(self, buffId, releaser)
698 846 if status then
699   - self.battle.player:attrChangeCondBuffCheck(2, buffId)
700 847 self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId)
701 848 self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId})
702 849 self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId})
... ... @@ -707,23 +854,30 @@ function Player:addBuff(buffId, releaser)
707 854 end
708 855 return status
709 856 end
  857 +-- 0=所有 1=怪物 2=玩家
  858 +function Player:checkAuraBuff(buffs)
  859 + local needBuffs = {}
710 860  
711   -function Player:attrChangeCondBuffCheck(etype, cond)
712   - local effect = {}
713   - for _, buff in ipairs(self.buffs) do
714   - if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then
715   - local _et, _attr, _co = buff:getEffectBy()
716   - if etype == _et and (not _co or _co == cond) then
717   - effect[_attr] = 1
718   - end
719   -
720   - end
  861 + for buffId, info in pairs(buffs[0] or {}) do
  862 + needBuffs[buffId] = needBuffs[buffId] or {}
  863 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  864 + needBuffs[buffId].exist = info.exist
721 865 end
722   - for attrName, _ in pairs(effect) do
723   - if attrName == "hp" then
724   - self:reSetHpMax()
725   - else
726   - self:reSetAttr(attrName)
  866 +
  867 + for buffId, info in pairs(buffs[2] or {}) do
  868 + needBuffs[buffId] = needBuffs[buffId] or {}
  869 + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count
  870 + needBuffs[buffId].exist = info.exist
  871 + end
  872 +
  873 + for buffId, info in pairs(needBuffs) do
  874 + if info.count < 0 then
  875 + local buff = self:getBuffById(buffId)
  876 + if buff then
  877 + buff:uncover(info.exist and -info.count or -1, true)
  878 + end
  879 + elseif info.count > 0 then
  880 + self:addBuff(buffId, nil, info.count)
727 881 end
728 882 end
729 883 end
... ... @@ -734,7 +888,8 @@ end
734 888  
735 889 function Player:getDB()
736 890 local db = Player.super.getDB(self)
737   - for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do
  891 + -- for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do
  892 + for _ , field in pairs({"level", "growth", "sp", "spMax"}) do
738 893 db[field] = self[field]
739 894 end
740 895 db["_spMax"] = self._spMax
... ...
1   -Subproject commit 02a9bbbb10bb99a91cc5d67f62dc7e5b49d8cb46
  1 +Subproject commit a2598231ccc5e16da1a27f976602871f30fcd035
... ...
src/models/Hero.lua
... ... @@ -15,6 +15,7 @@ Hero.schema = {
15 15 -- loveL = {"number", 0}, --好感度等级
16 16 equip = {"string",""}, --装备 type=level
17 17 rune = {"string",""}, --零件 type=id
  18 + faith = {"number", 0}, -- 信赖
18 19 }
19 20  
20 21 function Hero:ctor( properties )
... ... @@ -102,6 +103,7 @@ function Hero:data()
102 103 -- loveL = self:getProperty("loveL"),
103 104 equip = self:getProperty("equip"),
104 105 rune = self:getProperty("rune"),
  106 + faith = self:getProperty("faith")
105 107 }
106 108 end
107 109  
... ... @@ -113,4 +115,8 @@ function Hero:getRare()
113 115 return csvdb["unitCsv"][self:getProperty("type")].rare
114 116 end
115 117  
  118 +function Hero:getPosition()
  119 + return csvdb["unitCsv"][self:getProperty("type")].position
  120 +end
  121 +
116 122 return Hero
117 123 \ No newline at end of file
... ...
src/models/HeroPlugin.lua
... ... @@ -48,30 +48,29 @@ function HeroPlugin.bind(Hero)
48 48 local breakL = params.breakL or self:getProperty("breakL")
49 49 local wakeL = params.wakeL or self:getProperty("wakeL")
50 50 local talent = params.talent or self:getProperty("talent")
51   -
  51 + local heroCfgId = self:getProperty("type")
52 52 --天赋
53 53 local talentAttrS = {}
54 54  
55 55 -- 四个基础属性
56 56 local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)]
  57 + local curTalentLvl = 0
57 58 if not curData then -- 已经满阶段了
58   - curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]]
59   - local strength = curData[#curData].strength
60   - for i = 1, 4 do
61   - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + strength
62   - end
  59 + local cfgName = "unit_talent_"..heroCfgId.."Csv"
  60 + curData = csvdb[cfgName][#csvdb[cfgName]]
63 61 else
64   - for i = 1, 4 do --4个天赋
65   - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + curData[talent:getv(i, 0)].strength
66   - end
  62 + curTalentLvl = talent:getv(1, 1)
67 63 end
68   - --阶段属性
69   - for i = 1, (talent:getv(0, 1) - 1) do
70   - local curData = csvdb["unit_talentCsv"][i]
71   - local effect = curData[#curData].effect:toArray(true, "=")
72   - talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2]
  64 + for lvl, cfg in pairs(curData) do
  65 + if lvl < curTalentLvl or curTalentLvl == 0 then
  66 + if cfg.effect ~= 99 then
  67 + local curVal = talentAttrS[cfg.effect] or 0
  68 + if curVal < cfg.strength then
  69 + talentAttrS[cfg.effect] = cfg.strength
  70 + end
  71 + end
  72 + end
73 73 end
74   -
75 74  
76 75 for _, attrName in pairs(AttsEnumEx) do
77 76 if talentAttrS[attrName] then
... ... @@ -79,6 +78,22 @@ function HeroPlugin.bind(Hero)
79 78 end
80 79 end
81 80  
  81 + -- 信赖属性
  82 + local faithAttr = {}
  83 + local faith = self:getProperty("faith")
  84 + local faithConfig = csvdb["unit_trustCsv"]
  85 + for lvl = 1, #faithConfig do
  86 + if faith >= faithConfig[lvl].exp then
  87 + local add = faithConfig[lvl]["position_"..unitData.position]:toArray(true, "=")
  88 + faithAttr[add[1]] = (faithAttr[add[1]] or 0) + add[2]
  89 + end
  90 + end
  91 + for _, attrName in pairs(AttsEnumEx) do
  92 + if faithAttr[attrName] then
  93 + faithAttr[attrName] = addAttr(unitData[attrName], faithAttr[attrName], 1, attrName)
  94 + end
  95 + end
  96 +
82 97 local attrs = {}
83 98 for _, attName in pairs(AttsEnumEx) do
84 99 attrs[attName] = unitData[attName] or 0
... ... @@ -90,7 +105,7 @@ function HeroPlugin.bind(Hero)
90 105 for attr, value in pairs(attrs) do
91 106 attrs[attr] = attrs[attr] + addAttr(attrs[attr], lData[attr .. "Level"], 1, attr)
92 107 attrs[attr] = attrs[attr] + addAttr(attrs[attr], blData[attr .. "Level"], 1, attr)
93   - attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0)
  108 + attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0) + (faithAttr[attr] or 0)
94 109 end
95 110  
96 111 return attrs
... ... @@ -237,6 +252,37 @@ function HeroPlugin.bind(Hero)
237 252 return level
238 253 end
239 254  
  255 + -- 天赋获得的技能
  256 + function Hero:getTalentSkill()
  257 + local TalentEnum = {
  258 + [1] = 1, -- 血量
  259 + [2] = 2, -- 攻击
  260 + [3] = 3, -- 物理防御
  261 + [4] = 4, -- 命中
  262 + [5] = 5, -- 闪避
  263 + }
  264 + local talentCsv = csvdb["unit_talent_" .. self:getProperty("type") .. "Csv"]
  265 + local curLv = self:getProperty("talent"):getv(1,1) - 1
  266 + local curRan = self:getProperty("talent"):getv(0,1)
  267 + local skills = {}
  268 + for ran, data in ipairs(talentCsv) do
  269 + if ran <= curRan then
  270 + for lv, value in ipairs(data) do
  271 + if ran < curRan or lv <= curLv then
  272 + if not TalentEnum[value.effect] then
  273 + skills[value.strength] = true
  274 + end
  275 + else
  276 + break
  277 + end
  278 + end
  279 + else
  280 + break
  281 + end
  282 + end
  283 + return skills
  284 + end
  285 +
240 286 function Hero:getSkillData(idx)
241 287 local unitData = csvdb["unitCsv"][self:getProperty("type")]
242 288 if idx == 1 then
... ... @@ -296,6 +342,27 @@ function HeroPlugin.bind(Hero)
296 342 end
297 343 return
298 344 end
  345 +
  346 + -- 添加英雄信赖
  347 + function Hero:addHeroFaith(exp)
  348 + local faith = self:getProperty("faith")
  349 + local config = csvdb["unit_trustCsv"]
  350 + local star = self:getProperty("wakeL")
  351 + local tmpExp = faith + exp
  352 + for lvl = 1, #config do
  353 + if star < config[lvl].star then
  354 + break
  355 + end
  356 + if tmpExp < config[lvl].exp then
  357 + faith = tmpExp
  358 + break
  359 + else
  360 + faith = config[lvl].exp
  361 + end
  362 + end
  363 + self:setProperty("faith", faith)
  364 + end
  365 +
299 366 end
300 367  
301 368  
... ...
src/models/Role.lua
... ... @@ -103,7 +103,6 @@ Role.schema = {
103 103 --挂机相关
104 104 hangPass = {"table", {}}, -- 挂机通过的最大关卡
105 105 hangGift = {"table", {}}, -- 挂机奖励 {id = 1}
106   - hangTeam = {"table", {}}, -- 挂机队伍
107 106 hangTS = {"table", {}}, -- 挂机队伍他人可读的队伍信息
108 107 hangTB = {"table", {}}, -- 挂机队伍他人可用的战斗信息mao
109 108 hangTBV = {"number", 0}, -- 挂机队伍他人可用的战斗力
... ... @@ -111,11 +110,12 @@ Role.schema = {
111 110 hangInfo = {"table", {}}, -- 当前挂机信息
112 111 hangBag = {"table", {}}, -- 背包
113 112 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限
114   - bTeam = {"table", {}}, -- 奖励副本队伍
115 113 hangTeams = {"table", {}}, -- pve自选编队
116 114 teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType
117 115 advTeams = {"table", {}}, -- 拾荒自选编队
118 116  
  117 + bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1
  118 +
119 119 --引导相关
120 120 newerGuide = {"string","1=1"}, -- 新手引导 master=slave
121 121 funcGuide = {"string",""}, -- 功能引导 0=0跳过次数(999永久跳过) 1=1功能1触发情况
... ... @@ -145,7 +145,6 @@ Role.schema = {
145 145 boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}}
146 146  
147 147 towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey}
148   - towerF = {"table", {}}, -- 爬塔阵容
149 148  
150 149 spTask = {"table", {}}, -- 特殊任务 -- {id = status}
151 150  
... ... @@ -181,6 +180,7 @@ Role.schema = {
181 180 feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数
182 181  
183 182 calTask = {"table", {}}, -- 英雄令活动 日历任务活动
  183 + radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv
184 184 }
185 185  
186 186  
... ... @@ -356,14 +356,14 @@ function Role:data()
356 356  
357 357 hangPass = self:getProperty("hangPass"),
358 358 hangGift = self:getProperty("hangGift"),
359   - hangTeam = self:getProperty("hangTeam"),
360 359 hangInfo = self:getProperty("hangInfo"),
361 360 hangBag = self:getProperty("hangBag"),
362 361 hangBagLimit = self:getProperty("hangBagLimit"),
363   - bTeam = self:getProperty("bTeam"),
364 362 hangTeams = self:getProperty("hangTeams"),
365 363 teamIndex = self:getProperty("teamIndex"),
366 364 advTeams = self:getProperty("advTeams"),
  365 +
  366 + bonusStar = self:getProperty("bonusStar"),
367 367  
368 368 newerGuide = self:getProperty("newerGuide"),
369 369 funcGuide = self:getProperty("funcGuide"),
... ... @@ -379,7 +379,6 @@ function Role:data()
379 379 equips = self:getProperty("equips"),
380 380 boxL = self:getProperty("boxL"),
381 381 towerInfo = self:getProperty("towerInfo"),
382   - towerF = self:getProperty("towerF"),
383 382 spTask = self:getProperty("spTask"),
384 383 dTask = self:getProperty("dTask"),
385 384 wTask = self:getProperty("wTask"),
... ... @@ -406,6 +405,7 @@ function Role:data()
406 405 feedback = self:getProperty("feedback"),
407 406 ctime = self:getProperty("ctime"),
408 407 calTask = self:getProperty("calTask"),
  408 + radioTask = self:getProperty("radioTask"),
409 409 }
410 410 end
411 411  
... ...
src/models/RoleBattle.lua
... ... @@ -57,7 +57,6 @@ function Role:checkBattle(battleType, params)
57 57 end
58 58 end,
59 59 tower = function()
60   - --local towerF = self:getProperty("towerF")
61 60 local towerF = self:getTeamFormatByType(TeamSystemType.Tower)
62 61 for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do
63 62 selflist[slot] = hero.type
... ... @@ -73,7 +72,6 @@ function Role:checkBattle(battleType, params)
73 72 end
74 73 end,
75 74 bonus = function()
76   - --local bTeam = self:getProperty("bTeam")
77 75 local bTeam = self:getTeamFormatByType(TeamSystemType.BonusBattle)
78 76 for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do
79 77 selflist[slot] = hero.type
... ...
src/models/RoleLog.lua
... ... @@ -107,6 +107,8 @@ local ItemReason = {
107 107 unlockPool = 1208, -- 解锁英雄定向抽卡池
108 108 downloadCv = 1209, -- 下载 cv包奖励
109 109 refer = 1210, -- 穿戴
  110 + itemCompose = 1211, -- 天赋道具合成
  111 + radioQuest = 1212, -- 电台任务奖励
110 112  
111 113 -- pvp
112 114 pvpCHead = 1301, -- pvp 跨服竞技场头像
... ...
src/models/RolePlugin.lua
1 1  
2   -
  2 +local serverId = tonumber(skynet.getenv("servId"))
3 3 local RolePlugin = {}
4 4  
5 5 function RolePlugin.bind(Role)
... ... @@ -64,6 +64,9 @@ function RolePlugin.bind(Role)
64 64 [ItemId.PlayerExp] = function()
65 65 self:addPlayExp(count, pms)
66 66 end,
  67 + [ItemId.AdvPower] = function()
  68 + self:changeAdvCount(-count)
  69 + end,
67 70 }
68 71  
69 72 local itemTypeAward = {
... ... @@ -1132,7 +1135,6 @@ function RolePlugin.bind(Role)
1132 1135 local now = skynet.timex()
1133 1136 local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年
1134 1137 local ct = 10000 - ct -- 越早的排名越靠前
1135   - --local towerTeam = self:getProperty("towerF")
1136 1138 local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower)
1137 1139 local battleV = self:getTeamBattleValue(towerTeam.heros)
1138 1140 local score = (level * 10000 + ct) * 10000000 + battleV
... ... @@ -1280,11 +1282,13 @@ function RolePlugin.bind(Role)
1280 1282 info.specialLevel = hero:getSkillLevel(1)
1281 1283 info.passiveLevel = hero:getSkillLevel(3)
1282 1284 info.runeSkill = hero:getRuneSkill(102)
  1285 + info.talentSkills = hero:getTalentSkill()
1283 1286 teamInfo.heros[slot] = info
1284 1287 end
1285 1288 for slot, id in pairs(team.supports or {}) do
1286 1289 teamInfo.supports[slot] = {id, self.dinerData:getProperty("dishTree"):getv(id, 0)}
1287 1290 end
  1291 + teamInfo.tactics = globalCsv.tactics_skill_passive_cell[team.tactics] and team.tactics or nil
1288 1292 return teamInfo
1289 1293 end
1290 1294  
... ... @@ -1311,20 +1315,6 @@ function RolePlugin.bind(Role)
1311 1315 return self:getRealBattleValue(heros)
1312 1316 end
1313 1317  
1314   - -- 不传参数 只修改保存的阵容信息
1315   - function Role:saveHangTeam(team)
1316   - if not team then
1317   - team = self:getProperty("hangTeam")
1318   - else
1319   - self:updateProperty({field = "hangTeam", value = team})
1320   - end
1321   - self:setProperties({
1322   - hangTS = self:getTeamHerosInfo(team.heros),
1323   - hangTB = self:getTeamBattleInfo(team),
1324   - hangTBV = self:getTeamBattleValue(team.heros),
1325   - })
1326   - end
1327   -
1328 1318 function Role:updateHangTeamInfo()
1329 1319 local team = self:getTeamFormatByType(TeamSystemType.Hang)
1330 1320 if not team then return end
... ... @@ -1544,6 +1534,102 @@ function RolePlugin.bind(Role)
1544 1534 self:updateProperty({field = "redp", value = redp})
1545 1535 end
1546 1536  
  1537 + -- 获取充值订单号
  1538 + function Role:getPurchaseOrder(rechargeId)
  1539 + local roleId = self:getProperty("id")
  1540 + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
  1541 + if not rechargeData then
  1542 + skynet.error("recharge id not exist", rechargeId)
  1543 + return ""
  1544 + end
  1545 + local limit = rechargeData.limit
  1546 + local rechargeRecord = self:getProperty("payR") or {}
  1547 + if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then
  1548 + return ""
  1549 + end
  1550 +
  1551 + local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId)
  1552 + if orderId then
  1553 + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) })
  1554 + if orderObject:load() and orderObject:getProperty("rechargeId") == rechargeId and math.abs(skynet.timex() - orderObject:getProperty("createTime")) < 5 * 60 then
  1555 + return string.format("%d_%d_%d", serverId, roleId, orderId)
  1556 + end
  1557 + end
  1558 +
  1559 + orderId = redisproxy:hincrby("autoincrement_set", "order", 1)
  1560 + local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId)
  1561 + local orderKey = string.format(R_ORDER, roleId, orderId)
  1562 + redisproxy:del(orderKey) -- 删掉可能有了
  1563 + local order = require("models.Order").new({
  1564 + key = orderKey,
  1565 + order = partnerOrderId,
  1566 + rechargeId = rechargeId,
  1567 + })
  1568 + order:create()
  1569 + -- 正在进行中的订单 缓存
  1570 + redisproxy:hset(string.format(R_ORDERS, roleId), rechargeId, orderId)
  1571 + return partnerOrderId
  1572 + end
  1573 +
  1574 + -- 更新订单信息
  1575 + --[[
  1576 +
  1577 + status
  1578 +
  1579 + success
  1580 + fail
  1581 + finsh
  1582 + unknow
  1583 +
  1584 + --]]
  1585 + function Role:updatePurchaseOrder(partnerOrderStr, platformOrder, status)
  1586 + if not partnerOrderStr then return false end
  1587 + local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
  1588 +
  1589 + local roleId = self:getProperty("id")
  1590 + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) })
  1591 + if not orderObject:load() then
  1592 + return false
  1593 + end
  1594 +
  1595 + local rechargeId = orderObject:getProperty("rechargeId")
  1596 + local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
  1597 +
  1598 + if orderObject:getProperty("finishTime") > 0 then
  1599 + return false, "finsh"
  1600 + end
  1601 +
  1602 + if platformOrder then
  1603 + orderObject:setProperty("transactionId", platformOrder)
  1604 + end
  1605 + orderObject:setProperty("status", status)
  1606 +
  1607 + -- 开始下单
  1608 + if status == "success" then
  1609 + elseif status == "fail" then
  1610 + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId)
  1611 + elseif status == "finsh" then
  1612 + orderObject:setProperty("finishTime", skynet.time())
  1613 + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId)
  1614 + end
  1615 +
  1616 + if status ~= "unknow" then
  1617 + self:log("setOrder", {
  1618 + order_status = ({success = 100, finsh = 200, fail = 300})[status] or 1000, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
  1619 + item_id = rechargeId, -- 道具id
  1620 + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
  1621 + item_name = dataSet.title, -- 购买的道具名
  1622 + item_number = 1, -- 购买的道具数量
  1623 + item_level = 1, -- 购买的道具等级
  1624 + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
  1625 + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
  1626 + order_type = self:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0
  1627 + order_id = platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
  1628 + })
  1629 + end
  1630 +
  1631 + return true, rechargeId
  1632 + end
1547 1633  
1548 1634 -- 充值 --
1549 1635 --[[
... ... @@ -1558,63 +1644,37 @@ function RolePlugin.bind(Role)
1558 1644 local roleId = self:getProperty("id")
1559 1645 local partnerOrderStr = params.order
1560 1646  
1561   - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)")
1562   - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) })
1563   - if not orderObject:load() then
1564   - -- 订单不存在
1565   - skynet.error("ayncPurchaseRpc", string.format("order %s not exist", partnerOrderStr))
1566   - return
1567   - end
1568 1647  
1569   - if orderObject:getProperty("finishTime") > 0 then
1570   - -- 订单已经处理
1571   - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" }))
  1648 + local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh")
  1649 + if not status then
  1650 + if back == "finsh" then
  1651 + -- 订单已经处理
  1652 + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" }))
  1653 + end
1572 1654 return
1573 1655 end
1574   - local rechargeId = orderObject:getProperty("rechargeId")
  1656 + local rechargeId = back
1575 1657 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
1576 1658 if rechargeData.rmb ~= tonumber(params.amount) then
1577   - skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
  1659 + skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
1578 1660 params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount
1579 1661 ))
1580 1662 return
1581 1663 end
1582 1664  
1583   - local order_type = self:getProperty("rmbC") > 0 and 0 or 1
1584 1665 local status, reward = self:recharge({
1585 1666 id = rechargeId,
1586 1667 transactionId = params.transactionId,
1587 1668 pay_time = params.pay_time,
1588 1669 order = partnerOrderStr,
1589 1670 })
1590   - orderObject:setProperty("finishTime", skynet.time())
1591   - orderObject:setProperty("status", "finish")
1592   -
1593   - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr)
1594 1671  
1595 1672 if not status then
1596   - status = 200
1597   - else
1598   - status = 1000 + status
1599   - end
1600   - self:log("setOrder", {
1601   - order_status = status, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他"
1602   - item_id = rechargeId, -- 道具id
1603   - item_type = rechargeData.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表
1604   - item_name = rechargeData.title, -- 购买的道具名
1605   - item_number = 1, -- 购买的道具数量
1606   - item_level = 1, -- 购买的道具等级
1607   - order_cost = rechargeData.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee'
1608   - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范
1609   - order_type = order_type, -- 订单类型,首充记录为1,否则为0
1610   - order_id = params.transactionId, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no'
1611   - })
1612   - if status ~= 200 then return end
1613   -
1614   - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
1615   - result = "success", reward = reward}))
  1673 + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
  1674 + result = "success", reward = reward}))
  1675 + end
1616 1676  
1617   - return orderObject:getProperty("rechargeId")
  1677 + return rechargeId
1618 1678 end
1619 1679  
1620 1680  
... ... @@ -1622,7 +1682,7 @@ function RolePlugin.bind(Role)
1622 1682 local id = tonumber(params.id)
1623 1683 local rechargeData = csvdb["shop_rechargeCsv"][id]
1624 1684 if not rechargeData then
1625   - skynet.error("recharge id not exist", id)
  1685 + skynet.error("[recharge] recharge id not exist", id)
1626 1686 return 1
1627 1687 end
1628 1688  
... ... @@ -1647,7 +1707,7 @@ function RolePlugin.bind(Role)
1647 1707 elseif rechargeData.shop == 3 then -- 礼包商店
1648 1708 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
1649 1709 else
1650   - skynet.error("invalid recharge shop type " .. id)
  1710 + skynet.error("[recharge] invalid recharge shop type " .. id)
1651 1711 return 3
1652 1712 end
1653 1713  
... ...
src/models/RoleTask.lua
... ... @@ -33,7 +33,7 @@ local TaskType = {
33 33 HangQuick = 303, -- 快速挂机
34 34 HangBattle = 304, -- 挂机战斗 - id
35 35 HangGetGold = 305, -- 挂机获得齿轮 - count
36   - BonusPass = 306, -- 奖励副本通关 - id
  36 + BonusPass = 306, -- 奖励副本通关 - id count
37 37  
38 38 -- 冒险相关
39 39 AdvPass = 401, -- 冒险通过关 - id level score
... ... @@ -142,7 +142,7 @@ local CommonListener = {
142 142 [TaskType.GiveFriendP] = {{20, f("count")}},
143 143 [TaskType.UnionBoss] = {{21}},
144 144 [TaskType.GetFriendP] = {{22, f("count")}},
145   - [TaskType.BonusPass] = {{23}},
  145 + [TaskType.BonusPass] = {{23, f("count")}},
146 146 [TaskType.AdvStartSelf] = {{24}},
147 147 [TaskType.ShopAll] = {{25, f("count")}},
148 148 [TaskType.RuneUp] = {{26}},
... ... @@ -244,7 +244,7 @@ local CalendaTaskListener = {
244 244 func = "checkCalendaTask",
245 245 listen = {
246 246 [TaskType.DrawHero] = {{1, 1, f("count")}},
247   - [TaskType.BonusPass]= {{2, 1}},
  247 + [TaskType.BonusPass]= {{2, 1, f("count")}},
248 248 [TaskType.AdvStart]= {{3, 1}},
249 249 [TaskType.DinerLevelUp]= {{4, 2, f("level")}},
250 250 [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄
... ...
src/models/Store.lua
... ... @@ -226,7 +226,7 @@ end
226 226 function Store:checkRechargeRecord(limit, id)
227 227 local rechargeRecord = self:getProperty("payR") or {}
228 228 if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then
229   - skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
  229 + skynet.error(string.format("[recharge] recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id")))
230 230 return false
231 231 end
232 232 rechargeRecord[id] = (rechargeRecord[id] or 0) + 1
... ...