Commit 090340b9bd10fe5272a3bb78bf655d430cea98a3

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