Commit e820b3f342555571fcf69cb5d2af263ecd84428d
1 parent
5fb0ac5f
海港贸易季bug修正
Showing
2 changed files
with
38 additions
and
17 deletions
Show diff stats
src/actions/SeaportAction.lua
... | ... | @@ -28,23 +28,39 @@ function _M.donateRpc(agent, data) |
28 | 28 | local DonateCsv = csvdb["seaport_purchaseCsv"] |
29 | 29 | if not DonateCsv[phase] or not DonateCsv[phase][id] then return 2 end |
30 | 30 | |
31 | - local data = DonateCsv[phase][id] | |
32 | - local needs = data.need_item:toArray(true,"=") | |
31 | + local ddata = DonateCsv[phase][id] | |
32 | + local needs = ddata.need_item:toArray(true,"=") | |
33 | 33 | if itemId ~= needs[1] then return 3 end |
34 | 34 | if itemCount % needs[2] ~= 0 then return 4 end |
35 | 35 | |
36 | 36 | local group = itemCount / needs[2] |
37 | - local rewards = data.award:toNumMap() | |
37 | + local rewards = ddata.award:toNumMap() | |
38 | 38 | |
39 | 39 | for id, value in pairs(rewards) do |
40 | 40 | rewards[id] = value * group |
41 | 41 | end |
42 | 42 | |
43 | - local rediskey = {SEAPORT_TRADE_TASK_1,SEAPORT_TRADE_TASK_2} | |
44 | - redisproxy:hincrby(rediskey[phase],id,itemCount) | |
43 | + if phase == 1 then | |
44 | + local old = tonumber(redisproxy:hget(SEAPORT_TRADE_TASK_1,id)) or 0 | |
45 | + local need = ddata.need_num - old | |
46 | + if need >= itemCount then | |
47 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_1,id,itemCount) | |
48 | + else | |
49 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_1,id,need) | |
50 | + for _, temp in pairs(DonateCsv[2]) do | |
51 | + local items = temp.need_item:toArray(true,"=") | |
52 | + if items[1] == itemId then | |
53 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_2,temp.id,itemCount - need) | |
54 | + break | |
55 | + end | |
56 | + end | |
57 | + end | |
58 | + else | |
59 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_2,id,itemCount) | |
60 | + end | |
45 | 61 | |
46 | 62 | role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) |
47 | - local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = data.phase, int2 = data.id}}) | |
63 | + local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) | |
48 | 64 | |
49 | 65 | role:mylog("role_action", {desc = "seaportDonate", int1 = itemId, int2 = itemCount}) |
50 | 66 | ... | ... |
src/services/globald.lua
... | ... | @@ -155,22 +155,27 @@ end |
155 | 155 | |
156 | 156 | -- @desc: 检查海港贸易开启、关闭 |
157 | 157 | local function check_trade_seaport_status() |
158 | - local delta = 1615579200 + 1000 | |
159 | - local nowTime = delta or skynet.timex() | |
158 | + local nowTime = skynet.timex() | |
160 | 159 | local nextTime = dayLater(nowTime) |
161 | - local interval = nextTime - nowTime + 1 | |
160 | + local interval = 100 * (nextTime - nowTime + 1) | |
162 | 161 | |
163 | 162 | local curTm = os.date("*t", nowTime) |
164 | - if curTm.wday == 7 and curTm.hour == 4 then | |
165 | - redisproxy:hset("autoincrement_set", "seaportTime0", nowTime) | |
166 | - redisproxy:hset("autoincrement_set", "seaportTime1", 1) | |
167 | - redisproxy:del(SEAPORT_TRADE_TASK_1) | |
168 | - redisproxy:del(SEAPORT_TRADE_TASK_2) | |
163 | + if curTm.wday == 7 and curTm.hour >= 4 then -- 周六 | |
164 | + local oldTime = tonumber(redisproxy:hget("autoincrement_set", "seaportTime0")) or 0 | |
165 | + local cur4Time = specTime({hour = 4},nowTime) | |
166 | + if cur4Time ~= oldTime then | |
167 | + redisproxy:hset("autoincrement_set", "seaportTime0", cur4Time) | |
168 | + redisproxy:hset("autoincrement_set", "seaportTime1", 1) | |
169 | + redisproxy:del(SEAPORT_TRADE_TASK_1) | |
170 | + redisproxy:del(SEAPORT_TRADE_TASK_2) | |
171 | + end | |
169 | 172 | end |
170 | - if curTm.wday == 1 and curTm.hour == 4 then | |
171 | - redisproxy:hset("autoincrement_set", "seaportTime2", 1) | |
173 | + if curTm.wday == 1 and curTm.hour >= 4 then -- 周日 | |
174 | + if (tonumber(redisproxy:hget("autoincrement_set", "seaportTime1")) or 0) == 1 then | |
175 | + redisproxy:hset("autoincrement_set", "seaportTime2", 1) | |
176 | + end | |
172 | 177 | end |
173 | - if curTm.wday == 2 and curTm.hour == 4 then | |
178 | + if curTm.wday == 2 and curTm.hour >= 4 then -- 周一 | |
174 | 179 | -- redisproxy:hset("autoincrement_set", "seaportTime0", 0) |
175 | 180 | redisproxy:hset("autoincrement_set", "seaportTime1", 0) |
176 | 181 | redisproxy:hset("autoincrement_set", "seaportTime2", 0) | ... | ... |