✨ feat(服务器): 服务器命名路径修改
This commit is contained in:
@@ -3,7 +3,7 @@ import { genCode, getRandSingleEelm, isTimestamp, resResult } from '../../../pub
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { UpdateHiddenDataParam, CreatePvpConfigParam, CreateServerParam, UpdateRegionParams } from '../../../domain/backEndField/params';
|
||||
import { RegionModel, RegionType } from '../../../db/Region';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { getDicServerName } from '../../../pubUtils/data';
|
||||
import { Maintenance, ServerlistModel, ServerlistUpdate } from '../../../db/Serverlist';
|
||||
import { nowSeconds, getFutureTime, getPastTime } from '../../../pubUtils/timeUtil';
|
||||
import { calHiddenData, createNewServer } from '../../../services/gmService';
|
||||
@@ -56,9 +56,9 @@ export class GmHandler {
|
||||
console.log('******* curRegion', curRegion);
|
||||
if(!curRegion) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let { latestServer = 0 } = curRegion;
|
||||
let dicServerName = gameData.serverNames.get(latestServer + 1);
|
||||
if(!dicServerName) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let { latestServer = 0, env } = curRegion;
|
||||
let dic = getDicServerName(env, latestServer + 1);
|
||||
if(!dic) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
await createNewServer(curRegion, latestServer + 1, params, uid);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { PackageModel } from '@db/Package';
|
||||
import { Service } from 'egg';
|
||||
import { REDIS_KEY, SNS_LINK_TYPE, STATUS } from '@consts';
|
||||
import { ServerlistModel } from '@db/Serverlist';
|
||||
import { gameData } from '@pubUtils/data';
|
||||
import { gameData, getDicServerName } from '@pubUtils/data';
|
||||
import { DicHero } from '@pubUtils/dictionary/DicHero';
|
||||
import { DicRMB } from '@pubUtils/dictionary/DicRMB';
|
||||
import { DicActivityType } from '@pubUtils/dictionary/DicActivityType';
|
||||
@@ -15,7 +15,6 @@ import { ActivityGroupModel } from '@db/ActivityGroup';
|
||||
import { nowSeconds } from '@pubUtils/timeUtil';
|
||||
import { WhiteListModel } from '@db/RegionWhiteList';
|
||||
import { SearchMarqueeParam, SearchOrderParam, SearchSurveyParam } from '@domain/backEndField/search';
|
||||
import { DicServerName } from '@pubUtils/dictionary/DicServerName';
|
||||
import { CreateRegionParam, UpdateChannelParam } from '@domain/backEndField/params';
|
||||
import { UserOrderModel } from '@db/UserOrder';
|
||||
import { SurveyModel } from '@db/Survery';
|
||||
@@ -173,9 +172,10 @@ export default class Game extends Service {
|
||||
if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let activityGroups = await ActivityGroupModel.findAllActivityGroup();
|
||||
let dicServerName = getDicServerName(region.env, region.latestServer + 1);
|
||||
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
region, activityGroups
|
||||
region, activityGroups, newServerName: dicServerName?.sname
|
||||
});
|
||||
}
|
||||
|
||||
@@ -264,12 +264,9 @@ export default class Game extends Service {
|
||||
}
|
||||
|
||||
public async getServerName() {
|
||||
let list: DicServerName[] = [];
|
||||
for(let [_, serverName] of gameData.serverNames) {
|
||||
list.push(serverName);
|
||||
}
|
||||
|
||||
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list
|
||||
newServerName: '测试'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -398,7 +395,9 @@ export default class Game extends Service {
|
||||
const nextPVPTypes = await ServerGroupModel.findByTime(seasonEndTime, 2);
|
||||
|
||||
const servers = serverlists.map(server => {
|
||||
let dic = gameData.serverNames.get(server.serverId);
|
||||
let dic = getDicServerName(server.env, server.serverId);
|
||||
if(!dic) return
|
||||
|
||||
let curGVG = currentGVGTypes.find(obj => obj.serverId == server.id)?.groupId||dic.groupId;
|
||||
let nextGVG = nextGVGTypes.find(obj => obj.serverId == server.id)?.groupId||curGVG;
|
||||
let gvgTime = nextGVGTypes.find(obj => obj.serverId == server.id)?.time;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { SERVER_STATUS } from '../consts';
|
||||
import { CreateServerParam } from '../domain/backEndField/params';
|
||||
import { RegionType } from './Region';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { getDicServerName } from '../pubUtils/data';
|
||||
|
||||
export class Maintenance {
|
||||
|
||||
@@ -127,8 +127,9 @@ export default class Serverlist extends BaseModel {
|
||||
}
|
||||
|
||||
public static async newServer(params: CreateServerParam, region: RegionType, serverId: number, uid = 1 ) {
|
||||
let dicServerName = gameData.serverNames.get(serverId);
|
||||
let { prefix, id: regionId, env } = region;
|
||||
let dicServerName = getDicServerName(env, serverId);
|
||||
if(!dicServerName) return;
|
||||
// 分大区
|
||||
let { openTime, stopRegisterTime: hour, activityGroupId } = params;
|
||||
let { sname: name, groupId, groupName } = dicServerName;
|
||||
|
||||
@@ -844,21 +844,6 @@ function getCeRatio() {
|
||||
});
|
||||
}
|
||||
|
||||
// 根据服务器id获得当前大区名
|
||||
export function getServerName(id: number) {
|
||||
let name = gameData.serverNames.get(id);
|
||||
if(!name) {
|
||||
let maxId = 0;
|
||||
gameData.serverNames.forEach((sname, id) => {
|
||||
if(id > maxId) {
|
||||
maxId = id;
|
||||
name = sname;
|
||||
}
|
||||
})
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
export function getDicApByLv(level: number) {
|
||||
if(level > gameData.apMaxLevel.max) {
|
||||
return gameData.ap.get(gameData.apMaxLevel.max);
|
||||
@@ -1278,6 +1263,13 @@ function parseQuitGuildTime() {
|
||||
}
|
||||
}
|
||||
|
||||
export function getDicServerName(env: string, serverId: number) {
|
||||
let dic = gameData.serverNames.get(env);
|
||||
if(!dic) dic = gameData.serverNames.get('default');
|
||||
if(!dic) return null;
|
||||
return dic.get(serverId);
|
||||
}
|
||||
|
||||
// 初始加载
|
||||
function initDatas() {
|
||||
parseDicParam();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// 服务器名
|
||||
import { readFileAndParse } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { readServerNameFileList } from "../util";
|
||||
|
||||
// 服务器名
|
||||
export interface DicServerName {
|
||||
// id
|
||||
readonly id: number;
|
||||
@@ -13,14 +12,15 @@ export interface DicServerName {
|
||||
readonly groupName: string;
|
||||
}
|
||||
|
||||
export const dicServerName = new Map<number, DicServerName>();
|
||||
export const dicServerName = new Map<string, Map<number, DicServerName>>();
|
||||
export function loadServerName() {
|
||||
dicServerName.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_SERVER_NAME);
|
||||
|
||||
arr.forEach(o => {
|
||||
dicServerName.set(o.id, o);
|
||||
readServerNameFileList().forEach(({ name: fileName, str }) => {
|
||||
let name = fileName.split('.')[0];
|
||||
if(!dicServerName.has(name)) dicServerName.set(name, new Map());
|
||||
let arr = JSON.parse(str);
|
||||
arr.forEach(o => {
|
||||
dicServerName.get(name).set(o.id, o);
|
||||
})
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -448,6 +448,18 @@ export function readWarJsonFileList() {
|
||||
});
|
||||
}
|
||||
|
||||
export function readServerNameFileList() {
|
||||
const folder = 'serverName';
|
||||
return fs.readdirSync(__dirname + `/../resource/${folder}`)
|
||||
.filter(cur => { return cur.indexOf('.') != 0 })
|
||||
.map(file => {
|
||||
return {
|
||||
name: file,
|
||||
str: fs.readFileSync(path.resolve(__dirname, `../resource/${folder}/${file}`)).toString('utf8')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function readWordTxt(fileName: string) {
|
||||
try {
|
||||
let file = fs.readFileSync(path.resolve(__dirname, `../resource/${fileName}.txt`)).toString('utf8').replace(/^\uFEFF/, '');
|
||||
@@ -498,6 +510,7 @@ export function readWarJsonFileAndParse() {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 字典表常用解析方法
|
||||
// 解析物品 {"id": number, "count": number} 格式
|
||||
export function parseGoodStr(str: string) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
6008
shared/resource/serverName/default.json
Normal file
6008
shared/resource/serverName/default.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user