add season.js
This commit is contained in:
parent
9d78c8c141
commit
459df7f160
@ -8,6 +8,7 @@ function add(name) {
|
||||
function init() {
|
||||
add('fragment');
|
||||
add('damping');
|
||||
add('season');
|
||||
}
|
||||
|
||||
exports.init = init;
|
||||
|
32
server/game2006service/tasks/season.js
Normal file
32
server/game2006service/tasks/season.js
Normal file
@ -0,0 +1,32 @@
|
||||
const app = require('j7/app');
|
||||
const utils = require('j7/utils');
|
||||
const metaFactory = require('../metadata/factory');
|
||||
|
||||
const constant = require('../constant');
|
||||
|
||||
class Season {
|
||||
async start() {
|
||||
while (true) {
|
||||
await this.doRoutine(utils.getUtcTime());
|
||||
const nowTime = utils.getUtcTime();
|
||||
const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE);
|
||||
const sleepTime = daySeconds + 3600 * 24 - nowTime;
|
||||
await utils.sleep(sleepTime*1000);
|
||||
}
|
||||
}
|
||||
|
||||
async doRoutine(nowTime) {
|
||||
try {
|
||||
|
||||
}
|
||||
catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
(new Season()).start();
|
||||
}
|
||||
|
||||
exports.init = init;
|
Loading…
x
Reference in New Issue
Block a user