Commit 01ff9b4b57a066d7a2d6b145a12ad5a616a6ebb0
1 parent
7f21f75b
fix: 一番赏 优化; 抽奖记录分页;抽扭蛋机,返回值更新
1. 每次获取最新的20条record,然后再通过指令增量获取抽奖记录
2.
抽扭蛋机,返回值更新,{usual={},special={},incentive={},capsule={}}
Showing
5 changed files
with
151 additions
and
82 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -285,6 +285,7 @@ actionCodes = { | @@ -285,6 +285,7 @@ actionCodes = { | ||
| 285 | Capsule_exitRpc = 858, -- 退出 | 285 | Capsule_exitRpc = 858, -- 退出 |
| 286 | Capsule_getDataRpc = 859, --获取扭蛋机信息 | 286 | Capsule_getDataRpc = 859, --获取扭蛋机信息 |
| 287 | Capsule_convertCapsuleRpc = 890, --兑换消耗票 | 287 | Capsule_convertCapsuleRpc = 890, --兑换消耗票 |
| 288 | + Capsule_pageRecordRpc = 891, --抽奖记录分页查询 | ||
| 288 | } | 289 | } |
| 289 | 290 | ||
| 290 | rpcResponseBegin = 10000 | 291 | rpcResponseBegin = 10000 |
src/actions/CapsuleAction.lua
| @@ -96,7 +96,7 @@ function _M.drawRpc(agent, data) | @@ -96,7 +96,7 @@ function _M.drawRpc(agent, data) | ||
| 96 | local full = msg.full or 0-- 0=单次,1=十连抽 2=全收 | 96 | local full = msg.full or 0-- 0=单次,1=十连抽 2=全收 |
| 97 | local cares = msg.cares | 97 | local cares = msg.cares |
| 98 | 98 | ||
| 99 | - local ret, token, reward, change, rewardByGoods, capsule | 99 | + local ret, token, change, drawReward, capsule |
| 100 | 100 | ||
| 101 | --检查库存 | 101 | --检查库存 |
| 102 | if typ == 1 then | 102 | if typ == 1 then |
| @@ -127,26 +127,24 @@ function _M.drawRpc(agent, data) | @@ -127,26 +127,24 @@ function _M.drawRpc(agent, data) | ||
| 127 | 127 | ||
| 128 | --开始抽奖 | 128 | --开始抽奖 |
| 129 | if typ == 1 then | 129 | if typ == 1 then |
| 130 | - ret, reward, rewardByGoods, capsule = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares) | 130 | + ret, drawReward, capsule = skynet.call(agent.capsule_serv, "lua", "draw_capsule", roleId, capsuleId, full, cares) |
| 131 | else | 131 | else |
| 132 | - ret, reward, rewardByGoods, capsule= role:drawCapsule(capsuleId, full, cares) | 132 | + ret, drawReward, capsule = role:drawCapsule(capsuleId, full, cares) |
| 133 | end | 133 | end |
| 134 | if ret < 5 then | 134 | if ret < 5 then |
| 135 | return ret | 135 | return ret |
| 136 | end | 136 | end |
| 137 | 137 | ||
| 138 | - --dump(rewardByGoods) | ||
| 139 | - --dump(capsule) | ||
| 140 | - | ||
| 141 | if ret == 5 then | 138 | if ret == 5 then |
| 142 | - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({change = reward, capsule = capsule})) | 139 | + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({change = drawReward, capsule = capsule})) |
| 143 | return true | 140 | return true |
| 144 | end | 141 | end |
| 145 | 142 | ||
| 146 | - -- rewardByGoods是抽到的扭蛋信息,reward是抽扭蛋后获得的所有奖励信息。 | ||
| 147 | - if rewardByGoods and next(rewardByGoods) then | ||
| 148 | - reward, change = role:award(reward, {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}}) | ||
| 149 | - SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack({reward = rewardByGoods, capsule = capsule})) | 143 | + if drawReward["reward"] and next(drawReward["reward"]) then |
| 144 | + _, change = role:award(drawReward["reward"], {log = {desc = "CapsuleReward", int1 = tonumber(capsuleId), int2 = roleId}}) | ||
| 145 | + drawReward["capsule"] = capsule | ||
| 146 | + dump(drawReward) | ||
| 147 | + SendPacket(actionCodes.Capsule_drawRpc, MsgPack.pack(drawReward)) | ||
| 150 | else | 148 | else |
| 151 | return ret | 149 | return ret |
| 152 | end | 150 | end |
| @@ -195,4 +193,24 @@ function _M.convertCapsuleRpc(agent, data) | @@ -195,4 +193,24 @@ function _M.convertCapsuleRpc(agent, data) | ||
| 195 | return true | 193 | return true |
| 196 | end | 194 | end |
| 197 | 195 | ||
| 196 | +function _M.pageRecordRpc(agent, data) | ||
| 197 | + local role = agent.role | ||
| 198 | + local msg = MsgPack.unpack(data) | ||
| 199 | + local idx = msg.idx | ||
| 200 | + local up = msg.up or 0 | ||
| 201 | + local capsuleId = msg.capsule_id | ||
| 202 | + local typ = msg.typ --0=独享,1= 公开 | ||
| 203 | + | ||
| 204 | + local record | ||
| 205 | + if typ == 1 then | ||
| 206 | + record = skynet.call(agent.capsule_serv, "lua", "page_record", capsuleId, up, idx) | ||
| 207 | + else | ||
| 208 | + record = role:pageRecord(capsuleId, up, idx) | ||
| 209 | + end | ||
| 210 | + if not record then return 1 end | ||
| 211 | + | ||
| 212 | + SendPacket(actionCodes.Capsule_pageRecordRpc, MsgPack.pack({record = record})) | ||
| 213 | + return true | ||
| 214 | +end | ||
| 215 | + | ||
| 198 | return _M | 216 | return _M |
| 199 | \ No newline at end of file | 217 | \ No newline at end of file |
src/models/Capsule.lua
| @@ -673,6 +673,30 @@ function Capsule:checkIncentive(roleId, name, now) | @@ -673,6 +673,30 @@ function Capsule:checkIncentive(roleId, name, now) | ||
| 673 | return {} | 673 | return {} |
| 674 | end | 674 | end |
| 675 | 675 | ||
| 676 | +local rewardCollect = function(reward, goods) | ||
| 677 | + for _, v in pairs(goods) do | ||
| 678 | + for id, count in pairs(v.award:toNumMap()) do | ||
| 679 | + reward[id] = (reward[id] or 0) + count | ||
| 680 | + end | ||
| 681 | + end | ||
| 682 | +end | ||
| 683 | + | ||
| 684 | +local rewardCollectByRoleId = function(roleId, reward, goods) | ||
| 685 | + local tmp = {} | ||
| 686 | + for key, val in pairs(goods) do | ||
| 687 | + if roleId == key then | ||
| 688 | + for k, v in pairs(val) do | ||
| 689 | + for id, count in pairs(v.award:toNumMap()) do | ||
| 690 | + reward[id] = (reward[id] or 0) + count | ||
| 691 | + end | ||
| 692 | + | ||
| 693 | + end | ||
| 694 | + tmp = val | ||
| 695 | + end | ||
| 696 | + end | ||
| 697 | + return tmp | ||
| 698 | +end | ||
| 699 | + | ||
| 676 | function Capsule:drawByCount(roleId, count) | 700 | function Capsule:drawByCount(roleId, count) |
| 677 | if count <= 0 then return nil end | 701 | if count <= 0 then return nil end |
| 678 | 702 | ||
| @@ -689,9 +713,8 @@ function Capsule:drawByCount(roleId, count) | @@ -689,9 +713,8 @@ function Capsule:drawByCount(roleId, count) | ||
| 689 | local goods_id = ichibankuji["goods_id"] | 713 | local goods_id = ichibankuji["goods_id"] |
| 690 | local now = skynet.timex() | 714 | local now = skynet.timex() |
| 691 | 715 | ||
| 692 | - --奖励, 通知信息 | ||
| 693 | - local notify= {} | ||
| 694 | - notify[roleId] = {} | 716 | + --奖励,普通奖品信息 |
| 717 | + local goodsByUsual= {} | ||
| 695 | 718 | ||
| 696 | local name = getNameByRoleId(roleId) | 719 | local name = getNameByRoleId(roleId) |
| 697 | while (goods and next(goods) and count > 0) do | 720 | while (goods and next(goods) and count > 0) do |
| @@ -710,10 +733,10 @@ function Capsule:drawByCount(roleId, count) | @@ -710,10 +733,10 @@ function Capsule:drawByCount(roleId, count) | ||
| 710 | table.insert(record, tmpNotify) | 733 | table.insert(record, tmpNotify) |
| 711 | 734 | ||
| 712 | --作为奖励记录+通知 | 735 | --作为奖励记录+通知 |
| 713 | - if not notify[roleId][good_id] then | ||
| 714 | - notify[roleId][good_id] = tmpNotify | 736 | + if not goodsByUsual[good_id] then |
| 737 | + goodsByUsual[good_id] = tmpNotify | ||
| 715 | else | 738 | else |
| 716 | - notify[roleId][good_id].amount = notify[roleId][good_id].amount + 1 | 739 | + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + 1 |
| 717 | end | 740 | end |
| 718 | 741 | ||
| 719 | --记录角色的抽奖记录 计算激励奖需要用到 | 742 | --记录角色的抽奖记录 计算激励奖需要用到 |
| @@ -728,35 +751,28 @@ function Capsule:drawByCount(roleId, count) | @@ -728,35 +751,28 @@ function Capsule:drawByCount(roleId, count) | ||
| 728 | end | 751 | end |
| 729 | 752 | ||
| 730 | end | 753 | end |
| 754 | + | ||
| 755 | + --奖励池重新赋值 | ||
| 731 | rank[roleId] = rankRole | 756 | rank[roleId] = rankRole |
| 732 | recordByRole[roleId] = roleRecord | 757 | recordByRole[roleId] = roleRecord |
| 733 | self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank}) | 758 | self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank}) |
| 734 | 759 | ||
| 735 | - local tmpNotify = self:checkIncentive(roleId, name, now) | ||
| 736 | - for k, v in pairs(tmpNotify) do | ||
| 737 | - if not notify[roleId][k] then | ||
| 738 | - notify[roleId][k] = v | ||
| 739 | - else | ||
| 740 | - notify[roleId][k].amount = notify[roleId][k].amount + v.amount | ||
| 741 | - end | ||
| 742 | - end | 760 | + --奖励收集 |
| 761 | + local reward = {} | ||
| 762 | + rewardCollect(reward, goodsByUsual) | ||
| 743 | 763 | ||
| 744 | - local speciNotify = self:checkSpecialReward(now) | ||
| 745 | - rewardToNtyFunc(notify, speciNotify) | ||
| 746 | - | ||
| 747 | - local reward, rewardByGoods = {}, {} | ||
| 748 | - for key, val in pairs(notify) do | ||
| 749 | - if key == roleId then | ||
| 750 | - for k, v in pairs(val) do | ||
| 751 | - for id, count in pairs(v.award:toNumMap()) do | ||
| 752 | - reward[id] = (reward[id] or 0) + count | ||
| 753 | - end | ||
| 754 | - rewardByGoods[k] = v | ||
| 755 | - end | ||
| 756 | - end | 764 | + local goodsByIncentive = self:checkIncentive(roleId, name, now) |
| 765 | + rewardCollect(reward, goodsByIncentive) | ||
| 757 | 766 | ||
| 767 | + local goodsAmount = self:getGoodsAmount() | ||
| 768 | + if goodsAmount == 0 then | ||
| 769 | + self:setProperty("drawEndTime", now) | ||
| 758 | end | 770 | end |
| 759 | - return reward, rewardByGoods, notify | 771 | + |
| 772 | + local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) | ||
| 773 | + local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) | ||
| 774 | + | ||
| 775 | + return {reward = reward, usual = goodsByUsual, incentive = goodsByIncentive, specials = goodsBySpecial, special = specialByRole} | ||
| 760 | end | 776 | end |
| 761 | 777 | ||
| 762 | function Capsule:drawAll(roleId) | 778 | function Capsule:drawAll(roleId) |
| @@ -769,8 +785,7 @@ function Capsule:drawAll(roleId) | @@ -769,8 +785,7 @@ function Capsule:drawAll(roleId) | ||
| 769 | local now = skynet.timex() | 785 | local now = skynet.timex() |
| 770 | 786 | ||
| 771 | local name = getNameByRoleId(roleId) | 787 | local name = getNameByRoleId(roleId) |
| 772 | - local notify = {} | ||
| 773 | - notify[roleId] = {} | 788 | + local goodsByUsual = {} |
| 774 | for good_id, good in pairs(goods) do | 789 | for good_id, good in pairs(goods) do |
| 775 | if good.amount > 0 then | 790 | if good.amount > 0 then |
| 776 | --插入rank | 791 | --插入rank |
| @@ -783,10 +798,10 @@ function Capsule:drawAll(roleId) | @@ -783,10 +798,10 @@ function Capsule:drawAll(roleId) | ||
| 783 | end | 798 | end |
| 784 | 799 | ||
| 785 | --作为奖励记录+通知 | 800 | --作为奖励记录+通知 |
| 786 | - if not notify[roleId][good_id] then | ||
| 787 | - notify[roleId][good_id] = tmpNotify | 801 | + if not goodsByUsual[good_id] then |
| 802 | + goodsByUsual[good_id] = tmpNotify | ||
| 788 | else | 803 | else |
| 789 | - notify[roleId][good_id].amount = notify[roleId][good_id].amount + good.award | 804 | + goodsByUsual[good_id].amount = goodsByUsual[good_id].amount + good.award |
| 790 | end | 805 | end |
| 791 | 806 | ||
| 792 | --记录角色的抽奖记录 | 807 | --记录角色的抽奖记录 |
| @@ -804,37 +819,22 @@ function Capsule:drawAll(roleId) | @@ -804,37 +819,22 @@ function Capsule:drawAll(roleId) | ||
| 804 | recordByRole[roleId] = roleRecord | 819 | recordByRole[roleId] = roleRecord |
| 805 | self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank}) | 820 | self:setProperties({recordByRole = recordByRole, record = record, goods = goods, rank = rank}) |
| 806 | 821 | ||
| 807 | - local tmpNotify = self:checkIncentive(roleId, name, now) | ||
| 808 | - for k, v in pairs(tmpNotify) do | ||
| 809 | - if not notify[roleId][k] then | ||
| 810 | - notify[roleId][k] = v | ||
| 811 | - else | ||
| 812 | - notify[roleId][k].amount = notify[roleId][k].amount + v.amount | ||
| 813 | - end | ||
| 814 | - end | ||
| 815 | - | ||
| 816 | - local goodsAmount = self:getGoodsAmount() | ||
| 817 | - local speciNotify = self:checkSpecialReward(now, goodsAmount) | ||
| 818 | - rewardToNtyFunc(notify, speciNotify) | ||
| 819 | - | ||
| 820 | - local reward, rewardByGoods = {}, {} | ||
| 821 | - for key, val in pairs(notify) do | ||
| 822 | - if key == roleId then | ||
| 823 | - for k, v in pairs(val) do | ||
| 824 | - for id, count in pairs(v.award:toNumMap()) do | ||
| 825 | - reward[id] = (reward[id] or 0) + count | ||
| 826 | - end | ||
| 827 | - rewardByGoods[k] = v | ||
| 828 | - end | ||
| 829 | - end | 822 | + --奖励收集 |
| 823 | + local reward = {} | ||
| 824 | + rewardCollect(reward, goodsByUsual) | ||
| 830 | 825 | ||
| 831 | - end | 826 | + local goodsByIncentive = self:checkIncentive(roleId, name, now) |
| 827 | + rewardCollect(reward, goodsByIncentive) | ||
| 832 | 828 | ||
| 829 | + local goodsAmount = self:getGoodsAmount() | ||
| 833 | if goodsAmount == 0 then | 830 | if goodsAmount == 0 then |
| 834 | self:setProperty("drawEndTime", now) | 831 | self:setProperty("drawEndTime", now) |
| 835 | end | 832 | end |
| 836 | 833 | ||
| 837 | - return reward, rewardByGoods, notify | 834 | + local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) |
| 835 | + local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) | ||
| 836 | + | ||
| 837 | + return {reward = reward, usual = goodsByUsual, incentive = goodsByIncentive, specials = goodsBySpecial, special = specialByRole} | ||
| 838 | end | 838 | end |
| 839 | 839 | ||
| 840 | --@param | 840 | --@param |
| @@ -865,6 +865,33 @@ function Capsule:draw(roleId, full, cares) | @@ -865,6 +865,33 @@ function Capsule:draw(roleId, full, cares) | ||
| 865 | end | 865 | end |
| 866 | end | 866 | end |
| 867 | 867 | ||
| 868 | +function Capsule:pageRecord(up, idx) | ||
| 869 | + local record = self:getProperty("record") or {} | ||
| 870 | + if not next(record) then return nil end | ||
| 871 | + | ||
| 872 | + --默认取20条 | ||
| 873 | + idx = idx or #record | ||
| 874 | + up = up or 0 | ||
| 875 | + | ||
| 876 | + local count = 0 | ||
| 877 | + local tmpRecord = {} | ||
| 878 | + if up == 1 then | ||
| 879 | + --向上获取索引更大的 从上往下拉 | ||
| 880 | + count = math.min(#record - idx, 20) | ||
| 881 | + for i = idx, count do | ||
| 882 | + tmpRecord[i] = record[i] | ||
| 883 | + end | ||
| 884 | + else | ||
| 885 | + --向下获取索引更小的 从下往上拉 | ||
| 886 | + count = math.max(idx - 20, 0) | ||
| 887 | + for i = count, idx do | ||
| 888 | + tmpRecord[i] = record[i] | ||
| 889 | + end | ||
| 890 | + end | ||
| 891 | + | ||
| 892 | + return tmpRecord | ||
| 893 | +end | ||
| 894 | + | ||
| 868 | 895 | ||
| 869 | function Capsule:data(roleId) | 896 | function Capsule:data(roleId) |
| 870 | return { | 897 | return { |
| @@ -875,7 +902,7 @@ function Capsule:data(roleId) | @@ -875,7 +902,7 @@ function Capsule:data(roleId) | ||
| 875 | coin = self:getProperty("coin"), | 902 | coin = self:getProperty("coin"), |
| 876 | onlineCount = self:getOnlineCount(), | 903 | onlineCount = self:getOnlineCount(), |
| 877 | playerStatus = self:getRegisterByRoleId(roleId), | 904 | playerStatus = self:getRegisterByRoleId(roleId), |
| 878 | - record = self:getProperty("record"), | 905 | + record = self:pageRecord() or {}, |
| 879 | rank = self:getProperty("rank"), | 906 | rank = self:getProperty("rank"), |
| 880 | goods = self:getProperty("goods"), | 907 | goods = self:getProperty("goods"), |
| 881 | specials = self:getProperty("specials"), | 908 | specials = self:getProperty("specials"), |
src/models/RolePlugin.lua
| @@ -3165,16 +3165,19 @@ function RolePlugin.bind(Role) | @@ -3165,16 +3165,19 @@ function RolePlugin.bind(Role) | ||
| 3165 | end | 3165 | end |
| 3166 | 3166 | ||
| 3167 | function Role:drawCapsule(capsuleId, full, cares) | 3167 | function Role:drawCapsule(capsuleId, full, cares) |
| 3168 | - local capsule = self.capsules[capsuleId] or {} | ||
| 3169 | - if next(capsule) then | ||
| 3170 | - local roleId = self:getProperty("id") | ||
| 3171 | - return capsule:draw(roleId, full, cares) | ||
| 3172 | - end | ||
| 3173 | - return 3 | 3168 | + local capsule = self.capsules[capsuleId] |
| 3169 | + if not capsule then return nil end | ||
| 3170 | + | ||
| 3171 | + local roleId = self:getProperty("id") | ||
| 3172 | + local ret, drawReward = capsule:draw(roleId, full, cares) | ||
| 3173 | + drawReward["specials"] = nil | ||
| 3174 | + return ret, drawReward, capsule:data(roleId) | ||
| 3174 | end | 3175 | end |
| 3175 | 3176 | ||
| 3176 | function Role:joinCapsule(capsuleId) | 3177 | function Role:joinCapsule(capsuleId) |
| 3177 | - local capsule = self.capsules[capsuleId] or {} | 3178 | + local capsule = self.capsules[capsuleId] |
| 3179 | + if not capsule then return nil end | ||
| 3180 | + | ||
| 3178 | return capsule:data() | 3181 | return capsule:data() |
| 3179 | end | 3182 | end |
| 3180 | 3183 | ||
| @@ -3188,12 +3191,16 @@ function RolePlugin.bind(Role) | @@ -3188,12 +3191,16 @@ function RolePlugin.bind(Role) | ||
| 3188 | end | 3191 | end |
| 3189 | 3192 | ||
| 3190 | function Role:goodStock(capsuleId) | 3193 | function Role:goodStock(capsuleId) |
| 3191 | - local capsule = self.capsules[capsuleId] or {} | 3194 | + local capsule = self.capsules[capsuleId] |
| 3195 | + if not capsule then return 0 end | ||
| 3196 | + | ||
| 3192 | return capsule:getGoodsAmount(), capsule:getProperty("token") | 3197 | return capsule:getGoodsAmount(), capsule:getProperty("token") |
| 3193 | end | 3198 | end |
| 3194 | 3199 | ||
| 3195 | function Role:getCapsuleData(capsuleId) | 3200 | function Role:getCapsuleData(capsuleId) |
| 3196 | - local capsule = self.capsules[capsuleId] or {} | 3201 | + local capsule = self.capsules[capsuleId] |
| 3202 | + if not capsule then return nil end | ||
| 3203 | + | ||
| 3197 | return capsule:data() | 3204 | return capsule:data() |
| 3198 | end | 3205 | end |
| 3199 | 3206 | ||
| @@ -3220,6 +3227,13 @@ function RolePlugin.bind(Role) | @@ -3220,6 +3227,13 @@ function RolePlugin.bind(Role) | ||
| 3220 | end | 3227 | end |
| 3221 | end | 3228 | end |
| 3222 | end | 3229 | end |
| 3230 | + | ||
| 3231 | + function Role:pageRecord(capsuleId, up, idx) | ||
| 3232 | + local capsule = self.capsules[capsuleId] | ||
| 3233 | + if not capsule then return nil end | ||
| 3234 | + | ||
| 3235 | + return capsule:pageRecord(up, idx) | ||
| 3236 | + end | ||
| 3223 | end | 3237 | end |
| 3224 | 3238 | ||
| 3225 | return RolePlugin | 3239 | return RolePlugin |
| 3226 | \ No newline at end of file | 3240 | \ No newline at end of file |
src/services/capsuled.lua
| @@ -65,6 +65,7 @@ function broadCastCapsule(roleId, capsuleId, broadInfo) | @@ -65,6 +65,7 @@ function broadCastCapsule(roleId, capsuleId, broadInfo) | ||
| 65 | end | 65 | end |
| 66 | 66 | ||
| 67 | function broadCastSpecial(roleId, capsuleId, broadInfo) | 67 | function broadCastSpecial(roleId, capsuleId, broadInfo) |
| 68 | + if not broadInfo or not next(broadInfo) then return end | ||
| 68 | local capsule = capsules[capsuleId] | 69 | local capsule = capsules[capsuleId] |
| 69 | if not capsule then skynet.error("not capsule: " .. capsuleId) return end | 70 | if not capsule then skynet.error("not capsule: " .. capsuleId) return end |
| 70 | 71 | ||
| @@ -205,12 +206,13 @@ function CMD.draw_capsule(roleId, capsuleId, full, drawsNum, cares) | @@ -205,12 +206,13 @@ function CMD.draw_capsule(roleId, capsuleId, full, drawsNum, cares) | ||
| 205 | local capsule = capsules[capsuleId] | 206 | local capsule = capsules[capsuleId] |
| 206 | if not capsule then skynet.error("not capsule: " .. capsuleId) return 2 end | 207 | if not capsule then skynet.error("not capsule: " .. capsuleId) return 2 end |
| 207 | 208 | ||
| 208 | - local ret, reward, rewardByGoods, notify = capsule:draw(roleId, full, drawsNum, cares) | 209 | + local ret, drawReward = capsule:draw(roleId, full, drawsNum, cares) |
| 209 | if ret > 5 then | 210 | if ret > 5 then |
| 210 | --broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.DRAW, notify = notify}) | 211 | --broadCastCapsule(roleId, capsuleId, {notifyType = NotifyChangeType.DRAW, notify = notify}) |
| 211 | - broadCastSpecial(roleId, capsuleId, notify) | 212 | + broadCastSpecial(roleId, capsuleId, drawReward["specials"]) |
| 212 | end | 213 | end |
| 213 | - return ret, reward, rewardByGoods, capsule:data(roleId) | 214 | + drawReward["specials"] = nil |
| 215 | + return ret, drawReward, capsule:data(roleId) | ||
| 214 | end | 216 | end |
| 215 | 217 | ||
| 216 | function CMD.register(roleId, capsuleId) | 218 | function CMD.register(roleId, capsuleId) |
| @@ -234,6 +236,13 @@ function CMD.capsule_data(roleId, capsuleId) | @@ -234,6 +236,13 @@ function CMD.capsule_data(roleId, capsuleId) | ||
| 234 | return capsule:data(roleId) | 236 | return capsule:data(roleId) |
| 235 | end | 237 | end |
| 236 | 238 | ||
| 239 | +function CMD.page_record(capsuleId, up, idx) | ||
| 240 | + local capsule = capsules[capsuleId] | ||
| 241 | + if not capsule then skynet.error("not capsule: " .. capsuleId) return nil end | ||
| 242 | + | ||
| 243 | + return capsule:pageRecord(up, idx) | ||
| 244 | +end | ||
| 245 | + | ||
| 237 | skynet.start(function() | 246 | skynet.start(function() |
| 238 | skynet.dispatch("lua", function(session, address, cmd, ...) | 247 | skynet.dispatch("lua", function(session, address, cmd, ...) |
| 239 | local f = CMD[string.lower(cmd)] | 248 | local f = CMD[string.lower(cmd)] |