From c9c28a9db8620e7c4f401b7273c071764a83db16 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Sep 2022 20:06:24 +0800 Subject: [PATCH] 1 --- .../game2006service/config/gamedb2006.json | 6 ++++- server/game2006service/tasks/fragment.js | 22 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/server/bin/game2006service/config/gamedb2006.json b/server/bin/game2006service/config/gamedb2006.json index 0db3279e..e8879638 100644 --- a/server/bin/game2006service/config/gamedb2006.json +++ b/server/bin/game2006service/config/gamedb2006.json @@ -1,3 +1,7 @@ { - + "host": "127.0.0.1", + "port": 3306, + "user": "root", + "passwd": "keji178", + "database": "gamedb2006_dev_1" } diff --git a/server/game2006service/tasks/fragment.js b/server/game2006service/tasks/fragment.js index 0a4bade7..6e4ae3d0 100644 --- a/server/game2006service/tasks/fragment.js +++ b/server/game2006service/tasks/fragment.js @@ -17,6 +17,7 @@ const ITEM_PRE = 'item_'; class Fragment { async start() { + console.log('start'); while (true) { await this.alloc(utils.getUtcTime()); @@ -32,7 +33,10 @@ class Fragment { try { const daySeconds = utils.getDaySeconds(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) { const isAlloced = await this.isAlloced(conn, daySeconds, nowTime, hourSeconds); if (!isAlloced) { @@ -143,11 +147,27 @@ class Fragment { allocFunc(allocNode, constant.ALL_GUN_FRAGMENT, value, gunNum); }); + const items = []; allocResult.forEach( (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) {