后台:活动类型表
This commit is contained in:
@@ -33,6 +33,13 @@ export default class ActivityController extends Controller {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getActivityGroupTypeList() {
|
||||||
|
const { ctx } = this;
|
||||||
|
const { page, pageSize, sortField, sortOrder, groupType, groupTypeName } = ctx.request.body;
|
||||||
|
ctx.body = await ctx.service.activity.getActivityGroupTypeList(page, pageSize, sortField, sortOrder, groupType, groupTypeName);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
public async updateActivityGroupName() {
|
public async updateActivityGroupName() {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
const { groupId, groupName } = ctx.request.body;
|
const { groupId, groupName } = ctx.request.body;
|
||||||
|
|||||||
@@ -66,5 +66,6 @@ export default (app: Application) => {
|
|||||||
router.post('/api/activity/savegrouptoserver', tokenParser, controller.activity.saveGroupToServer);
|
router.post('/api/activity/savegrouptoserver', tokenParser, controller.activity.saveGroupToServer);
|
||||||
router.post('/api/activity/creategroup', tokenParser, controller.activity.createGroup);
|
router.post('/api/activity/creategroup', tokenParser, controller.activity.createGroup);
|
||||||
router.post('/api/activity/deletegroup', tokenParser, controller.activity.deleteGroup);
|
router.post('/api/activity/deletegroup', tokenParser, controller.activity.deleteGroup);
|
||||||
|
router.post('/api/activity/getactivitygrouptypelist', controller.activity.getActivityGroupTypeList);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ActivityGroupModel } from '@db/ActivityGroup';
|
|||||||
import { ServerlistModel } from '@db/Serverlist';
|
import { ServerlistModel } from '@db/Serverlist';
|
||||||
import { GMUserType } from '@db/GMUser';
|
import { GMUserType } from '@db/GMUser';
|
||||||
import { SignInData } from '@domain/activityField/signInField';
|
import { SignInData } from '@domain/activityField/signInField';
|
||||||
|
import { ActivityGroupTypeModel } from '@db/ActivityGroupType';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Service
|
* Test Service
|
||||||
@@ -110,7 +111,7 @@ export default class Activity extends Service {
|
|||||||
public async updateActivityGroupName(groupId: number, groupName: string) {
|
public async updateActivityGroupName(groupId: number, groupName: string) {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
try {
|
try {
|
||||||
await ActivityGroupModel.updateGroupName(groupId, groupName);
|
await ActivityGroupModel.updateGroupName(groupId, groupName, ctx.user?.uid);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack);
|
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack);
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ export default class Activity extends Service {
|
|||||||
}
|
}
|
||||||
await ServerlistModel.updateActivityGroup(server._id, pushArr, pullArr);
|
await ServerlistModel.updateActivityGroup(server._id, pushArr, pullArr);
|
||||||
}
|
}
|
||||||
await ActivityGroupModel.updateServerData(groupId, serverIds);
|
await ActivityGroupModel.updateServerData(groupId, serverIds, ctx.user?.uid);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack);
|
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack);
|
||||||
}
|
}
|
||||||
@@ -160,7 +161,7 @@ export default class Activity extends Service {
|
|||||||
public async createGroup() {
|
public async createGroup() {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
try {
|
try {
|
||||||
await ActivityGroupModel.createGroup();
|
await ActivityGroupModel.createGroup(ctx.user?.uid);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack);
|
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack);
|
||||||
}
|
}
|
||||||
@@ -182,5 +183,18 @@ export default class Activity extends Service {
|
|||||||
}
|
}
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS)
|
return ctx.service.utils.resResult(STATUS.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得活动组类型列表
|
||||||
|
*/
|
||||||
|
public async getActivityGroupTypeList(page: number, pageSize: number, sortField: string, sortOrder: string, groupType: number, groupTypeName: string) {
|
||||||
|
const { ctx } = this;
|
||||||
|
// console.log('***', page, pageSize, type, serverId, current, activityId)
|
||||||
|
const list = await ActivityGroupTypeModel.findByCondition(page, pageSize, sortField, sortOrder, { groupType, groupTypeName });
|
||||||
|
const total = await ActivityGroupTypeModel.countByCondition({ groupType, groupTypeName });
|
||||||
|
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||||
|
list, total
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ export const COUNTER = {
|
|||||||
SERVER_STATEGY: { name: 'stategy', def: 1 },
|
SERVER_STATEGY: { name: 'stategy', def: 1 },
|
||||||
SERVER_GROUP: { name: 'group', def: 1 },
|
SERVER_GROUP: { name: 'group', def: 1 },
|
||||||
SERVER_BY_TYPE: { name: 'serverby', def: 1 },
|
SERVER_BY_TYPE: { name: 'serverby', def: 1 },
|
||||||
SERVER: { name: 'server', def: 1 }
|
SERVER: { name: 'server', def: 1 },
|
||||||
|
ACTIVITY_GROUP_TYPE: { name: 'actgrptype', def: 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_HEROES = [19, 53, 46, 40, 22, 56, 32, 28, 18];
|
export const DEFAULT_HEROES = [19, 53, 46, 40, 22, 56, 32, 28, 18];
|
||||||
@@ -444,7 +445,9 @@ export const FILENAME = {
|
|||||||
DIC_ACTIVITY_TYPE: 'dic_zyz_activityType',
|
DIC_ACTIVITY_TYPE: 'dic_zyz_activityType',
|
||||||
DIC_TASK_TYPE: 'dic_zyz_taskType',
|
DIC_TASK_TYPE: 'dic_zyz_taskType',
|
||||||
DIC_GK_SZTM: 'dic_zyz_gk_activity_sztm',
|
DIC_GK_SZTM: 'dic_zyz_gk_activity_sztm',
|
||||||
DIC_GK_MJSD: 'dic_zyz_gk_activity_mjsd'
|
DIC_GK_MJSD: 'dic_zyz_gk_activity_mjsd',
|
||||||
|
DIC_SERVER_NAME: 'dic_zyz_serverName',
|
||||||
|
DIC_SERVER_GROUP_NAME: 'dic_zyz_serverGropName',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WAR_RELATE_TABLES = [
|
export const WAR_RELATE_TABLES = [
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export default class Activity extends BaseModel {
|
|||||||
}
|
}
|
||||||
if (groupId != undefined) {
|
if (groupId != undefined) {
|
||||||
if (groupId == 0) {
|
if (groupId == 0) {
|
||||||
let newGroup = await ActivityGroupModel.createGroup();
|
let newGroup = await ActivityGroupModel.createGroup(uid);
|
||||||
groupId = newGroup.groupId;
|
groupId = newGroup.groupId;
|
||||||
}
|
}
|
||||||
await ActivityGroupModel.addActivitiesToGroupData(groupId, aids, uid);
|
await ActivityGroupModel.addActivitiesToGroupData(groupId, aids, uid);
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ export default class Activity_Group extends BaseModel {
|
|||||||
|
|
||||||
|
|
||||||
//查询组
|
//查询组
|
||||||
public static async createGroup() {
|
public static async createGroup(uid = 1) {
|
||||||
let groupId = await CounterModel.getNewCounter(COUNTER.ACTIVITY_GROUP);
|
let groupId = await CounterModel.getNewCounter(COUNTER.ACTIVITY_GROUP);
|
||||||
|
|
||||||
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId }, {
|
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId }, {
|
||||||
$setOnInsert: { groupName: `活动组${groupId}`, activities: [], serverIds: [] }
|
$setOnInsert: { groupName: `活动组${groupId}`, activities: [], serverIds: [], createdBy: uid }, $set: { updatedBy: uid }
|
||||||
}, { new: true, upsert: true }).lean();
|
}, { new: true, upsert: true }).lean();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -49,9 +49,9 @@ export default class Activity_Group extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新名字
|
//更新名字
|
||||||
public static async updateGroupName(groupId: number, groupName: string) {
|
public static async updateGroupName(groupId: number, groupName: string, uid = 1) {
|
||||||
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
||||||
{ $set: { groupName } }, { new: true }).lean(true);
|
{ $set: { groupName, updatedBy: uid } }, { new: true }).lean(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,9 +59,9 @@ export default class Activity_Group extends BaseModel {
|
|||||||
public static async setActivitiesToGroupData(groupId: number, activities: number[], uid = 1) {
|
public static async setActivitiesToGroupData(groupId: number, activities: number[], uid = 1) {
|
||||||
await this.pullByActivityIds(activities, uid); // 先将原先的删除
|
await this.pullByActivityIds(activities, uid); // 先将原先的删除
|
||||||
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
||||||
{ $set: { activities } }, { new: true }).lean(true);
|
{ $set: { activities, updatedBy: uid } }, { new: true }).lean(true);
|
||||||
await ActivityModel.updateGroupId(activities, groupId, uid);
|
await ActivityModel.updateGroupId(activities, groupId, uid);
|
||||||
result = await this.updateTime(result.groupId, result.activities);
|
result = await this.updateTime(result.groupId, result.activities, uid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,12 +71,12 @@ export default class Activity_Group extends BaseModel {
|
|||||||
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
||||||
{ $addToSet: { activities: { $each: activities } } }, { new: true }).lean(true);
|
{ $addToSet: { activities: { $each: activities } } }, { new: true }).lean(true);
|
||||||
await ActivityModel.updateGroupId(activities, groupId, uid);
|
await ActivityModel.updateGroupId(activities, groupId, uid);
|
||||||
result = await this.updateTime(result.groupId, result.activities);
|
result = await this.updateTime(result.groupId, result.activities, uid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据包含的活动更新开始和结束时间
|
// 根据包含的活动更新开始和结束时间
|
||||||
private static async updateTime(groupId: number, aids: number[]) {
|
private static async updateTime(groupId: number, aids: number[], uid = 1) {
|
||||||
let activities = await ActivityModel.findActivityByIds(aids);
|
let activities = await ActivityModel.findActivityByIds(aids);
|
||||||
let beginTime = undefined, endTime = undefined;
|
let beginTime = undefined, endTime = undefined;
|
||||||
for (let activity of activities) {
|
for (let activity of activities) {
|
||||||
@@ -84,7 +84,7 @@ export default class Activity_Group extends BaseModel {
|
|||||||
if (!endTime || activity.endTime > endTime) endTime = activity.endTime;
|
if (!endTime || activity.endTime > endTime) endTime = activity.endTime;
|
||||||
}
|
}
|
||||||
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
||||||
{ $set: { beginTime, endTime } }, { new: true }).lean(true);
|
{ $set: { beginTime, endTime, updatedBy: uid } }, { new: true }).lean(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,16 +94,16 @@ export default class Activity_Group extends BaseModel {
|
|||||||
await ActivityModel.updateGroupId(activities, 0, uid);
|
await ActivityModel.updateGroupId(activities, 0, uid);
|
||||||
let activityGroups = await ActivityGroupModel.find({ activities: { $in: activities } });
|
let activityGroups = await ActivityGroupModel.find({ activities: { $in: activities } });
|
||||||
for (let { groupId } of activityGroups) {
|
for (let { groupId } of activityGroups) {
|
||||||
let result = await ActivityGroupModel.findOneAndUpdate({ groupId }, { $pull: { activities: { $in: activities } } }, { new: true }).lean(true);
|
let result = await ActivityGroupModel.findOneAndUpdate({ groupId }, { $pull: { activities: { $in: activities } }, $set: { updatedBy: uid } }, { new: true }).lean(true);
|
||||||
await this.updateTime(result.groupId, result.activities);
|
await this.updateTime(result.groupId, result.activities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//更新服务器
|
//更新服务器
|
||||||
public static async updateServerData(groupId: number, serverIds: number[]) {
|
public static async updateServerData(groupId: number, serverIds: number[], uid = 1) {
|
||||||
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
let result: ActivityGroupModelType = await ActivityGroupModel.findOneAndUpdate({ groupId },
|
||||||
{ $set: { serverIds } }, { new: true }).lean(true);
|
{ $set: { serverIds, updatedBy: uid } }, { new: true }).lean(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
78
shared/db/ActivityGroupType.ts
Normal file
78
shared/db/ActivityGroupType.ts
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import BaseModel from './BaseModel';
|
||||||
|
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||||
|
import { CounterModel } from './Counter';
|
||||||
|
import { COUNTER, ACTIVITY_TYPE } from '../consts';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动合集
|
||||||
|
*/
|
||||||
|
@index({ activityId: 1 })
|
||||||
|
|
||||||
|
class ActivityType {
|
||||||
|
@prop({ required: true })
|
||||||
|
index: number; // 活动集合内部id,防止activityType有重复的情况
|
||||||
|
|
||||||
|
@prop({ required: true, enum: ACTIVITY_TYPE })
|
||||||
|
activityType: ACTIVITY_TYPE; // 活动类型
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Activity_GroupType extends BaseModel {
|
||||||
|
@prop({ required: true })
|
||||||
|
groupType: number; // 类型id,创建时自增
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
groupTypeName: string; // 类型名
|
||||||
|
|
||||||
|
@prop({ required: true, type: ActivityType, _id: false })
|
||||||
|
activityTypes: ActivityType[]; // 活动类型集合
|
||||||
|
|
||||||
|
public static async createActivityGroupType(groupTypeName: string, types: number[], uid = 1) {
|
||||||
|
let activityTypes = types.map((value, index) => {
|
||||||
|
return { index: index + 1, activityType: value };
|
||||||
|
});
|
||||||
|
let groupType = await CounterModel.getNewCounter(COUNTER.ACTIVITY_GROUP_TYPE);
|
||||||
|
|
||||||
|
let result: ActivityGroupTypeInter = await ActivityGroupTypeModel.findOneAndUpdate({ groupType }, {
|
||||||
|
$setOnInsert: { groupTypeName, activityTypes, createdBy: uid }, $set: { updatedBy: uid }
|
||||||
|
}, { new: true, upsert: true }).lean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getSearchObj(form: { groupType?: number, groupTypeName?: string }) {
|
||||||
|
let searchObj = {};
|
||||||
|
if(form.groupType != undefined) searchObj['groupType'] = form.groupType;
|
||||||
|
if(form.groupTypeName != undefined) searchObj['groupTypeName'] = form.groupTypeName;
|
||||||
|
return searchObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询
|
||||||
|
public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: { groupType?: number, groupTypeName?: string } = {}) {
|
||||||
|
let searchObj = this.getSearchObj(form);
|
||||||
|
let sort = {};
|
||||||
|
if(sortField && sortOrder) {
|
||||||
|
if(sortOrder == 'ascend') {
|
||||||
|
sort[sortField] = 1;
|
||||||
|
} else if (sortOrder == 'descend') {
|
||||||
|
sort[sortField] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const result: ActivityGroupTypeInter[] = await ActivityGroupTypeModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获得活动数量
|
||||||
|
public static async countByCondition(form: { groupType?: number, groupTypeName?: string } = {}) {
|
||||||
|
let searchObj = this.getSearchObj(form);
|
||||||
|
const result = await ActivityGroupTypeModel.count(searchObj);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ActivityGroupTypeModel = getModelForClass(Activity_GroupType);
|
||||||
|
|
||||||
|
export interface ActivityGroupTypeInter extends Pick<DocumentType<Activity_GroupType>, keyof Activity_GroupType> {
|
||||||
|
id: number;
|
||||||
|
};
|
||||||
|
export type ActivityGroupTypeUpdate = Partial<ActivityGroupTypeInter>; // 将所有字段变成可选项
|
||||||
@@ -4,6 +4,7 @@ import { GameModel } from './Game';
|
|||||||
import { CounterModel } from './Counter';
|
import { CounterModel } from './Counter';
|
||||||
import { COUNTER } from '../consts';
|
import { COUNTER } from '../consts';
|
||||||
import { ServerStategyTypeParam } from './ServerStategy';
|
import { ServerStategyTypeParam } from './ServerStategy';
|
||||||
|
import { getServerName, getServerGroupName } from '../pubUtils/data';
|
||||||
|
|
||||||
// 暂时服务器列表是从game表取的,之后会转移到使用这张表,目前用作查询该服战力中位数
|
// 暂时服务器列表是从game表取的,之后会转移到使用这张表,目前用作查询该服战力中位数
|
||||||
|
|
||||||
@@ -99,11 +100,11 @@ export default class Serverlist extends BaseModel {
|
|||||||
if(groupServerCount > 10) {
|
if(groupServerCount > 10) {
|
||||||
groupId = await CounterModel.getNewCounter(COUNTER.SERVER_GROUP);
|
groupId = await CounterModel.getNewCounter(COUNTER.SERVER_GROUP);
|
||||||
}
|
}
|
||||||
let groupName = '逍遥津' + groupId;
|
let groupName = getServerGroupName(groupId)||"";
|
||||||
|
|
||||||
let serverId = await CounterModel.getNewCounter({ name: `${COUNTER.SERVER_BY_TYPE.name}_${serverType}`, def: COUNTER.SERVER_BY_TYPE.def });
|
let serverId = await CounterModel.getNewCounter({ name: `${COUNTER.SERVER_BY_TYPE.name}_${serverType}`, def: COUNTER.SERVER_BY_TYPE.def });
|
||||||
let id = await CounterModel.getNewCounter(COUNTER.SERVER);
|
let id = await CounterModel.getNewCounter(COUNTER.SERVER);
|
||||||
if(!name) name = '出师表' + id
|
if(!name) name = getServerName(id)||"";
|
||||||
|
|
||||||
const doc = new ServerlistModel();
|
const doc = new ServerlistModel();
|
||||||
const update = Object.assign(doc.toJSON(), params, { id, serverId, host, groupId, groupName, name, createdBy: uid, updatedBy: uid }, { activityGroupId: stategy.activityGroupId, maxPlayerCnt: stategy.maxPlayerCnt});
|
const update = Object.assign(doc.toJSON(), params, { id, serverId, host, groupId, groupName, name, createdBy: uid, updatedBy: uid }, { activityGroupId: stategy.activityGroupId, maxPlayerCnt: stategy.maxPlayerCnt});
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ import { dicRecruit, loadRecruit } from './dictionary/DicRecruit';
|
|||||||
import { loadRMB, dicRMB } from './dictionary/DicRMB';
|
import { loadRMB, dicRMB } from './dictionary/DicRMB';
|
||||||
import { dicActivityType, loadActivityType } from './dictionary/DicActivityType';
|
import { dicActivityType, loadActivityType } from './dictionary/DicActivityType';
|
||||||
import { dicTaskTypeDesc, loadTaskType } from './dictionary/DicTaskType';
|
import { dicTaskTypeDesc, loadTaskType } from './dictionary/DicTaskType';
|
||||||
|
import { dicServerName, dicServerGroupName, loadServerName } from "./dictionary/DicServerName";
|
||||||
|
|
||||||
export const gameData = {
|
export const gameData = {
|
||||||
blurprtCompose: dicBlueprtCompose,
|
blurprtCompose: dicBlueprtCompose,
|
||||||
@@ -204,7 +205,9 @@ export const gameData = {
|
|||||||
recruit: dicRecruit,
|
recruit: dicRecruit,
|
||||||
rmb: dicRMB,
|
rmb: dicRMB,
|
||||||
activityType: dicActivityType,
|
activityType: dicActivityType,
|
||||||
taskTypeDesc: dicTaskTypeDesc
|
taskTypeDesc: dicTaskTypeDesc,
|
||||||
|
serverNames: dicServerName,
|
||||||
|
serverGroupNames: dicServerGroupName,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||||
@@ -668,6 +671,36 @@ function getHeroTransPiece() {
|
|||||||
gameData.heroTransPiece = newMap
|
gameData.heroTransPiece = newMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据groupId获得当前大区名
|
||||||
|
export function getServerGroupName(groupId: number) {
|
||||||
|
let name = gameData.serverGroupNames.get(groupId);
|
||||||
|
if(!name) {
|
||||||
|
let maxId = 0;
|
||||||
|
gameData.serverGroupNames.forEach((gname, id) => {
|
||||||
|
if(id > maxId) {
|
||||||
|
maxId = id;
|
||||||
|
name = gname;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据服务器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;
|
||||||
|
}
|
||||||
|
|
||||||
// 初始加载
|
// 初始加载
|
||||||
function initDatas() {
|
function initDatas() {
|
||||||
parseDicParam();
|
parseDicParam();
|
||||||
@@ -765,6 +798,7 @@ function loadDatas() {
|
|||||||
loadRMB();
|
loadRMB();
|
||||||
loadActivityType();
|
loadActivityType();
|
||||||
loadTaskType();
|
loadTaskType();
|
||||||
|
loadServerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重载dicParam
|
// 重载dicParam
|
||||||
|
|||||||
35
shared/pubUtils/dictionary/DicServerName.ts
Normal file
35
shared/pubUtils/dictionary/DicServerName.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// 武将特技表
|
||||||
|
import { readFileAndParse } from '../util'
|
||||||
|
import { FILENAME } from '../../consts'
|
||||||
|
|
||||||
|
export interface DicServerName {
|
||||||
|
// id
|
||||||
|
readonly id: number;
|
||||||
|
// 小区名
|
||||||
|
readonly name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const dicServerName = new Map<number, string>();
|
||||||
|
export const dicServerGroupName = new Map<number, string>();
|
||||||
|
export function loadServerName() {
|
||||||
|
|
||||||
|
{
|
||||||
|
let arr = readFileAndParse(FILENAME.DIC_SERVER_NAME);
|
||||||
|
|
||||||
|
arr.forEach(o => {
|
||||||
|
let { id, sname } = o;
|
||||||
|
dicServerName.set(id, sname);
|
||||||
|
});
|
||||||
|
arr = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let arr = readFileAndParse(FILENAME.DIC_SERVER_GROUP_NAME);
|
||||||
|
|
||||||
|
arr.forEach(o => {
|
||||||
|
let { id, groupName } = o;
|
||||||
|
dicServerGroupName.set(id, groupName);
|
||||||
|
});
|
||||||
|
arr = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user