Commit d93ec42cb3decdd446e835d3820e6f1eabfc362b
Merge branch 'develop' of 120.26.43.151:wasteland/server into develop
Showing
9 changed files
with
305 additions
and
148 deletions
Show diff stats
src/RedisKeys.lua
@@ -12,6 +12,8 @@ R_RUNE = "role:%d:rune:%d" -- 符文详细信息 | @@ -12,6 +12,8 @@ R_RUNE = "role:%d:rune:%d" -- 符文详细信息 | ||
12 | R_EMAIL = "role:%d:emailIds" --邮件列表 | 12 | R_EMAIL = "role:%d:emailIds" --邮件列表 |
13 | R_EMAIL_ITEM = "email:%d:%d" --邮件 | 13 | R_EMAIL_ITEM = "email:%d:%d" --邮件 |
14 | R_STORE = "role:%d:store" -- 商店 | 14 | R_STORE = "role:%d:store" -- 商店 |
15 | +R_ORDERS = "role:%d:orders" -- 订单 | ||
16 | +R_ORDER = "order:%d:%d" | ||
15 | 17 | ||
16 | 18 | ||
17 | -- rank | 19 | -- rank |
src/actions/HangAction.lua
@@ -498,10 +498,53 @@ function _M.buyBonusCountRpc(agent, data) | @@ -498,10 +498,53 @@ function _M.buyBonusCountRpc(agent, data) | ||
498 | return true | 498 | return true |
499 | end | 499 | end |
500 | 500 | ||
501 | +local function bonusWinReward(role, bonusData, bwin, count) | ||
502 | + count = count or 1 | ||
503 | + local open, actId = role.activity:isOpen("BonusDouble") | ||
504 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
505 | + local extraCnt = role.storeData:getBonusExtraFightCount() | ||
506 | + | ||
507 | + local coef = 1 | ||
508 | + if open and actData then | ||
509 | + coef = tonumber(actData.condition2) | ||
510 | + end | ||
511 | + local bonusC = role.dailyData:getProperty("bonusC") | ||
512 | + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | ||
513 | + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end | ||
514 | + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | ||
515 | + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | ||
516 | + | ||
517 | + local reward, change | ||
518 | + reward = bonusData.reward:toNumMap() | ||
519 | + for itemId, c in pairs(reward) do | ||
520 | + reward[itemId] = c * count | ||
521 | + end | ||
522 | + for i = 1, count do | ||
523 | + local chance = bonusData.chance:randWeight(true) | ||
524 | + if chance[1] ~= 0 then | ||
525 | + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | ||
526 | + end | ||
527 | + end | ||
528 | + | ||
529 | + for k, v in pairs(reward) do | ||
530 | + reward[k] = v * (coef > 1 and actData.condition or 1) | ||
531 | + end | ||
532 | + | ||
533 | + if bwin then -- 满星 额外奖励 | ||
534 | + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do | ||
535 | + reward[k] = (reward[k] or 0) + v | ||
536 | + end | ||
537 | + end | ||
538 | + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | ||
539 | + role:checkTaskEnter("BonusPass", {id = id, count = count}) | ||
540 | + return true, reward, change | ||
541 | +end | ||
542 | + | ||
501 | function _M.startBonusBattleRpc(agent, data) | 543 | function _M.startBonusBattleRpc(agent, data) |
502 | local role = agent.role | 544 | local role = agent.role |
503 | local msg = MsgPack.unpack(data) | 545 | local msg = MsgPack.unpack(data) |
504 | local id = msg.id | 546 | local id = msg.id |
547 | + local count = msg.count or 1 | ||
505 | 548 | ||
506 | local open, actId = role.activity:isOpen("BonusDouble") | 549 | local open, actId = role.activity:isOpen("BonusDouble") |
507 | 550 | ||
@@ -516,9 +559,6 @@ function _M.startBonusBattleRpc(agent, data) | @@ -516,9 +559,6 @@ function _M.startBonusBattleRpc(agent, data) | ||
516 | if not bonusData then return 3 end | 559 | if not bonusData then return 3 end |
517 | if not role:checkHangPass(bonusData.unlock) then return 4 end | 560 | if not role:checkHangPass(bonusData.unlock) then return 4 end |
518 | 561 | ||
519 | - local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | ||
520 | - if not next(bTeam) then return 5 end | ||
521 | - | ||
522 | local bonusC = role.dailyData:getProperty("bonusC") | 562 | local bonusC = role.dailyData:getProperty("bonusC") |
523 | bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | 563 | bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} |
524 | 564 | ||
@@ -529,15 +569,24 @@ function _M.startBonusBattleRpc(agent, data) | @@ -529,15 +569,24 @@ function _M.startBonusBattleRpc(agent, data) | ||
529 | if open and actData then | 569 | if open and actData then |
530 | coef = tonumber(actData.condition2) | 570 | coef = tonumber(actData.condition2) |
531 | end | 571 | end |
572 | + | ||
573 | + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end | ||
532 | 574 | ||
533 | - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end | ||
534 | - | 575 | + local bonusStar = role:getProperty("bonusStar") |
576 | + if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then | ||
577 | + local status, reward, change = bonusWinReward(role, bonusData, nil, count) | ||
578 | + if not status then return 10 * (reward or 0) end | ||
579 | + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) | ||
580 | + else | ||
581 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | ||
582 | + if not next(bTeam) then return 5 end | ||
583 | + role.__bonusBattleCache = { | ||
584 | + key = tostring(math.random()), | ||
585 | + id = id, | ||
586 | + } | ||
587 | + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) | ||
588 | + end | ||
535 | 589 | ||
536 | - role.__bonusBattleCache = { | ||
537 | - key = tostring(math.random()), | ||
538 | - id = id, | ||
539 | - } | ||
540 | - SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) | ||
541 | return true | 590 | return true |
542 | end | 591 | end |
543 | 592 | ||
@@ -548,14 +597,7 @@ function _M.endBonusBattleRpc(agent, data) | @@ -548,14 +597,7 @@ function _M.endBonusBattleRpc(agent, data) | ||
548 | local key = msg.key | 597 | local key = msg.key |
549 | local starNum = msg.starNum | 598 | local starNum = msg.starNum |
550 | if not role.__bonusBattleCache then return 1 end | 599 | if not role.__bonusBattleCache then return 1 end |
551 | - local open, actId = role.activity:isOpen("BonusDouble") | ||
552 | - local actData = csvdb["activity_ctrlCsv"][actId] | ||
553 | - local extraCnt = role.storeData:getBonusExtraFightCount() | ||
554 | - | ||
555 | - local coef = 1 | ||
556 | - if open and actData then | ||
557 | - coef = tonumber(actData.condition2) | ||
558 | - end | 600 | + |
559 | 601 | ||
560 | if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then | 602 | if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then |
561 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1})) | 603 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1})) |
@@ -564,24 +606,79 @@ function _M.endBonusBattleRpc(agent, data) | @@ -564,24 +606,79 @@ function _M.endBonusBattleRpc(agent, data) | ||
564 | local bonusData = csvdb["bonus_battleCsv"][id] | 606 | local bonusData = csvdb["bonus_battleCsv"][id] |
565 | 607 | ||
566 | local reward, change | 608 | local reward, change |
609 | + | ||
610 | + local bonusStar = role:getProperty("bonusStar") | ||
611 | + local curStar = 0 | ||
567 | if starNum and starNum > 0 then | 612 | if starNum and starNum > 0 then |
568 | -- 胜利扣除次数 | 613 | -- 胜利扣除次数 |
569 | - local bonusC = role.dailyData:getProperty("bonusC") | ||
570 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | ||
571 | - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 3 end | ||
572 | - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 | ||
573 | - role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | ||
574 | - | ||
575 | - reward = bonusData.reward:toNumMap() | ||
576 | - local chance = bonusData.chance:randWeight(true) | ||
577 | - if chance[1] ~= 0 then | ||
578 | - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | 614 | + |
615 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | ||
616 | + local herosInfo = role:getTeamHerosInfo(bTeam.heros) | ||
617 | + | ||
618 | + local check = {} | ||
619 | + -- 1 通关 | ||
620 | + check[1] = function(_) | ||
621 | + return true | ||
622 | + end | ||
623 | + -- 2 阵亡人数 <= N | ||
624 | + check[2] = function(_, cond) | ||
625 | + return msg.info.dead and msg.info.dead <= cond | ||
626 | + end | ||
627 | + -- 3 全员存活 | ||
628 | + check[3] = function(_) | ||
629 | + return msg.info.dead and msg.info.dead == 0 | ||
630 | + end | ||
631 | + -- 4 指定种族 >= N | ||
632 | + check[4] = function(_, cond) | ||
633 | + local count = 0 | ||
634 | + for _, one in pairs(herosInfo) do | ||
635 | + local heroData = csv["unitCsv"][one.type] | ||
636 | + if heroData.camp == cond then | ||
637 | + count = count + 1 | ||
638 | + end | ||
639 | + end | ||
640 | + return count >= cond | ||
579 | end | 641 | end |
580 | - for k, v in pairs(reward) do | ||
581 | - reward[k] = v * (coef > 1 and actData.condition or 1) | 642 | + -- 5 指定职业 >= N |
643 | + check[5] = function(_, cond) | ||
644 | + local count = 0 | ||
645 | + for _, one in pairs(herosInfo) do | ||
646 | + local heroData = csv["unitCsv"][one.type] | ||
647 | + if heroData.job == cond then | ||
648 | + count = count + 1 | ||
649 | + end | ||
650 | + end | ||
651 | + return count >= cond | ||
582 | end | 652 | end |
583 | - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | ||
584 | - role:checkTaskEnter("BonusPass", {id = id}) | 653 | + -- 6 含有指定角色 |
654 | + check[6] = function(_, cond) | ||
655 | + for _, one in pairs(herosInfo) do | ||
656 | + if one.type == cond then | ||
657 | + return true | ||
658 | + end | ||
659 | + end | ||
660 | + return false | ||
661 | + end | ||
662 | + -- 7 通关耗时 <= X 秒 msg.info.atime | ||
663 | + check[7] = function(_, cond) | ||
664 | + return msg.info.atime and msg.info.atime <= cond | ||
665 | + end | ||
666 | + curStar = 0 | ||
667 | + local sweepConds = bonusData.sweep_condition:toTableArray(true) | ||
668 | + for i, cond in ipairs(sweepConds) do | ||
669 | + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then | ||
670 | + curStar = curStar + (1 << (i - 1)) | ||
671 | + end | ||
672 | + end | ||
673 | + local status | ||
674 | + status, reward, change = bonusWinReward(role, bonusData, curStar >= (1 << #sweepConds) - 1) | ||
675 | + if not status then return 10 + (reward or 0) end | ||
676 | + else | ||
677 | + curStar = 0 | ||
678 | + end | ||
679 | + if curStar ~= bonusStar[id] then | ||
680 | + bonusStar[id] = curStar | ||
681 | + role:updateProperty({field = "bonusStar", value = bonusStar}) | ||
585 | end | 682 | end |
586 | 683 | ||
587 | role:checkBattle("bonus", { | 684 | role:checkBattle("bonus", { |
src/actions/StoreAction.lua
1 | local _M = {} | 1 | local _M = {} |
2 | 2 | ||
3 | -local serverId = tonumber(skynet.getenv("servId")) | ||
4 | local md5 = require "md5" | 3 | local md5 = require "md5" |
5 | 4 | ||
6 | -local function makeOrder(role, rechargeId) | ||
7 | - local roleId = role:getProperty("id") | ||
8 | - local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | ||
9 | - if not rechargeData then | ||
10 | - skynet.error("recharge id not exist", rechargeId) | ||
11 | - return "" | ||
12 | - end | ||
13 | - local limit = rechargeData.limit | ||
14 | - local rechargeRecord = role:getProperty("payR") or {} | ||
15 | - if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then | ||
16 | - skynet.error(string.format("recharge id:%d count over limit, user id:%d", rechargeId, roleId)) | ||
17 | - return "" | ||
18 | - end | ||
19 | - | ||
20 | - local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) | ||
21 | - local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId) | ||
22 | - local orderKey = string.format("order:%d:%d", roleId, orderId) | ||
23 | - redisproxy:del(orderKey) | ||
24 | - local order = require("models.Order").new({ | ||
25 | - key = orderKey, | ||
26 | - order = partnerOrderId, | ||
27 | - rechargeId = rechargeId, | ||
28 | - }) | ||
29 | - order:create() | ||
30 | - redisproxy:sadd(string.format("role:%d:orders", roleId), partnerOrderId) | ||
31 | - return partnerOrderId | ||
32 | -end | ||
33 | - | ||
34 | -- 入口在正式服关闭 -- mock 充值 | 5 | -- 入口在正式服关闭 -- mock 充值 |
35 | function _M.rechargeRpc(agent , data) | 6 | function _M.rechargeRpc(agent , data) |
36 | local role = agent.role | 7 | local role = agent.role |
@@ -41,7 +12,7 @@ function _M.rechargeRpc(agent , data) | @@ -41,7 +12,7 @@ function _M.rechargeRpc(agent , data) | ||
41 | local roleId = role:getProperty("id") | 12 | local roleId = role:getProperty("id") |
42 | 13 | ||
43 | --创建订单号 | 14 | --创建订单号 |
44 | - local partnerOrderId = makeOrder(role, id) | 15 | + local partnerOrderId = role:getPurchaseOrder(id) |
45 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) | 16 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) |
46 | 17 | ||
47 | 18 | ||
@@ -90,7 +61,7 @@ function _M.googleRechargeRpc(agent, data) | @@ -90,7 +61,7 @@ function _M.googleRechargeRpc(agent, data) | ||
90 | 61 | ||
91 | role.ignoreHeartbeat = true | 62 | role.ignoreHeartbeat = true |
92 | --创建订单号 | 63 | --创建订单号 |
93 | - local partnerOrderId = makeOrder(role, id) | 64 | + local partnerOrderId = role:getPurchaseOrder(id) |
94 | -- 签名 | 65 | -- 签名 |
95 | local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" | 66 | local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" |
96 | local need = { | 67 | local need = { |
@@ -117,7 +88,7 @@ function _M.myCardRechargeRpc(agent, data) | @@ -117,7 +88,7 @@ function _M.myCardRechargeRpc(agent, data) | ||
117 | 88 | ||
118 | role.ignoreHeartbeat = true | 89 | role.ignoreHeartbeat = true |
119 | --创建订单号 | 90 | --创建订单号 |
120 | - local partnerOrderId = makeOrder(role, id) | 91 | + local partnerOrderId = role:getPurchaseOrder(id) |
121 | -- 签名 | 92 | -- 签名 |
122 | local secret_key = "48759e07540f46d9af17ec82669b4272" | 93 | local secret_key = "48759e07540f46d9af17ec82669b4272" |
123 | local need = { | 94 | local need = { |
@@ -143,7 +114,7 @@ function _M.iosRechargeRpc(agent, data) | @@ -143,7 +114,7 @@ function _M.iosRechargeRpc(agent, data) | ||
143 | 114 | ||
144 | role.ignoreHeartbeat = true | 115 | role.ignoreHeartbeat = true |
145 | --创建订单号 | 116 | --创建订单号 |
146 | - local partnerOrderId = makeOrder(role, id) | 117 | + local partnerOrderId = role:getPurchaseOrder(id) |
147 | -- 签名 | 118 | -- 签名 |
148 | local secret_key = "9647d2efe1074c73b9ac19af4337a70e" | 119 | local secret_key = "9647d2efe1074c73b9ac19af4337a70e" |
149 | local need = { | 120 | local need = { |
@@ -167,43 +138,15 @@ function _M.purchaseOrderResult(agent, data) | @@ -167,43 +138,15 @@ function _M.purchaseOrderResult(agent, data) | ||
167 | 138 | ||
168 | role.ignoreHeartbeat = false | 139 | role.ignoreHeartbeat = false |
169 | 140 | ||
170 | - local partnerOrderStr = msg.order | ||
171 | - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)") | ||
172 | - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) }) | ||
173 | - if not orderObject:load() then | ||
174 | - -- 订单不存在 | ||
175 | - skynet.error("cancelPurchaseRpc", string.format("order %s not exist", partnerOrderStr)) | ||
176 | - return true | ||
177 | - end | ||
178 | - | ||
179 | - if msg.status == "success" then | ||
180 | - orderObject:setProperty("transactionId", msg.platformOrder or "") | ||
181 | - local rechargeId = orderObject:getProperty("rechargeId") | ||
182 | - local dataSet = csvdb["shop_rechargeCsv"][rechargeId] | ||
183 | - | ||
184 | - role:log("setOrder", { | ||
185 | - order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" | ||
186 | - item_id = rechargeId, -- 道具id | ||
187 | - item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 | ||
188 | - item_name = dataSet.title, -- 购买的道具名 | ||
189 | - item_number = 1, -- 购买的道具数量 | ||
190 | - item_level = 1, -- 购买的道具等级 | ||
191 | - order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' | ||
192 | - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 | ||
193 | - order_type = role:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0 | ||
194 | - order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' | ||
195 | - }) | ||
196 | - | ||
197 | - return true | ||
198 | - end | 141 | + local status = { |
142 | + fail = true, | ||
143 | + success = true | ||
144 | + } | ||
199 | 145 | ||
200 | - if orderObject:getProperty("finishTime") > 0 then | ||
201 | - return true | 146 | + local partnerOrderStr = msg.order |
147 | + if partnerOrderStr then | ||
148 | + role:updatePurchaseOrder(partnerOrderStr, msg.platformOrder, status[msg.status] and msg.status or "unknown") | ||
202 | end | 149 | end |
203 | - | ||
204 | - orderObject:setProperty("status", msg.status) | ||
205 | - | ||
206 | - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr) | ||
207 | return true | 150 | return true |
208 | end | 151 | end |
209 | 152 |
src/adv/AdvBuff.lua
@@ -36,6 +36,8 @@ Buff.SNEAK = 32 --潜行 | @@ -36,6 +36,8 @@ Buff.SNEAK = 32 --潜行 | ||
36 | Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用 | 36 | Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用 |
37 | Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效 | 37 | Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效 |
38 | Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 0 - 1 | 38 | Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 0 - 1 |
39 | +Buff.DISABLE_AURA = 36 -- 禁用光环 | ||
40 | +Buff.GET_AURA = 37 -- 获得光环 | ||
39 | 41 | ||
40 | 42 | ||
41 | --角色一些属性的变化 | 43 | --角色一些属性的变化 |
@@ -332,6 +334,18 @@ local BuffFactory = { | @@ -332,6 +334,18 @@ local BuffFactory = { | ||
332 | end | 334 | end |
333 | end, | 335 | end, |
334 | 336 | ||
337 | + [Buff.DISABLE_AURA] = function(_Buff) | ||
338 | + _Buff._effectValue = function(self) | ||
339 | + return self.buffData.effectValue1 | ||
340 | + end | ||
341 | + end, | ||
342 | + | ||
343 | + [Buff.GET_AURA] = function(_Buff) | ||
344 | + _Buff._effectValue = function(self) | ||
345 | + return self.buffData.effectValue1 | ||
346 | + end | ||
347 | + end, | ||
348 | + | ||
335 | [Buff.SP_MAX_CHANGE] = function(_Buff) | 349 | [Buff.SP_MAX_CHANGE] = function(_Buff) |
336 | _Buff._init = function(self) --初始化变化值 | 350 | _Buff._init = function(self) --初始化变化值 |
337 | self.owner:reSetSpMax() | 351 | self.owner:reSetSpMax() |
src/adv/AdvPlayer.lua
@@ -143,6 +143,19 @@ function BaseObject:getDisablePassiveCount() | @@ -143,6 +143,19 @@ function BaseObject:getDisablePassiveCount() | ||
143 | return count | 143 | return count |
144 | end | 144 | end |
145 | 145 | ||
146 | +function BaseObject:getDisableAuraCount() | ||
147 | + local count | ||
148 | + for _, buff in ipairs(self.buffs) do | ||
149 | + if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then | ||
150 | + if buff:effect() == 0 then | ||
151 | + return 0 | ||
152 | + end | ||
153 | + count = (count or 0) + buff:effect() | ||
154 | + end | ||
155 | + end | ||
156 | + return count | ||
157 | +end | ||
158 | + | ||
146 | function BaseObject:addBuff(buffId, releaser, layer) | 159 | function BaseObject:addBuff(buffId, releaser, layer) |
147 | layer = layer or 1 | 160 | layer = layer or 1 |
148 | local buffData = csvdb["adv_map_buffCsv"][buffId] | 161 | local buffData = csvdb["adv_map_buffCsv"][buffId] |
@@ -229,22 +242,36 @@ function BaseObject:checkAuraBuff(buffs) | @@ -229,22 +242,36 @@ function BaseObject:checkAuraBuff(buffs) | ||
229 | end | 242 | end |
230 | 243 | ||
231 | function BaseObject:getAuras() | 244 | function BaseObject:getAuras() |
245 | + local disable = self:getDisableAuraCount() | ||
232 | local auras = {} | 246 | local auras = {} |
247 | + local function addAura(one) | ||
248 | + if disable > 0 then | ||
249 | + disable = disable - 1 | ||
250 | + else | ||
251 | + table.insert(auras, one) | ||
252 | + end | ||
253 | + end | ||
233 | if self:is("Enemy") then | 254 | if self:is("Enemy") then |
234 | local halo = csvdb["event_monsterCsv"][self.monsterId].halo | 255 | local halo = csvdb["event_monsterCsv"][self.monsterId].halo |
235 | if halo then | 256 | if halo then |
236 | for _, one in ipairs(halo:toArray(true, "=")) do | 257 | for _, one in ipairs(halo:toArray(true, "=")) do |
237 | - table.insert(auras, one) | 258 | + addAura(one) |
238 | end | 259 | end |
239 | end | 260 | end |
240 | elseif self:is("Build") then | 261 | elseif self:is("Build") then |
241 | local halo = csvdb["event_buildingCsv"][self.id].halo | 262 | local halo = csvdb["event_buildingCsv"][self.id].halo |
242 | if halo then | 263 | if halo then |
243 | for _, one in ipairs(halo:toArray(true, "=")) do | 264 | for _, one in ipairs(halo:toArray(true, "=")) do |
244 | - table.insert(auras, one) | 265 | + addAura(one) |
245 | end | 266 | end |
246 | end | 267 | end |
247 | - end | 268 | + end |
269 | + | ||
270 | + for _, buff in ipairs(self.buffs) do | ||
271 | + if not buff:isHide() and buff:getType() == Buff.GET_AURA then | ||
272 | + addAura(buff:effect()) | ||
273 | + end | ||
274 | + end | ||
248 | 275 | ||
249 | return auras | 276 | return auras |
250 | end | 277 | end |
src/models/Role.lua
@@ -114,6 +114,8 @@ Role.schema = { | @@ -114,6 +114,8 @@ Role.schema = { | ||
114 | teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType | 114 | teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType |
115 | advTeams = {"table", {}}, -- 拾荒自选编队 | 115 | advTeams = {"table", {}}, -- 拾荒自选编队 |
116 | 116 | ||
117 | + bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 | ||
118 | + | ||
117 | --引导相关 | 119 | --引导相关 |
118 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave | 120 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave |
119 | funcGuide = {"string",""}, -- 功能引导 0=0跳过次数(999永久跳过) 1=1功能1触发情况 | 121 | funcGuide = {"string",""}, -- 功能引导 0=0跳过次数(999永久跳过) 1=1功能1触发情况 |
@@ -360,6 +362,8 @@ function Role:data() | @@ -360,6 +362,8 @@ function Role:data() | ||
360 | hangTeams = self:getProperty("hangTeams"), | 362 | hangTeams = self:getProperty("hangTeams"), |
361 | teamIndex = self:getProperty("teamIndex"), | 363 | teamIndex = self:getProperty("teamIndex"), |
362 | advTeams = self:getProperty("advTeams"), | 364 | advTeams = self:getProperty("advTeams"), |
365 | + | ||
366 | + bonusStar = self:getProperty("bonusStar"), | ||
363 | 367 | ||
364 | newerGuide = self:getProperty("newerGuide"), | 368 | newerGuide = self:getProperty("newerGuide"), |
365 | funcGuide = self:getProperty("funcGuide"), | 369 | funcGuide = self:getProperty("funcGuide"), |
src/models/RolePlugin.lua
1 | 1 | ||
2 | - | 2 | +local serverId = tonumber(skynet.getenv("servId")) |
3 | local RolePlugin = {} | 3 | local RolePlugin = {} |
4 | 4 | ||
5 | function RolePlugin.bind(Role) | 5 | function RolePlugin.bind(Role) |
@@ -1534,6 +1534,102 @@ function RolePlugin.bind(Role) | @@ -1534,6 +1534,102 @@ function RolePlugin.bind(Role) | ||
1534 | self:updateProperty({field = "redp", value = redp}) | 1534 | self:updateProperty({field = "redp", value = redp}) |
1535 | end | 1535 | end |
1536 | 1536 | ||
1537 | + -- 获取充值订单号 | ||
1538 | + function Role:getPurchaseOrder(rechargeId) | ||
1539 | + local roleId = self:getProperty("id") | ||
1540 | + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | ||
1541 | + if not rechargeData then | ||
1542 | + skynet.error("recharge id not exist", rechargeId) | ||
1543 | + return "" | ||
1544 | + end | ||
1545 | + local limit = rechargeData.limit | ||
1546 | + local rechargeRecord = self:getProperty("payR") or {} | ||
1547 | + if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then | ||
1548 | + return "" | ||
1549 | + end | ||
1550 | + | ||
1551 | + local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) | ||
1552 | + if orderId then | ||
1553 | + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) }) | ||
1554 | + if orderObject:load() and orderObject:getProperty("rechargeId") == rechargeId and math.abs(skynet.timex() - orderObject:getProperty("createTime")) < 5 * 60 then | ||
1555 | + return string.format("%d_%d_%d", serverId, roleId, orderId) | ||
1556 | + end | ||
1557 | + end | ||
1558 | + | ||
1559 | + orderId = redisproxy:hincrby("autoincrement_set", "order", 1) | ||
1560 | + local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId) | ||
1561 | + local orderKey = string.format(R_ORDER, roleId, orderId) | ||
1562 | + redisproxy:del(orderKey) -- 删掉可能有了 | ||
1563 | + local order = require("models.Order").new({ | ||
1564 | + key = orderKey, | ||
1565 | + order = partnerOrderId, | ||
1566 | + rechargeId = rechargeId, | ||
1567 | + }) | ||
1568 | + order:create() | ||
1569 | + -- 正在进行中的订单 缓存 | ||
1570 | + redisproxy:hset(string.format(R_ORDERS, roleId), rechargeId, orderId) | ||
1571 | + return partnerOrderId | ||
1572 | + end | ||
1573 | + | ||
1574 | + -- 更新订单信息 | ||
1575 | + --[[ | ||
1576 | + | ||
1577 | + status | ||
1578 | + | ||
1579 | + success | ||
1580 | + fail | ||
1581 | + finsh | ||
1582 | + unknow | ||
1583 | + | ||
1584 | + --]] | ||
1585 | + function Role:updatePurchaseOrder(partnerOrderStr, platformOrder, status) | ||
1586 | + if not partnerOrderStr then return false end | ||
1587 | + local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)") | ||
1588 | + | ||
1589 | + local roleId = self:getProperty("id") | ||
1590 | + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) }) | ||
1591 | + if not orderObject:load() then | ||
1592 | + return false | ||
1593 | + end | ||
1594 | + | ||
1595 | + local rechargeId = orderObject:getProperty("rechargeId") | ||
1596 | + local dataSet = csvdb["shop_rechargeCsv"][rechargeId] | ||
1597 | + | ||
1598 | + if orderObject:getProperty("finishTime") > 0 then | ||
1599 | + return false, "finsh" | ||
1600 | + end | ||
1601 | + | ||
1602 | + if platformOrder then | ||
1603 | + orderObject:setProperty("transactionId", platformOrder) | ||
1604 | + end | ||
1605 | + orderObject:setProperty("status", status) | ||
1606 | + | ||
1607 | + -- 开始下单 | ||
1608 | + if status == "success" then | ||
1609 | + elseif status == "fail" then | ||
1610 | + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | ||
1611 | + elseif status == "finsh" then | ||
1612 | + orderObject:setProperty("finishTime", skynet.time()) | ||
1613 | + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | ||
1614 | + end | ||
1615 | + | ||
1616 | + if status ~= "unknow" then | ||
1617 | + self:log("setOrder", { | ||
1618 | + order_status = ({success = 100, finsh = 200, fail = 300})[status] or 1000, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" | ||
1619 | + item_id = rechargeId, -- 道具id | ||
1620 | + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 | ||
1621 | + item_name = dataSet.title, -- 购买的道具名 | ||
1622 | + item_number = 1, -- 购买的道具数量 | ||
1623 | + item_level = 1, -- 购买的道具等级 | ||
1624 | + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' | ||
1625 | + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 | ||
1626 | + order_type = self:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0 | ||
1627 | + order_id = platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' | ||
1628 | + }) | ||
1629 | + end | ||
1630 | + | ||
1631 | + return true, rechargeId | ||
1632 | + end | ||
1537 | 1633 | ||
1538 | -- 充值 -- | 1634 | -- 充值 -- |
1539 | --[[ | 1635 | --[[ |
@@ -1548,63 +1644,37 @@ function RolePlugin.bind(Role) | @@ -1548,63 +1644,37 @@ function RolePlugin.bind(Role) | ||
1548 | local roleId = self:getProperty("id") | 1644 | local roleId = self:getProperty("id") |
1549 | local partnerOrderStr = params.order | 1645 | local partnerOrderStr = params.order |
1550 | 1646 | ||
1551 | - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)") | ||
1552 | - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) }) | ||
1553 | - if not orderObject:load() then | ||
1554 | - -- 订单不存在 | ||
1555 | - skynet.error("ayncPurchaseRpc", string.format("order %s not exist", partnerOrderStr)) | ||
1556 | - return | ||
1557 | - end | ||
1558 | 1647 | ||
1559 | - if orderObject:getProperty("finishTime") > 0 then | ||
1560 | - -- 订单已经处理 | ||
1561 | - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" })) | 1648 | + local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") |
1649 | + if not status then | ||
1650 | + if back == "finsh" then | ||
1651 | + -- 订单已经处理 | ||
1652 | + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" })) | ||
1653 | + end | ||
1562 | return | 1654 | return |
1563 | end | 1655 | end |
1564 | - local rechargeId = orderObject:getProperty("rechargeId") | 1656 | + local rechargeId = back |
1565 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | 1657 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] |
1566 | if rechargeData.rmb ~= tonumber(params.amount) then | 1658 | if rechargeData.rmb ~= tonumber(params.amount) then |
1567 | - skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s", | 1659 | + skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s", |
1568 | params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount | 1660 | params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount |
1569 | )) | 1661 | )) |
1570 | return | 1662 | return |
1571 | end | 1663 | end |
1572 | 1664 | ||
1573 | - local order_type = self:getProperty("rmbC") > 0 and 0 or 1 | ||
1574 | local status, reward = self:recharge({ | 1665 | local status, reward = self:recharge({ |
1575 | id = rechargeId, | 1666 | id = rechargeId, |
1576 | transactionId = params.transactionId, | 1667 | transactionId = params.transactionId, |
1577 | pay_time = params.pay_time, | 1668 | pay_time = params.pay_time, |
1578 | order = partnerOrderStr, | 1669 | order = partnerOrderStr, |
1579 | }) | 1670 | }) |
1580 | - orderObject:setProperty("finishTime", skynet.time()) | ||
1581 | - orderObject:setProperty("status", "finish") | ||
1582 | - | ||
1583 | - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr) | ||
1584 | 1671 | ||
1585 | if not status then | 1672 | if not status then |
1586 | - status = 200 | ||
1587 | - else | ||
1588 | - status = 1000 + status | ||
1589 | - end | ||
1590 | - self:log("setOrder", { | ||
1591 | - order_status = status, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" | ||
1592 | - item_id = rechargeId, -- 道具id | ||
1593 | - item_type = rechargeData.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 | ||
1594 | - item_name = rechargeData.title, -- 购买的道具名 | ||
1595 | - item_number = 1, -- 购买的道具数量 | ||
1596 | - item_level = 1, -- 购买的道具等级 | ||
1597 | - order_cost = rechargeData.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' | ||
1598 | - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 | ||
1599 | - order_type = order_type, -- 订单类型,首充记录为1,否则为0 | ||
1600 | - order_id = params.transactionId, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' | ||
1601 | - }) | ||
1602 | - if status ~= 200 then return end | ||
1603 | - | ||
1604 | - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, | ||
1605 | - result = "success", reward = reward})) | 1673 | + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, |
1674 | + result = "success", reward = reward})) | ||
1675 | + end | ||
1606 | 1676 | ||
1607 | - return orderObject:getProperty("rechargeId") | 1677 | + return rechargeId |
1608 | end | 1678 | end |
1609 | 1679 | ||
1610 | 1680 | ||
@@ -1612,7 +1682,7 @@ function RolePlugin.bind(Role) | @@ -1612,7 +1682,7 @@ function RolePlugin.bind(Role) | ||
1612 | local id = tonumber(params.id) | 1682 | local id = tonumber(params.id) |
1613 | local rechargeData = csvdb["shop_rechargeCsv"][id] | 1683 | local rechargeData = csvdb["shop_rechargeCsv"][id] |
1614 | if not rechargeData then | 1684 | if not rechargeData then |
1615 | - skynet.error("recharge id not exist", id) | 1685 | + skynet.error("[recharge] recharge id not exist", id) |
1616 | return 1 | 1686 | return 1 |
1617 | end | 1687 | end |
1618 | 1688 | ||
@@ -1637,7 +1707,7 @@ function RolePlugin.bind(Role) | @@ -1637,7 +1707,7 @@ function RolePlugin.bind(Role) | ||
1637 | elseif rechargeData.shop == 3 then -- 礼包商店 | 1707 | elseif rechargeData.shop == 3 then -- 礼包商店 |
1638 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 1708 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) |
1639 | else | 1709 | else |
1640 | - skynet.error("invalid recharge shop type " .. id) | 1710 | + skynet.error("[recharge] invalid recharge shop type " .. id) |
1641 | return 3 | 1711 | return 3 |
1642 | end | 1712 | end |
1643 | 1713 |
src/models/RoleTask.lua
@@ -33,7 +33,7 @@ local TaskType = { | @@ -33,7 +33,7 @@ local TaskType = { | ||
33 | HangQuick = 303, -- 快速挂机 | 33 | HangQuick = 303, -- 快速挂机 |
34 | HangBattle = 304, -- 挂机战斗 - id | 34 | HangBattle = 304, -- 挂机战斗 - id |
35 | HangGetGold = 305, -- 挂机获得齿轮 - count | 35 | HangGetGold = 305, -- 挂机获得齿轮 - count |
36 | - BonusPass = 306, -- 奖励副本通关 - id | 36 | + BonusPass = 306, -- 奖励副本通关 - id count |
37 | 37 | ||
38 | -- 冒险相关 | 38 | -- 冒险相关 |
39 | AdvPass = 401, -- 冒险通过关 - id level score | 39 | AdvPass = 401, -- 冒险通过关 - id level score |
@@ -142,7 +142,7 @@ local CommonListener = { | @@ -142,7 +142,7 @@ local CommonListener = { | ||
142 | [TaskType.GiveFriendP] = {{20, f("count")}}, | 142 | [TaskType.GiveFriendP] = {{20, f("count")}}, |
143 | [TaskType.UnionBoss] = {{21}}, | 143 | [TaskType.UnionBoss] = {{21}}, |
144 | [TaskType.GetFriendP] = {{22, f("count")}}, | 144 | [TaskType.GetFriendP] = {{22, f("count")}}, |
145 | - [TaskType.BonusPass] = {{23}}, | 145 | + [TaskType.BonusPass] = {{23, f("count")}}, |
146 | [TaskType.AdvStartSelf] = {{24}}, | 146 | [TaskType.AdvStartSelf] = {{24}}, |
147 | [TaskType.ShopAll] = {{25, f("count")}}, | 147 | [TaskType.ShopAll] = {{25, f("count")}}, |
148 | [TaskType.RuneUp] = {{26}}, | 148 | [TaskType.RuneUp] = {{26}}, |
@@ -244,7 +244,7 @@ local CalendaTaskListener = { | @@ -244,7 +244,7 @@ local CalendaTaskListener = { | ||
244 | func = "checkCalendaTask", | 244 | func = "checkCalendaTask", |
245 | listen = { | 245 | listen = { |
246 | [TaskType.DrawHero] = {{1, 1, f("count")}}, | 246 | [TaskType.DrawHero] = {{1, 1, f("count")}}, |
247 | - [TaskType.BonusPass]= {{2, 1}}, | 247 | + [TaskType.BonusPass]= {{2, 1, f("count")}}, |
248 | [TaskType.AdvStart]= {{3, 1}}, | 248 | [TaskType.AdvStart]= {{3, 1}}, |
249 | [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, | 249 | [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, |
250 | [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 | 250 | [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 |
src/models/Store.lua
@@ -226,7 +226,7 @@ end | @@ -226,7 +226,7 @@ end | ||
226 | function Store:checkRechargeRecord(limit, id) | 226 | function Store:checkRechargeRecord(limit, id) |
227 | local rechargeRecord = self:getProperty("payR") or {} | 227 | local rechargeRecord = self:getProperty("payR") or {} |
228 | if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then | 228 | if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then |
229 | - skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id"))) | 229 | + skynet.error(string.format("[recharge] recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id"))) |
230 | return false | 230 | return false |
231 | end | 231 | end |
232 | rechargeRecord[id] = (rechargeRecord[id] or 0) + 1 | 232 | rechargeRecord[id] = (rechargeRecord[id] or 0) + 1 |