Commit 4cd978194a935e556a54146cb950493385b71224
1 parent
ffb897e9
工作日玩法增加机器人
Showing
2 changed files
with
22 additions
and
2 deletions
Show diff stats
src/services/globald.lua
... | ... | @@ -245,6 +245,23 @@ local function check_trade_seaport_donate() |
245 | 245 | skynet.timeout(interval * 100, check_trade_seaport_donate) |
246 | 246 | end |
247 | 247 | |
248 | +local function check_work_battle() | |
249 | + local csvdb = require "shared.csvdata" | |
250 | + local now = skynet.timex() | |
251 | + local day = weekday(now) | |
252 | + local workMainCsv = csvdb["work_mainCsv"][day] | |
253 | + if workMainCsv and isSpecTime(now - RESET_TIME * 3600, csvdb["time_resetCsv"][TimeReset["WorkBattle1"]].start / 3600, 24) then | |
254 | + local round = math.floor((now - START_RESET_TIME) / 604800) | |
255 | + local field = round * 10 + day | |
256 | + local count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, field)) | |
257 | + if count < workMainCsv.target_num then | |
258 | + local add = math.floor(workMainCsv.target_num * math.randomInt(3125, 5000) / 100000) | |
259 | + redisproxy:hincrby(WORK_BATTLE_COUNT, field, add) | |
260 | + end | |
261 | + end | |
262 | + skynet.timeout(math.randomInt(10, 15) * 60 * 100, check_work_battle) | |
263 | +end | |
264 | + | |
248 | 265 | local CMD = {} |
249 | 266 | |
250 | 267 | |
... | ... | @@ -266,10 +283,12 @@ end |
266 | 283 | |
267 | 284 | |
268 | 285 | function CMD.start() |
286 | + math.randomInit(skynet.timex()) | |
269 | 287 | check_mail_queue() |
270 | 288 | --check_battle_act_close() |
271 | 289 | check_trade_seaport_status() |
272 | 290 | check_trade_seaport_donate() |
291 | + check_work_battle() | |
273 | 292 | end |
274 | 293 | |
275 | 294 | local function __init__() | ... | ... |
src/utils/CommonFunc.lua
... | ... | @@ -235,8 +235,9 @@ function specMonday(now) |
235 | 235 | return time - (wday - 1) * 86400 |
236 | 236 | end |
237 | 237 | |
238 | -function isSpecTime(startHour, endHour, specday) | |
239 | - local tm = os.date("*t", skynet.timex()) | |
238 | +function isSpecTime(ctime, startHour, endHour, specday) | |
239 | + ctime = ctime or skynet.timex() | |
240 | + local tm = os.date("*t", ctime) | |
240 | 241 | if specday then |
241 | 242 | local day = (tm.wday+6)%7 |
242 | 243 | if day == 0 then day = 7 end | ... | ... |