diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index 25e718bc5..a38c8d5a7 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -112,6 +112,10 @@ export class GmHandler { for(let { id } of systimerServers) { await this.app.rpc.systimer.systimerRemote.reloadResources.toServer(id); } + let orderServers = this.app.getServersByType('order'); + for(let { id } of orderServers) { + await this.app.rpc.order.orderRemote.reloadResources.toServer(id); + } return resResult(STATUS.SUCCESS, { isOK: true }); diff --git a/game-server/app/servers/order/remote/orderRemote.ts b/game-server/app/servers/order/remote/orderRemote.ts new file mode 100644 index 000000000..e912ac73a --- /dev/null +++ b/game-server/app/servers/order/remote/orderRemote.ts @@ -0,0 +1,23 @@ +import { Application, ChannelService } from 'pinus'; +import { reloadResources } from '../../../pubUtils/data'; + +export default function (app: Application) { + return new OrderRemote(app); +} + +export class OrderRemote { + + constructor(private app: Application) { + this.app = app; + this.channelService = app.get('channelService'); + } + + private channelService: ChannelService; + + /** + * 重载json资源 + */ + public async reloadResources() { + reloadResources(); + } +} \ No newline at end of file diff --git a/game-server/app/servers/user.rpc.define.ts b/game-server/app/servers/user.rpc.define.ts index e09f7a478..9f653f6bd 100644 --- a/game-server/app/servers/user.rpc.define.ts +++ b/game-server/app/servers/user.rpc.define.ts @@ -14,6 +14,7 @@ import { RoleRemote } from './role/remote/roleRemote'; import { GuildActivityRemote } from './guild/remote/guildActivityRemote'; import { GuildRemote as GuildRemote2 } from './guild/remote/guildRemote'; import { ActivityRemote } from './activity/remote/activityRemote'; +import { OrderRemote } from './order/remote/orderRemote'; declare global { interface UserRpc { activity: { @@ -42,6 +43,9 @@ declare global { }, role: { roleRemote: RemoterClass; + }, + order: { + orderRemote: RemoterClass; } } } \ No newline at end of file diff --git a/shared/domain/activityField/growthFundField.ts b/shared/domain/activityField/growthFundField.ts index bd4935852..ff75aad37 100644 --- a/shared/domain/activityField/growthFundField.ts +++ b/shared/domain/activityField/growthFundField.ts @@ -1,4 +1,4 @@ -import { TASK_TYPE, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../consts'; +import { ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../consts'; import { ActivityModelType } from '../../db/Activity'; import { ActivityBuyRecordsModelType } from '../../db/ActivityBuyRecords'; import { ActivityGrowthFundModelType } from '../../db/ActivityGrowthFund'; diff --git a/shared/domain/activityField/limitShopField.ts b/shared/domain/activityField/limitShopField.ts index 35d4b93da..b47faf02c 100644 --- a/shared/domain/activityField/limitShopField.ts +++ b/shared/domain/activityField/limitShopField.ts @@ -1,5 +1,4 @@ import moment = require('moment'); -import { ACTIVITY_RESOURCES_TYPE } from '../../consts'; import { ActivityModelType } from '../../db/Activity'; import { ActivityShopModelType } from '../../db/ActivityShop'; import { ActivityBase } from './activityField'; diff --git a/shared/domain/activityField/selfServiceShopField.ts b/shared/domain/activityField/selfServiceShopField.ts index 5d608257a..c46b59050 100644 --- a/shared/domain/activityField/selfServiceShopField.ts +++ b/shared/domain/activityField/selfServiceShopField.ts @@ -1,7 +1,5 @@ -import { SELF_SERVICE_SHOP_CELL_TYPE, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../consts'; import { ActivityModelType } from '../../db/Activity'; import { ActivitySelfServiceShopModelType } from '../../db/ActivitySelfServiceShop'; -import { deltaDays } from '../../pubUtils/util'; import { ActivityBase } from './activityField'; // 自助商店数据坑位数据 diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index cc2b85357..7bdfc3065 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -81,6 +81,7 @@ import { dicGacha, loadGacha } from "./dictionary/DicGacha"; import { dicGachaContent, dicGachaContentHero, loadGachaContent } from "./dictionary/DicGachaContent"; import { dicGiftPackage, loadGiftPackage } from "./dictionary/DicGiftPackage"; import { dicRecruit, loadRecruit } from './dictionary/DicRecruit'; +import { loadRMB } from './dictionary/DicRMB'; export const gameData = { blurprtCompose: dicBlueprtCompose, @@ -756,34 +757,37 @@ function loadDatas() { loadGachaContent(); loadGiftPackage(); loadRecruit(); + loadRMB(); } // 重载dicParam export function reloadDicParam() { let file = readTsFile('dicParam'); - - let lines = file.split('\n'); - let outer = ''; - lines.forEach(line => { - if(line.replace(/ /g, '')) { - if(line.indexOf('export') != -1) { - outer = line.split(' ')[2]; - // console.log(outer) - } - if(line.indexOf('export') == -1 && line.indexOf('}') == -1) { - let s = line.split(', //')[0].split(':'); - let key = s[0].replace(/ /g, ''); - let value = s[1].replace(/ /g, ''); - let isString = value.match(/(?<=')[^']*/); - if(isString) { - param[outer][key] = isString[0]; - } else { - param[outer][key] = parseFloat(value); + if(file) { + let lines = file.split('\n'); + let outer = ''; + lines.forEach(line => { + if(line.replace(/ /g, '')) { + if(line.indexOf('export') != -1) { + outer = line.split(' ')[2]; + // console.log(outer) + } + if(line.indexOf('export') == -1 && line.indexOf('}') == -1) { + let s = line.split(', //')[0].split(':'); + let key = s[0].replace(/ /g, ''); + let value = s[1].replace(/ /g, ''); + let isString = value.match(/(?<=')[^']*/); + if(isString) { + param[outer][key] = isString[0]; + } else { + param[outer][key] = parseFloat(value); + } } } - } - }); - parseDicParam(); + }); + parseDicParam(); + } + } // 后台调用重载资源 diff --git a/shared/pubUtils/dictionary/DicArmy.ts b/shared/pubUtils/dictionary/DicArmy.ts deleted file mode 100644 index e532c8ce3..000000000 --- a/shared/pubUtils/dictionary/DicArmy.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { readJsonFile, parseGoodStr } from '../util' -import { FILENAME } from '../../consts' -type KeysEnum = { [P in keyof Required]: true }; -import { RewardInter } from '../interface'; -const _ = require('lodash'); - -export interface DicArmyBossRank { - readonly id: number; - readonly rankMin: number; - readonly rankMax: number; - readonly reward: Array; -} - -const DicArmyBossRankKeys: KeysEnum = { - id: true, - rankMin: true, - rankMax: true, - reward: true, -}; - -const str = readJsonFile(FILENAME.DIC_ARMY_BOSS_RANK_REWARD); -let arr = JSON.parse(str); - -export const dicArmyBossRank = new Array(); -arr.forEach(o => { - o.reward = parseGoodStr(o.reward); - dicArmyBossRank.push(_.pick(o, Object.keys(DicArmyBossRankKeys))); -}); -arr = undefined; \ No newline at end of file diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index 24a4b9d7d..0ca8c2051 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -405,8 +405,12 @@ export function readWarJsonFileList() { } export function readTsFile(fileName: string) { - let file = fs.readFileSync(path.resolve(__dirname, `../pubUtils/${fileName}.ts`)).toString('utf8').replace(/^\uFEFF/, ''); - return file; + try { + let file = fs.readFileSync(path.resolve(__dirname, `../pubUtils/${fileName}.ts`)).toString('utf8').replace(/^\uFEFF/, ''); + return file; + } catch(e) { + return null + } } export function readFileAndParse(fileName: string) { diff --git a/web-server/app/middleware/parmsDecode.ts b/web-server/app/middleware/parmsDecode.ts index 9fb4fe8a6..d9c9bb72c 100644 --- a/web-server/app/middleware/parmsDecode.ts +++ b/web-server/app/middleware/parmsDecode.ts @@ -20,7 +20,8 @@ function aesDecrypt(data, key, iv) { module.exports = options => { return async function parmsDecode(ctx: Context, next) { let m = ctx.request.url.indexOf("/dev"); - if(m == 0) { + let n = ctx.request.url.indexOf("/web"); + if(m == 0 || n == 0) { await next(); return; }