✨ feat(服务器): 服务器命名路径修改
This commit is contained in:
@@ -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