✨ feat(服务器): 服务器命名路径修改
This commit is contained in:
@@ -3,7 +3,7 @@ import { genCode, getRandSingleEelm, isTimestamp, resResult } from '../../../pub
|
|||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import { UpdateHiddenDataParam, CreatePvpConfigParam, CreateServerParam, UpdateRegionParams } from '../../../domain/backEndField/params';
|
import { UpdateHiddenDataParam, CreatePvpConfigParam, CreateServerParam, UpdateRegionParams } from '../../../domain/backEndField/params';
|
||||||
import { RegionModel, RegionType } from '../../../db/Region';
|
import { RegionModel, RegionType } from '../../../db/Region';
|
||||||
import { gameData } from '../../../pubUtils/data';
|
import { getDicServerName } from '../../../pubUtils/data';
|
||||||
import { Maintenance, ServerlistModel, ServerlistUpdate } from '../../../db/Serverlist';
|
import { Maintenance, ServerlistModel, ServerlistUpdate } from '../../../db/Serverlist';
|
||||||
import { nowSeconds, getFutureTime, getPastTime } from '../../../pubUtils/timeUtil';
|
import { nowSeconds, getFutureTime, getPastTime } from '../../../pubUtils/timeUtil';
|
||||||
import { calHiddenData, createNewServer } from '../../../services/gmService';
|
import { calHiddenData, createNewServer } from '../../../services/gmService';
|
||||||
@@ -56,9 +56,9 @@ export class GmHandler {
|
|||||||
console.log('******* curRegion', curRegion);
|
console.log('******* curRegion', curRegion);
|
||||||
if(!curRegion) return resResult(STATUS.WRONG_PARMS);
|
if(!curRegion) return resResult(STATUS.WRONG_PARMS);
|
||||||
|
|
||||||
let { latestServer = 0 } = curRegion;
|
let { latestServer = 0, env } = curRegion;
|
||||||
let dicServerName = gameData.serverNames.get(latestServer + 1);
|
let dic = getDicServerName(env, latestServer + 1);
|
||||||
if(!dicServerName) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
if(!dic) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
|
|
||||||
await createNewServer(curRegion, latestServer + 1, params, uid);
|
await createNewServer(curRegion, latestServer + 1, params, uid);
|
||||||
return resResult(STATUS.SUCCESS);
|
return resResult(STATUS.SUCCESS);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { PackageModel } from '@db/Package';
|
|||||||
import { Service } from 'egg';
|
import { Service } from 'egg';
|
||||||
import { REDIS_KEY, SNS_LINK_TYPE, STATUS } from '@consts';
|
import { REDIS_KEY, SNS_LINK_TYPE, STATUS } from '@consts';
|
||||||
import { ServerlistModel } from '@db/Serverlist';
|
import { ServerlistModel } from '@db/Serverlist';
|
||||||
import { gameData } from '@pubUtils/data';
|
import { gameData, getDicServerName } from '@pubUtils/data';
|
||||||
import { DicHero } from '@pubUtils/dictionary/DicHero';
|
import { DicHero } from '@pubUtils/dictionary/DicHero';
|
||||||
import { DicRMB } from '@pubUtils/dictionary/DicRMB';
|
import { DicRMB } from '@pubUtils/dictionary/DicRMB';
|
||||||
import { DicActivityType } from '@pubUtils/dictionary/DicActivityType';
|
import { DicActivityType } from '@pubUtils/dictionary/DicActivityType';
|
||||||
@@ -15,7 +15,6 @@ import { ActivityGroupModel } from '@db/ActivityGroup';
|
|||||||
import { nowSeconds } from '@pubUtils/timeUtil';
|
import { nowSeconds } from '@pubUtils/timeUtil';
|
||||||
import { WhiteListModel } from '@db/RegionWhiteList';
|
import { WhiteListModel } from '@db/RegionWhiteList';
|
||||||
import { SearchMarqueeParam, SearchOrderParam, SearchSurveyParam } from '@domain/backEndField/search';
|
import { SearchMarqueeParam, SearchOrderParam, SearchSurveyParam } from '@domain/backEndField/search';
|
||||||
import { DicServerName } from '@pubUtils/dictionary/DicServerName';
|
|
||||||
import { CreateRegionParam, UpdateChannelParam } from '@domain/backEndField/params';
|
import { CreateRegionParam, UpdateChannelParam } from '@domain/backEndField/params';
|
||||||
import { UserOrderModel } from '@db/UserOrder';
|
import { UserOrderModel } from '@db/UserOrder';
|
||||||
import { SurveyModel } from '@db/Survery';
|
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);
|
if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
|
|
||||||
let activityGroups = await ActivityGroupModel.findAllActivityGroup();
|
let activityGroups = await ActivityGroupModel.findAllActivityGroup();
|
||||||
|
let dicServerName = getDicServerName(region.env, region.latestServer + 1);
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
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() {
|
public async getServerName() {
|
||||||
let list: DicServerName[] = [];
|
|
||||||
for(let [_, serverName] of gameData.serverNames) {
|
|
||||||
list.push(serverName);
|
|
||||||
}
|
|
||||||
return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
|
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 nextPVPTypes = await ServerGroupModel.findByTime(seasonEndTime, 2);
|
||||||
|
|
||||||
const servers = serverlists.map(server => {
|
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 curGVG = currentGVGTypes.find(obj => obj.serverId == server.id)?.groupId||dic.groupId;
|
||||||
let nextGVG = nextGVGTypes.find(obj => obj.serverId == server.id)?.groupId||curGVG;
|
let nextGVG = nextGVGTypes.find(obj => obj.serverId == server.id)?.groupId||curGVG;
|
||||||
let gvgTime = nextGVGTypes.find(obj => obj.serverId == server.id)?.time;
|
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 { CreateServerParam } from '../domain/backEndField/params';
|
||||||
import { RegionType } from './Region';
|
import { RegionType } from './Region';
|
||||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||||
import { gameData } from '../pubUtils/data';
|
import { getDicServerName } from '../pubUtils/data';
|
||||||
|
|
||||||
export class Maintenance {
|
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 ) {
|
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 { prefix, id: regionId, env } = region;
|
||||||
|
let dicServerName = getDicServerName(env, serverId);
|
||||||
|
if(!dicServerName) return;
|
||||||
// 分大区
|
// 分大区
|
||||||
let { openTime, stopRegisterTime: hour, activityGroupId } = params;
|
let { openTime, stopRegisterTime: hour, activityGroupId } = params;
|
||||||
let { sname: name, groupId, groupName } = dicServerName;
|
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) {
|
export function getDicApByLv(level: number) {
|
||||||
if(level > gameData.apMaxLevel.max) {
|
if(level > gameData.apMaxLevel.max) {
|
||||||
return gameData.ap.get(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() {
|
function initDatas() {
|
||||||
parseDicParam();
|
parseDicParam();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// 服务器名
|
import { readServerNameFileList } from "../util";
|
||||||
import { readFileAndParse } from '../util'
|
|
||||||
import { FILENAME } from '../../consts'
|
|
||||||
|
|
||||||
|
// 服务器名
|
||||||
export interface DicServerName {
|
export interface DicServerName {
|
||||||
// id
|
// id
|
||||||
readonly id: number;
|
readonly id: number;
|
||||||
@@ -13,14 +12,15 @@ export interface DicServerName {
|
|||||||
readonly groupName: string;
|
readonly groupName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dicServerName = new Map<number, DicServerName>();
|
export const dicServerName = new Map<string, Map<number, DicServerName>>();
|
||||||
export function loadServerName() {
|
export function loadServerName() {
|
||||||
dicServerName.clear();
|
dicServerName.clear();
|
||||||
|
readServerNameFileList().forEach(({ name: fileName, str }) => {
|
||||||
let arr = readFileAndParse(FILENAME.DIC_SERVER_NAME);
|
let name = fileName.split('.')[0];
|
||||||
|
if(!dicServerName.has(name)) dicServerName.set(name, new Map());
|
||||||
arr.forEach(o => {
|
let arr = JSON.parse(str);
|
||||||
dicServerName.set(o.id, o);
|
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) {
|
export function readWordTxt(fileName: string) {
|
||||||
try {
|
try {
|
||||||
let file = fs.readFileSync(path.resolve(__dirname, `../resource/${fileName}.txt`)).toString('utf8').replace(/^\uFEFF/, '');
|
let file = fs.readFileSync(path.resolve(__dirname, `../resource/${fileName}.txt`)).toString('utf8').replace(/^\uFEFF/, '');
|
||||||
@@ -498,6 +510,7 @@ export function readWarJsonFileAndParse() {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字典表常用解析方法
|
// 字典表常用解析方法
|
||||||
// 解析物品 {"id": number, "count": number} 格式
|
// 解析物品 {"id": number, "count": number} 格式
|
||||||
export function parseGoodStr(str: string) {
|
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