Commit 37037eebce759fd4a355508ad01a73716de6ee58

Authored by zhengshouren
1 parent 0c0b161d

计算奖励

1 -Subproject commit 99bfdd1307c6d1747124b4d614ca55d6830f34aa 1 +Subproject commit dce531485f84bb7a555e9bb35b22c58fb469192c
@@ -58,7 +58,7 @@ ItemId = { @@ -58,7 +58,7 @@ ItemId = {
58 PlayerExp = 4, -- 突破材料 58 PlayerExp = 4, -- 突破材料
59 BreakCost = 10, -- 突破材料 59 BreakCost = 10, -- 突破材料
60 EquipUp = 11, -- 装备升级材料 60 EquipUp = 11, -- 装备升级材料
61 - SupSkillUp = 12, --支援技升级材料 61 + DinerCoin = 12, --后勤物资
62 LoveUp = 14, --好感度提升道具 62 LoveUp = 14, --好感度提升道具
63 LoveBreak = 21, --好感度突破道具 63 LoveBreak = 21, --好感度突破道具
64 BoxKey = 20, -- 开箱钥匙 64 BoxKey = 20, -- 开箱钥匙
src/actions/DinerAction.lua
@@ -59,6 +59,8 @@ function _M.addSellRpc( agent, data ) @@ -59,6 +59,8 @@ function _M.addSellRpc( agent, data )
59 level = dishLevel, 59 level = dishLevel,
60 reward = {}, 60 reward = {},
61 count = 0, 61 count = 0,
  62 + reward = "",
  63 + famous = 0,
62 } 64 }
63 end 65 end
64 local sell = sells[slot] 66 local sell = sells[slot]
src/actions/HangAction.lua
@@ -193,6 +193,7 @@ end @@ -193,6 +193,7 @@ end
193 function _M.roleFormatRpc(agent , data) 193 function _M.roleFormatRpc(agent , data)
194 local role = agent.role 194 local role = agent.role
195 local msg = MsgPack.unpack(data) 195 local msg = MsgPack.unpack(data)
  196 + dump(msg)
196 local hangTeam = role:getProperty("hangTeam") 197 local hangTeam = role:getProperty("hangTeam")
197 for slot, heroId in pairs(msg.heros) do 198 for slot, heroId in pairs(msg.heros) do
198 if not role.heros[heroId] then 199 if not role.heros[heroId] then
1 -Subproject commit d3aeaaee05774f52eb0a42f851adf90978fed324 1 +Subproject commit a877f94b084a3571e2f3d57e4997fd00c0a51eaf
@@ -15,8 +15,8 @@ skynet.start(function() @@ -15,8 +15,8 @@ skynet.start(function()
15 ngxd = ngxd, 15 ngxd = ngxd,
16 16
17 redishost = "127.0.0.1", 17 redishost = "127.0.0.1",
18 - redisport = 6100,  
19 - redisdb = 1, 18 + redisport = 6379,
  19 + redisdb = 10,
20 auth = nil, 20 auth = nil,
21 21
22 mongohost = "127.0.0.1", 22 mongohost = "127.0.0.1",
src/models/Diner.lua
@@ -76,6 +76,47 @@ function Diner:notifyUpdateProperty(field, newValue, oldValue) @@ -76,6 +76,47 @@ function Diner:notifyUpdateProperty(field, newValue, oldValue)
76 SendPacket(actionCodes.Diner_updateProperty, MsgPack.pack(datas)) 76 SendPacket(actionCodes.Diner_updateProperty, MsgPack.pack(datas))
77 end 77 end
78 78
  79 +local function calSellReward(sell, delta, dishData)
  80 + local reward = sell.reward or ""
  81 + local famous = sell.famous or 0
  82 + if delta <= 0 then
  83 + return reward, famous
  84 + end
  85 + for type, value in pairs(dishData.item_normal:toNumMap()) do
  86 + reward = reward:incrv(type, value * delta)
  87 + end
  88 + famous = famous + dishData.famous_normal * delta
  89 + if sell.hot > 0 then
  90 + for type, value in pairs(dishData.item_popular:toNumMap()) do
  91 + reward = reward:incrv(type, value * delta)
  92 + end
  93 + famous = famous + dishData.famous_popular * delta
  94 + end
  95 +
  96 + for buildType = 1, 6 do
  97 + local level = self:getProperty("buildL"):getv(buildType, 1)
  98 + local buildData = csvdb["diner_buildingCsv"][buildType][level]
  99 + if buildData.gold_up > 0 then
  100 + local value = reward:getv(ItemId.Gold, 0)
  101 + value = math.floor(value * (100 + buildData.gold_up) / 100)
  102 + if value > 0 then
  103 + reward = reward:setv(ItemId.Gold, value)
  104 + end
  105 + end
  106 + if buildData.item_up > 0 then
  107 + local value = reward:getv(ItemId.DinerCoin, 0)
  108 + value = math.floor(value * (100 + buildData.item_up) / 100)
  109 + if value > 0 then
  110 + reward = reward:setv(ItemId.DinerCoin, value)
  111 + end
  112 + end
  113 + if buildData and buildData.famous_up > 0 then
  114 + famous = math.floor(famous * (100 + buildData.famous_up) / 100)
  115 + end
  116 + end
  117 + return reward, famous
  118 +end
  119 +
79 function Diner:updateSell(slot, calOnly) 120 function Diner:updateSell(slot, calOnly)
80 local sells = json.decode(self:getProperty("sells")) 121 local sells = json.decode(self:getProperty("sells"))
81 local sell = sells[slot] 122 local sell = sells[slot]
@@ -88,9 +129,7 @@ function Diner:updateSell(slot, calOnly) @@ -88,9 +129,7 @@ function Diner:updateSell(slot, calOnly)
88 local deltaCount = 0 129 local deltaCount = 0
89 local timePass = skynet.timex() - sell.time 130 local timePass = skynet.timex() - sell.time
90 local sellTime = dishData.sell_time 131 local sellTime = dishData.sell_time
91 - if self:getProperty("hot"):getv(sell.dish, 0) > 0 then  
92 - sellTime = sellTime * 1.5  
93 - end 132 +
94 deltaCount = math.floor(timePass / sellTime) 133 deltaCount = math.floor(timePass / sellTime)
95 if deltaCount < sell.count then 134 if deltaCount < sell.count then
96 deltaTime = math.floor(timePass - sellTime * deltaCount) 135 deltaTime = math.floor(timePass - sellTime * deltaCount)
@@ -99,33 +138,13 @@ function Diner:updateSell(slot, calOnly) @@ -99,33 +138,13 @@ function Diner:updateSell(slot, calOnly)
99 local lastCount = sell.count - deltaCount 138 local lastCount = sell.count - deltaCount
100 139
101 if not calOnly then 140 if not calOnly then
102 - local reward = {}  
103 - if deltaCount > 0 then  
104 - local tmp = dishData.item_normal:toNumMap()  
105 - if sell.hot then  
106 - for k,v in pairs(dishData.item_popular:toNumMap()) do  
107 - if tmp[k] then  
108 - tmp[k] = tmp[k] + v  
109 - else  
110 - tmp[k] = v  
111 - end  
112 - end  
113 - end  
114 -  
115 - for k, n in pairs(tmp) do  
116 - local sum = n*deltaCount  
117 - if reward[tostring(k)] then  
118 - reward[tostring(k)] = reward[tostring(k)] + sum  
119 - else  
120 - reward[tostring(k)] = sum  
121 - end  
122 - end  
123 - end  
124 - 141 + local reward, famous = self:calSellReward(sell, deltaCount, dishData)
125 sell.time = skynet.timex() - deltaTime 142 sell.time = skynet.timex() - deltaTime
126 sell.count = lastCount 143 sell.count = lastCount
127 sell.level = self:getProperty("dishTree"):getv(sell.dish, 1) 144 sell.level = self:getProperty("dishTree"):getv(sell.dish, 1)
  145 + sell.hot = self:getProperty("hot"):getv(sell.dish, 0)
128 sell.reward = reward 146 sell.reward = reward
  147 + sell.famous = famous
129 self:setProperty("sells", json.encode(sells)) 148 self:setProperty("sells", json.encode(sells))
130 end 149 end
131 return { 150 return {
src/models/Role.lua
@@ -35,6 +35,7 @@ Role.schema = { @@ -35,6 +35,7 @@ Role.schema = {
35 exp = {"number", 0}, 35 exp = {"number", 0},
36 items = {"string", ""}, 36 items = {"string", ""},
37 loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL 37 loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL
  38 + crown = {"number", 0}, -- 看伴娘
38 39
39 bagLimit = {"table", globalCsv.store_limit_max}, 40 bagLimit = {"table", globalCsv.store_limit_max},
40 41