Commit 0cd001ee4ac3232cdca918c4d5f08cef6e98eff4
Merge branch 'cn/develop' into cn/publish/release
Showing
6 changed files
with
102 additions
and
64 deletions
Show diff stats
src/actions/AdvAction.lua
| @@ -459,11 +459,12 @@ function _M.endHangRpc(agent, data) | @@ -459,11 +459,12 @@ function _M.endHangRpc(agent, data) | ||
| 459 | heroCnt = heroCnt + 1 | 459 | heroCnt = heroCnt + 1 |
| 460 | end | 460 | end |
| 461 | 461 | ||
| 462 | - local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 | ||
| 463 | - | ||
| 464 | - local idleReward = totalReward:toNumMap() | ||
| 465 | - for itemId, count in pairs(idleReward) do | ||
| 466 | - idleReward[itemId] = count * adv_idle_reward_coef | 462 | + local idleReward = {} |
| 463 | + for k, v in pairs(campSiteData.idleReward_1:toNumMap()) do | ||
| 464 | + idleReward[k] = (idleReward[k] or 0) + v * adv_idle_reward_coef | ||
| 465 | + end | ||
| 466 | + for k, v in pairs(campSiteData.idleReward_2:toNumMap()) do | ||
| 467 | + idleReward[k] = (idleReward[k] or 0) + v * adv_idle_reward_coef | ||
| 467 | end | 468 | end |
| 468 | 469 | ||
| 469 | local bnousReward = role:getBnousAdv() | 470 | local bnousReward = role:getBnousAdv() |
src/actions/CapsuleAction.lua
| @@ -17,18 +17,18 @@ function _M.listRpc(agent, data) | @@ -17,18 +17,18 @@ function _M.listRpc(agent, data) | ||
| 17 | local role = agent.role | 17 | local role = agent.role |
| 18 | local msg = MsgPack.unpack(data) | 18 | local msg = MsgPack.unpack(data) |
| 19 | local typ = msg.typ | 19 | local typ = msg.typ |
| 20 | - local coin = msg.coin | 20 | + local id = msg.id |
| 21 | 21 | ||
| 22 | local capsules = {} | 22 | local capsules = {} |
| 23 | if typ == 1 then | 23 | if typ == 1 then |
| 24 | - local ret = skynet.call(agent.capsule_serv, "lua", "list", coin) | 24 | + local ret = skynet.call(agent.capsule_serv, "lua", "list", id) |
| 25 | if next(ret) then | 25 | if next(ret) then |
| 26 | for k, v in pairs(ret) do | 26 | for k, v in pairs(ret) do |
| 27 | capsules[k] = v | 27 | capsules[k] = v |
| 28 | end | 28 | end |
| 29 | end | 29 | end |
| 30 | elseif typ == 0 then | 30 | elseif typ == 0 then |
| 31 | - local ret = role:getCapsuleList(coin) | 31 | + local ret = role:getCapsuleList(id) |
| 32 | if next(ret) then | 32 | if next(ret) then |
| 33 | for k, v in pairs(ret) do | 33 | for k, v in pairs(ret) do |
| 34 | capsules[k] = v | 34 | capsules[k] = v |
src/actions/SeaportAction.lua
| @@ -267,7 +267,7 @@ function _M.shopRpc(agent, data) | @@ -267,7 +267,7 @@ function _M.shopRpc(agent, data) | ||
| 267 | local shopCsv = {} | 267 | local shopCsv = {} |
| 268 | local dataSet = csvdb["shop_normalCsv"] | 268 | local dataSet = csvdb["shop_normalCsv"] |
| 269 | for _, datat in pairs(dataSet) do | 269 | for _, datat in pairs(dataSet) do |
| 270 | - if datat.shop == 5 then | 270 | + if datat.shop == 4 then |
| 271 | shopCsv[datat.id] = datat | 271 | shopCsv[datat.id] = datat |
| 272 | end | 272 | end |
| 273 | end | 273 | end |
src/models/Capsule.lua
| @@ -145,7 +145,20 @@ function Capsule:isShow() | @@ -145,7 +145,20 @@ function Capsule:isShow() | ||
| 145 | return true | 145 | return true |
| 146 | end | 146 | end |
| 147 | 147 | ||
| 148 | -function Capsule:resetTimeOut(curTime, now) | 148 | +function Capsule:reset2TimeOut(curTime, now) |
| 149 | + now = now or skynet.timex() | ||
| 150 | + local interval | ||
| 151 | + if now >= curTime then | ||
| 152 | + self:init() | ||
| 153 | + self:create() | ||
| 154 | + else | ||
| 155 | + interval = curTime - now | ||
| 156 | + end | ||
| 157 | + interval = (interval)* 100 | ||
| 158 | + skynet.timeout(interval, handler(self,self.reset3TimeOut)(curTime)) | ||
| 159 | +end | ||
| 160 | + | ||
| 161 | +function Capsule:reset3TimeOut(curTime, now) | ||
| 149 | now = now or skynet.timex() | 162 | now = now or skynet.timex() |
| 150 | local cur4Time = curTime or (specTime({hour = 4},now)) | 163 | local cur4Time = curTime or (specTime({hour = 4},now)) |
| 151 | 164 | ||
| @@ -162,8 +175,8 @@ function Capsule:resetTimeOut(curTime, now) | @@ -162,8 +175,8 @@ function Capsule:resetTimeOut(curTime, now) | ||
| 162 | local nextTime = dayLater(now) | 175 | local nextTime = dayLater(now) |
| 163 | interval = nextTime - now | 176 | interval = nextTime - now |
| 164 | end | 177 | end |
| 165 | - interval = (interval + 1)* 100 | ||
| 166 | - skynet.timeout(interval, handler(self,self.resetTimeOut)) | 178 | + interval = (interval)* 100 |
| 179 | + skynet.timeout(interval, handler(self,self.reset3TimeOut)) | ||
| 167 | end | 180 | end |
| 168 | 181 | ||
| 169 | function Capsule:reset4TimeOut(curTime, now) | 182 | function Capsule:reset4TimeOut(curTime, now) |
| @@ -180,19 +193,30 @@ function Capsule:reset4TimeOut(curTime, now) | @@ -180,19 +193,30 @@ function Capsule:reset4TimeOut(curTime, now) | ||
| 180 | 193 | ||
| 181 | return false | 194 | return false |
| 182 | end | 195 | end |
| 183 | - interval = (interval + 1)* 100 | 196 | + interval = (interval)* 100 |
| 184 | skynet.timeout(interval, handler(self,self.reset4TimeOut)) | 197 | skynet.timeout(interval, handler(self,self.reset4TimeOut)) |
| 185 | end | 198 | end |
| 186 | 199 | ||
| 187 | -function Capsule:checkTime(resetArr, now) | ||
| 188 | - if resetArr[1] == "3" then | 200 | +function Capsule:checkTime(reset, now) |
| 201 | + local resetArr = reset:toArray(true, "=") | ||
| 202 | + if not next(resetArr) then return false end | ||
| 203 | + | ||
| 204 | + if resetArr[1] == 2 then | ||
| 205 | + if self:getGoodsAmount() > 0 then return false end | ||
| 206 | + local drawEndTime = self:getProperty("drawEndTime") or 0 | ||
| 207 | + if drawEndTime == 0 then return false end | ||
| 208 | + if now - drawEndTime >= resetArr[2] then return true end | ||
| 209 | + --self:reset2TimeOut(drawEndTime + resetArr[2], now) | ||
| 210 | + elseif resetArr[1] == 3 then | ||
| 189 | local cur4Time = specTime({hour = 4},now) | 211 | local cur4Time = specTime({hour = 4},now) |
| 190 | if now == cur4Time then return true end | 212 | if now == cur4Time then return true end |
| 191 | - self:resetTimeOut(cur4Time, now) | ||
| 192 | - elseif resetArr[1] == "4" then | 213 | + --self:reset3TimeOut(cur4Time, now) |
| 214 | + elseif resetArr[1] == 4 then | ||
| 193 | if now == resetArr[2] then return true end | 215 | if now == resetArr[2] then return true end |
| 194 | - self:reset4TimeOut(resetArr[2], now) | 216 | + --self:reset4TimeOut(resetArr[2], now) |
| 195 | end | 217 | end |
| 218 | + | ||
| 219 | + return false | ||
| 196 | end | 220 | end |
| 197 | 221 | ||
| 198 | function Capsule:refreshing(now) | 222 | function Capsule:refreshing(now) |
| @@ -204,29 +228,13 @@ function Capsule:refreshing(now) | @@ -204,29 +228,13 @@ function Capsule:refreshing(now) | ||
| 204 | if reset == "0" then | 228 | if reset == "0" then |
| 205 | return false | 229 | return false |
| 206 | elseif reset == "1" then | 230 | elseif reset == "1" then |
| 207 | - if self:getProperty("resetTimes") == 1 then | 231 | + if self:getProperty("resetTimes") == 0 then |
| 232 | + self:setProperty("resetTime", 1) | ||
| 208 | return true | 233 | return true |
| 209 | end | 234 | end |
| 210 | return false | 235 | return false |
| 211 | else | 236 | else |
| 212 | - local resetArr = reset:toArray(true, "=") | ||
| 213 | - if not next(resetArr) then return false end | ||
| 214 | - | ||
| 215 | - if resetArr[1] == "2" then | ||
| 216 | - if self:getGoodsAmount() > 0 then return false end | ||
| 217 | - | ||
| 218 | - local drawEndTime = self:getProperty("drawEndTime") or 0 | ||
| 219 | - if drawEndTime == 0 then return false end | ||
| 220 | - | ||
| 221 | - if now - drawEndTime >= resetArr[2] then | ||
| 222 | - return true | ||
| 223 | - end | ||
| 224 | - return false | ||
| 225 | - | ||
| 226 | - else | ||
| 227 | - self:checkTime(resetArr, now) | ||
| 228 | - end | ||
| 229 | - | 237 | + return self:checkTime(reset, now) |
| 230 | end | 238 | end |
| 231 | 239 | ||
| 232 | return false | 240 | return false |
| @@ -613,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now) | @@ -613,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now) | ||
| 613 | end | 621 | end |
| 614 | 622 | ||
| 615 | local count = math.floor(amount / incentive["amount"]["np"]) | 623 | local count = math.floor(amount / incentive["amount"]["np"]) |
| 616 | - local tmpCount = count * incentive["amount"]["np"] | ||
| 617 | - notify["amount"] = {name = name, roleId= roleId, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now} | ||
| 618 | - | ||
| 619 | - --填充v.calculated 字段,标识已经用于每x抽的计算中。 | ||
| 620 | - for _, v in pairs(roleRecord) do | ||
| 621 | - if tmpCount <= 0 then break end | ||
| 622 | - | ||
| 623 | - v.calculated = v.calculated or 0 | ||
| 624 | - if v.calculated ~= v.amount then | ||
| 625 | - if tmpCount <= v.amount then | ||
| 626 | - v.calculated = tmpCount | ||
| 627 | - tmpCount = 0 | ||
| 628 | - else | ||
| 629 | - v.calculated = v.amount | ||
| 630 | - tmpCount = tmpCount - v.amount | 624 | + if count > 0 then |
| 625 | + local tmpCount = count * incentive["amount"]["np"] | ||
| 626 | + notify["amount"] = {name = name, roleId= roleId, good_id = "amount", typ = RewardType.INCENTIVE, award = incentive["amount"]["award"], amount = count, quality = 2, create_time= now} | ||
| 627 | + | ||
| 628 | + --填充v.calculated 字段,标识已经用于每x抽的计算中。 | ||
| 629 | + for _, v in pairs(roleRecord) do | ||
| 630 | + if tmpCount <= 0 then break end | ||
| 631 | + | ||
| 632 | + v.calculated = v.calculated or 0 | ||
| 633 | + if v.calculated ~= v.amount then | ||
| 634 | + if tmpCount <= v.amount then | ||
| 635 | + v.calculated = tmpCount | ||
| 636 | + tmpCount = 0 | ||
| 637 | + else | ||
| 638 | + v.calculated = v.amount | ||
| 639 | + tmpCount = tmpCount - v.amount | ||
| 640 | + end | ||
| 631 | end | 641 | end |
| 632 | end | 642 | end |
| 633 | - | ||
| 634 | end | 643 | end |
| 635 | end | 644 | end |
| 636 | 645 | ||
| @@ -757,7 +766,13 @@ function Capsule:drawByCount(roleId, count) | @@ -757,7 +766,13 @@ function Capsule:drawByCount(roleId, count) | ||
| 757 | local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) | 766 | local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) |
| 758 | local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) | 767 | local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) |
| 759 | 768 | ||
| 760 | - return {reward = reward, usual = goodsByUsual, incentive = goodsByIncentive, specials = goodsBySpecial, special = specialByRole} | 769 | + local drawReward = {} |
| 770 | + drawReward["reward"] = reward | ||
| 771 | + drawReward["usual"] = goodsByUsual | ||
| 772 | + drawReward["specials"] = goodsBySpecial | ||
| 773 | + if next(goodsByIncentive) then drawReward["incentive"] = goodsByIncentive end | ||
| 774 | + if next(specialByRole) then drawReward["special"] = specialByRole end | ||
| 775 | + return drawReward | ||
| 761 | end | 776 | end |
| 762 | 777 | ||
| 763 | function Capsule:drawAll(roleId) | 778 | function Capsule:drawAll(roleId) |
| @@ -819,7 +834,13 @@ function Capsule:drawAll(roleId) | @@ -819,7 +834,13 @@ function Capsule:drawAll(roleId) | ||
| 819 | local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) | 834 | local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) |
| 820 | local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) | 835 | local specialByRole = rewardCollectByRoleId(roleId, reward, goodsBySpecial) |
| 821 | 836 | ||
| 822 | - return {reward = reward, usual = goodsByUsual, incentive = goodsByIncentive, specials = goodsBySpecial, special = specialByRole} | 837 | + local drawReward = {} |
| 838 | + drawReward["reward"] = reward | ||
| 839 | + drawReward["usual"] = goodsByUsual | ||
| 840 | + drawReward["specials"] = goodsBySpecial | ||
| 841 | + if next(goodsByIncentive) then drawReward["incentive"] = goodsByIncentive end | ||
| 842 | + if next(specialByRole) then drawReward["special"] = specialByRole end | ||
| 843 | + return drawReward | ||
| 823 | end | 844 | end |
| 824 | 845 | ||
| 825 | --@param | 846 | --@param |
| @@ -909,6 +930,18 @@ function Capsule:clearSpecialNty(roleId, good_ids) | @@ -909,6 +930,18 @@ function Capsule:clearSpecialNty(roleId, good_ids) | ||
| 909 | self:setProperty("specialsRecord", specialsRecord) | 930 | self:setProperty("specialsRecord", specialsRecord) |
| 910 | end | 931 | end |
| 911 | 932 | ||
| 933 | +function Capsule:getRoleProgress(roleId) | ||
| 934 | + local recordByRole = self:getProperty("recordByRole") or {} | ||
| 935 | + local roleRecord = recordByRole[roleId] or {} | ||
| 936 | + local amount = 0 | ||
| 937 | + for _, v in pairs(roleRecord) do | ||
| 938 | + v.calculated = v.calculated or 0 | ||
| 939 | + if v.calculated ~= v.amount then | ||
| 940 | + amount = amount + (v.amount - v.calculated) | ||
| 941 | + end | ||
| 942 | + end | ||
| 943 | + return amount | ||
| 944 | +end | ||
| 912 | 945 | ||
| 913 | function Capsule:data(roleId) | 946 | function Capsule:data(roleId) |
| 914 | return { | 947 | return { |
| @@ -925,6 +958,7 @@ function Capsule:data(roleId) | @@ -925,6 +958,7 @@ function Capsule:data(roleId) | ||
| 925 | specials = self:getProperty("specials"), | 958 | specials = self:getProperty("specials"), |
| 926 | incentive = self:getProperty("incentive"), | 959 | incentive = self:getProperty("incentive"), |
| 927 | specialsRecord= self:getProperty("specialsRecord"), | 960 | specialsRecord= self:getProperty("specialsRecord"), |
| 961 | + roleProgress = self:getRoleProgress(roleId), | ||
| 928 | } | 962 | } |
| 929 | end | 963 | end |
| 930 | 964 |
src/models/RolePlugin.lua
| @@ -3153,10 +3153,10 @@ function RolePlugin.bind(Role) | @@ -3153,10 +3153,10 @@ function RolePlugin.bind(Role) | ||
| 3153 | return itemRandomOccupy | 3153 | return itemRandomOccupy |
| 3154 | end | 3154 | end |
| 3155 | 3155 | ||
| 3156 | - function Role:getCapsuleList(coin) | 3156 | + function Role:getCapsuleList(id) |
| 3157 | local capsules = {} | 3157 | local capsules = {} |
| 3158 | for k, v in pairs(self.capsules) do | 3158 | for k, v in pairs(self.capsules) do |
| 3159 | - if v:getProperty("coin") == coin then | 3159 | + if v:getProperty("id") == id then |
| 3160 | local onlineCount= v:getOnlineCount() | 3160 | local onlineCount= v:getOnlineCount() |
| 3161 | capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} | 3161 | capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} |
| 3162 | end | 3162 | end |
src/services/capsuled.lua
| @@ -81,7 +81,7 @@ end | @@ -81,7 +81,7 @@ end | ||
| 81 | 81 | ||
| 82 | local function add(roleId, capsuleId) | 82 | local function add(roleId, capsuleId) |
| 83 | local capsule = capsules[capsuleId] | 83 | local capsule = capsules[capsuleId] |
| 84 | - if not capsule then skynet.error("not capsule: " .. capsuleId) return end | 84 | + if not capsule then skynet.error("add not capsule: " .. capsuleId) return end |
| 85 | if next(capsule) then | 85 | if next(capsule) then |
| 86 | capsule:join(roleId) | 86 | capsule:join(roleId) |
| 87 | broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId}) | 87 | broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId}) |
| @@ -91,10 +91,12 @@ local function add(roleId, capsuleId) | @@ -91,10 +91,12 @@ local function add(roleId, capsuleId) | ||
| 91 | return nil | 91 | return nil |
| 92 | end | 92 | end |
| 93 | 93 | ||
| 94 | -local function capsuleRefreshing() | ||
| 95 | - local now = skynet.timex() | 94 | +local function capsuleRefreshing(now) |
| 96 | for _, v in pairs(capsules) do | 95 | for _, v in pairs(capsules) do |
| 97 | if v:refreshing(now) then | 96 | if v:refreshing(now) then |
| 97 | + print("刷新机器looooook....") | ||
| 98 | + print(v:getProperty("id")) | ||
| 99 | + print(v:getProperty("room")) | ||
| 98 | v:init() | 100 | v:init() |
| 99 | v:create() | 101 | v:create() |
| 100 | end | 102 | end |
| @@ -103,8 +105,9 @@ end | @@ -103,8 +105,9 @@ end | ||
| 103 | 105 | ||
| 104 | --扭蛋机刷新 | 106 | --扭蛋机刷新 |
| 105 | local function check_capsules() | 107 | local function check_capsules() |
| 106 | - pcall(capsuleRefreshing) | ||
| 107 | - skynet.timeout(60, check_capsules) | 108 | + local now = skynet.timex() |
| 109 | + pcall(capsuleRefreshing, now) | ||
| 110 | + skynet.timeout(100, check_capsules) | ||
| 108 | end | 111 | end |
| 109 | 112 | ||
| 110 | function CMD.reset() | 113 | function CMD.reset() |
| @@ -168,10 +171,10 @@ function CMD.start() | @@ -168,10 +171,10 @@ function CMD.start() | ||
| 168 | check_capsules() | 171 | check_capsules() |
| 169 | end | 172 | end |
| 170 | 173 | ||
| 171 | -function CMD.list(coin) | 174 | +function CMD.list(id) |
| 172 | local tmpCapsules = {} | 175 | local tmpCapsules = {} |
| 173 | for k, v in pairs(capsules) do | 176 | for k, v in pairs(capsules) do |
| 174 | - if v:getProperty("coin") == coin then | 177 | + if v:getProperty("id") == id then |
| 175 | local onlineCount= v:getOnlineCount() | 178 | local onlineCount= v:getOnlineCount() |
| 176 | tmpCapsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} | 179 | tmpCapsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} |
| 177 | end | 180 | end |