✨ feat(gvg): 定时器
This commit is contained in:
@@ -15,7 +15,7 @@ class GVGBattleData {
|
||||
public serverType: number; // 单服还是跨服
|
||||
|
||||
private teams: Map<string, GVGTeamMem> = new Map(); // 队伍, teamCode => team
|
||||
private rolePoints: Map<string, Set<number>> = new Map(); // roleId => pointId[],用于更新玩家的积分
|
||||
private rolePoints: Map<string, Map<number, string>> = new Map(); // roleId => pointId[],用于更新玩家的积分
|
||||
private roleToTeam: Map<string, string[]> = new Map(); // roleId => teamCode
|
||||
private areaToTeams: Map<number, Set<string>> = new Map(); // areaId => teamCode set,用于定时下发地图玩家数据
|
||||
|
||||
@@ -63,9 +63,9 @@ class GVGBattleData {
|
||||
this.teams.set(team.teamCode, new GVGTeamMem(team))
|
||||
}
|
||||
this.teams.get(team.teamCode).setCity(team.cityId, team.areaId, team.pointId);
|
||||
if(team.pointId > 0) {
|
||||
if(!this.rolePoints.has(team.roleId)) this.rolePoints.set(team.roleId, new Set());
|
||||
this.rolePoints.get(team.roleId).add(team.pointId);
|
||||
if(team.pointId > 0 && !team.isRobot) {
|
||||
if(!this.rolePoints.has(team.roleId)) this.rolePoints.set(team.roleId, new Map());
|
||||
this.rolePoints.get(team.roleId).set(team.pointId, team.teamCode);
|
||||
}
|
||||
let teamCodesOfRole = this.roleToTeam.get(team.roleId)||[];
|
||||
if(teamCodesOfRole.indexOf(team.teamCode) == -1) teamCodesOfRole.push(team.teamCode);
|
||||
@@ -87,14 +87,14 @@ class GVGBattleData {
|
||||
}
|
||||
}
|
||||
|
||||
private setRolePoints(roleId: string, fromPointId: number, pointId: number) {
|
||||
private setRolePoints(roleId: string, fromPointId: number, pointId: number, teamCode: string) {
|
||||
if(fromPointId > 0 && pointId == 0) { // 被打得撤离积分点
|
||||
if(this.rolePoints.has(roleId) && this.rolePoints.get(roleId).has(pointId)) {
|
||||
this.rolePoints.get(roleId).delete(pointId);
|
||||
}
|
||||
} else if (fromPointId == 0 && pointId > 0) {
|
||||
if(!this.rolePoints.has(roleId)) this.rolePoints.set(roleId, new Set());
|
||||
this.rolePoints.get(roleId).add(pointId);
|
||||
if(!this.rolePoints.has(roleId)) this.rolePoints.set(roleId, new Map());
|
||||
this.rolePoints.get(roleId).set(pointId, teamCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class GVGBattleData {
|
||||
let teamMem = this.teams.get(teamCode);
|
||||
if(!teamMem) return;
|
||||
let { pointId: fromPointId } = teamMem;
|
||||
this.setRolePoints(roleId, fromPointId, pointId);
|
||||
this.setRolePoints(roleId, fromPointId, pointId, teamCode);
|
||||
teamMem.pointId = pointId;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class GVGBattleData {
|
||||
}
|
||||
let { areaId: fromAreaId, pointId: fromPointId } = teamMem;
|
||||
teamMem.updateTeam(team);
|
||||
this.setRolePoints(team.roleId, fromPointId, team.pointId);
|
||||
this.setRolePoints(team.roleId, fromPointId, team.pointId, team.teamCode);
|
||||
this.setAreaMap(team.teamCode, fromAreaId, team.areaId);
|
||||
}
|
||||
}
|
||||
@@ -140,6 +140,18 @@ class GVGBattleData {
|
||||
let teamCodes = this.roleToTeam.get(GVG_CATAPULT)||[];
|
||||
return teamCodes.map(teamCode => this.teams.get(teamCode));
|
||||
}
|
||||
|
||||
// 积分点情况
|
||||
public findSettledPoint() {
|
||||
let teams: GVGTeamMem[] = [];
|
||||
for(let [_roleId, pointIds] of this.rolePoints) {
|
||||
for(let [pointId, teamCode] of pointIds) {
|
||||
let team = this.teams.get(teamCode);
|
||||
if(pointId > 0 && team) teams.push(team);
|
||||
}
|
||||
}
|
||||
return teams;
|
||||
}
|
||||
}
|
||||
|
||||
export function getGVGBattleData(groupId: number, serverType: number) {
|
||||
@@ -156,6 +168,7 @@ export function getGVGBattleMap() {
|
||||
|
||||
export async function initTeamToMem() {
|
||||
let sid = pinus.app.getServerId();
|
||||
console.log('##### initTeamToMem', sid)
|
||||
let servers = pinus.app.getServersByType('guild');
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
// if(period != GVG_PERIOD.BATTLE) return;
|
||||
|
||||
Reference in New Issue
Block a user