Files
ZYZ/gm-server/app/service/Game.ts
2021-05-26 19:36:19 +08:00

55 lines
1.5 KiB
TypeScript

import { Service } from 'egg';
import { STATUS } from '@consts';
import { GameModel } from '@db/Game';
import { ServerlistModel } from '@db/Serverlist';
import { gameData } from '@pubUtils/data';
import { DicHero } from '@pubUtils/dictionary/DicHero';
/**
* Test Service
*/
export default class Game extends Service {
/**
* 获取正式服,测试服,开发服等环境
*/
public async getServerEnv() {
const { ctx, app } = this;
const list = await GameModel.getServerEnvList();
return ctx.service.utils.resResult(STATUS.SUCCESS, {
list,
env: app.config.env
});
}
/**
* 获取正式服,测试服,开发服等环境
*/
public async getServerListByEnv() {
const { ctx, app } = this;
const envlist = await GameModel.getServerEnvList();
let cur = envlist.find(cur => cur.env == app.config.env);
if(!cur) return ctx.service.utils.resResult(STATUS.SUCCESS, { list: [] });
const list = await ServerlistModel.findByServerType(cur.serverType);
return ctx.service.utils.resResult(STATUS.SUCCESS, {
list
});
}
public async getDicHero() {
let list: DicHero[] = [];
for(let [heroId, hero] of gameData.hero) {
if(heroId <= 300) {
list.push(hero)
}
}
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
list
})
}
}