Commit 090340b9bd10fe5272a3bb78bf655d430cea98a3
1 parent
3a603a4b
fix 餐车
#人气不需要领取,直接增加 #reward 格式调整
Showing
2 changed files
with
12 additions
and
12 deletions
Show diff stats
src/actions/DinerAction.lua
| ... | ... | @@ -57,9 +57,8 @@ function _M.addSellRpc( agent, data ) |
| 57 | 57 | sells[slot] = { |
| 58 | 58 | dish = dish, |
| 59 | 59 | level = dishLevel, |
| 60 | - reward = {}, | |
| 61 | - count = 0, | |
| 62 | 60 | reward = "", |
| 61 | + count = 0, | |
| 63 | 62 | famous = 0, |
| 64 | 63 | } |
| 65 | 64 | end |
| ... | ... | @@ -122,7 +121,7 @@ function _M.getSellRewardRpc( agent, data ) |
| 122 | 121 | local sells = json.decode(role.dinerData:getProperty("sells")) |
| 123 | 122 | for slot,sell in pairs(sells) do |
| 124 | 123 | role.dinerData:updateSell(slot) |
| 125 | - for k,v in pairs(sell.reward) do | |
| 124 | + for k,v in pairs(sell.reward:toMap()) do | |
| 126 | 125 | if reward[k] then |
| 127 | 126 | reward[k] = reward[k] + v |
| 128 | 127 | else | ... | ... |
src/models/Diner.lua
| ... | ... | @@ -11,6 +11,7 @@ Diner.schema = { |
| 11 | 11 | hot = {"string", ""}, -- 今日热门 |
| 12 | 12 | dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 |
| 13 | 13 | skillTree = {"string", ""}, -- 支援天赋 |
| 14 | + popular = {"number",0}, -- 累计人气 | |
| 14 | 15 | } |
| 15 | 16 | |
| 16 | 17 | function Diner:refreshDailyData(notify) |
| ... | ... | @@ -76,21 +77,21 @@ function Diner:notifyUpdateProperty(field, newValue, oldValue) |
| 76 | 77 | SendPacket(actionCodes.Diner_updateProperty, MsgPack.pack(datas)) |
| 77 | 78 | end |
| 78 | 79 | |
| 79 | -local function calSellReward(sell, delta, dishData) | |
| 80 | +function Diner:calSellReward(sell, delta, dishData) | |
| 80 | 81 | local reward = sell.reward or "" |
| 81 | - local famous = sell.famous or 0 | |
| 82 | + local popular = 0 | |
| 82 | 83 | if delta <= 0 then |
| 83 | - return reward, famous | |
| 84 | + return reward, popular | |
| 84 | 85 | end |
| 85 | 86 | for type, value in pairs(dishData.item_normal:toNumMap()) do |
| 86 | 87 | reward = reward:incrv(type, value * delta) |
| 87 | 88 | end |
| 88 | - famous = famous + dishData.famous_normal * delta | |
| 89 | + popular = popular + dishData.famous_normal * delta | |
| 89 | 90 | if sell.hot > 0 then |
| 90 | 91 | for type, value in pairs(dishData.item_popular:toNumMap()) do |
| 91 | 92 | reward = reward:incrv(type, value * delta) |
| 92 | 93 | end |
| 93 | - famous = famous + dishData.famous_popular * delta | |
| 94 | + popular = popular + dishData.famous_popular * delta | |
| 94 | 95 | end |
| 95 | 96 | |
| 96 | 97 | for buildType = 1, 6 do |
| ... | ... | @@ -111,10 +112,10 @@ local function calSellReward(sell, delta, dishData) |
| 111 | 112 | end |
| 112 | 113 | end |
| 113 | 114 | if buildData and buildData.famous_up > 0 then |
| 114 | - famous = math.floor(famous * (100 + buildData.famous_up) / 100) | |
| 115 | + popular = math.floor(popular * (100 + buildData.famous_up) / 100) | |
| 115 | 116 | end |
| 116 | 117 | end |
| 117 | - return reward, famous | |
| 118 | + return reward, popular | |
| 118 | 119 | end |
| 119 | 120 | |
| 120 | 121 | function Diner:updateSell(slot, calOnly) |
| ... | ... | @@ -138,14 +139,14 @@ function Diner:updateSell(slot, calOnly) |
| 138 | 139 | local lastCount = sell.count - deltaCount |
| 139 | 140 | |
| 140 | 141 | if not calOnly then |
| 141 | - local reward, famous = self:calSellReward(sell, deltaCount, dishData) | |
| 142 | + local reward, popular = self:calSellReward(sell, deltaCount, dishData) | |
| 142 | 143 | sell.time = skynet.timex() - deltaTime |
| 143 | 144 | sell.count = lastCount |
| 144 | 145 | sell.level = self:getProperty("dishTree"):getv(sell.dish, 1) |
| 145 | 146 | sell.hot = self:getProperty("hot"):getv(sell.dish, 0) |
| 146 | 147 | sell.reward = reward |
| 147 | - sell.famous = famous | |
| 148 | 148 | self:setProperty("sells", json.encode(sells)) |
| 149 | + self:incrProperty("popular",popular) | |
| 149 | 150 | end |
| 150 | 151 | return { |
| 151 | 152 | deltaCount = deltaCount, | ... | ... |