Commit 9962b061fa40582d9c186888aa71bcddab4e8f96
1 parent
5af8b4aa
补充 挂机
Showing
4 changed files
with
66 additions
and
16 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/HangAction.lua
@@ -24,11 +24,11 @@ local function checkReward(role) | @@ -24,11 +24,11 @@ local function checkReward(role) | ||
24 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | 24 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] |
25 | local nowTime = math.min(skynet.timex(), hangInfo.endTime or 0) | 25 | local nowTime = math.min(skynet.timex(), hangInfo.endTime or 0) |
26 | 26 | ||
27 | - local coinCount = math.max(0, math.floor((nowTime - hangInfo.coinTime) / 5)) | ||
28 | - hangInfo.coinTime = hangInfo.coinTime + coinCount * 5 | 27 | + local coinCount = math.max(0, math.floor((nowTime - hangInfo.coinTime) / globalCsv.idle_money_produce_cd)) |
28 | + hangInfo.coinTime = hangInfo.coinTime + coinCount * globalCsv.idle_money_produce_cd | ||
29 | 29 | ||
30 | - local itemCount = math.max(0, math.floor((nowTime - hangInfo.itemTime) / 60)) | ||
31 | - hangInfo.itemTime = hangInfo.itemTime + itemCount * 60 | 30 | + local itemCount = math.max(0, math.floor((nowTime - hangInfo.itemTime) / globalCsv.idle_item_produce_cd)) |
31 | + hangInfo.itemTime = hangInfo.itemTime + itemCount * globalCsv.idle_item_produce_cd | ||
32 | 32 | ||
33 | local items = role:getProperty("hangBag") | 33 | local items = role:getProperty("hangBag") |
34 | items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money | 34 | items[ItemId.Gold] = (items[ItemId.Gold] or 0) + coinCount * carbonData.money |
@@ -38,9 +38,20 @@ local function checkReward(role) | @@ -38,9 +38,20 @@ local function checkReward(role) | ||
38 | for _, temp in pairs(carbonData.item:toArray()) do | 38 | for _, temp in pairs(carbonData.item:toArray()) do |
39 | table.insert(pool, temp:toArray(true, "=")) | 39 | table.insert(pool, temp:toArray(true, "=")) |
40 | end | 40 | end |
41 | + local curTypeCount = 0 | ||
42 | + for id, _ in pairs(items) do | ||
43 | + if id ~= ItemId.Gold and id ~= ItemId.Exp then | ||
44 | + curTypeCount = curTypeCount + 1 | ||
45 | + end | ||
46 | + end | ||
41 | for i = 1, itemCount do | 47 | for i = 1, itemCount do |
42 | local cur = pool[math.randWeight(pool, 3)] | 48 | local cur = pool[math.randWeight(pool, 3)] |
43 | - items[cur[1]] = (items[cur[1]] or 0) + cur[2] | 49 | + if items[cur[1]] or curTypeCount < role:getProperty("hangBagLimit") then |
50 | + if not items[cur[1]] then | ||
51 | + curTypeCount = curTypeCount + 1 | ||
52 | + end | ||
53 | + items[cur[1]] = (items[cur[1]] or 0) + cur[2] | ||
54 | + end | ||
44 | end | 55 | end |
45 | 56 | ||
46 | if coinCount > 0 or itemCount > 0 then | 57 | if coinCount > 0 or itemCount > 0 then |
@@ -72,7 +83,7 @@ function _M.startRpc( agent, data ) | @@ -72,7 +83,7 @@ function _M.startRpc( agent, data ) | ||
72 | hangInfo.coinTime = nowTime | 83 | hangInfo.coinTime = nowTime |
73 | hangInfo.itemTime = nowTime | 84 | hangInfo.itemTime = nowTime |
74 | if isNew then | 85 | if isNew then |
75 | - hangInfo.endTime = nowTime + 12 * 3600 | 86 | + hangInfo.endTime = nowTime + globalCsv.idle_producetime_max |
76 | end | 87 | end |
77 | if not hangPass[carbonId] then | 88 | if not hangPass[carbonId] then |
78 | hangInfo.bossTime = nowTime + carbonData.idle_time | 89 | hangInfo.bossTime = nowTime + carbonData.idle_time |
@@ -128,16 +139,13 @@ function _M.endBattleRpc(agent, data) | @@ -128,16 +139,13 @@ function _M.endBattleRpc(agent, data) | ||
128 | 139 | ||
129 | -- reward | 140 | -- reward |
130 | reward = {} | 141 | reward = {} |
131 | - local items = role:getProperty("hangBag") | ||
132 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | 142 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] |
133 | - items[ItemId.Gold] = (items[ItemId.Gold] or 0) + carbonData.money_clear | ||
134 | - items[ItemId.Exp] = (items[ItemId.Exp] or 0) + carbonData.exp_clear | ||
135 | reward[ItemId.Gold] = carbonData.money_clear | 143 | reward[ItemId.Gold] = carbonData.money_clear |
136 | reward[ItemId.Exp] = carbonData.exp_clear | 144 | reward[ItemId.Exp] = carbonData.exp_clear |
137 | for itemId, count in pairs(carbonData.item_clear:toNumMap()) do | 145 | for itemId, count in pairs(carbonData.item_clear:toNumMap()) do |
138 | - items[itemId] = (items[itemId] or 0) + count | ||
139 | reward[itemId] = count | 146 | reward[itemId] = count |
140 | end | 147 | end |
148 | + reward = role:award(reward, {}) | ||
141 | end | 149 | end |
142 | hangInfo.key = nil | 150 | hangInfo.key = nil |
143 | role:updateProperty({field = "hangInfo", value = hangInfo}) | 151 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
@@ -178,7 +186,7 @@ function _M.getRewardRpc(agent , data) | @@ -178,7 +186,7 @@ function _M.getRewardRpc(agent , data) | ||
178 | table.clear(items) | 186 | table.clear(items) |
179 | local hangInfo = role:getProperty("hangInfo") | 187 | local hangInfo = role:getProperty("hangInfo") |
180 | local nowTime = skynet.timex() | 188 | local nowTime = skynet.timex() |
181 | - hangInfo.endTime = nowTime + 12 * 3600 | 189 | + hangInfo.endTime = nowTime + globalCsv.idle_producetime_max |
182 | hangInfo.coinTime = nowTime | 190 | hangInfo.coinTime = nowTime |
183 | hangInfo.itemTime = nowTime | 191 | hangInfo.itemTime = nowTime |
184 | role:updateProperty({field = "hangBag", value = items}) | 192 | role:updateProperty({field = "hangBag", value = items}) |
@@ -190,4 +198,47 @@ function _M.getRewardRpc(agent , data) | @@ -190,4 +198,47 @@ function _M.getRewardRpc(agent , data) | ||
190 | return true | 198 | return true |
191 | end | 199 | end |
192 | 200 | ||
201 | + | ||
202 | +function _M.quickRpc(agent , data) | ||
203 | + local role = agent.role | ||
204 | + | ||
205 | + local hangInfo = role:getProperty("hangInfo") | ||
206 | + if not hangInfo.carbonId then return end | ||
207 | + local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | ||
208 | + | ||
209 | + local curCount = role.dailyData:getProperty("hangQC") + 1 | ||
210 | + local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") | ||
211 | + if not costs[curCount] then return end | ||
212 | + if costs[curCount] > 0 then | ||
213 | + if not role:checkItemEnough({[ItemId.Diamond] = costs[curCount]}) then return end | ||
214 | + role:costItems({[ItemId.Diamond] = costs[curCount]}, {}) | ||
215 | + end | ||
216 | + | ||
217 | + role.dailyData:updateProperty({field = "hangQC", value = curCount}) | ||
218 | + | ||
219 | + local time = globalCsv.idle_quickproduce_time | ||
220 | + local reward = {} | ||
221 | + | ||
222 | + local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) | ||
223 | + local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) | ||
224 | + reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + coinCount * carbonData.money | ||
225 | + reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + coinCount * carbonData.exp | ||
226 | + | ||
227 | + local pool = {} | ||
228 | + for _, temp in pairs(carbonData.item:toArray()) do | ||
229 | + table.insert(pool, temp:toArray(true, "=")) | ||
230 | + end | ||
231 | + for i = 1, itemCount do | ||
232 | + local cur = pool[math.randWeight(pool, 3)] | ||
233 | + reward[cur[1]] = (reward[cur[1]] or 0) + cur[2] | ||
234 | + end | ||
235 | + | ||
236 | + reward = role:award(reward, {}) | ||
237 | + | ||
238 | + SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ | ||
239 | + reward = reward | ||
240 | + })) | ||
241 | + return true | ||
242 | +end | ||
243 | + | ||
193 | return _M | 244 | return _M |
194 | \ No newline at end of file | 245 | \ No newline at end of file |
src/models/Daily.lua
@@ -8,6 +8,7 @@ end | @@ -8,6 +8,7 @@ end | ||
8 | 8 | ||
9 | Daily.schema = { | 9 | Daily.schema = { |
10 | commentHero = {"string", ""}, --单日评论食灵记录 type=1 | 10 | commentHero = {"string", ""}, --单日评论食灵记录 type=1 |
11 | + hangQC ={"number", 0}, -- 挂机快速次数 | ||
11 | } | 12 | } |
12 | 13 | ||
13 | function Daily:updateProperty(params) | 14 | function Daily:updateProperty(params) |
@@ -41,6 +42,7 @@ end | @@ -41,6 +42,7 @@ end | ||
41 | function Daily:data() | 42 | function Daily:data() |
42 | return { | 43 | return { |
43 | -- dailyTaskStatus = self:getProperty("dailyTaskStatus"), | 44 | -- dailyTaskStatus = self:getProperty("dailyTaskStatus"), |
45 | + hangQC = self:getProperty("hangQC"), | ||
44 | } | 46 | } |
45 | end | 47 | end |
46 | 48 |
src/models/Role.lua
@@ -31,8 +31,6 @@ Role.schema = { | @@ -31,8 +31,6 @@ Role.schema = { | ||
31 | 31 | ||
32 | -- roleInfo | 32 | -- roleInfo |
33 | level = {"number", 0}, | 33 | level = {"number", 0}, |
34 | - diamond = {"number", 0}, | ||
35 | - reDiamond = {"number", 0}, | ||
36 | items = {"string", ""}, | 34 | items = {"string", ""}, |
37 | loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL | 35 | loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL |
38 | 36 | ||
@@ -47,7 +45,7 @@ Role.schema = { | @@ -47,7 +45,7 @@ Role.schema = { | ||
47 | hangTeam = {"table", {}}, -- 挂机队伍 | 45 | hangTeam = {"table", {}}, -- 挂机队伍 |
48 | hangInfo = {"table", {}}, -- 当前挂机信息 | 46 | hangInfo = {"table", {}}, -- 当前挂机信息 |
49 | hangBag = {"table", {}}, -- 背包 | 47 | hangBag = {"table", {}}, -- 背包 |
50 | - hangBagLimit = {"number", 10}, --背包上限 | 48 | + hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 |
51 | 49 | ||
52 | } | 50 | } |
53 | 51 | ||
@@ -147,8 +145,6 @@ function Role:data() | @@ -147,8 +145,6 @@ function Role:data() | ||
147 | id = self:getProperty("id"), | 145 | id = self:getProperty("id"), |
148 | name = self:getProperty("name"), | 146 | name = self:getProperty("name"), |
149 | level = self:getProperty("level"), | 147 | level = self:getProperty("level"), |
150 | - diamond = self:getProperty("diamond"), | ||
151 | - reDiamond = self:getProperty("reDiamond"), | ||
152 | items = self:getProperty("items"):toNumMap(), | 148 | items = self:getProperty("items"):toNumMap(), |
153 | loveStatus = self:getProperty("loveStatus"):toNumMap(), | 149 | loveStatus = self:getProperty("loveStatus"):toNumMap(), |
154 | 150 |