✨ feat(pvp): 巅峰演武战区化
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import { pinus } from "pinus";
|
||||
import { GVGConfigModel, GVGConfigType } from "../../db/GVGConfig";
|
||||
import { getTimeFun, getZeroPoint, getZeroPointOfTime, nowSeconds, WEEK_TO_SECOND } from "../../pubUtils/timeUtil";
|
||||
import { getAllServerCreateTime, getServerCreateTime } from "../redisService";
|
||||
import { GVG_PERIOD, GVG_SERVER_TYPE, LEAGUE_JOB, PUSH_ROUTE, SHOP_REFRESH_TYPE } from "../../consts";
|
||||
import { getTimeFun, nowSeconds, WEEK_TO_SECOND } from "../../pubUtils/timeUtil";
|
||||
import { getServerCreateTime } from "../redisService";
|
||||
import { GVG_PERIOD, GVG_SERVER_TYPE, LEAGUE_JOB, PUSH_ROUTE } from "../../consts";
|
||||
import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGLeaguePrepareModel } from "../../db/GVGLeaguePrepare";
|
||||
import { GVGServerGroupModel } from "../../db/GVGServerGroup";
|
||||
import { gameData } from "../../pubUtils/data";
|
||||
import { getRandSingleEelm } from "../../pubUtils/util";
|
||||
import { GVG } from "../../pubUtils/dicParam";
|
||||
import { ServerlistModel } from "../../db/Serverlist";
|
||||
import { GuildModel, GuildType } from "../../db/Guild";
|
||||
import { GVGLeagueApplyModel } from "../../db/GVGLeagueApply";
|
||||
import { GVGMainData, LeagueContributeInfo } from "../../domain/gvgField/returnData";
|
||||
@@ -26,6 +24,7 @@ import { GVGTeamModel } from "../../db/GVGTeam";
|
||||
import { sendMessageToGuildWithSuc } from "../pushService";
|
||||
import { GVGCityModel } from "../../db/GVGCity";
|
||||
import { GVGRoleDataModel } from "../../db/GVGRoleData";
|
||||
import { getGVGGroupIdOfServer } from "../serverService";
|
||||
|
||||
// 定时器相关
|
||||
export async function createNewGVGConfig() {
|
||||
@@ -33,11 +32,11 @@ export async function createNewGVGConfig() {
|
||||
const config = await GVGConfigModel.createNewConfig(teamTime, prepareTime, battleTime, scheduleTime);
|
||||
try {
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGConfig.broadcast(config);
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.chat.chatRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.connector.connectorRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.gm.gmRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.systimer.systimerRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.guild.guildRemote.setServerGroup.broadcast();
|
||||
await pinus.app.rpc.chat.chatRemote.setServerGroup.broadcast();
|
||||
await pinus.app.rpc.connector.connectorRemote.setServerGroup.broadcast();
|
||||
await pinus.app.rpc.gm.gmRemote.setServerGroup.broadcast();
|
||||
await pinus.app.rpc.systimer.systimerRemote.setServerGroup.broadcast();
|
||||
await pinus.app.rpc.guild?.guildRemote?.clearBattleMemory.broadcast();
|
||||
} catch(e) {
|
||||
console.log('remote未初始完');
|
||||
@@ -165,7 +164,7 @@ export function getGVGPeriodData() {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('######## getGVGPeriodData', configId, teamTime, prepareTime, battleTime, scheduleTime)
|
||||
// console.log('######## getGVGPeriodData', configId, teamTime, prepareTime, battleTime, scheduleTime)
|
||||
return { configId, period, countdownTime };
|
||||
}
|
||||
|
||||
@@ -203,41 +202,6 @@ export async function initLeaguePrepare() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function setGVGServerGroup() {
|
||||
const servers = await ServerlistModel.findByEnv(pinus.app.get('env'));
|
||||
const serverGroups = await GVGServerGroupModel.findByTime(nowSeconds());
|
||||
pinus.app.set('gvgServerGroup', servers.map(obj => {
|
||||
let server = serverGroups.find(cur => cur.serverId == obj.id);
|
||||
return { serverId: obj.id, groupId: server? server.groupId: obj.groupId }
|
||||
}));
|
||||
}
|
||||
|
||||
// 查询本小区所在的战区
|
||||
// gvgServerGroup: id-小区唯一id serverId-小区在大区下的id
|
||||
export async function getGroupIdOfServer(id: number) {
|
||||
let arr: { serverId: number; groupId: number }[] = pinus.app.get('gvgServerGroup')||[];
|
||||
let obj = arr.find(cur => cur.serverId == id);
|
||||
return obj?.groupId||0;
|
||||
}
|
||||
|
||||
// 查询当前和本小区同一个战区的其他小区
|
||||
export async function getServersOfSameGroup(type: GVG_SERVER_TYPE, id: number) {
|
||||
if(type == GVG_SERVER_TYPE.SINGLE) return [id];
|
||||
|
||||
let groupId = await getGroupIdOfServer(id);
|
||||
return await getServersByGroupId(groupId);
|
||||
}
|
||||
|
||||
export async function getServersByGroupId(groupId: number) {
|
||||
let arr: { serverId: number; groupId: number }[] = pinus.app.get('gvgServerGroup')||[];
|
||||
let serverCreateTimes = await getAllServerCreateTime();
|
||||
|
||||
return arr.filter(obj => {
|
||||
let openTime = parseInt(serverCreateTimes[obj.serverId]);
|
||||
return obj.groupId == groupId && getServerTypeByTime(openTime) == GVG_SERVER_TYPE.MULTI;
|
||||
}).map(obj => obj.serverId);
|
||||
}
|
||||
|
||||
export async function getGVGInfoInGuild(roleId: string, guild: GuildType) {
|
||||
let hasLeague = !!guild.leagueCode;
|
||||
let serverId = guild.serverId;
|
||||
@@ -344,7 +308,7 @@ export async function getGroupKey(serverId: number) {
|
||||
if(serverType == GVG_SERVER_TYPE.SINGLE) {
|
||||
return `s${serverId}`;
|
||||
} else {
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
let groupId = await getGVGGroupIdOfServer(serverId);
|
||||
return `g${groupId}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user