Commit 68ce7a2db86b6b1c5f051a7f3393a91def6416d0

Authored by zhouhaihai
2 parents 153e72e5 576c791c

Merge branch 'develop' into tr/ob

* develop: (41 commits)
  玛尼英雄帖活动通过任务bug 元旦挂机活动
  多队挂机70005报错 Bug
  合成道具数量不对bug
  元旦关卡活动
  不要穿装备的引导了
  拾荒bug  增加bug log
  考场没有 宝藏怪
  宝藏怪bug
  匹配规则调整
  效果发给客户端
  扭蛋机调试
  兑换活动重置,累充功能
  宝藏怪刷新,计数
  自己不清楚  格子
  passive 距离生效bug
  被动效果
  扭蛋活动,万能碎片bug
  全部有的怪都处理
  翻开格子 加1sp
  判断错误
  ...

# Conflicts:
#	config/nodenames.lua
src/GlobalVar.lua
  1 +BUG_LOG = false
  2 +
  3 +function buglog(tag, advstr, ...)
  4 + if BUG_LOG then
  5 + print(string.format("[%s] %s", tag, string.format(advstr, ...)))
  6 + end
  7 +end
  8 +
  9 +
1 10 XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18"
2 11 RESET_TIME = 4
3 12  
... ... @@ -214,6 +223,7 @@ AdvBackEventType = {
214 223 Level = 25, -- 升级
215 224 LinkChooseOver = 26, -- 连锁事件结束
216 225 BuffEffect = 27, -- buff 效果
  226 + PassiveEffect = 28, -- 被动 效果
217 227 }
218 228  
219 229 AdvScoreType = {
... ... @@ -304,6 +314,7 @@ MailId = {
304 314 ActDrawCardReward = 222,
305 315 ActAdvDrawReward = 223,
306 316 ActOpenBoxReward = 224,
  317 + ActItemRecycle = 225,
307 318  
308 319 PaySignAward = 241,
309 320 PayBackAward = 242,
... ...
src/ProtocolCode.lua
... ... @@ -50,6 +50,7 @@ actionCodes = {
50 50 Role_useSelectItemRpc = 134, -- 使用多选一礼包
51 51 Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄
52 52 Role_renameTeamRpc = 136, -- 编队改名
  53 + Role_accuseRpc = 137, -- 举报
53 54  
54 55 Adv_startAdvRpc = 151,
55 56 Adv_startHangRpc = 152,
... ... @@ -100,6 +101,7 @@ actionCodes = {
100 101 Hero_changeCrown = 223,
101 102 Hero_drawHeroExtraRewardNtf = 224,
102 103 Hero_itemComposeRpc = 225,
  104 + Hero_setWishPoolRpc = 226,
103 105  
104 106 Hang_startRpc = 251,
105 107 Hang_checkRpc = 252,
... ... @@ -202,6 +204,7 @@ actionCodes = {
202 204 Store_getGrowFundRewardRpc = 561, --成长助力奖励
203 205 Store_getBattlePassRewardRpc = 562, --赛季卡奖励
204 206 Store_getExploreCommandRewardRpc = 563, --探索指令
  207 + Store_getTotalRechargeAwardRpc = 564, -- 累计充值
205 208  
206 209  
207 210 Email_listRpc = 600,
... ... @@ -217,9 +220,17 @@ actionCodes = {
217 220 Activity_actPaySignRewardNtf = 654,
218 221 Activity_actCalendaTaskRpc = 655,
219 222 Activity_actPaySignRpc = 656,
  223 + Activity_exchangeRpc = 657,
  224 + Activity_gachakonRpc = 658,
  225 + Activity_hangDropRpc = 659,
  226 + Activity_startBattleRpc = 660,
  227 + Activity_endBattleRpc = 661,
  228 + Activity_battleRankRpc = 662,
  229 + Activity_battleMilestoneRpc = 663,
220 230  
221 231 Radio_startQuestRpc = 700,
222 232 Radio_finishQuestRpc = 701,
  233 + Radio_cancelQuestRpc = 702,
223 234 }
224 235  
225 236 rpcResponseBegin = 10000
... ...
src/RedisKeys.lua
... ... @@ -15,6 +15,11 @@ R_STORE = "role:%d:store" -- 商店
15 15 R_ORDERS = "role:%d:orders" -- 订单
16 16 R_ORDER = "order:%d:%d"
17 17  
  18 +-- 通用排行榜
  19 +RANK_COMMON = "rank:common:"
  20 +RANK_TYPE = {
  21 + ActBattleBoss = "act_battle_boss",
  22 +}
18 23  
19 24 -- rank
20 25 RANK_TOWER = "rank:tower"
... ...
src/actions/ActivityAction.lua
... ... @@ -263,4 +263,473 @@ function _M.actCalendaTaskRpc(agent, data)
263 263 return true
264 264 end
265 265  
  266 +function _M.exchangeRpc(agent, data)
  267 + local role = agent.role
  268 + local msg = MsgPack.unpack(data)
  269 + local actid = msg.actid
  270 + local id = msg.id
  271 + if not role.activity:isOpenById(actid) then return 1 end
  272 +
  273 + local exchangeCfg = csvdb["activity_exchangeCsv"][actid]
  274 + if not exchangeCfg then return 2 end
  275 + if not exchangeCfg[id] then return 3 end
  276 + local curData = role.activity:getActData("Exchange") or {}
  277 + local exchangeData = curData[actid] or {}
  278 + local curCount = exchangeData[id] or 0
  279 + local actCfg = exchangeCfg[id]
  280 + local limitArr = actCfg.limit:toArray(true, "=")
  281 + if curCount >= limitArr[2] then return 4 end
  282 +
  283 + local costs = actCfg.goods:toNumMap()
  284 + if not role:checkItemEnough(costs) then return 5 end
  285 + role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}})
  286 +
  287 + curCount = curCount + 1
  288 + exchangeData[id] = curCount
  289 + curData[actid] = exchangeData
  290 + role.activity:updateActData("Exchange", curData)
  291 +
  292 + local reward, change = role:award(actCfg.award, {log = {desc = "actExchange", int1 = actid, int2 = id}})
  293 +
  294 +
  295 + SendPacket(actionCodes.Activity_exchangeRpc, MsgPack.pack(role:packReward(reward, change)))
  296 + return true
  297 +end
  298 +
  299 +function _M.gachakonRpc(agent, data)
  300 + local role = agent.role
  301 + local msg = MsgPack.unpack(data)
  302 + local actid = msg.actid
  303 + local count = msg.count
  304 +
  305 + if count > 10 then return end
  306 +
  307 + if not role.activity:isOpenById(actid) then return 1 end
  308 +
  309 + local actCtrlData = csvdb["activity_ctrlCsv"][actid]
  310 + if not actCtrlData then return 2 end
  311 + local cost = actCtrlData.condition2:toNumMap()
  312 +
  313 + local actCfg = csvdb["activity_capsuleToysCsv"][actid]
  314 + if not actCfg then return 3 end
  315 +
  316 + local gachakonInfo = role.activity:getActData("Gachakon") or {}
  317 + local award = {}
  318 + local remain = 0
  319 + for i = 1, count do
  320 + local tmpCfg = clone(actCfg)
  321 + remain = 0
  322 + for id, cfg in pairs(tmpCfg) do
  323 + local num = gachakonInfo[id] or 0
  324 + num = cfg.amount >= num and cfg.amount - num or 0
  325 + cfg.weight = cfg.weight * num
  326 + if cfg.weight > 0 then
  327 + remain = remain + num
  328 + end
  329 + --print("num ".. num, id, cfg.weight, cfg.amount)
  330 + end
  331 + if remain == 0 then
  332 + break
  333 + end
  334 + local id = math.randWeight(tmpCfg, "weight")
  335 + if not id then return 4 end
  336 + gachakonInfo[id] = (gachakonInfo[id] or 0) + 1
  337 + local curAward = tmpCfg[id].award:toNumMap()
  338 + for k, v in pairs(curAward) do
  339 + award[k] = (award[k] or 0) + v
  340 + end
  341 + end
  342 +
  343 + for k, v in pairs(cost) do
  344 + cost[k] = v * count
  345 + end
  346 +
  347 + if not role:checkItemEnough(cost) then return 5 end
  348 +
  349 + role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}})
  350 +
  351 + local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}})
  352 + --print("-----------", remain, count)
  353 + if remain <= 1 then
  354 + gachakonInfo = {}
  355 + end
  356 + role.activity:updateActData("Gachakon", gachakonInfo)
  357 +
  358 + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change)))
  359 + return true
  360 +end
  361 +
  362 +function _M.hangDropRpc(agent, data)
  363 + local role = agent.role
  364 + local msg = MsgPack.unpack(data)
  365 + local actid = msg.actid
  366 + if not role.activity:isOpenById(actid) then return 1 end
  367 +
  368 + local actCfg = csvdb["activity_putCsv"][actid]
  369 + if not actCfg then return 2 end
  370 +
  371 + local award, period = "", 0
  372 + for i = 1, #actCfg do
  373 + local cfg = actCfg[i]
  374 + if not cfg then
  375 + break
  376 + end
  377 + if cfg.condition ~= "" then
  378 + local arr = cfg.condition:toArray(true, "=")
  379 + local type = arr[1]
  380 + if type == 1 then
  381 + local actId = arr[2]
  382 + local carbonId = arr[3]
  383 + if not role.activity:isOpenById(actid) then return 3 end
  384 + local clInfo = role.activity:getActData("ChallengeLevel") or {}
  385 + if not clInfo[carbonId] then
  386 + break
  387 + end
  388 + end
  389 + end
  390 + award = cfg.reward
  391 + period = cfg.period * 60
  392 + end
  393 + local actData = role.activity:getActData("HangDrop") or 0
  394 + local timeNow = skynet.timex()
  395 + if period == 0 or award == "" then
  396 + return 4
  397 + end
  398 + local num = math.floor((timeNow - actData)/ period)
  399 + num = num > 8 and 8 or num
  400 + if num == 0 then
  401 + return 5
  402 + end
  403 + local reward, change = {}, nil
  404 + for id, value in pairs(award:toNumMap()) do
  405 + reward[id] = value * num
  406 + end
  407 +
  408 + reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}})
  409 +
  410 + if num < 8 then
  411 + actData = actData + num * period
  412 + else
  413 + actData = timeNow
  414 + end
  415 +
  416 + role.activity:updateActData("HangDrop", actData)
  417 +
  418 + SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change)))
  419 +
  420 + return true
  421 +end
  422 +
  423 +local function getStarCount(cfg, data)
  424 + local count = 0
  425 + for i = 0, #(cfg.sweep_condition:toTableArray(true)) do
  426 + if (1 << i & data) > 0 then
  427 + count = count + 1
  428 + end
  429 + end
  430 +
  431 + return count
  432 +end
  433 +
  434 +function _M.startBattleRpc(agent, data)
  435 + local role = agent.role
  436 + local msg = MsgPack.unpack(data)
  437 + local actid = msg.actid
  438 + local id = msg.id
  439 + local count = msg.count
  440 + if not role.activity:isOpenById(actid) then return 1 end
  441 +
  442 + local actCfg = csvdb["activity_battleCsv"][actid]
  443 + if not actCfg then return 2 end
  444 +
  445 + local battleCfg = actCfg[id]
  446 + if not battleCfg then return 3 end
  447 +
  448 + local actData = role.activity:getActData("ChallengeLevel") or {}
  449 +
  450 + local preArr = battleCfg.prepose:toArray(true, "=")
  451 + for _, v in ipairs(preArr) do
  452 + local battleInfo = actData[v]
  453 + if not battleInfo then
  454 + return 4
  455 + end
  456 + local star = battleInfo["star"] or 0
  457 + if star <= 0 then
  458 + return 4
  459 + end
  460 + end
  461 + -- check cost
  462 + local changeFlag = false
  463 + local ticket = actData["ticket"]
  464 + if battleCfg.type ~= "" then
  465 + role.activity:getBattleTicket(actid)
  466 + local num = battleCfg.type:toArray(true, "=")[3]
  467 + if count and count > 0 then
  468 + if battleCfg.rank == 0 then
  469 + return 7
  470 + end
  471 + local bi = actData[id]
  472 + if not bi then return 8 end
  473 + local star = bi["star"] or 0
  474 + if star < 1 then
  475 + return 9
  476 + end
  477 + num = num * count
  478 + end
  479 + if ticket < num then
  480 + return 6
  481 + end
  482 + actData["ticket"] = ticket - num
  483 + changeFlag = true
  484 + end
  485 +
  486 + if not count then
  487 + role.__actBattleCache = {
  488 + key = tostring(math.random()),
  489 + actid = actid,
  490 + id = id,
  491 + }
  492 + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack({key = role.__actBattleCache.key}))
  493 + else
  494 + if count <= 0 then
  495 + return
  496 + end
  497 + if battleCfg.rank == 0 then
  498 + return 7
  499 + end
  500 + local bi = actData[id]
  501 + local star = bi["star"]
  502 + local award = battleCfg.item_clear:toNumMap()
  503 + if getStarCount(battleCfg, star) == 3 then
  504 + local aw = battleCfg.perfect_reward:toNumMap()
  505 + for k, v in pairs(aw) do
  506 + award[k] = (award[k] or 0) + v
  507 + end
  508 + end
  509 + for k, v in pairs(award) do
  510 + award[k] = v * count
  511 + end
  512 + local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}})
  513 + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change)))
  514 +
  515 + bi["sum"] = bi["sum"] + bi["top"]
  516 + actData[id] = bi
  517 + changeFlag = true
  518 +
  519 + local rankVal = 0
  520 + if battleCfg.rank == 1 then
  521 + rankVal = bi["sum"]
  522 + elseif battleCfg.rank == 2 then
  523 + rankVal = bi["top"]
  524 + end
  525 + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal)
  526 + end
  527 + if changeFlag then
  528 + role.activity:updateActData("ChallengeLevel", actData)
  529 + end
  530 +
  531 + return true
  532 +end
  533 +
  534 +function _M.endBattleRpc(agent, data)
  535 + local role = agent.role
  536 + local msg = MsgPack.unpack(data)
  537 + local actid = msg.actid
  538 + local id = msg.id
  539 + local key = msg.key
  540 + local isWin = msg.isWin
  541 + local heros = msg.heros
  542 + local support = msg.support
  543 + if not role.activity:isOpenById(actid) then return 1 end
  544 +
  545 + if not role.__actBattleCache then return 2 end
  546 +
  547 + if role.__actBattleCache.id ~= id or role.__actBattleCache.key ~= key and role.__actBattleCache.actid ~= actid then
  548 + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({errorCode = 1}))
  549 + end
  550 +
  551 + local actCfg = csvdb["activity_battleCsv"][actid]
  552 + if not actCfg then return 3 end
  553 +
  554 + local battleCfg = actCfg[id]
  555 + if not battleCfg then return 4 end
  556 +
  557 + local actData = role.activity:getActData("ChallengeLevel") or {}
  558 +
  559 + local reward, change = {}, nil
  560 +
  561 + local battleInfo = actData[id] or {}
  562 + local curStar = 0
  563 + if isWin then
  564 + local herosInfo = msg.heros
  565 +
  566 + local check = {}
  567 + -- 1 通关
  568 + check[1] = function(_)
  569 + return true
  570 + end
  571 + -- 2 阵亡人数 <= N
  572 + check[2] = function(_, cond)
  573 + return msg.info.dead and msg.info.dead <= cond
  574 + end
  575 + -- 3 全员存活
  576 + check[3] = function(_)
  577 + return msg.info.dead and msg.info.dead == 0
  578 + end
  579 + -- 4 指定种族 >= N
  580 + check[4] = function(_, cond)
  581 + local count = 0
  582 + for _, one in pairs(herosInfo) do
  583 + local heroData = csvdb["unitCsv"][one.type]
  584 + if heroData.camp == cond then
  585 + count = count + 1
  586 + end
  587 + end
  588 + return count >= cond
  589 + end
  590 + -- 5 指定职业 >= N
  591 + check[5] = function(_, cond)
  592 + local count = 0
  593 + for _, one in pairs(herosInfo) do
  594 + local heroData = csvdb["unitCsv"][one.type]
  595 + if heroData.job == cond then
  596 + count = count + 1
  597 + end
  598 + end
  599 + return count >= cond
  600 + end
  601 + -- 6 含有指定角色
  602 + check[6] = function(_, cond)
  603 + for _, one in pairs(herosInfo) do
  604 + if one.type == cond then
  605 + return true
  606 + end
  607 + end
  608 + return false
  609 + end
  610 + -- 7 通关耗时 <= X 秒 msg.info.atime
  611 + check[7] = function(_, cond)
  612 + return msg.info.atime and msg.info.atime <= cond
  613 + end
  614 + curStar = 0
  615 + local sweepConds = battleCfg.sweep_condition:toTableArray(true)
  616 + for i, cond in ipairs(sweepConds) do
  617 + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
  618 + curStar = curStar + (1 << (i - 1))
  619 + end
  620 + end
  621 + else
  622 + curStar = 0
  623 + end
  624 + local oldStarNum = getStarCount(battleCfg, battleInfo["star"] or 0)
  625 + local newStarNum = getStarCount(battleCfg, curStar)
  626 + if newStarNum > oldStarNum then
  627 + battleInfo["star"] = curStar
  628 + end
  629 +
  630 + if battleCfg.rank ~= 0 then
  631 + -- 更新排行榜 最高伤害
  632 + local dmg = 0
  633 + for k, v in pairs(msg.info.damage) do
  634 + if k % 100 == 2 then
  635 + dmg = dmg + v
  636 + end
  637 + end
  638 + battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg)
  639 + battleInfo["sum"] = (battleInfo["sum"] or 0) + dmg
  640 + local rankVal = 0
  641 + if battleCfg.rank == 1 then
  642 + rankVal = battleInfo["sum"]
  643 + elseif battleCfg.rank == 2 then
  644 + rankVal = battleInfo["top"]
  645 + end
  646 + if rankVal > 0 then
  647 + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal)
  648 + end
  649 + end
  650 + actData[id] = battleInfo
  651 + role.activity:updateActData("ChallengeLevel", actData)
  652 +
  653 + if oldStarNum == 0 or battleCfg.rank ~= 0 then
  654 + reward = battleCfg.item_clear:toNumMap()
  655 + end
  656 + if (oldStarNum < 3 and newStarNum == 3) or battleCfg.rank ~= 0 then
  657 + local aw = battleCfg.perfect_reward:toNumMap()
  658 + for k, v in pairs(aw) do
  659 + reward[k] = (reward[k] or 0) + v
  660 + end
  661 + end
  662 +
  663 + role:checkBattle("act_battle", {
  664 + cfg = battleCfg,
  665 + star = newStarNum,
  666 + isWin = isWin,
  667 + info = msg.info,
  668 + reward = reward,
  669 + heros = heros,
  670 + supports = support,
  671 + })
  672 +
  673 + reward, change = role:award(reward, {log = {desc = "actBattle", int1 = actid, int2 = newStarNum}})
  674 +
  675 + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({
  676 + reward = reward,
  677 + change = change
  678 + }))
  679 +
  680 + return true
  681 +end
  682 +
  683 +function _M.battleRankRpc(agent, data)
  684 + local role = agent.role
  685 + local msg = MsgPack.unpack(data)
  686 + local actid = msg.actid
  687 + if not role.activity:isOpenById(actid) then return 1 end
  688 +
  689 + local rankInfo = role:getRankInfoCommon(RANK_TYPE.ActBattleBoss)
  690 +
  691 + SendPacket(actionCodes.Activity_battleRankRpc, MsgPack.pack(rankInfo))
  692 + return true
  693 +end
  694 +
  695 +function _M.battleMilestoneRpc(agent, data)
  696 + local role = agent.role
  697 + local msg = MsgPack.unpack(data)
  698 + local actid = msg.actid
  699 + local id = msg.id
  700 + local index = msg.index
  701 +
  702 + if not role.activity:isOpenById(actid) then return 1 end
  703 +
  704 + local actCfg = csvdb["activity_mileageCsv"][actid]
  705 + if not actCfg then return 3 end
  706 +
  707 + local mileCfg = actCfg[index]
  708 + if not mileCfg then return 4 end
  709 +
  710 + local actData = role.activity:getActData("ChallengeLevel") or {}
  711 + local battleInfo = actData[id] or {}
  712 + local val = 0
  713 + if mileCfg.type == 1 then
  714 + val = battleInfo["sum"] or 0
  715 + elseif mileCfg.type == 2 then
  716 + val = battleInfo["top"] or 0
  717 + end
  718 +
  719 + local record = battleInfo["r"] or ""
  720 + local flag = string.char(string.getbit(record, index))
  721 + if flag == "1" then return 5 end
  722 + if mileCfg.condition > val then return 6 end
  723 +
  724 + battleInfo["r"] = string.setbit(record, index)
  725 + actData[id] = battleInfo
  726 + role.activity:updateActData("ChallengeLevel", actData)
  727 +
  728 + local award = mileCfg.reward:toNumMap()
  729 + local reward, change = role:award(award, {log = {desc = "actMilestone", int1 = actid, int2 = index}})
  730 + SendPacket(actionCodes.Activity_battleMilestoneRpc, MsgPack.pack(role:packReward(reward, change)))
  731 +
  732 + return true
  733 +end
  734 +
266 735 return _M
267 736 \ No newline at end of file
... ...
src/actions/AdvAction.lua
... ... @@ -746,7 +746,7 @@ function _M.endBattleRpc(agent, data)
746 746 end
747 747 end
748 748 adv:mylog({desc = "endBattle"})
749   - local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill})
  749 + local status = adv:clickBlock(roomId, blockId, {player = player, enemy = msg.enemy, bySkill = bySkill})
750 750  
751 751 if not status then return end
752 752 SendPacket(actionCodes.Adv_endBattleRpc, MsgPack.pack({events = adv:popBackEvents()}))
... ...
src/actions/EmailAction.lua
... ... @@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data)
121 121 local attachments = getEmailAttachments(email)
122 122 if attachments == "" then return end
123 123  
124   - local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId}})
  124 + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}})
125 125 email:setProperty("status", 2)
126 126 email:log(role, 2)
127 127 SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change}))
... ...
src/actions/GmAction.lua
... ... @@ -533,7 +533,9 @@ function _M.test(role, pms)
533 533 local id = tonum(pms.pm1, 0)
534 534 --local hero = require ("actions.HeroAction")
535 535 --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id}))
536   - print(role:getPaybackReward(0, 10000))
  536 +
  537 + --role:sendMail(13, nil, "1=2", {111})
  538 + dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES"))
537 539 return "成功"
538 540 end
539 541  
... ...
src/actions/HangAction.lua
... ... @@ -632,7 +632,7 @@ function _M.endBonusBattleRpc(agent, data)
632 632 check[4] = function(_, cond)
633 633 local count = 0
634 634 for _, one in pairs(herosInfo) do
635   - local heroData = csv["unitCsv"][one.type]
  635 + local heroData = csvdb["unitCsv"][one.type]
636 636 if heroData.camp == cond then
637 637 count = count + 1
638 638 end
... ... @@ -643,7 +643,7 @@ function _M.endBonusBattleRpc(agent, data)
643 643 check[5] = function(_, cond)
644 644 local count = 0
645 645 for _, one in pairs(herosInfo) do
646   - local heroData = csv["unitCsv"][one.type]
  646 + local heroData = csvdb["unitCsv"][one.type]
647 647 if heroData.job == cond then
648 648 count = count + 1
649 649 end
... ...
src/actions/HeroAction.lua
... ... @@ -477,8 +477,6 @@ function _M.referEquipsRpc(agent, data)
477 477 -- 更新角色
478 478 hero:updateProperty({field = "equip", value = curEquip})
479 479  
480   - role:finishGuide(23)
481   -
482 480 local curAttr = hero:getTotalAttrs()
483 481 local attrChange = getChangeAttrJson(oldAttr, curAttr)
484 482 for typ, data in pairs(wear) do
... ... @@ -585,16 +583,16 @@ function _M.createHeroRandomRpc(agent, data)
585 583 local itemData = csvdb["itemCsv"][itemId]
586 584 if not itemData or itemData.type ~= ItemType.HeroFCommon then return end
587 585 local cost = globalCsv.unit_fragment_cost[itemData.quality]
588   - if not cost or role:getItemCount(itemId) < cost then return end
  586 + if not cost or role:getItemCount(itemId) < cost then return 1 end
589 587  
590 588 local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)]
591   - if not randomData then return end
  589 + if not randomData then return 2 end
592 590  
593 591 local temp = randomData.gift1:randWeight(true)
594   - if not temp or not next(temp) then return end
  592 + if not temp or not next(temp) then return 3 end
595 593  
596 594 role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}})
597   - local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}})
  595 + local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}})
598 596  
599 597  
600 598 SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change)))
... ... @@ -604,7 +602,6 @@ end
604 602 function _M.getResetRewardRpc(agent, data)
605 603 local role = agent.role
606 604 local msg = MsgPack.unpack(data)
607   - local pay = msg.pay
608 605  
609 606 local hero = role.heros[msg.id]
610 607 if not hero then return end
... ... @@ -617,12 +614,30 @@ function _M.getResetRewardRpc(agent, data)
617 614 local tmpLevel = level
618 615 if level <= 1 and talent == "" then return end
619 616  
  617 + local pay = true
620 618 if level <= 60 then
621 619 pay = false
622 620 end
623 621  
624   - if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then
625   - return 1
  622 + if pay then
  623 + local costArr = globalCsv.unit_heroBack_cost:toArray(true, "=")
  624 + local itemCount = role:getItemCount(costArr[1])
  625 + local totalCost = {}
  626 + if itemCount >= costArr[2] then
  627 + totalCost[costArr[1]] = costArr[2]
  628 + else
  629 + local diamond = (costArr[2] - itemCount) * costArr[3]
  630 + if role:getItemCount(ItemId.Diamond) < diamond then
  631 + return 1
  632 + end
  633 + totalCost[costArr[1]] = itemCount
  634 + totalCost[ItemId.Diamond] = diamond
  635 + end
  636 +
  637 + --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then
  638 + -- return 1
  639 + --end
  640 + role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}})
626 641 end
627 642  
628 643 local reward = {}
... ... @@ -677,10 +692,10 @@ function _M.getResetRewardRpc(agent, data)
677 692 })
678 693 hero:mylog({desc = "resetHero"})
679 694  
680   - local coef = globalCsv.unit_back_discount
681   - coef = (pay or tmpLevel <= 60) and 1 or coef
  695 + --local coef = globalCsv.unit_back_discount
  696 + --coef = (pay or tmpLevel <= 60) and 1 or coef
682 697 for itemId, count in pairs(reward) do
683   - reward[itemId] = math.floor(count * coef)
  698 + reward[itemId] = count
684 699 end
685 700 local change
686 701 reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
... ... @@ -699,11 +714,14 @@ function _M.drawHeroRpc(agent, data)
699 714 local msg = MsgPack.unpack(data)
700 715  
701 716 if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end
702   - local btype = msg.pool -- 1 2 3 卡池类型
  717 + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池
703 718 local subType = msg.subType or 1-- 定向卡池需要传 子类型
704 719 local drawType = msg.type -- 1 单抽 2 十连
705 720 if btype ~= 1 then
706 721 subType = 1
  722 + if btype == 4 and role:getProperty("newerDraw") >= 10 then
  723 + subType = 2
  724 + end
707 725 end
708 726  
709 727 if btype == 1 then
... ... @@ -724,23 +742,32 @@ function _M.drawHeroRpc(agent, data)
724 742  
725 743 -- 计算抽卡消耗品
726 744 local cost = {}
727   - local lastCount = drawCount[drawType]
728   - for _, costType in ipairs({"draw_card", "draw_coin"}) do
  745 + if buildTypeData["draw_coin_1"] == "" then
  746 + return 11
  747 + end
  748 + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=")
  749 +
  750 + local isEnough = true
  751 + for _, costType in ipairs({"draw_card_"}) do
  752 + costType = costType..drawCount[drawType]
729 753 if buildTypeData[costType] ~= "" then
730 754 local curCost = buildTypeData[costType]:toArray(true, "=")
731 755 local hadCount = role:getItemCount(curCost[1])
732   - local curCount = math.floor(hadCount / curCost[2])
733   - if curCount >= lastCount then
734   - cost[curCost[1]] = curCost[2] * lastCount
735   - lastCount = 0
  756 + if hadCount >= curCost[2] then
  757 + cost[curCost[1]] = curCost[2]
736 758 break
737   - elseif curCount > 0 then
738   - cost[curCost[1]] = curCost[2] * curCount
739   - lastCount = lastCount - curCount
  759 + else
  760 + cost[curCost[1]] = hadCount
  761 + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2]
  762 + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then
  763 + isEnough = false
  764 + break
  765 + end
  766 + cost[diamondCost[1]] = diamondCost[2]
740 767 end
741 768 end
742 769 end
743   - if lastCount > 0 then -- 钱不够
  770 + if isEnough == false then -- 钱不够
744 771 return 4
745 772 end
746 773  
... ... @@ -803,6 +830,9 @@ function _M.drawHeroRpc(agent, data)
803 830 --print(poolId, rand_v, weight, up_pool, values[1])
804 831 if rand_v < weight and up_pool then
805 832 up_pool = up_pool:toArray(true, "=")
  833 + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子
  834 + up_pool = role:getProperty("wishPool")
  835 + end
806 836 for k, v in ipairs(up_pool) do
807 837 resultPool[v] = {1}
808 838 end
... ... @@ -868,8 +898,14 @@ function _M.drawHeroRpc(agent, data)
868 898 end
869 899 end
870 900  
871   - if itemData.quality >= HeroQuality.SR then
872   - floorHeroCount = 0
  901 + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池
  902 + if itemData.quality == HeroQuality.SSR then
  903 + floorHeroCount = 0
  904 + end
  905 + else
  906 + if itemData.quality >= HeroQuality.SR then
  907 + floorHeroCount = 0
  908 + end
873 909 end
874 910  
875 911 if role:isHaveHero(itemData.id - ItemStartId.Hero) then
... ... @@ -892,6 +928,11 @@ function _M.drawHeroRpc(agent, data)
892 928 role:setProperty("floorHero", floorHero)
893 929 end
894 930  
  931 + if btype == 4 then
  932 + local newCount = role:getProperty("newerDraw")
  933 + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]})
  934 + end
  935 +
895 936 role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
896 937 if ssrCount > 0 then
897 938 role:checkTaskEnter("DrawSSR", {count = ssrCount})
... ... @@ -1049,6 +1090,9 @@ function _M.itemComposeRpc(agent, data)
1049 1090 if not config then return 2 end
1050 1091  
1051 1092 local cost = config.cost:toNumMap()
  1093 + for k, v in pairs(cost) do
  1094 + cost[k] = v * count
  1095 + end
1052 1096 if not role:checkItemEnough(cost) then return 2 end
1053 1097 role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}})
1054 1098 role:award({[itemId] = count}, {log = {desc = "itemCompose"}})
... ... @@ -1057,4 +1101,32 @@ function _M.itemComposeRpc(agent, data)
1057 1101 return true
1058 1102 end
1059 1103  
  1104 +function _M.setWishPoolRpc(agent, data)
  1105 + local role = agent.role
  1106 + local msg = MsgPack.unpack(data)
  1107 +
  1108 + local heros = msg.heros
  1109 + if #heros > 3 then return 1 end
  1110 +
  1111 + for _, heroId in pairs(heros) do
  1112 + local cfg = csvdb["build_poolCsv"][heroId]
  1113 + if not cfg then return 2 end
  1114 +
  1115 + local buildTypeData = csvdb["build_typeCsv"][5]
  1116 + if not buildTypeData then return 3 end
  1117 + local poolMap = buildTypeData["pool"]:toNumMap()
  1118 + local poolId = poolMap[1]
  1119 + if not poolId then return 4 end
  1120 +
  1121 + if cfg["pool_"..poolId] == 0 then
  1122 + return 5
  1123 + end
  1124 + end
  1125 +
  1126 + role:updateProperty({field="wishPool", value = heros})
  1127 +
  1128 + SendPacket(actionCodes.Hero_setWishPoolRpc, "")
  1129 + return true
  1130 +end
  1131 +
1060 1132 return _M
... ...
src/actions/PvpAction.lua
... ... @@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔
23 23 local RevengeWaitTime = 60
24 24  
25 25 function _M.formatCommonRpc(agent , data)
  26 + if true then return end
26 27 local role = agent.role
27 28 local roleId = role:getProperty("id")
28 29 local msg = MsgPack.unpack(data)
... ... @@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data)
63 64 local role = agent.role
64 65 local roleId = role:getProperty("id")
65 66 local msg = MsgPack.unpack(data)
66   -
  67 +
  68 + if not role:isCrossServerPvpPlayer() then return end
67 69 local pvpTH = {}
68 70 local had = {} -- 上阵的角色
69 71 local supportHad = {}
... ... @@ -169,7 +171,7 @@ function _M.infoRpc(agent, data)
169 171  
170 172 local pvpMC = role:getProperty("pvpMC")
171 173 if not next(pvpMC) then --没有分配过对手
172   - role:refreshPvpMatchC(score)
  174 + role:refreshPvpMatchC(score, -1)
173 175 pvpMC = role:getProperty("pvpMC")
174 176 end
175 177 if not next(pvpMC) then return end
... ... @@ -189,7 +191,7 @@ function _M.infoRpc(agent, data)
189 191  
190 192 local pvpMH = role:getProperty("pvpMH")
191 193 if not next(pvpMH) then --没有分配过对手
192   - role:refreshPvpMatchH(score)
  194 + role:refreshPvpMatchH(score, -1)
193 195 pvpMH = role:getProperty("pvpMH")
194 196 end
195 197 if not next(pvpMH) then return end
... ... @@ -255,8 +257,38 @@ function _M.startBattleRpc(agent, data)
255 257 local idx = msg.idx
256 258 local revenge = msg.revenge
257 259  
258   - local pvpTC = role:getProperty("pvpTC")
259   - if not pvpTC.heros or not next(pvpTC.heros) then return 1 end
  260 + -- local pvpTC = role:getProperty("pvpTC")
  261 + -- if not pvpTC.heros or not next(pvpTC.heros) then return 1 end
  262 +
  263 + local team = msg.team
  264 + if not team then return end
  265 +
  266 + for slot, heroId in pairs(team.heros or {}) do
  267 + if not role.heros[heroId] then
  268 + return
  269 + end
  270 + end
  271 + if not team.heros or not next(team.heros) then
  272 + return
  273 + end
  274 + local supports = {}
  275 + for slot, support in pairs(team.supports) do
  276 + if slot ~= 1 and slot ~= 2 then return end
  277 + local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
  278 + if level <= 0 then return end
  279 + supports[slot] = support
  280 + end
  281 +
  282 + local pvpTC = {}
  283 + pvpTC.heros = {}
  284 + for slot, heroId in pairs(team.heros) do
  285 + pvpTC.heros[slot] = heroId
  286 + end
  287 + pvpTC.leader = team.leader
  288 + pvpTC.supports = supports
  289 + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then
  290 + pvpTC.tactics = team.tactics
  291 + end
260 292  
261 293 local matchInfo, result, key, wait
262 294  
... ... @@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data)
299 331 end
300 332  
301 333 key = tostring(math.random())
302   - _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge}
  334 + _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge, pvpTC = pvpTC}
303 335  
304 336 role:checkTaskEnter("PvpBattle")
305 337  
... ... @@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data)
342 374  
343 375 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true)
344 376 local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}})
345   - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin)
  377 + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1
  378 + -- 失败了没再排行榜 不计入
  379 + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_COMMON)) then
  380 + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank= role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin)
  381 + end
  382 + if isWin then
  383 + -- 记录编队
  384 + role:savePvpCTeam(_pvpStartBattleCacheC.pvpTC)
  385 + end
346 386  
347 387 -- 请求上传录像
348 388 local params = {
... ... @@ -433,8 +473,8 @@ function _M.startBattleHRpc(agent, data)
433 473 local revenge = msg.revenge
434 474 if not role:isTimeResetOpen(TimeReset.PvpHight) then return end
435 475  
436   - local pvpTH = role:getProperty("pvpTH")
437   - if not next(pvpTH) then return 1 end
  476 + -- local pvpTH = role:getProperty("pvpTH")
  477 + -- if not next(pvpTH) then return 1 end
438 478  
439 479 -- 检查并记录玩家队伍
440 480 local pvpTH = {}
... ... @@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data)
472 512 curTeam.tactics = team.tactics
473 513 end
474 514  
475   -
476 515 table.insert(pvpTH, curTeam)
477 516 end
478 517  
... ... @@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data)
644 683 -- 战斗结束了发奖
645 684 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true)
646 685 local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}})
647   - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0
648   - if role:isTimeResetOpen(TimeReset.PvpHight) then
649   - myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin)
  686 +
  687 +
  688 + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1
  689 + -- 失败了没再排行榜 不计入
  690 + if role:isTimeResetOpen(TimeReset.PvpHight) then
  691 + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_HIGHT)) then
  692 + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin)
  693 + end
  694 + -- 记录编队
  695 + if isWin then
  696 + role:savePvpHTeam(_pvpStartBattleCacheH.pvpTH)
  697 + end
650 698 end
651 699  
652 700 -- 加入战斗记录
... ... @@ -735,6 +783,7 @@ function _M.endBattleHRpc(agent, data)
735 783 myRank = myRank,
736 784 oldMyRank = oldMyRank,
737 785 video = video,
  786 + headers = headers,
738 787 isWin = isWin,
739 788 }))
740 789 return true
... ...
src/actions/RadioAction.lua
... ... @@ -69,7 +69,7 @@ function _M.startQuestRpc(agent, data)
69 69 needHeroCnt = it[2]
70 70 end
71 71 end
72   - for _, heroId in ipairs(heros) do
  72 + for _, heroId in pairs(heros) do
73 73 local hero = role.heros[heroId]
74 74 if hero then
75 75 needHeroCnt = needHeroCnt - 1
... ... @@ -122,7 +122,7 @@ function _M.finishQuestRpc(agent, data)
122 122 -- get heros
123 123 local totalCoef = 0
124 124 local exp = config.time / 60
125   - heroFaithMap = {}
  125 + local heroFaithMap = {}
126 126 for _, heroId in ipairs(task.heros) do
127 127 local hero = role.heros[heroId]
128 128 if hero then
... ... @@ -162,4 +162,20 @@ function _M.finishQuestRpc(agent, data)
162 162 return true
163 163 end
164 164  
  165 +function _M.cancelQuestRpc(agent, data)
  166 + local role = agent.role
  167 + local msg = MsgPack.unpack(data)
  168 + local id = msg.id
  169 + -- check finish time
  170 + local radioTask = role:getProperty("radioTask")
  171 + local task = radioTask[id]
  172 + if not task then return 1 end
  173 + if skynet.timex() > task.time then return 2 end
  174 + radioTask[id] = nil
  175 + role:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  176 +
  177 + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id}))
  178 + return true
  179 +end
  180 +
165 181 return _M
166 182 \ No newline at end of file
... ...
src/actions/RoleAction.lua
... ... @@ -1279,4 +1279,16 @@ function _M.renameTeamRpc(agent, data)
1279 1279 return true
1280 1280 end
1281 1281  
  1282 +function _M.accuseRpc(agent, data)
  1283 + local role = agent.role
  1284 + local msg = MsgPack.unpack(data)
  1285 + local targetId = msg.targetId
  1286 + local atype = msg.type
  1287 + local note = msg.note
  1288 +
  1289 + role:mylog("role_action", {desc = "accuse", int1 = targetId, short1 = atype, text1 = note})
  1290 + SendPacket(actionCodes.Role_accuseRpc, "")
  1291 + return true
  1292 +end
  1293 +
1282 1294 return _M
1283 1295 \ No newline at end of file
... ...
src/actions/StoreAction.lua
... ... @@ -396,4 +396,30 @@ function _M.getExploreCommandRewardRpc(agent, data)
396 396 return true
397 397 end
398 398  
  399 +-- 累充奖励
  400 +function _M.getTotalRechargeAwardRpc(agent, data)
  401 + local role = agent.role
  402 + local msg = MsgPack.unpack(data)
  403 + local index = msg.index -- 领取的索引id
  404 + local totalTwd = role:getProperty("twdC")
  405 + local totalRechargeRecord = role.storeData:getProperty("totalRR")
  406 + local flag = string.char(string.getbit(totalRechargeRecord, index))
  407 + if flag == "1" then return 1 end
  408 + local cfg = csvdb["activity_payRebateCsv"][index]
  409 + if not cfg then return 2 end
  410 + if cfg.twd > totalTwd then return 3 end
  411 +
  412 + totalRechargeRecord = string.setbit(totalRechargeRecord, index)
  413 + role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord})
  414 + local main = cfg.main_reward:toNumMap()
  415 + local sub = cfg.sub_reward:toNumMap()
  416 + for k, v in pairs(sub) do
  417 + main[k] = (main[k] or 0) + v
  418 + end
  419 +
  420 + local reward, change = role:award(main, {log = {desc = "totalRecharge", int1 = index}})
  421 + SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack(role:packReward(reward, change)))
  422 + return true
  423 +end
  424 +
399 425 return _M
400 426 \ No newline at end of file
... ...
src/adv/Adv.lua
... ... @@ -58,7 +58,7 @@ function Adv:initByInfo(advInfo)
58 58 self.maps[id] = AdvMap.new(self, id, map)
59 59 end
60 60  
61   - self:initBattle()
  61 + self:initBattle(advInfo)
62 62 end
63 63 -- 找出level 是否存在中继层
64 64 function Adv:isHaveRelay(level, chapterId)
... ... @@ -149,7 +149,7 @@ function Adv:initByChapter(params)
149 149 self.maps = {}
150 150 self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay)
151 151  
152   - self:initBattle(true)
  152 + self:initBattle(nil)
153 153  
154 154 self:initLayerTask()
155 155  
... ... @@ -456,7 +456,7 @@ function Adv:clearAdvUnlockCache()
456 456 self.cacheUnlock = {}
457 457 end
458 458  
459   -function Adv:initBattle(notDb)
  459 +function Adv:initBattle(info)
460 460 self.battle = require("adv.AdvBattle").new(self)
461 461 for _, passiveC in ipairs(self.cachePassiveEvent or {}) do
462 462 self.battle:triggerPassive(passiveC[1], passiveC[2])
... ... @@ -468,13 +468,15 @@ function Adv:initBattle(notDb)
468 468 map:initBattleAfter()
469 469 end
470 470 --下层
471   - if notDb and self.level ~= 1 then
  471 + if not info and self.level ~= 1 then
472 472 self.battle.player:attrChangeCondBuffCheck(1)
473 473 end
474 474  
475 475 -- 初始化
476   - if notDb then
  476 + if not info then
477 477 self.battle:newBattle()
  478 + else
  479 + self.battle:loadBattle(info)
478 480 end
479 481 end
480 482  
... ... @@ -1386,19 +1388,31 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1386 1388 [14] = function() -- 指定地块召唤 指定类型的id
1387 1389 local change = self:getCurMap():layEventToStage(effect[2], effect[3], effect[4], effect[5])
1388 1390 for _, one in ipairs(change) do
1389   - self:backBlockChange(one[1].roomId, one[2].blockId)
  1391 + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then
  1392 + clearBlock = false
  1393 + else
  1394 + self:backBlockChange(one[1].roomId, one[2].blockId)
  1395 + end
1390 1396 end
1391 1397 end,
1392 1398 [15] = function() -- 移除指定事件
1393 1399 local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4])
1394 1400 for _, one in ipairs(change) do
1395   - self:backBlockChange(one[1].roomId, one[2].blockId)
  1401 + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then
  1402 + clearBlock = false
  1403 + else
  1404 + self:backBlockChange(one[1].roomId, one[2].blockId)
  1405 + end
1396 1406 end
1397 1407 end,
1398 1408 [16] = function() -- 指定事件转移
1399 1409 local change = self:getCurMap():eventChangeToOther(effect[2], effect[3], effect[4], effect[5], effect[6])
1400 1410 for _, one in ipairs(change) do
1401   - self:backBlockChange(one[1].roomId, one[2].blockId)
  1411 + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then
  1412 + clearBlock = false
  1413 + else
  1414 + self:backBlockChange(one[1].roomId, one[2].blockId)
  1415 + end
1402 1416 end
1403 1417 end,
1404 1418 }
... ... @@ -1524,6 +1538,24 @@ local function clickBuild(self, room, block, params)
1524 1538 local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build")
1525 1539 if not status then return end
1526 1540  
  1541 + local isMine = false -- 是不是宝藏怪
  1542 + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do
  1543 + if mid == oldId then
  1544 + isMine = true
  1545 + break
  1546 + end
  1547 + end
  1548 + if isMine then
  1549 + local advMine = self.owner:getProperty("advMine")
  1550 + advMine[2] = advMine[2] or {}
  1551 + local mineCo2 = advMine[2].co or {}
  1552 + if chooseData.limit ~= 0 then
  1553 + mineCo2[oldId] = (mineCo2[oldId] or 0) + 1
  1554 + end
  1555 + advMine[2].co = mineCo2
  1556 + self.owner:setProperty("advMine", advMine)
  1557 + end
  1558 +
1527 1559 self:checkTask(Adv.TaskType.Build, 1, oldId)
1528 1560 self:checkAchievement(Adv.AchievType.Build, 1, oldId)
1529 1561 self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose)
... ... @@ -1951,73 +1983,143 @@ function Adv:enemyDead(enemy, escape)
1951 1983 -- self:backDead(enemyId, changeV)
1952 1984 self:backDead(enemyId)
1953 1985  
1954   - local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK)
1955   - if toClick then
1956   - toClick = toClick:effect()
  1986 + local isMine = false -- 是不是宝藏怪
  1987 + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do
  1988 + if mid == enemyId then
  1989 + isMine = true
  1990 + break
  1991 + end
1957 1992 end
1958 1993  
1959   - local changItem = enemy:hadBuff(Buff.CHANGE_DROP)
1960   - if changItem then
1961   - changItem = table.pack(changItem:effect())
1962   - end
  1994 + if isMine then
  1995 + local advMine = self.owner:getProperty("advMine")
  1996 + advMine[1] = advMine[1] or {}
  1997 + advMine[2] = advMine[2] or {}
  1998 + local mineCo = advMine[1].co or {}
  1999 + local mineCo2 = advMine[2].co or {}
  2000 + local mineCh = advMine[2].ch or globalCsv.adv_egg_treasureLayer_showup
  2001 + if monsterData.limit ~= 0 then
  2002 + mineCo[enemyId] = (mineCo[enemyId] or 0) + 1
  2003 + end
1963 2004  
1964   - local addMult = 0
1965   - local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数
1966   - if dropBuff then
1967   - local team = enemy:getTeam(1, true)
1968   - addMult = addMult + 0.2 * #team
1969   - end
  2005 + local had = false
  2006 + if math.randomInt(1, 100) <= mineCh then -- 刷出来了
  2007 + local mpool = {}
  2008 + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do
  2009 + local layer = csvdb["event_buildingCsv"][mid]
  2010 + if (not mineCo2[mid] or layer.limit == 0 or mineCo2[mid] < layer.limit) and layer.showup > 0 then
  2011 + mpool[mid] = {layer.showup}
  2012 + end
  2013 + end
  2014 + if next(mpool) then
  2015 + local cId = math.randWeight(mpool, 1)
  2016 + block:updateEvent({
  2017 + etype = AdvEventType.Build,
  2018 + id = cId
  2019 + })
  2020 + had = true
  2021 + end
  2022 + end
  2023 + if had then
  2024 + mineCh = nil
  2025 + else
  2026 + block:clear()
  2027 + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100)
  2028 + end
1970 2029  
1971   - local dropIds = monsterData.dropid:toArray(true, "=")
1972   - local drops = {}
1973   - local cCcount = 0 -- 需要改变为click 的个数
1974   - for _, dropId in ipairs(dropIds) do
1975   - local dropData = csvdb["event_dropCsv"][dropId]
1976   - if dropData then
1977   - local cur = dropData["range"]:randWeight(true)
1978   - if cur and cur[1] ~= 0 then
1979   - if toClick then
1980   - cCcount = cCcount + 1
1981   - else
1982   - local item = changItem and changItem or cur
1983   - item[2] = math.floor(item[2] * (1 + addMult))
1984   - drops[#drops + 1] = item
  2030 + local drops = {}
  2031 + for _, dropId in ipairs(monsterData.dropid:toArray(true, "=")) do
  2032 + local dropData = csvdb["event_dropCsv"][dropId]
  2033 + if dropData then
  2034 + local cur = dropData["range"]:randWeight(true)
  2035 + if cur and cur[1] ~= 0 then
  2036 + drops[#drops + 1] = cur
1985 2037 end
1986 2038 end
1987 2039 end
1988   - end
1989   - -- 这些奖励可能会有被动加成
1990   - self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops})
  2040 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
  2041 + for _i, cblock in ipairs(blocks) do
  2042 + cblock:updateEvent({
  2043 + etype = AdvEventType.Drop,
  2044 + item = drops[_i]
  2045 + })
  2046 + if cblock ~= block then
  2047 + self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2048 + end
  2049 + end
  2050 + advMine[1].co = mineCo
  2051 + advMine[2].co = mineCo2
  2052 + advMine[2].ch = mineCh
  2053 + self.owner:setProperty("advMine", advMine)
  2054 + else
  2055 + local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK)
  2056 + if toClick then
  2057 + toClick = toClick:effect()
  2058 + end
1991 2059  
1992   - -- 自身带的掉落是不会被改变的 也不会被加成
1993   - if block.event.item and block.event.item[1] ~= 0 then
1994   - table.insert(drops, 1, block.event.item)
1995   - end
  2060 + local changItem = enemy:hadBuff(Buff.CHANGE_DROP)
  2061 + if changItem then
  2062 + changItem = table.pack(changItem:effect())
  2063 + end
1996 2064  
1997   - -- 清空当前的格子
1998   - block:clear()
  2065 + local addMult = 0
  2066 + local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数
  2067 + if dropBuff then
  2068 + local team = enemy:getTeam(1, true)
  2069 + addMult = addMult + 0.2 * #team
  2070 + end
1999 2071  
2000   - -- 掉落走一波
2001   - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
2002   - for _i, cblock in ipairs(blocks) do
2003   - cblock:updateEvent({
2004   - etype = AdvEventType.Drop,
2005   - item = drops[_i]
2006   - })
2007   - if cblock ~= block then
2008   - self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2072 + local dropIds = monsterData.dropid:toArray(true, "=")
  2073 + local drops = {}
  2074 + local cCcount = 0 -- 需要改变为click 的个数
  2075 + for _, dropId in ipairs(dropIds) do
  2076 + local dropData = csvdb["event_dropCsv"][dropId]
  2077 + if dropData then
  2078 + local cur = dropData["range"]:randWeight(true)
  2079 + if cur and cur[1] ~= 0 then
  2080 + if toClick then
  2081 + cCcount = cCcount + 1
  2082 + else
  2083 + local item = changItem and changItem or cur
  2084 + item[2] = math.floor(item[2] * (1 + addMult))
  2085 + drops[#drops + 1] = item
  2086 + end
  2087 + end
  2088 + end
2009 2089 end
2010   - end
  2090 + -- 这些奖励可能会有被动加成
  2091 + self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops})
2011 2092  
2012   - -- 转换的click走一波
2013   - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount)
2014   - for _i, cblock in ipairs(blocks) do
2015   - cblock:updateEvent({
2016   - etype = AdvEventType.Click,
2017   - id = clickId
2018   - })
2019   - if cblock ~= block then
2020   - self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2093 + -- 自身带的掉落是不会被改变的 也不会被加成
  2094 + if block.event.item and block.event.item[1] ~= 0 then
  2095 + table.insert(drops, 1, block.event.item)
  2096 + end
  2097 +
  2098 + -- 清空当前的格子
  2099 + block:clear()
  2100 +
  2101 + -- 掉落走一波
  2102 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
  2103 + for _i, cblock in ipairs(blocks) do
  2104 + cblock:updateEvent({
  2105 + etype = AdvEventType.Drop,
  2106 + item = drops[_i]
  2107 + })
  2108 + if cblock ~= block then
  2109 + self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2110 + end
  2111 + end
  2112 +
  2113 + -- 转换的click走一波
  2114 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount)
  2115 + for _i, cblock in ipairs(blocks) do
  2116 + cblock:updateEvent({
  2117 + etype = AdvEventType.Click,
  2118 + id = clickId
  2119 + })
  2120 + if cblock ~= block then
  2121 + self:backBlockChange(cblock.room.roomId, cblock.blockId)
  2122 + end
2021 2123 end
2022 2124 end
2023 2125  
... ...
src/adv/AdvBattle.lua
... ... @@ -316,8 +316,19 @@ function Battle:afterRound()
316 316 build:afterRound("buffAfter")
317 317 end
318 318  
  319 + self.player:triggerPassive(Passive.AFTER_ROUND)
  320 +
  321 + self:checkAura()
  322 +
  323 + self:clearRound()
319 324  
  325 + if self.player.isDead then
  326 + self.adv:over(false, nil, -2)
  327 + end
  328 +end
320 329  
  330 +function Battle:clearRound()
  331 + local mapIdx = self.adv:getCurMapIdx()
321 332 self.player:clearRound()
322 333 for _, enemy in ipairs(self.enemys[mapIdx]) do
323 334 enemy:clearRound()
... ... @@ -347,14 +358,6 @@ function Battle:afterRound()
347 358 build:clear()
348 359 end
349 360 end
350   -
351   - self.player:triggerPassive(Passive.AFTER_ROUND)
352   -
353   - self:checkAura()
354   -
355   - if self.player.isDead then
356   - self.adv:over(false, nil, -2)
357   - end
358 361 end
359 362  
360 363  
... ... @@ -363,18 +366,32 @@ function Battle:battleBegin(roomId, blockId, params)
363 366 if not enemy then return end
364 367 local player = params.player
365 368 if not player then return end
  369 + local penemy = params.enemy or {hp = 0}
  370 + if player.hp ~= 0 then
  371 + if penemy.hp <= 0 then
  372 + enemy:kill()
  373 + self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId})
  374 + else
  375 + -- 处理一下怪物
  376 + if penemy.hp > enemy.hp then
  377 + enemy:recover(penemy.hp - enemy.hp)
  378 + else
  379 + enemy:hurt(math.max(0, math.ceil(enemy.hp - penemy.hp)), self.player, {hurtType = 5}) --战斗血量只会变少
  380 + end
  381 + if penemy.escape and penemy.escape == 0 then
  382 + enemy.isDead = 1
  383 + end
  384 + end
  385 + end
366 386 -- 玩家没死就是怪死了
367 387 if player.hp > 0 then
368   - enemy:kill()
369 388 self.player:effectBattleBuff()
370   -
371   - self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId})
372 389 if params.bySkill then
373 390 self.player:triggerPassive(Passive.SKILL_KILL)
374 391 end
375 392 end
376 393 if player.hp > self.player.hp then
377   - self.player:recover(player.hp - self.player.hp, player)
  394 + self.player:recover(player.hp - self.player.hp)
378 395 else
379 396 self.player:hurt(math.max(0, math.ceil(self.player.hp - player.hp)), enemy, {hurtType = 5}) --战斗血量只会变少
380 397 end
... ... @@ -429,7 +446,7 @@ function Battle:initMapEffect(ilayer)
429 446 end
430 447  
431 448 for _, buff in ipairs(buffs[1] or {}) do
432   - self.palyer:addBuff(buff)
  449 + self.player:addBuff(buff)
433 450 end
434 451  
435 452 for _, buff in ipairs(buffs[2] or {}) do
... ... @@ -446,16 +463,18 @@ function Battle:iLayerChange(oldMapIdx)
446 463 local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras)
447 464 local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras)
448 465 self.player:checkAuraBuff(playerBuffs)
449   - for _, enemy in pairs(self.player:getTeam(2)) do
  466 + for _, enemy in ipairs(self.enemys[self.adv:getCurMapIdx()]) do
450 467 enemy:checkAuraBuff(enemyBuffs)
451 468 end
452 469 self:setMapAuras(auras)
  470 + self:clearRound()
453 471 end
454 472  
455 473 -- 新的 关卡 关闭旧的战斗模块 清理 玩家身上的光环效果
456 474 function Battle:overBattle()
457 475 local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), {})
458 476 self.player:checkAuraBuff(buffs)
  477 + self:clearRound()
459 478 self.adv.owner:getProperty("advTeam").player = self.player:getDB() -- 临时缓存住 battle 的player
460 479 end
461 480  
... ... @@ -463,9 +482,17 @@ end
463 482 function Battle:newBattle()
464 483 local auras = self:getActiveAuras()
465 484 local buffs = self:checkDiffAuraBuff({}, auras)
  485 + self.player:checkAuraBuff(buffs)
  486 + for _, enemy in ipairs(self.enemys[self.adv:getCurMapIdx()]) do
  487 + enemy:checkAuraBuff(buffs)
  488 + end
466 489 self:setMapAuras(auras)
467 490 end
468 491  
  492 +function Battle:loadBattle(info)
  493 + self.auras = info.auras or {}
  494 +end
  495 +
469 496 -- 过了回合 检查光环
470 497 function Battle:checkAura()
471 498 local auras = self:getActiveAuras()
... ...
src/adv/AdvBlock.lua
... ... @@ -332,7 +332,9 @@ end
332 332 function Block:getObstacle()
333 333 if self:isMonster() then
334 334 local enemy = self.room.map.adv.battle:getEnemy(self.room.roomId, self.blockId)
335   - return enemy:getObstacle()
  335 + if enemy then
  336 + return enemy:getObstacle()
  337 + end
336 338 end
337 339 local data = self:getEventData()
338 340 if not data then return 0 end
... ...
src/adv/AdvBuff.lua
... ... @@ -489,6 +489,8 @@ function Buff:createAfter(layer)
489 489 if self._init then
490 490 self:_init()
491 491 end
  492 + self:pushBackEffect(1)
  493 + buglog("Buff", "who: %s create buffId: %s", self.owner.monsterId, self.id)
492 494 end
493 495  
494 496 function Buff:initByDB(data)
... ... @@ -620,11 +622,20 @@ function Buff:canEffect(...)
620 622 return self:_canEffect(...)
621 623 end
622 624  
  625 +function Buff:pushBackEffect(etype)
  626 + local shows = self.buffData.show:toTableArray(true)
  627 + for _, one in ipairs(shows) do
  628 + if one[1] == etype then
  629 + self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = etype, id = self.id, blockId = self.owner.blockId, roomId = self.owner.roomId})
  630 + break
  631 + end
  632 + end
  633 +end
  634 +
623 635 function Buff:effect()
  636 + buglog("Buff", "who: %s effect buffId: %s", self.owner.monsterId, self.id)
624 637 self:decCount()
625   - if self.buffData.show:sismember(2, " ") then
626   - self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 2})
627   - end
  638 + self:pushBackEffect(2)
628 639 if self._effectValue then
629 640 return self:_effectValue()
630 641 end
... ... @@ -646,6 +657,7 @@ function Buff:endBuff()
646 657 if self._endBuff then
647 658 self:_endBuff()
648 659 end
  660 + buglog("Buff", "who: %s endBuff buffId: %s", self.owner.monsterId, self.id)
649 661 end
650 662  
651 663 function Buff:getType()
... ... @@ -698,6 +710,9 @@ function Buff:overlay(releaser, data, layer)
698 710 if self._overlay then
699 711 self:_overlay()
700 712 end
  713 +
  714 + self:pushBackEffect(1)
  715 + buglog("Buff", "who: %s overlay buffId: %s", self.owner.monsterId, self.id)
701 716 end
702 717 end
703 718  
... ...
src/adv/AdvMap.lua
... ... @@ -13,12 +13,12 @@ local createMap, getEventLib
13 13 function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay)
14 14 self.adv = adv
15 15 local isNew = type(mapInfo) == "number"
  16 + self.mapIdx = mapIdx
16 17 if isNew then -- mapInfo 传入 id
17 18 mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图
18 19 end
19 20 if not mapInfo then return end
20 21  
21   - self.mapIdx = mapIdx
22 22 self.mapId = mapInfo.mapId
23 23 self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用
24 24 self.rooms = {}
... ... @@ -258,7 +258,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
258 258 if isPlayer then
259 259 self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId})
260 260 self.adv.owner:checkTaskEnter("AdvOpenBlock")
261   -
  261 + self.adv.battle.player:changeSp(1) -- 翻开格子 sp 加1
262 262 -- 潜行检查
263 263 local sneakBuff = self.adv.battle.player:hadBuff(Buff.SNEAK)
264 264 if sneakBuff then
... ... @@ -313,13 +313,13 @@ function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack)
313 313 end
314 314 end
315 315  
316   - if not count or count == -1 or count >= len(allBlock) then
  316 + if not count or count == -1 or count >= #allBlock then
317 317 for _, blockId in ipairs(allBlock) do
318 318 openBlock(blockId)
319 319 end
320 320 else
321 321 for i = 1, count do
322   - local idx = math.randomInt(1, len(allBlock))
  322 + local idx = math.randomInt(1, #allBlock)
323 323 openBlock(allBlock[idx])
324 324 table.remove(allBlock, idx)
325 325 end
... ... @@ -349,8 +349,8 @@ function Map:getDistance(froomId, fblockId, troomId, tblockId)
349 349 local room1 = self.rooms[froomId]
350 350 local room2 = self.rooms[troomId]
351 351 if room1 and room2 then
352   - local block1 = room1[fblockId]
353   - local block2 = room2[tblockId]
  352 + local block1 = room1.blocks[fblockId]
  353 + local block2 = room2.blocks[tblockId]
354 354 if block1 and block2 then
355 355 local c1, r1 = room1:tranLtoG(block1.col, block1.row)
356 356 local c2, r2 = room2:tranLtoG(block2.col, block2.row)
... ... @@ -811,6 +811,48 @@ createMap = function(self, mapId, isEnter, isNewRelay)
811 811 end
812 812 end
813 813 end
  814 + -- 宝藏怪刷新
  815 + if self.mapIdx == 1 and not self.adv.isRelay and self.adv.chapterId ~= 100 then
  816 + for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do
  817 + local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId}
  818 + if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在
  819 + table.remove(stagePool["global"][AdvCodeRandomStage], idx)
  820 + end
  821 + end
  822 + local ln = #(stagePool["global"][AdvCodeRandomStage] or {})
  823 + local advMine = self.adv.owner:getProperty("advMine")
  824 + advMine[1] = advMine[1] or {}
  825 + local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup
  826 + local mineCo = advMine[1].co or {}
  827 + local had = false
  828 + if ln > 0 then
  829 + if math.randomInt(1, 100) <= mineCh then -- 刷出来了
  830 + local mpool = {}
  831 + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do
  832 + local monster = csvdb["event_monsterCsv"][mid]
  833 + if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then
  834 + mpool[mid] = {monster.showup}
  835 + end
  836 + end
  837 + if next(mpool) then
  838 + local idx = math.randomInt(1, ln)
  839 + local cur = stagePool["global"][AdvCodeRandomStage][idx]
  840 + giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1))
  841 + table.remove(stagePool["global"][AdvCodeRandomStage], idx)
  842 + ln = ln - 1
  843 + had = true
  844 + end
  845 + end
  846 + end
  847 + if had then
  848 + mineCh = nil
  849 + else
  850 + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100)
  851 + end
  852 + advMine[1].ch = mineCh
  853 + self.adv.owner:setProperty("advMine", advMine)
  854 + end
  855 +
814 856  
815 857 if mapCsvData.clearType == 1 and not haveBoss then
816 858 if not next(monsterEvents) then
... ...
src/adv/AdvPassive.lua
... ... @@ -50,7 +50,7 @@ end
50 50  
51 51 FilterFactory[Filter.RANGE] = function (_Filter)
52 52 _Filter._execute = function (self, target, params)
53   - if self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then
  53 + if params and self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then
54 54 local distance = self.owner.battle.adv:getCurMap():getDistance(self.owner.roomId, self.owner.blockId, params.roomId, params.blockId)
55 55 return distance ~= -1 and distance <= self.value
56 56 end
... ... @@ -95,9 +95,8 @@ function Filter:execute(params)
95 95 if not target then
96 96 return
97 97 end
98   - if self:_execute(target) then
99   - return self:_execute(target, params)
100   - end
  98 +
  99 + return self:_execute(target, params)
101 100 end
102 101  
103 102 -->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
... ... @@ -203,7 +202,7 @@ PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF]
203 202  
204 203 PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive)
205 204 _Passive._trigger = function(self, params)
206   - if params.classify:sismember(self.passiveData.value) then
  205 + if params.classify:sismember(self.passiveData.value, " ") then
207 206 return true
208 207 end
209 208 end
... ... @@ -340,6 +339,7 @@ function Passive:canEffect(effType, effValue)
340 339 end
341 340  
342 341 function Passive:effect(triggerPms)
  342 + local hadEffect = false
343 343 for _, effect in ipairs(self.effects) do
344 344 local effType = effect[1]
345 345 local effValue = effect[2]
... ... @@ -348,10 +348,14 @@ function Passive:effect(triggerPms)
348 348 table.insert(otherPms, effect[i])
349 349 end
350 350 if self:canEffect(effType, effValue) then
  351 + hadEffect = true
351 352 self["effect" .. effType](self, effValue, triggerPms, table.unpack(otherPms))
352 353 end
353 354 end
354   -
  355 + if hadEffect then
  356 + self.owner.battle.adv:pushBackEvent(AdvBackEventType.PassiveEffect, {id = self.id, level = self.level, roomId = self.owner.roomId, blockId = self.owner.blockId})
  357 + buglog("Passive", "who: %s effect id: %s", self.owner.monsterId, self.id)
  358 + end
355 359 if self.count > 0 then
356 360 self.count = self.count < 999 and self.count - 1 or self.count
357 361 self.round = self.passiveData.round
... ... @@ -401,6 +405,8 @@ function Passive:trigger(condType, params) --触发检查
401 405 params = params or {}
402 406 if self.isDel or self.owner.isDead then return end
403 407 if self:getCondType() ~= condType then return end
  408 +
  409 + buglog("Passive", "who: %s trigger id: %s", self.owner.monsterId, self.id)
404 410 if not self:canTrigger() then return end
405 411 if self._trigger then
406 412 if not self:_trigger(params) then return end --检查
... ... @@ -597,5 +603,9 @@ function Passive:effect16(value, triggerPms, changeType)
597 603 self.owner.battle.adv:blockDropChange(changeType, blocks)
598 604 end
599 605  
  606 +--17=玩家获得buff
  607 +function Passive:effect17(value, triggerPms)
  608 + self.owner.battle.player:addBuff(value, self.owner)
  609 +end
600 610  
601 611 return Passive
602 612 \ No newline at end of file
... ...
src/adv/AdvPlayer.lua
... ... @@ -144,7 +144,7 @@ function BaseObject:getDisablePassiveCount()
144 144 end
145 145  
146 146 function BaseObject:getDisableAuraCount()
147   - local count
  147 + local count = 0
148 148 for _, buff in ipairs(self.buffs) do
149 149 if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then
150 150 if buff:effect() == 0 then
... ... @@ -699,7 +699,7 @@ function Enemy:checkAuraBuff(buffs)
699 699 if buff then
700 700 buff:uncover(info.exist and -info.count or -1, true)
701 701 end
702   - elseif count > 0 then
  702 + elseif info.count > 0 then
703 703 self:addBuff(buffId, nil, info.count)
704 704 end
705 705 end
... ... @@ -847,10 +847,6 @@ function Player:addBuff(buffId, releaser)
847 847 self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId)
848 848 self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId})
849 849 self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId})
850   - local buffData = csvdb["adv_map_buffCsv"][buffId]
851   - if buffData and buffData.show:sismember(1, " ") then
852   - self.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 1})
853   - end
854 850 end
855 851 return status
856 852 end
... ...
src/models/Activity.lua
... ... @@ -19,6 +19,11 @@ Activity.ActivityType = {
19 19 AdvDraw = 13, --拾荒抽周 资助
20 20 OpenBox = 14, --拆解周 时钟箱
21 21 RaceDraw = 16, -- 定向招募活动
  22 +
  23 + ChallengeLevel = 17, -- 挑战关卡活动
  24 + Exchange = 18, -- 兑换活动
  25 + HangDrop = 19, -- 挂机掉落活动
  26 + Gachakon = 20, -- 扭蛋活动
22 27 }
23 28  
24 29  
... ... @@ -48,6 +53,11 @@ Activity.schema = {
48 53 act12 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励
49 54 act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励
50 55 act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励
  56 +
  57 + act17 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害}
  58 + act18 = {"table", {}, true}, -- {id=兑换数量}
  59 + act19 = {"number", 0}, -- {挂机信息}
  60 + act20 = {"table", {}}, -- {id=扭蛋抽出数量}
51 61 }
52 62  
53 63 function Activity:data()
... ... @@ -61,6 +71,11 @@ function Activity:data()
61 71 act12 = self:getProperty("act12"),
62 72 act13 = self:getProperty("act13"),
63 73 act14 = self:getProperty("act14"),
  74 +
  75 + act17 = self:getProperty("act17"),
  76 + act18 = self:getProperty("act18"),
  77 + act19 = self:getProperty("act19"),
  78 + act20 = self:getProperty("act20"),
64 79 }
65 80 end
66 81  
... ... @@ -138,6 +153,10 @@ function Activity:isOpen(activityType)
138 153 return false
139 154 end
140 155  
  156 +function Activity:isOpenById(id)
  157 + return self._isOpen[id]
  158 +end
  159 +
141 160 function Activity:getActData(actType)
142 161 actType = checkActivityType(actType)
143 162 return self:getProperty("act" .. actType)
... ... @@ -160,6 +179,7 @@ function Activity:checkActivityStatus(now, isCrossDay, notify)
160 179  
161 180 if isOpen then
162 181 if actime[actId] and actime[actId] == startTime then -- 还是之前的状态 开放中
  182 + self:onLoginActivity(actId)
163 183 else -- 重置
164 184 actime[actId] = startTime
165 185 self:closeActivity(actId, notify, true)
... ... @@ -400,7 +420,8 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
400 420 local towerInfo = role:getProperty("towerInfo")
401 421 role:checkTaskEnter("TowerPass", {level = towerInfo.l})
402 422 --"PvpWin"
403   - role:checkTaskEnter("HangPass", {})
  423 + --role:checkTaskEnter("HangPass", {id = 0})
  424 + role:checkCalendaTask(true, 15, 3)
404 425 role:checkTaskEnter("HeroStarCollect", {})
405 426 role:checkTaskEnter("RuneQualityCollect", {})
406 427  
... ... @@ -409,12 +430,88 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
409 430 -- end,
410 431 }
411 432  
  433 +-- 兑换
  434 +activityFunc[Activity.ActivityType.Exchange] = {
  435 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  436 + local actData = self:getActData(actType) or {}
  437 + actData[actId] = {}
  438 + self:updateActData(actType, actData, not notify)
  439 + end,
  440 + ["crossDay"] = function(self, actType, notify, actId)
  441 + local actData = self:getActData(actType) or {}
  442 + local lastTs = actData["ts"] or 0
  443 + local timeNow = skynet.timex()
  444 + local cfg = csvdb["activity_ctrlCsv"][actId]
  445 + if not cfg then return end
  446 + local refreshTimes = cfg.condition2:toArray(false, "=")
  447 + for i = 1, #refreshTimes do
  448 + local rt = toUnixtime(refreshTimes[1]..string_format("%02x", RESET_TIME))
  449 + if timeNow >= rt and rt > lastTs then
  450 + lastTs = rt
  451 + actData = {}
  452 + end
  453 + end
  454 + if next(actData) then
  455 + actData["ts"] = lastTs
  456 + self:updateActData(actType, actData, not notify)
  457 + end
  458 + end,
  459 + ["close"] = function(self, actType, notify, actId)
  460 + local actData = self:getActData(actType) or {}
  461 + actData[actId] = nil
  462 + self:updateActData(actType, actData, not notify)
  463 + end,
  464 +}
  465 +
  466 +-- 扭蛋机
  467 +activityFunc[Activity.ActivityType.Gachakon] = {
  468 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  469 + self:updateActData(actType, {}, not notify)
  470 + end,
  471 + ["crossDay"] = function(self, actType, notify)
  472 + self:updateActData(actType, {}, not notify)
  473 + end,
  474 +}
  475 +
  476 +-- 挂机掉落
  477 +activityFunc[Activity.ActivityType.HangDrop] = {
  478 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  479 + local actime = self:getProperty("actime")
  480 + local ctime = self.owner:getProperty("ctime")
  481 + local startTime = math.max(actime[actId], ctime)
  482 + local actData = self:getActData(actType) or 0
  483 + local cfg = csvdb["activity_putCsv"][actId]
  484 + if not cfg then return end
  485 + actData = startTime
  486 + self:updateActData(actType, actData, not notify)
  487 + end
  488 +}
  489 +
  490 +--ChallengeLevel
  491 +activityFunc[Activity.ActivityType.ChallengeLevel] = {
  492 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  493 + self:getBattleTicket(actId)
  494 + end,
  495 + ["login"] = function(self, actType, actId)
  496 + self:getBattleTicket(actId)
  497 + end
  498 +}
  499 +
  500 +function Activity:onLoginActivity(actId)
  501 + local actData = csvdb["activity_ctrlCsv"][actId]
  502 + if not actData then return end
  503 + local actType = actData.showType
  504 + if activityFunc[actType] and activityFunc[actType]['login'] then
  505 + activityFunc[actType]["login"](self, actType, actId)
  506 + end
  507 +end
  508 +
412 509 function Activity:initActivity(actId, isCrossDay, notify)
413 510 local actData = csvdb["activity_ctrlCsv"][actId]
414 511 if not actData then return end
415 512 local actType = actData.showType
416   - if activityFunc[actType] and activityFunc[actType]['close'] then
417   - activityFunc[actType]["init"](self, actType, isCrossDay, notify)
  513 + if activityFunc[actType] and activityFunc[actType]['init'] then
  514 + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId)
418 515 end
419 516 end
420 517  
... ... @@ -423,7 +520,8 @@ function Activity:closeActivity(actId, notify, notUpdateAct)
423 520 if not actData then return end
424 521 local actType = actData.showType
425 522 if activityFunc[actType] and activityFunc[actType]['close'] then
426   - activityFunc[actType]["close"](self, actType, notify)
  523 + activityFunc[actType]["close"](self, actType, notify, actId)
  524 + self:recycleActItem(actId)
427 525 end
428 526 if Activity.schema["act".. actType] then
429 527 self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct)
... ... @@ -436,7 +534,7 @@ function Activity:refreshDailyData(notify)
436 534 if status and actData then
437 535 local actType = actData.showType
438 536 if activityFunc[actType] and activityFunc[actType]['crossDay'] then
439   - activityFunc[actType]["crossDay"](self, actType, notify)
  537 + activityFunc[actType]["crossDay"](self, actType, notify, actId)
440 538 end
441 539 end
442 540 end
... ... @@ -453,8 +551,8 @@ end
453 551 -- 获取此次挂机掉落翻倍时长
454 552 function Activity:getActHangDoubleTime(lastTs, nowTs)
455 553 local type = "DoubleDrop"
456   - local actId = checkActivityType(type)
457   - local isOpen = self:isOpen(type)
  554 + --local actId = checkActivityType(type)
  555 + local isOpen, actId = self:isOpen(type)
458 556 local openTs = self:getProperty("actime")[actId] or 0
459 557 local timeNow = skynet.timex()
460 558 lastTs = math.max(lastTs, openTs)
... ... @@ -529,5 +627,67 @@ function Activity:getPaySignReward()
529 627 --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change)))
530 628 end
531 629  
  630 +-- 回收活动道具
  631 +function Activity:recycleActItem(actId)
  632 + local role = self.owner
  633 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  634 + if not actCfg then return end
  635 + local gift = {}
  636 + local costs = {}
  637 + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do
  638 + local fromId, toId, toNum = arr[1], arr[2], arr[3]
  639 + local itemCount = role:getItemCount(fromId)
  640 + if itemCount > 0 then
  641 + costs[fromId] = (costs[fromId] or 0) + itemCount
  642 + gift[toId] = toNum * itemCount
  643 + end
  644 + end
  645 + if next(costs) then
  646 + local itemStr = ""
  647 + for k, v in pairs(costs) do
  648 + if itemStr ~= "" then
  649 + itemStr = itemStr .. " "
  650 + end
  651 + itemStr = itemStr .. k .. "=" .. v
  652 + end
  653 + role:costItems(costs, {log = {desc = "actRecycle"}})
  654 + role:sendMail(actCfg.recycle_email, nil, gift, {itemStr})
  655 + end
  656 +end
  657 +
  658 +-- 活动挑战关卡计算门票
  659 +function Activity:getBattleTicket(actId)
  660 + local role = self.owner
  661 + local createTs = role:getProperty("ctime")
  662 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  663 + if not actCfg then return 0 end
  664 +
  665 + local actStartTime = 0
  666 + local openTimes = actCfg.time:toArray(false, "=")
  667 + actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME))
  668 + local actData = self:getActData("ChallengeLevel") or {}
  669 + local startTs = actData["ts"] or math.max(actStartTime, createTs)
  670 + local timeNow = skynet.timex()
  671 + local modify = false
  672 + local arr = actCfg.condition2:toArray(true, "=")
  673 +
  674 + local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000
  675 +
  676 + local count = actData["ticket"] or init
  677 + local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0)
  678 +
  679 + local newCount= math.min(count + add, limit)
  680 + if newCount ~= count or newCount >= limit then
  681 + modify = true
  682 + end
  683 + add = newCount - count
  684 +
  685 + if modify or not next(actData) then
  686 + actData["ticket"] = newCount
  687 + actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60)
  688 + self:updateActData("ChallengeLevel", actData)
  689 + end
  690 +end
  691 +
532 692  
533 693 return Activity
... ...
src/models/Email.lua
... ... @@ -48,10 +48,10 @@ function Email:data()
48 48  
49 49 if emailData then
50 50 -- 如果内容是直接插入到数据库
51   - if content == "" and emailData.body ~= "" then
52   - content = io.readfile("src/" .. emailData.body) or ""
53   - content = content:format(table.unpack(contentPms))
54   - end
  51 + --if content == "" and emailData.body ~= "" then
  52 + -- content = io.readfile("src/" .. emailData.body) or ""
  53 + -- content = content:format(table.unpack(contentPms))
  54 + --end
55 55  
56 56 if title == "" and emailData.title ~= "" then
57 57 title = emailData.title
... ... @@ -67,12 +67,14 @@ function Email:data()
67 67 end
68 68  
69 69 return {
  70 + cfgId = emailId,
70 71 id = self:getProperty("id"),
71 72 status = self:getProperty("status"),
72 73 createtime = self:getProperty("createtime"),
73 74 title = title,
74 75 stitle = stitle,
75 76 content = content,
  77 + contentPms = contentPms,
76 78 attachments = attachments,
77 79 }
78 80 end
... ...
src/models/HeroPlugin.lua
... ... @@ -126,11 +126,11 @@ function HeroPlugin.bind(Hero)
126 126 end
127 127  
128 128 -- 羁绊加成
129   - if params.activeRelation then
130   - for k, attName in pairs(AttsEnumEx) do
131   - attrs[attName] = attrs[attName] + addAttr(attrs[attName], params.activeRelation[attName], 1, attName)
132   - end
133   - end
  129 + -- if params.activeRelation then
  130 + -- for k, attName in pairs(AttsEnumEx) do
  131 + -- attrs[attName] = attrs[attName] + addAttr(attrs[attName], params.activeRelation[attName], 1, attName)
  132 + -- end
  133 + -- end
134 134 return attrs
135 135 end
136 136  
... ... @@ -224,8 +224,10 @@ function HeroPlugin.bind(Hero)
224 224  
225 225  
226 226 -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ]
227   - function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成
228   - local attrs = self:getTotalAttrs({activeRelation = activeRelation})
  227 + -- function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成
  228 + function Hero:getBattleValue() -- isReal包括队伍加成
  229 + -- local attrs = self:getTotalAttrs({activeRelation = activeRelation})
  230 + local attrs = self:getTotalAttrs()
229 231 local battleValue = ((attrs["hp"] + attrs["def"] * 7 + attrs["miss"] * 4) * (attrs["atk"] * 4 + attrs["hit"] * 2) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 600000) ^ 0.8
230 232 return math.floor(battleValue)
231 233 end
... ...
src/models/Role.lua
... ... @@ -99,7 +99,8 @@ Role.schema = {
99 99 advLimit = {"table", {}}, -- 冒险事件每次的limit
100 100 advC = {"number", 0}, -- 冒险次数(消耗体力)
101 101 advCT = {"number", 0}, -- 冒险次数 上次恢复时间
102   -
  102 + advMine = {"table", {}}, -- -- {1 = {ch = 0, co = {id = count}}, 2 = {ch = 0, co = {id = count}}} 宝藏怪刷出概率 1 宝藏怪 2 宝藏洞 ch 概率 co 不同id 次数记录
  103 +
103 104 --挂机相关
104 105 hangPass = {"table", {}}, -- 挂机通过的最大关卡
105 106 hangGift = {"table", {}}, -- 挂机奖励 {id = 1}
... ... @@ -167,7 +168,8 @@ Role.schema = {
167 168 repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次
168 169 floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count}
169 170 ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count}
170   - newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr
  171 + newerDraw = {"number", 0}, -- 新手池子抽卡次数
  172 + wishPool = {"table", {}}, -- 心愿池子
171 173  
172 174 sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况
173 175 sign = {"table", {}}, -- 签到记录 {[1] = 20181029}
... ... @@ -394,6 +396,7 @@ function Role:data()
394 396 repayHero = self:getProperty("repayHero"),
395 397 newerDraw = self:getProperty("newerDraw"),
396 398 floorHero = self:getProperty("floorHero"),
  399 + wishPool = self:getProperty("wishPool"),
397 400  
398 401 sudoku = self:getProperty("sudoku"),
399 402 sign = self:getProperty("sign"),
... ...
src/models/RoleBattle.lua
... ... @@ -16,6 +16,7 @@ local BattleType = {
16 16 bonus = 300,
17 17 pvpc = 500,
18 18 pvph = 501,
  19 + act_battle = 502,
19 20 }
20 21  
21 22 RoleBattle.bind = function (Role)
... ... @@ -86,6 +87,20 @@ function Role:checkBattle(battleType, params)
86 87 enemylist[#enemylist + 1] = one["unitType"]
87 88 end
88 89 end,
  90 + act_battle = function()
  91 + for slot, hero in pairs(self:getTeamHerosInfo(params.heros)) do
  92 + selflist[slot] = hero.type
  93 + end
  94 + heroscore = self:getTeamBattleValue(params.heros)
  95 + for slot , one in pairs(params.supports) do
  96 + teamskill[one[1]] = one[2]
  97 + end
  98 + local carbonData = params.cfg
  99 + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"]
  100 + for slot, one in pairs(monsterData[1]) do
  101 + enemylist[#enemylist + 1] = one["unitType"]
  102 + end
  103 + end,
89 104 pvpc = function()
90 105 for slot, hero in pairs(self:getProperty("pvpTSC")) do
91 106 selflist[slot] = hero.type
... ... @@ -163,7 +178,7 @@ function Role:checkBattle(battleType, params)
163 178 mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级
164 179 mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒)
165 180 mission_result = params.isWin and 1 or 2, -- 战斗结果(0-无效,1-胜利,2-失败)
166   - mission_star = 0, -- 战斗完成星数,无星级的话填写0
  181 + mission_star = params.star or 0, -- 战斗完成星数,无星级的话填写0
167 182 mission_restriction = 0, -- 周期内参与限制(0表示没有上限)
168 183 mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0
169 184 mission_strength = 1, -- 消耗的体力或次数
... ...
src/models/RoleLog.lua
... ... @@ -42,6 +42,13 @@ local ItemReason = {
42 42 freeGift = 127, -- 免费礼包
43 43 exploreCommand = 128, -- 探索指令
44 44 drawHeroExtraReward = 129, -- 抽卡阶段奖励
  45 + actRecycle = 130, -- 活动道具回收
  46 + actExchange = 131, -- 兑换活动
  47 + actGachakon = 132, -- 扭蛋活动
  48 + totalRecharge = 133, -- 累计充值奖励
  49 + actHangDrop = 134, -- 掉落活动奖励
  50 + actBattle = 135, -- 活动关卡
  51 + actMilestone = 136, -- 活动关卡boss伤害里程碑
45 52  
46 53  
47 54 advHang = 301, -- 拾荒挂机
... ...
src/models/RolePlugin.lua
... ... @@ -102,6 +102,35 @@ function RolePlugin.bind(Role)
102 102 [ItemType.FuncOpen] = function()
103 103 self:funcOpen(itemId, count, pms)
104 104 end,
  105 + [ItemType.HeroFCommon] = function()
  106 + if itemData.use_type == 2 then
  107 + local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)]
  108 + for _i = 1, count do
  109 + for i = 1, 10 do
  110 + local num = randomData["num" .. i]
  111 + local gift = randomData["gift" .. i]
  112 + if num and gift and num > 0 and gift ~= "" then
  113 + local pool = {}
  114 + for _, temp in ipairs(gift:toArray()) do
  115 + table.insert(pool, temp:toArray(true, "="))
  116 + end
  117 + local needCount = math.min(#pool, num)
  118 + for j = 1, needCount do
  119 + local idx = math.randWeight(pool, 3)
  120 + change[pool[idx][1]] = (change[pool[idx][1]] or 0) + pool[idx][2]
  121 + table.remove(pool, idx)
  122 + end
  123 + end
  124 + end
  125 + end
  126 + change[0] = nil
  127 + count = 0
  128 + else
  129 + pms.itemId = itemId
  130 + pms.count = count
  131 + self:addItem(pms)
  132 + end
  133 + end,
105 134 }
106 135 -- 对数量筛查
107 136 count = checkItemCount(self, itemId, count)
... ... @@ -806,50 +835,50 @@ function RolePlugin.bind(Role)
806 835 SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey}))
807 836 end
808 837  
809   - function Role:getHeroActiveRelationData(heros)
810   - local relations = {}
811   - for _, id in pairs(heros or {}) do
812   - local hero = self.heros[id]
813   - if hero then
814   - local camp = csvdb["unitCsv"][hero:getProperty("type")].camp
815   - relations[camp] = (relations[camp] or 0) + 1
816   - end
817   - end
818   - local curData = csvdb["unit_relationCsv"][0]
819   - if not next(relations) then return curData end
  838 + -- function Role:getHeroActiveRelationData(heros)
  839 + -- local relations = {}
  840 + -- for _, id in pairs(heros or {}) do
  841 + -- local hero = self.heros[id]
  842 + -- if hero then
  843 + -- local camp = csvdb["unitCsv"][hero:getProperty("type")].camp
  844 + -- relations[camp] = (relations[camp] or 0) + 1
  845 + -- end
  846 + -- end
  847 + -- local curData = csvdb["unit_relationCsv"][0]
  848 + -- if not next(relations) then return curData end
820 849  
821   - for _, data in ipairs(csvdb["unit_relationCsv"]) do
822   - local had = {}
823   - local isDone = true
824   - for _, count in pairs(data.relation:toArray(true, "=")) do
825   - local find = false
826   - for camp, _count in pairs(relations) do
827   - if count == _count and not had[camp] then
828   - had[camp] = true
829   - find = true
830   - break
831   - end
832   - end
833   - if not find then
834   - isDone = false
835   - break
836   - end
837   - end
838   - if isDone then
839   - curData = data
840   - end
841   - end
842   - return curData
843   - end
844   -
845   - function Role:getHeroActiveRelation(heros)
846   - local data = self:getHeroActiveRelationData(heros)
847   - local result = {}
848   - for attr, value in pairs(data.effect:toNumMap()) do
849   - result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value
850   - end
851   - return result
852   - end
  850 + -- for _, data in ipairs(csvdb["unit_relationCsv"]) do
  851 + -- local had = {}
  852 + -- local isDone = true
  853 + -- for _, count in pairs(data.relation:toArray(true, "=")) do
  854 + -- local find = false
  855 + -- for camp, _count in pairs(relations) do
  856 + -- if count == _count and not had[camp] then
  857 + -- had[camp] = true
  858 + -- find = true
  859 + -- break
  860 + -- end
  861 + -- end
  862 + -- if not find then
  863 + -- isDone = false
  864 + -- break
  865 + -- end
  866 + -- end
  867 + -- if isDone then
  868 + -- curData = data
  869 + -- end
  870 + -- end
  871 + -- return curData
  872 + -- end
  873 +
  874 + -- function Role:getHeroActiveRelation(heros)
  875 + -- local data = self:getHeroActiveRelationData(heros)
  876 + -- local result = {}
  877 + -- for attr, value in pairs(data.effect:toNumMap()) do
  878 + -- result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value
  879 + -- end
  880 + -- return result
  881 + -- end
853 882  
854 883 function Role:getHerosCamp(heros)
855 884 local had = {}
... ... @@ -870,14 +899,16 @@ function RolePlugin.bind(Role)
870 899 return curCamp
871 900 end
872 901  
873   - function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成
  902 + -- function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成
  903 + function Role:getRealBattleValue(heros) -- 获取队伍战斗力 羁绊加成
874 904 heros = heros or {}
875   - local activeRelation = activeRelation or self:getHeroActiveRelation(heros)
  905 + -- local activeRelation = activeRelation or self:getHeroActiveRelation(heros)
876 906 local battleValue = 0
877 907 for _, id in pairs(heros) do
878 908 local hero = self.heros[id]
879 909 if hero then
880   - battleValue = battleValue + hero:getBattleValue(activeRelation)
  910 + -- battleValue = battleValue + hero:getBattleValue(activeRelation)
  911 + battleValue = battleValue + hero:getBattleValue()
881 912 end
882 913 end
883 914 return battleValue
... ... @@ -1263,7 +1294,7 @@ function RolePlugin.bind(Role)
1263 1294  
1264 1295 function Role:getTeamBattleInfo(team)
1265 1296 local teamInfo = {heros = {}, supports = {}}
1266   - local activeRelation = self:getHeroActiveRelation(team.heros)
  1297 + -- local activeRelation = self:getHeroActiveRelation(team.heros)
1267 1298  
1268 1299 for slot, id in pairs(team.heros or {}) do
1269 1300 local info = {}
... ... @@ -1271,7 +1302,8 @@ function RolePlugin.bind(Role)
1271 1302 if not hero then
1272 1303 print("error heroid " .. id)
1273 1304 end
1274   - local attrs = hero:getTotalAttrs({activeRelation = activeRelation})
  1305 + -- local attrs = hero:getTotalAttrs({activeRelation = activeRelation})
  1306 + local attrs = hero:getTotalAttrs()
1275 1307 for k, v in pairs(AttsEnumEx) do
1276 1308 info[v] = (attrs[v] or 0)
1277 1309 end
... ... @@ -1897,6 +1929,53 @@ function RolePlugin.bind(Role)
1897 1929 end
1898 1930 deleteNotify({pattern = pattern})
1899 1931 end
  1932 +
  1933 + local CommonRankTime = toUnixtime("2019010100")
  1934 + local CommonCoef1 = 10000
  1935 + local CommonCoef2 = 10000
  1936 + function Role:updateRankCommon(rankType, rankVal, reserve)
  1937 + if not rankType then return end
  1938 + reserve = reserve or 0
  1939 + local now = skynet.timex()
  1940 + local ct = math.ceil((now - CommonRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年
  1941 + ct = 10000 - ct -- 越早的排名越靠前
  1942 + local score = (rankVal * CommonCoef1 + ct) * CommonCoef2 + reserve
  1943 +
  1944 + local roleId = self:getProperty("id")
  1945 + redisproxy:pipelining(function (red)
  1946 + red:zadd(RANK_COMMON..rankType, score, roleId) --更新分数
  1947 + end)
  1948 + end
  1949 +
  1950 + function Role:getRankInfoCommon(rankType)
  1951 + if not rankType then return end
  1952 + local list = {}
  1953 + local rankKey = RANK_COMMON .. rankType
  1954 + local ids = redisproxy:zrevrange(rankKey, 0 , 99, "WITHSCORES")
  1955 + for i = 1, #ids, 2 do
  1956 + local roleId = tonumber(ids[i])
  1957 + local rankVal = tonumber(ids[i + 1])
  1958 + rankVal = math.floor(math.floor(rankVal / CommonCoef2) / CommonCoef1)
  1959 + table.insert(list, {roleId = roleId, player = rankVal})
  1960 + end
  1961 +
  1962 + for _, v in ipairs(list) do
  1963 + local _, curInfo = rpcRole(v.roleId, "friendSInfo")
  1964 + curInfo.ltime = nil
  1965 + curInfo.rankVal = v.player
  1966 + v.player = curInfo
  1967 + end
  1968 +
  1969 + local rank = redisproxy:ZREVRANK(rankKey, self:getProperty("id"))
  1970 + if not rank then
  1971 + rank = -1
  1972 + else
  1973 + rank = rank + 1
  1974 + end
  1975 + return {list = list, rank = rank}
  1976 + end
  1977 +
  1978 +
1900 1979 end
1901 1980  
1902 1981 return RolePlugin
1903 1982 \ No newline at end of file
... ...
src/models/RolePvp.lua
... ... @@ -6,7 +6,12 @@ RolePvp.bind = function (Role)
6 6 local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00
7 7 local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数
8 8 local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异
9   -local PVP_RANK_ROBOT_SCORE = globalCsv.pvp_base_score -- 机器人积分
  9 +local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 初始积分
  10 +
  11 +-- 匹配规则改为以排名来匹配
  12 +local PVP_GET_ROBOT_SCORE = 2400 -- 2400分以下低档位匹配机器人
  13 +local PRE_RANGE_COUNT = 20 -- 每个档位人数
  14 +local NEED_MATCH = 3 --匹配到多少人
10 15  
11 16  
12 17 function Role:unpackPvpScore(score)
... ... @@ -34,7 +39,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId)
34 39 end)
35 40 local myScore = self:unpackPvpScore(redret[1])
36 41 local oldMyRank = tonumber(redret[2] or -2) + 1
37   - local matchScore = PVP_RANK_ROBOT_SCORE
  42 + local matchScore = PVP_RANK_BASE_SCORE
38 43 if isPlayer then
39 44 matchScore = self:unpackPvpScore(redret[3])
40 45 end
... ... @@ -68,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin)
68 73 if isWin then
69 74 local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400)))
70 75 myScore = myScore + scoreChange
71   - matchScore = matchScore - scoreChange
  76 + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3
72 77 else
73 78 local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400)))
74 79 myScore = myScore - scoreChange
... ... @@ -78,7 +83,7 @@ function Role:changePvpScoreCommon(matchId, isWin)
78 83 end
79 84  
80 85 local result = self:changePvpScore(RANK_PVP_COMMON, changeScoreCallback, matchId)
81   - self:refreshPvpMatchC(result[1])
  86 + self:refreshPvpMatchC(result[1], result[5])
82 87 return table.unpack(result)
83 88 end
84 89  
... ... @@ -134,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin)
134 139 if isWin then
135 140 local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000)))
136 141 myScore = myScore + scoreChange
137   - matchScore = matchScore - scoreChange
  142 + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3
138 143 else
139 144 local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000)))
140 145 myScore = myScore - scoreChange
... ... @@ -162,85 +167,50 @@ function Role:changePvpScoreHigh(matchId, isWin)
162 167 })
163 168 end
164 169  
165   - self:refreshPvpMatchH(result[1])
  170 + self:refreshPvpMatchH(result[1], result[5])
166 171 return table.unpack(result)
167 172 end
168 173  
169   -function Role:refreshPvpMatch(score, rankKey)
  174 +function Role:isInPvpRank(rankKey)
  175 + local Fields = {
  176 + [RANK_PVP_COMMON] = "pvpMC",
  177 + [RANK_PVP_HIGHT] = "pvpMH",
  178 + }
  179 + local dbKey = self:getPvpDBKey(rankKey)
  180 + local roleId = self:getProperty("id")
  181 + if redisproxy:zscore(dbKey, roleId) then
  182 + return true
  183 + end
  184 + return false
  185 +end
170 186  
  187 +-- 新的匹配规则
  188 +function Role:refreshPvpMatch(score, rank, rankKey)
171 189 local Fields = {
172 190 [RANK_PVP_COMMON] = "pvpMC",
173 191 [RANK_PVP_HIGHT] = "pvpMH",
174 192 }
175 193 local RobotCsvs = {
176 194 [RANK_PVP_COMMON] = "pvp_robotCsv",
177   - [RANK_PVP_HIGHT] = "pvp_robotCsv",
  195 + [RANK_PVP_HIGHT] = "pvp_robot_groupCsv",
178 196 }
  197 +
179 198 local mField = Fields[rankKey]
180 199 local robotCsv = RobotCsvs[rankKey]
181   - local dbKey = self:getPvpDBKey(rankKey)
182 200  
  201 + local dbKey = self:getPvpDBKey(rankKey)
183 202 local roleId = self:getProperty("id")
184   - score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId))
185   -
186   - local function getPlayers(levels)
  203 + if not score and not rank then
187 204 local redret = redisproxy:pipelining(function(red)
188   - for _, level in ipairs(levels) do
189   - local low, high = table.unpack(level)
190   - red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1")
191   - red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2")
192   - red:ZREVRANK(dbKey, "std_temp1")
193   - red:ZREVRANK(dbKey, "std_temp2")
194   - end
195   - red:zrem(dbKey, "std_temp1", "std_temp2")
  205 + red:zscore(dbKey, roleId)
  206 + red:zrevrank(dbKey, roleId)
196 207 end)
197   -
198   - local PreGetCount = 7
199   - local redret = redisproxy:pipelining(function(red)
200   - for idx, level in ipairs(levels) do
201   - local rank1 = tonumber(redret[(idx - 1) * 4 + 3])
202   - local rank2 = tonumber(redret[(idx - 1) * 4 + 4])
203   - if rank1 - rank2 > PreGetCount then
204   - rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1)
205   - rank1 = rank2 + PreGetCount - 1
206   - end
207   - red:ZREVRANGE(dbKey, rank2, rank1)
208   - end
209   - end)
210   - return redret
211   - end
212   -
213   - local findIdx = #globalCsv.pvp_division
214   - for idx, limit in ipairs(globalCsv.pvp_division) do
215   - if score < limit then
216   - findIdx = idx - 1
217   - break
218   - end
  208 + score = self:unpackPvpScore(redret[1])
  209 + rank = tonumber(redret[2] or -2) + 1
219 210 end
220   - local levels = {
221   - {}, {}, {}
222   - }
223   - if globalCsv.pvp_division[findIdx + 1] then
224   - levels[1] = {globalCsv.pvp_division[findIdx + 1], (globalCsv.pvp_division[findIdx + 2] or 100000000) - 1}
225   - end
226   - levels[2] = {globalCsv.pvp_division[findIdx], (globalCsv.pvp_division[findIdx + 1] or 100000000) - 1}
227   - if globalCsv.pvp_division[findIdx - 1] then
228   - levels[3] = {globalCsv.pvp_division[findIdx - 1], globalCsv.pvp_division[findIdx] - 1}
229   - end
230   - local redirect = {}
231   - for i = #levels , 1, -1 do
232   - if not next(levels[i]) then
233   - table.remove(levels, i)
234   - redirect[i] = -1
235   - for _, v in pairs(redirect) do
236   - redirect[_] = v - 1
237   - end
238   - else
239   - redirect[i] = i
240   - end
241   - end
242   -
243   - local result = getPlayers(levels)
  211 + score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId))
  212 + rank = rank or tonumber(redisproxy:zrevrank(dbKey, roleId) or -2) + 1
  213 +
244 214 local match = self:getProperty(mField)
245 215 local hadPlayer = {[roleId] = 1}
246 216 local hadRobot = {}
... ... @@ -252,97 +222,261 @@ function Role:refreshPvpMatch(score, rankKey)
252 222 end
253 223 end
254 224  
255   - for _, temp in pairs(result) do
256   - for i = #temp, 1, -1 do
257   - local id = tonumber(temp[i])
258   - if hadPlayer[id] then
259   - table.remove(temp, i)
260   - else
261   - temp[i] = id
262   - hadPlayer[id] = 1
263   - end
  225 + local tempMatch = {}
  226 + local needRobot = 0
  227 + -- -1 没有上榜
  228 + if rank == -1 then
  229 + needRobot = NEED_MATCH
  230 + else
  231 + local need = PRE_RANGE_COUNT * NEED_MATCH
  232 + local low, heigh = math.floor(rank - need / 2 - 1), math.floor(rank + need / 2 - 1)
  233 + if low < 0 then
  234 + low = 0
264 235 end
265   - end
266   - -- 增加第几个
267   - local function getPlayer(idx)
268   - for i = idx, 3 do
269   - if redirect[i] ~= -1 then
270   - local curR = result[redirect[i]] or {}
271   - if next(curR) then
272   - local curIdx = math.randomInt(1, #curR)
273   - local objId = curR[curIdx]
274   - table.remove(curR, curIdx)
275   - return objId
276   - end
  236 + print(low, heigh)
  237 + local rangeIds = redisproxy:ZREVRANGE(dbKey, low, heigh)
  238 + local lastRangeIds = {}
  239 + for idx, one in ipairs(rangeIds) do
  240 + local cid = tonumber(one)
  241 + if not hadPlayer[cid] then
  242 + lastRangeIds[#lastRangeIds + 1] = cid
277 243 end
278 244 end
279   - end
280   -
281   - local tempMatch = {}
282   - local curCount = 0
283   - for i = 1, 3 do
284   - local objId = getPlayer(i)
285   - if objId then
286   - tempMatch[i] = {t = 1, id = objId}
287   - curCount = curCount + 1
  245 + if score < PVP_GET_ROBOT_SCORE then
  246 + needRobot = 1
288 247 end
289   - end
290   -
291   - -- 正常的玩家不够了 低一档继续
292   - if curCount < 3 then
293   - local level = nil
294   - if globalCsv.pvp_division[findIdx - 2] then
295   - level = {globalCsv.pvp_division[findIdx - 2], globalCsv.pvp_division[findIdx - 1] - 1}
  248 + local len = #lastRangeIds
  249 + if len < NEED_MATCH then
  250 + needRobot = NEED_MATCH - len
296 251 end
297   - if level then
298   - local result = getPlayers({level})[1] or {}
299   - for i = #result, 1, -1 do
300   - local id = tonumber(result[i])
301   - if hadPlayer[id] then
302   - table.remove(result, i)
303   - else
304   - result[i] = id
305   - hadPlayer[id] = 1
306   - end
  252 + local needPlayer = NEED_MATCH - needRobot
  253 + if needPlayer > 0 then
  254 + local pre = math.floor(len / needPlayer)
  255 + for i = 1, needPlayer do
  256 + local idx = math.randomInt((i - 1) * pre + 1, i * pre)
  257 + tempMatch[#tempMatch + 1] = {t = 1, id = lastRangeIds[idx]}
307 258 end
  259 + end
308 260  
309   - if next(result) then
310   - for i = curCount + 1, 3 do
311   - local curIdx = math.randomInt(1, #result)
312   - local objId = result[curIdx]
313   - table.remove(result, curIdx)
314   - tempMatch[i] = {t = 1, id = objId}
315   - curCount = curCount + 1
316   - if not next(result) then
317   - break
318   - end
319   - end
  261 + end
  262 + if needRobot > 0 then
  263 + local RobotPoolCount = 20
  264 + local max = #csvdb[robotCsv]
  265 + local min = 1
  266 + local mid
  267 + while min <= max do
  268 + mid = math.floor((min + max) / 2)
  269 + local tempPt = csvdb[robotCsv][mid].pt
  270 + if score == tempPt then
  271 + break
  272 + elseif score > tempPt then
  273 + min = mid + 1
  274 + elseif score < tempPt then
  275 + max = mid - 1
320 276 end
321 277 end
322   - end
323   -
324   - -- 增加机器人
325   - if curCount < 3 then
326   - for i = curCount + 1, 3 do
327   - while true do
328   - local id = math.randomInt(1, #csvdb[robotCsv])
329   - if not hadRobot[id] then
330   - hadRobot[id] = 1
331   - tempMatch[i] = {t = 2, id = id}
332   - break
333   - end
  278 + assert(mid, "pvp no robot " .. robotCsv)
  279 + local low = mid - RobotPoolCount / 2
  280 + local heigh = mid + RobotPoolCount / 2
  281 + if low < 1 then
  282 + heigh = heigh + (1 - low)
  283 + low = 1
  284 + end
  285 + if heigh > #csvdb[robotCsv] then
  286 + heigh = #csvdb[robotCsv]
  287 + end
  288 + local pools = {}
  289 + for i = low, heigh do
  290 + if not hadRobot[i] then
  291 + pools[#pools + 1] = i
334 292 end
335 293 end
  294 + local pre = math.floor(#pools / needRobot)
  295 + for i = 1, needRobot do
  296 + local idx = math.randomInt((i - 1) * pre + 1, i * pre)
  297 + tempMatch[#tempMatch + 1] = {t = 2, id = pools[idx]}
  298 + end
336 299 end
337 300 self:setProperty(mField, tempMatch)
338 301 end
339 302  
340   -function Role:refreshPvpMatchC(score)
341   - self:refreshPvpMatch(score, RANK_PVP_COMMON)
  303 +-- function Role:refreshPvpMatch(score, rank, rankKey)
  304 +
  305 +-- local Fields = {
  306 +-- [RANK_PVP_COMMON] = "pvpMC",
  307 +-- [RANK_PVP_HIGHT] = "pvpMH",
  308 +-- }
  309 +-- local RobotCsvs = {
  310 +-- [RANK_PVP_COMMON] = "pvp_robotCsv",
  311 +-- [RANK_PVP_HIGHT] = "pvp_robotCsv",
  312 +-- }
  313 +-- local mField = Fields[rankKey]
  314 +-- local robotCsv = RobotCsvs[rankKey]
  315 +-- local dbKey = self:getPvpDBKey(rankKey)
  316 +
  317 +-- local roleId = self:getProperty("id")
  318 +-- score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId))
  319 +
  320 +-- local function getPlayers(levels)
  321 +-- local redret = redisproxy:pipelining(function(red)
  322 +-- for _, level in ipairs(levels) do
  323 +-- local low, high = table.unpack(level)
  324 +-- red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1")
  325 +-- red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2")
  326 +-- red:ZREVRANK(dbKey, "std_temp1")
  327 +-- red:ZREVRANK(dbKey, "std_temp2")
  328 +-- end
  329 +-- red:zrem(dbKey, "std_temp1", "std_temp2")
  330 +-- end)
  331 +
  332 +-- local PreGetCount = 7
  333 +-- local redret = redisproxy:pipelining(function(red)
  334 +-- for idx, level in ipairs(levels) do
  335 +-- local rank1 = tonumber(redret[(idx - 1) * 4 + 3])
  336 +-- local rank2 = tonumber(redret[(idx - 1) * 4 + 4])
  337 +-- if rank1 - rank2 > PreGetCount then
  338 +-- rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1)
  339 +-- rank1 = rank2 + PreGetCount - 1
  340 +-- end
  341 +-- red:ZREVRANGE(dbKey, rank2, rank1)
  342 +-- end
  343 +-- end)
  344 +-- return redret
  345 +-- end
  346 +
  347 +-- local findIdx = #globalCsv.pvp_division
  348 +-- for idx, limit in ipairs(globalCsv.pvp_division) do
  349 +-- if score < limit then
  350 +-- findIdx = idx - 1
  351 +-- break
  352 +-- end
  353 +-- end
  354 +-- local levels = {
  355 +-- {}, {}, {}
  356 +-- }
  357 +-- if globalCsv.pvp_division[findIdx + 1] then
  358 +-- levels[1] = {globalCsv.pvp_division[findIdx + 1], (globalCsv.pvp_division[findIdx + 2] or 100000000) - 1}
  359 +-- end
  360 +-- levels[2] = {globalCsv.pvp_division[findIdx], (globalCsv.pvp_division[findIdx + 1] or 100000000) - 1}
  361 +-- if globalCsv.pvp_division[findIdx - 1] then
  362 +-- levels[3] = {globalCsv.pvp_division[findIdx - 1], globalCsv.pvp_division[findIdx] - 1}
  363 +-- end
  364 +-- local redirect = {}
  365 +-- for i = #levels , 1, -1 do
  366 +-- if not next(levels[i]) then
  367 +-- table.remove(levels, i)
  368 +-- redirect[i] = -1
  369 +-- for _, v in pairs(redirect) do
  370 +-- redirect[_] = v - 1
  371 +-- end
  372 +-- else
  373 +-- redirect[i] = i
  374 +-- end
  375 +-- end
  376 +
  377 +-- local result = getPlayers(levels)
  378 +-- local match = self:getProperty(mField)
  379 +-- local hadPlayer = {[roleId] = 1}
  380 +-- local hadRobot = {}
  381 +-- for _, one in pairs(match) do
  382 +-- if one.t == 1 then
  383 +-- hadPlayer[one.id] = 1
  384 +-- elseif one.t == 2 then
  385 +-- hadRobot[one.id] = 1
  386 +-- end
  387 +-- end
  388 +
  389 +-- for _, temp in pairs(result) do
  390 +-- for i = #temp, 1, -1 do
  391 +-- local id = tonumber(temp[i])
  392 +-- if hadPlayer[id] then
  393 +-- table.remove(temp, i)
  394 +-- else
  395 +-- temp[i] = id
  396 +-- hadPlayer[id] = 1
  397 +-- end
  398 +-- end
  399 +-- end
  400 +-- -- 增加第几个
  401 +-- local function getPlayer(idx)
  402 +-- for i = idx, 3 do
  403 +-- if redirect[i] ~= -1 then
  404 +-- local curR = result[redirect[i]] or {}
  405 +-- if next(curR) then
  406 +-- local curIdx = math.randomInt(1, #curR)
  407 +-- local objId = curR[curIdx]
  408 +-- table.remove(curR, curIdx)
  409 +-- return objId
  410 +-- end
  411 +-- end
  412 +-- end
  413 +-- end
  414 +
  415 +-- local tempMatch = {}
  416 +-- local curCount = 0
  417 +-- for i = 1, 3 do
  418 +-- local objId = getPlayer(i)
  419 +-- if objId then
  420 +-- tempMatch[i] = {t = 1, id = objId}
  421 +-- curCount = curCount + 1
  422 +-- end
  423 +-- end
  424 +
  425 +-- -- 正常的玩家不够了 低一档继续
  426 +-- if curCount < 3 then
  427 +-- local level = nil
  428 +-- if globalCsv.pvp_division[findIdx - 2] then
  429 +-- level = {globalCsv.pvp_division[findIdx - 2], globalCsv.pvp_division[findIdx - 1] - 1}
  430 +-- end
  431 +-- if level then
  432 +-- local result = getPlayers({level})[1] or {}
  433 +-- for i = #result, 1, -1 do
  434 +-- local id = tonumber(result[i])
  435 +-- if hadPlayer[id] then
  436 +-- table.remove(result, i)
  437 +-- else
  438 +-- result[i] = id
  439 +-- hadPlayer[id] = 1
  440 +-- end
  441 +-- end
  442 +
  443 +-- if next(result) then
  444 +-- for i = curCount + 1, 3 do
  445 +-- local curIdx = math.randomInt(1, #result)
  446 +-- local objId = result[curIdx]
  447 +-- table.remove(result, curIdx)
  448 +-- tempMatch[i] = {t = 1, id = objId}
  449 +-- curCount = curCount + 1
  450 +-- if not next(result) then
  451 +-- break
  452 +-- end
  453 +-- end
  454 +-- end
  455 +-- end
  456 +-- end
  457 +
  458 +-- -- 增加机器人
  459 +-- if curCount < 3 then
  460 +-- for i = curCount + 1, 3 do
  461 +-- while true do
  462 +-- local id = math.randomInt(1, #csvdb[robotCsv])
  463 +-- if not hadRobot[id] then
  464 +-- hadRobot[id] = 1
  465 +-- tempMatch[i] = {t = 2, id = id}
  466 +-- break
  467 +-- end
  468 +-- end
  469 +-- end
  470 +-- end
  471 +-- self:setProperty(mField, tempMatch)
  472 +-- end
  473 +
  474 +function Role:refreshPvpMatchC(score, rank)
  475 + self:refreshPvpMatch(score, rank, RANK_PVP_COMMON)
342 476 end
343 477  
344   -function Role:refreshPvpMatchH(score)
345   - self:refreshPvpMatch(score, RANK_PVP_HIGHT)
  478 +function Role:refreshPvpMatchH(score, rank)
  479 + self:refreshPvpMatch(score, rank, RANK_PVP_HIGHT)
346 480 end
347 481  
348 482 function Role:getPvpDBKey(ptype)
... ...
src/models/RoleTimeReset.lua
... ... @@ -17,6 +17,11 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
17 17 self:advRandomSupportEffect(not notify)
18 18  
19 19 self:checkExpireItem(not notify)
  20 + local advMine = self:getProperty("advMine")
  21 + if advMine[1] then
  22 + advMine[1].co = nil
  23 + end
  24 + self:setProperty("advMine", advMine)
20 25  
21 26 response.dTask = {}
22 27 response.advSup = self:getProperty("advSup")
... ... @@ -24,10 +29,16 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
24 29 end
25 30  
26 31 ResetFunc["CrossWeek"] = function(self, notify, response)
  32 + local advMine = self:getProperty("advMine")
  33 + if advMine[2] then
  34 + advMine[2].co = nil
  35 + end
27 36 self:setProperties({
28 37 wTask = {},
29 38 dinerS = {},
  39 + advMine = advMine,
30 40 })
  41 +
31 42 response.wTask = {}
32 43 response.dinerS = {}
33 44 end
... ...
src/models/Store.lua
... ... @@ -33,6 +33,8 @@ Store.schema = {
33 33 actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买
34 34  
35 35 bpInfo = {"table", {}}, -- battle pass 探索指令 1={flag=0 为1表示买了,br=""付费领取记录, fr=""免费领取记录},2,3,4
  36 +
  37 + totalRR = {"string", ""}, -- 累计充值奖励领取记录
36 38 }
37 39  
38 40 function Store:updateProperty(params)
... ... @@ -464,6 +466,7 @@ function Store:data()
464 466 --packTrigger = self:getProperty("packTrigger"),
465 467 actGoodsFlag = self:getProperty("actGoodsFlag"),
466 468 bpInfo = self:getProperty("bpInfo"),
  469 + totalRR = self:getProperty("totalRR"),
467 470 }
468 471 end
469 472  
... ...
src/services/globald.lua
... ... @@ -7,6 +7,7 @@ require &quot;shared.init&quot;
7 7 require "utils.init"
8 8 require "RedisKeys"
9 9 require "skynet.manager"
  10 +require "GlobalVar"
10 11  
11 12  
12 13 local ipairs = ipairs
... ... @@ -16,6 +17,7 @@ local string_format = string.format
16 17  
17 18  
18 19 local CHECK_MAIL_STATUS_INTERVAL = 100 * 60
  20 +local CHECK_BATTLE_ACT_CLOSE_INTERVAL = 100 * 1
19 21 local function mailQuene()
20 22 local delayEmail = tonum(redisproxy:hget("autoincrement_set", "delay_email"))
21 23 if delayEmail == 0 then
... ... @@ -91,6 +93,64 @@ local function check_mail_queue()
91 93 skynet.timeout(CHECK_MAIL_STATUS_INTERVAL, check_mail_queue)
92 94 end
93 95  
  96 +-- @desc: 检测关卡活动结束 排行榜奖励发放
  97 +local lastCheckBattleActTs = 0
  98 +local function check_battle_act_close()
  99 + local csvdb = require "shared.csvdata"
  100 + local act = require "models.Activity"
  101 + local st = 0
  102 + local et = 0
  103 + local actId = 0
  104 + local timeNow = skynet.timex()
  105 + for k, v in pairs(csvdb["activity_ctrlCsv"]) do
  106 + if v.showType == act.ActivityType.ChallengeLevel then
  107 + local openTimes = v.time:toArray(false, "=")
  108 + if openTimes[1] ~= "0" then
  109 + st = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME))
  110 + end
  111 + if openTimes[2] ~= "0" then
  112 + et = toUnixtime(openTimes[2]..string_format("%02x", RESET_TIME))
  113 + end
  114 + actId = k
  115 + break
  116 + end
  117 + end
  118 + if st ~= 0 and et ~= 0 and actId ~= 0 then
  119 + -- close
  120 + if lastCheckBattleActTs < et and timeNow >= et then
  121 + -- check rank key exist
  122 + local rankKey = RANK_COMMON..RANK_TYPE.ActBattleBoss
  123 + local flag = redisproxy:exists(rankKey)
  124 + if flag then
  125 + local actData = csvdb["activity_groupCsv"][actId]
  126 + local lastRank = actData[#actData].rank
  127 +
  128 + local ids = redisproxy:zrevrange(rankKey, 0 , lastRank - 1)
  129 + local rankIndex = 0
  130 + for roleId in pairs(ids) do
  131 + rankIndex = rankIndex + 1
  132 + for _, cfg in pairs(actData) do
  133 + if rankIndex <= cfg.rank then
  134 + redisproxy:insertEmail({
  135 + roleId = roleId,
  136 + emailId = cfg.email_1,
  137 + attachments = cfg.reward_1,
  138 + contentPms = {rankIndex},
  139 + })
  140 + break
  141 + end
  142 + end
  143 + end
  144 +
  145 + redisproxy:del(rankKey..":bak")
  146 + redisproxy:rename(rankKey, rankKey..":bak")
  147 + end
  148 + end
  149 + end
  150 + lastCheckBattleActTs = skynet.timex()
  151 + skynet.timeout(CHECK_BATTLE_ACT_CLOSE_INTERVAL, check_battle_act_close)
  152 +end
  153 +
94 154  
95 155  
96 156 local CMD = {}
... ... @@ -115,6 +175,7 @@ end
115 175  
116 176 function CMD.start()
117 177 check_mail_queue()
  178 + check_battle_act_close()
118 179 end
119 180  
120 181 local function __init__()
... ...