Commit bde0b30d911001c38609d335af34448206cb329c

Authored by 熊润斐
2 parents d34562d5 e6dc06cc

Merge branch 'develop' into tr/qa

# 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,13 @@ 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,
220 226  
221 227 Radio_startQuestRpc = 700,
222 228 Radio_finishQuestRpc = 701,
  229 + Radio_cancelQuestRpc = 702,
223 230 }
224 231  
225 232 rpcResponseBegin = 10000
... ...
src/actions/ActivityAction.lua
... ... @@ -263,4 +263,156 @@ 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 + print("-----------------, ", i)
  323 + for id, cfg in pairs(tmpCfg) do
  324 + local num = gachakonInfo[id] or 0
  325 + num = cfg.amount >= num and cfg.amount - num or 0
  326 + cfg.weight = cfg.weight * num
  327 + if cfg.weight > 0 then
  328 + remain = remain + num
  329 + end
  330 + print("num ".. num, id, cfg.weight, cfg.amount)
  331 + end
  332 + if remain == 0 then
  333 + break
  334 + end
  335 + local id = math.randWeight(tmpCfg, "weight")
  336 + if not id then return 4 end
  337 + gachakonInfo[id] = (gachakonInfo[id] or 0) + 1
  338 + local curAward = tmpCfg[id].award:toNumMap()
  339 + for k, v in pairs(curAward) do
  340 + award[k] = (award[k] or 0) + v
  341 + end
  342 + end
  343 +
  344 + for k, v in pairs(cost) do
  345 + cost[k] = v * count
  346 + end
  347 +
  348 + if not role:checkItemEnough(cost) then return 5 end
  349 +
  350 + role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}})
  351 +
  352 + local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}})
  353 + if remain <= count then
  354 + gachakonInfo = {}
  355 + print("hahaha")
  356 + end
  357 + role.activity:updateActData("Gachakon", gachakonInfo)
  358 +
  359 + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change)))
  360 + return true
  361 +end
  362 +
  363 +function _M.hangDropRpc(agent, data)
  364 + local role = agent.role
  365 + local msg = MsgPack.unpack(data)
  366 + local actid = msg.actid
  367 + if not role.activity:isOpenById(actid) then return 1 end
  368 +
  369 + local actCfg = csvdb["activity_putCsv"][actid]
  370 + if not actCfg then return 2 end
  371 +
  372 + local award, period = "", 0
  373 + for i = 1, #actCfg do
  374 + local cfg = actCfg[i]
  375 + if not cfg then
  376 + break
  377 + end
  378 + if cfg.condition ~= "" then
  379 + local arr = cfg.condition:toArray(true, "=")
  380 + local type = arr[1]
  381 + if type == 1 then
  382 + local actId = arr[2]
  383 + local carbonId = arr[3]
  384 + if not role.activity:isOpenById(actid) then return 3 end
  385 + local clInfo = role.activity:getActData("ChallengeLevel") or {}
  386 + if not clInfo[carbonId] then
  387 + break
  388 + end
  389 + end
  390 + end
  391 + award = cfg.reward
  392 + period = cfg.period * 60
  393 + end
  394 + local actData = role.activity:getActData("HangDrop") or 0
  395 + local timeNow = skynet.timex()
  396 + if period == 0 or award == "" then
  397 + return 4
  398 + end
  399 + local num = math.floor((timeNow - actData)/ period)
  400 + num = num > 8 and 8 or num
  401 + if num == 0 then
  402 + return 5
  403 + end
  404 + local reward, change = {}, nil
  405 + for id, value in pairs(award:toNumMap()) do
  406 + reward[id] = value * num
  407 + end
  408 +
  409 + reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}})
  410 +
  411 + role.activity:updateActData("HangDrop", timeNow)
  412 +
  413 + SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change)))
  414 +
  415 + return true
  416 +end
  417 +
266 418 return _M
267 419 \ 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,8 @@ 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})
537 538 return "成功"
538 539 end
539 540  
... ...
src/actions/HeroAction.lua
... ... @@ -585,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data)
585 585 local itemData = csvdb["itemCsv"][itemId]
586 586 if not itemData or itemData.type ~= ItemType.HeroFCommon then return end
587 587 local cost = globalCsv.unit_fragment_cost[itemData.quality]
588   - if not cost or role:getItemCount(itemId) < cost then return end
  588 + if not cost or role:getItemCount(itemId) < cost then return 1 end
589 589  
590 590 local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)]
591   - if not randomData then return end
  591 + if not randomData then return 2 end
592 592  
593 593 local temp = randomData.gift1:randWeight(true)
594   - if not temp or not next(temp) then return end
  594 + if not temp or not next(temp) then return 3 end
595 595  
596 596 role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}})
597   - local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}})
  597 + local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}})
598 598  
599 599  
600 600 SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change)))
... ... @@ -604,7 +604,6 @@ end
604 604 function _M.getResetRewardRpc(agent, data)
605 605 local role = agent.role
606 606 local msg = MsgPack.unpack(data)
607   - local pay = msg.pay
608 607  
609 608 local hero = role.heros[msg.id]
610 609 if not hero then return end
... ... @@ -617,12 +616,30 @@ function _M.getResetRewardRpc(agent, data)
617 616 local tmpLevel = level
618 617 if level <= 1 and talent == "" then return end
619 618  
  619 + local pay = true
620 620 if level <= 60 then
621 621 pay = false
622 622 end
623 623  
624   - if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then
625   - return 1
  624 + if pay then
  625 + local costArr = globalCsv.unit_heroBack_cost:toArray(true, "=")
  626 + local itemCount = role:getItemCount(costArr[1])
  627 + local totalCost = {}
  628 + if itemCount >= costArr[2] then
  629 + totalCost[costArr[1]] = costArr[2]
  630 + else
  631 + local diamond = (costArr[2] - itemCount) * costArr[3]
  632 + if role:getItemCount(ItemId.Diamond) < diamond then
  633 + return 1
  634 + end
  635 + totalCost[costArr[1]] = itemCount
  636 + totalCost[ItemId.Diamond] = diamond
  637 + end
  638 +
  639 + --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then
  640 + -- return 1
  641 + --end
  642 + role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}})
626 643 end
627 644  
628 645 local reward = {}
... ... @@ -677,10 +694,10 @@ function _M.getResetRewardRpc(agent, data)
677 694 })
678 695 hero:mylog({desc = "resetHero"})
679 696  
680   - local coef = globalCsv.unit_back_discount
681   - coef = (pay or tmpLevel <= 60) and 1 or coef
  697 + --local coef = globalCsv.unit_back_discount
  698 + --coef = (pay or tmpLevel <= 60) and 1 or coef
682 699 for itemId, count in pairs(reward) do
683   - reward[itemId] = math.floor(count * coef)
  700 + reward[itemId] = count
684 701 end
685 702 local change
686 703 reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
... ... @@ -699,11 +716,14 @@ function _M.drawHeroRpc(agent, data)
699 716 local msg = MsgPack.unpack(data)
700 717  
701 718 if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end
702   - local btype = msg.pool -- 1 2 3 卡池类型
  719 + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池
703 720 local subType = msg.subType or 1-- 定向卡池需要传 子类型
704 721 local drawType = msg.type -- 1 单抽 2 十连
705 722 if btype ~= 1 then
706 723 subType = 1
  724 + if btype == 4 and role:getProperty("newerDraw") >= 10 then
  725 + subType = 2
  726 + end
707 727 end
708 728  
709 729 if btype == 1 then
... ... @@ -724,23 +744,32 @@ function _M.drawHeroRpc(agent, data)
724 744  
725 745 -- 计算抽卡消耗品
726 746 local cost = {}
727   - local lastCount = drawCount[drawType]
728   - for _, costType in ipairs({"draw_card", "draw_coin"}) do
  747 + if buildTypeData["draw_coin_1"] == "" then
  748 + return 11
  749 + end
  750 + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=")
  751 +
  752 + local isEnough = true
  753 + for _, costType in ipairs({"draw_card_"}) do
  754 + costType = costType..drawCount[drawType]
729 755 if buildTypeData[costType] ~= "" then
730 756 local curCost = buildTypeData[costType]:toArray(true, "=")
731 757 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
  758 + if hadCount >= curCost[2] then
  759 + cost[curCost[1]] = curCost[2]
736 760 break
737   - elseif curCount > 0 then
738   - cost[curCost[1]] = curCost[2] * curCount
739   - lastCount = lastCount - curCount
  761 + else
  762 + cost[curCost[1]] = hadCount
  763 + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2]
  764 + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then
  765 + isEnough = false
  766 + break
  767 + end
  768 + cost[diamondCost[1]] = diamondCost[2]
740 769 end
741 770 end
742 771 end
743   - if lastCount > 0 then -- 钱不够
  772 + if isEnough == false then -- 钱不够
744 773 return 4
745 774 end
746 775  
... ... @@ -803,6 +832,9 @@ function _M.drawHeroRpc(agent, data)
803 832 --print(poolId, rand_v, weight, up_pool, values[1])
804 833 if rand_v < weight and up_pool then
805 834 up_pool = up_pool:toArray(true, "=")
  835 + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子
  836 + up_pool = role:getProperty("wishPool")
  837 + end
806 838 for k, v in ipairs(up_pool) do
807 839 resultPool[v] = {1}
808 840 end
... ... @@ -868,8 +900,14 @@ function _M.drawHeroRpc(agent, data)
868 900 end
869 901 end
870 902  
871   - if itemData.quality >= HeroQuality.SR then
872   - floorHeroCount = 0
  903 + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池
  904 + if itemData.quality == HeroQuality.SSR then
  905 + floorHeroCount = 0
  906 + end
  907 + else
  908 + if itemData.quality >= HeroQuality.SR then
  909 + floorHeroCount = 0
  910 + end
873 911 end
874 912  
875 913 if role:isHaveHero(itemData.id - ItemStartId.Hero) then
... ... @@ -892,6 +930,11 @@ function _M.drawHeroRpc(agent, data)
892 930 role:setProperty("floorHero", floorHero)
893 931 end
894 932  
  933 + if btype == 4 then
  934 + local newCount = role:getProperty("newerDraw")
  935 + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]})
  936 + end
  937 +
895 938 role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
896 939 if ssrCount > 0 then
897 940 role:checkTaskEnter("DrawSSR", {count = ssrCount})
... ... @@ -1057,4 +1100,32 @@ function _M.itemComposeRpc(agent, data)
1057 1100 return true
1058 1101 end
1059 1102  
  1103 +function _M.setWishPoolRpc(agent, data)
  1104 + local role = agent.role
  1105 + local msg = MsgPack.unpack(data)
  1106 +
  1107 + local heros = msg.heros
  1108 + if #heros > 3 then return 1 end
  1109 +
  1110 + for _, heroId in pairs(heros) do
  1111 + local cfg = csvdb["build_poolCsv"][heroId]
  1112 + if not cfg then return 2 end
  1113 +
  1114 + local buildTypeData = csvdb["build_typeCsv"][5]
  1115 + if not buildTypeData then return 3 end
  1116 + local poolMap = buildTypeData["pool"]:toNumMap()
  1117 + local poolId = poolMap[1]
  1118 + if not poolId then return 4 end
  1119 +
  1120 + if cfg["pool_"..poolId] == 0 then
  1121 + return 5
  1122 + end
  1123 + end
  1124 +
  1125 + role:updateProperty({field="wishPool", value = heros})
  1126 +
  1127 + SendPacket(actionCodes.Hero_setWishPoolRpc, "")
  1128 + return true
  1129 +end
  1130 +
1060 1131 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
... ... @@ -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
... ...
1   -Subproject commit a2598231ccc5e16da1a27f976602871f30fcd035
  1 +Subproject commit 295feade86593a4793972e2cd2d83135d8aee247
... ...
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)
... ... @@ -409,12 +428,68 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
409 428 -- end,
410 429 }
411 430  
  431 +-- 兑换
  432 +activityFunc[Activity.ActivityType.Exchange] = {
  433 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  434 + local actData = self:getActData(actType) or {}
  435 + actData[actId] = {}
  436 + self:updateActData(actType, actData, not notify)
  437 + end,
  438 + ["crossDay"] = function(self, actType, notify, actId)
  439 + local actData = self:getActData(actType) or {}
  440 + local lastTs = actData["ts"] or 0
  441 + local timeNow = skynet.timex()
  442 + local cfg = csvdb["activity_ctrlCsv"][actId]
  443 + if not cfg then return end
  444 + local refreshTimes = cfg.condition2:toArray(false, "=")
  445 + for i = 1, #refreshTimes do
  446 + local rt = toUnixtime(refreshTimes[1]..string_format("%02x", RESET_TIME))
  447 + if timeNow >= rt and rt > lastTs then
  448 + lastTs = rt
  449 + actData = {}
  450 + end
  451 + end
  452 + if next(actData) then
  453 + actData["ts"] = lastTs
  454 + self:updateActData(actType, actData, not notify)
  455 + end
  456 + end,
  457 + ["close"] = function(self, actType, notify, actId)
  458 + local actData = self:getActData(actType) or {}
  459 + actData[actId] = nil
  460 + self:updateActData(actType, actData, not notify)
  461 + end,
  462 +}
  463 +
  464 +-- 扭蛋机
  465 +activityFunc[Activity.ActivityType.Gachakon] = {
  466 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  467 + self:updateActData(actType, {}, not notify)
  468 + end,
  469 + ["crossDay"] = function(self, actType, notify)
  470 + self:updateActData(actType, {}, not notify)
  471 + end,
  472 +}
  473 +
  474 +-- 挂机掉落
  475 +activityFunc[Activity.ActivityType.HangDrop] = {
  476 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  477 + local actime = self:getProperty("actime")
  478 + local startTime = actime[actId]
  479 + local actData = self:getActData(actType) or 0
  480 + local cfg = csvdb["activity_putCsv"][actId]
  481 + if not cfg then return end
  482 + actData = startTime
  483 + self:updateActData(actType, actData, not notify)
  484 + end
  485 +}
  486 +
412 487 function Activity:initActivity(actId, isCrossDay, notify)
413 488 local actData = csvdb["activity_ctrlCsv"][actId]
414 489 if not actData then return end
415 490 local actType = actData.showType
416 491 if activityFunc[actType] and activityFunc[actType]['close'] then
417   - activityFunc[actType]["init"](self, actType, isCrossDay, notify)
  492 + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId)
418 493 end
419 494 end
420 495  
... ... @@ -423,7 +498,8 @@ function Activity:closeActivity(actId, notify, notUpdateAct)
423 498 if not actData then return end
424 499 local actType = actData.showType
425 500 if activityFunc[actType] and activityFunc[actType]['close'] then
426   - activityFunc[actType]["close"](self, actType, notify)
  501 + activityFunc[actType]["close"](self, actType, notify, actId)
  502 + self:recycleActItem(actId)
427 503 end
428 504 if Activity.schema["act".. actType] then
429 505 self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct)
... ... @@ -436,7 +512,7 @@ function Activity:refreshDailyData(notify)
436 512 if status and actData then
437 513 local actType = actData.showType
438 514 if activityFunc[actType] and activityFunc[actType]['crossDay'] then
439   - activityFunc[actType]["crossDay"](self, actType, notify)
  515 + activityFunc[actType]["crossDay"](self, actType, notify, actId)
440 516 end
441 517 end
442 518 end
... ... @@ -453,8 +529,8 @@ end
453 529 -- 获取此次挂机掉落翻倍时长
454 530 function Activity:getActHangDoubleTime(lastTs, nowTs)
455 531 local type = "DoubleDrop"
456   - local actId = checkActivityType(type)
457   - local isOpen = self:isOpen(type)
  532 + --local actId = checkActivityType(type)
  533 + local isOpen, actId = self:isOpen(type)
458 534 local openTs = self:getProperty("actime")[actId] or 0
459 535 local timeNow = skynet.timex()
460 536 lastTs = math.max(lastTs, openTs)
... ... @@ -529,5 +605,33 @@ function Activity:getPaySignReward()
529 605 --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change)))
530 606 end
531 607  
  608 +-- 回收活动道具
  609 +function Activity:recycleActItem(actId)
  610 + local role = self.owner
  611 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  612 + if not actCfg then return end
  613 + local gift = {}
  614 + local costs = {}
  615 + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do
  616 + local fromId, toId, toNum = arr[1], arr[2], arr[3]
  617 + local itemCount = role:getItemCount(fromId)
  618 + if itemCount > 0 then
  619 + costs[fromId] = (costs[fromId] or 0) + itemCount
  620 + gift[toId] = toNum * itemCount
  621 + end
  622 + end
  623 + if next(costs) then
  624 + local itemStr = ""
  625 + for k, v in pairs(costs) do
  626 + if itemStr ~= "" then
  627 + itemStr = itemStr .. " "
  628 + end
  629 + itemStr = itemStr .. k .. "=" .. v
  630 + end
  631 + role:costItems(costs, {log = {desc = "actRecycle"}})
  632 + role:sendMail(actCfg.recycle_email, nil, gift, {itemStr})
  633 + end
  634 +end
  635 +
532 636  
533 637 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/RoleLog.lua
... ... @@ -42,6 +42,11 @@ 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, -- 掉落活动奖励
45 50  
46 51  
47 52 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
... ...
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  
... ...