This commit is contained in:
aozhiwei 2022-09-21 20:06:24 +08:00
parent 9f0c5a0a19
commit c9c28a9db8
2 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,7 @@
{ {
"host": "127.0.0.1",
"port": 3306,
"user": "root",
"passwd": "keji178",
"database": "gamedb2006_dev_1"
} }

View File

@ -17,6 +17,7 @@ const ITEM_PRE = 'item_';
class Fragment { class Fragment {
async start() { async start() {
console.log('start');
while (true) { while (true) {
await this.alloc(utils.getUtcTime()); await this.alloc(utils.getUtcTime());
@ -32,7 +33,10 @@ class Fragment {
try { try {
const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE); const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE);
const hourSeconds = utils.getHourSeconds(nowTime, constant.TIME_ZONE); const hourSeconds = utils.getHourSeconds(nowTime, constant.TIME_ZONE);
const {err, conn} = await app.getDbConn("GameDb1"); const {err, conn} = await app.getDbConn("GameDb20061");
if (err) {
throw err;
}
if (!err && conn) { if (!err && conn) {
const isAlloced = await this.isAlloced(conn, daySeconds, nowTime, hourSeconds); const isAlloced = await this.isAlloced(conn, daySeconds, nowTime, hourSeconds);
if (!isAlloced) { if (!isAlloced) {
@ -143,11 +147,27 @@ class Fragment {
allocFunc(allocNode, constant.ALL_GUN_FRAGMENT, value, gunNum); allocFunc(allocNode, constant.ALL_GUN_FRAGMENT, value, gunNum);
}); });
const items = [];
allocResult.forEach( allocResult.forEach(
(value, key) => { (value, key) => {
value.forEach(
(value2, key2) => {
items.push({
'type' : key,
'item_id': key2,
'item_num': value2
});
}
);
} }
); );
await utils.serial(
items,
(element) => {
console.log(element);
}
);
} }
async getRemainData(daySeconds, nowTime, hourSeconds, allocedFragments) { async getRemainData(daySeconds, nowTime, hourSeconds, allocedFragments) {