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 | 459 | heroCnt = heroCnt + 1 |
460 | 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 | 468 | end |
468 | 469 | |
469 | 470 | local bnousReward = role:getBnousAdv() | ... | ... |
src/actions/CapsuleAction.lua
... | ... | @@ -17,18 +17,18 @@ function _M.listRpc(agent, data) |
17 | 17 | local role = agent.role |
18 | 18 | local msg = MsgPack.unpack(data) |
19 | 19 | local typ = msg.typ |
20 | - local coin = msg.coin | |
20 | + local id = msg.id | |
21 | 21 | |
22 | 22 | local capsules = {} |
23 | 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 | 25 | if next(ret) then |
26 | 26 | for k, v in pairs(ret) do |
27 | 27 | capsules[k] = v |
28 | 28 | end |
29 | 29 | end |
30 | 30 | elseif typ == 0 then |
31 | - local ret = role:getCapsuleList(coin) | |
31 | + local ret = role:getCapsuleList(id) | |
32 | 32 | if next(ret) then |
33 | 33 | for k, v in pairs(ret) do |
34 | 34 | capsules[k] = v | ... | ... |
src/actions/SeaportAction.lua
... | ... | @@ -267,7 +267,7 @@ function _M.shopRpc(agent, data) |
267 | 267 | local shopCsv = {} |
268 | 268 | local dataSet = csvdb["shop_normalCsv"] |
269 | 269 | for _, datat in pairs(dataSet) do |
270 | - if datat.shop == 5 then | |
270 | + if datat.shop == 4 then | |
271 | 271 | shopCsv[datat.id] = datat |
272 | 272 | end |
273 | 273 | end | ... | ... |
src/models/Capsule.lua
... | ... | @@ -145,7 +145,20 @@ function Capsule:isShow() |
145 | 145 | return true |
146 | 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 | 162 | now = now or skynet.timex() |
150 | 163 | local cur4Time = curTime or (specTime({hour = 4},now)) |
151 | 164 | |
... | ... | @@ -162,8 +175,8 @@ function Capsule:resetTimeOut(curTime, now) |
162 | 175 | local nextTime = dayLater(now) |
163 | 176 | interval = nextTime - now |
164 | 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 | 180 | end |
168 | 181 | |
169 | 182 | function Capsule:reset4TimeOut(curTime, now) |
... | ... | @@ -180,19 +193,30 @@ function Capsule:reset4TimeOut(curTime, now) |
180 | 193 | |
181 | 194 | return false |
182 | 195 | end |
183 | - interval = (interval + 1)* 100 | |
196 | + interval = (interval)* 100 | |
184 | 197 | skynet.timeout(interval, handler(self,self.reset4TimeOut)) |
185 | 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 | 211 | local cur4Time = specTime({hour = 4},now) |
190 | 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 | 215 | if now == resetArr[2] then return true end |
194 | - self:reset4TimeOut(resetArr[2], now) | |
216 | + --self:reset4TimeOut(resetArr[2], now) | |
195 | 217 | end |
218 | + | |
219 | + return false | |
196 | 220 | end |
197 | 221 | |
198 | 222 | function Capsule:refreshing(now) |
... | ... | @@ -204,29 +228,13 @@ function Capsule:refreshing(now) |
204 | 228 | if reset == "0" then |
205 | 229 | return false |
206 | 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 | 233 | return true |
209 | 234 | end |
210 | 235 | return false |
211 | 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 | 238 | end |
231 | 239 | |
232 | 240 | return false |
... | ... | @@ -613,24 +621,25 @@ function Capsule:checkIncentive(roleId, name, now) |
613 | 621 | end |
614 | 622 | |
615 | 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 | 641 | end |
632 | 642 | end |
633 | - | |
634 | 643 | end |
635 | 644 | end |
636 | 645 | |
... | ... | @@ -757,7 +766,13 @@ function Capsule:drawByCount(roleId, count) |
757 | 766 | local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) |
758 | 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 | 776 | end |
762 | 777 | |
763 | 778 | function Capsule:drawAll(roleId) |
... | ... | @@ -819,7 +834,13 @@ function Capsule:drawAll(roleId) |
819 | 834 | local goodsBySpecial = self:checkSpecialReward(now, goodsAmount) |
820 | 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 | 844 | end |
824 | 845 | |
825 | 846 | --@param |
... | ... | @@ -909,6 +930,18 @@ function Capsule:clearSpecialNty(roleId, good_ids) |
909 | 930 | self:setProperty("specialsRecord", specialsRecord) |
910 | 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 | 946 | function Capsule:data(roleId) |
914 | 947 | return { |
... | ... | @@ -925,6 +958,7 @@ function Capsule:data(roleId) |
925 | 958 | specials = self:getProperty("specials"), |
926 | 959 | incentive = self:getProperty("incentive"), |
927 | 960 | specialsRecord= self:getProperty("specialsRecord"), |
961 | + roleProgress = self:getRoleProgress(roleId), | |
928 | 962 | } |
929 | 963 | end |
930 | 964 | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -3153,10 +3153,10 @@ function RolePlugin.bind(Role) |
3153 | 3153 | return itemRandomOccupy |
3154 | 3154 | end |
3155 | 3155 | |
3156 | - function Role:getCapsuleList(coin) | |
3156 | + function Role:getCapsuleList(id) | |
3157 | 3157 | local capsules = {} |
3158 | 3158 | for k, v in pairs(self.capsules) do |
3159 | - if v:getProperty("coin") == coin then | |
3159 | + if v:getProperty("id") == id then | |
3160 | 3160 | local onlineCount= v:getOnlineCount() |
3161 | 3161 | capsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} |
3162 | 3162 | end | ... | ... |
src/services/capsuled.lua
... | ... | @@ -81,7 +81,7 @@ end |
81 | 81 | |
82 | 82 | local function add(roleId, capsuleId) |
83 | 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 | 85 | if next(capsule) then |
86 | 86 | capsule:join(roleId) |
87 | 87 | broadCastCapsule(roleId, capsuleId, {notifyType= NotifyChangeType.JOIN, roleId = roleId}) |
... | ... | @@ -91,10 +91,12 @@ local function add(roleId, capsuleId) |
91 | 91 | return nil |
92 | 92 | end |
93 | 93 | |
94 | -local function capsuleRefreshing() | |
95 | - local now = skynet.timex() | |
94 | +local function capsuleRefreshing(now) | |
96 | 95 | for _, v in pairs(capsules) do |
97 | 96 | if v:refreshing(now) then |
97 | + print("刷新机器looooook....") | |
98 | + print(v:getProperty("id")) | |
99 | + print(v:getProperty("room")) | |
98 | 100 | v:init() |
99 | 101 | v:create() |
100 | 102 | end |
... | ... | @@ -103,8 +105,9 @@ end |
103 | 105 | |
104 | 106 | --扭蛋机刷新 |
105 | 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 | 111 | end |
109 | 112 | |
110 | 113 | function CMD.reset() |
... | ... | @@ -168,10 +171,10 @@ function CMD.start() |
168 | 171 | check_capsules() |
169 | 172 | end |
170 | 173 | |
171 | -function CMD.list(coin) | |
174 | +function CMD.list(id) | |
172 | 175 | local tmpCapsules = {} |
173 | 176 | for k, v in pairs(capsules) do |
174 | - if v:getProperty("coin") == coin then | |
177 | + if v:getProperty("id") == id then | |
175 | 178 | local onlineCount= v:getOnlineCount() |
176 | 179 | tmpCapsules[k] = {id=v:getProperty("id"), room=v:getProperty("room"), typ=v:getProperty("typ"), people=onlineCount[2], coin= v:getProperty("coin")} |
177 | 180 | end | ... | ... |