✨ feat(gvg): 激战期获取挑战对手阵容
This commit is contained in:
@@ -15,10 +15,9 @@ class GVGBattleData {
|
||||
public serverType: number; // 单服还是跨服
|
||||
|
||||
private teams: Map<string, GVGTeamMem> = new Map(); // 队伍, teamCode => team
|
||||
private rolePoints: Map<string, number[]> = new Map(); // roleId => pointId[],用于更新玩家的积分
|
||||
private rolePoints: Map<string, Set<number>> = new Map(); // roleId => pointId[],用于更新玩家的积分
|
||||
private roleToTeam: Map<string, string[]> = new Map(); // roleId => teamCode
|
||||
private areaToTeams: Map<number, Set<string>> = new Map(); // areaId => teamCode set,用于定时下发地图玩家数据
|
||||
private hasRobot: Map<number, boolean> = new Map(); // cityId => boolean
|
||||
|
||||
constructor(groupId: number, serverType: number) {
|
||||
this.groupId = groupId;
|
||||
@@ -44,7 +43,7 @@ class GVGBattleData {
|
||||
this.rolePoints.delete(roleId);
|
||||
}
|
||||
|
||||
public enterCity(teams: GVGTeamType[]) {
|
||||
public enterCity(...teams: GVGTeamType[]) {
|
||||
for(let team of teams) {
|
||||
let fromAreaId = this.teams.get(team.teamCode)?.areaId||0;
|
||||
|
||||
@@ -53,15 +52,13 @@ class GVGBattleData {
|
||||
}
|
||||
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, []);
|
||||
this.rolePoints.get(team.roleId).push(team.pointId);
|
||||
if(!this.rolePoints.has(team.roleId)) this.rolePoints.set(team.roleId, new Set());
|
||||
this.rolePoints.get(team.roleId).add(team.pointId);
|
||||
}
|
||||
let teamCodesOfRole = this.roleToTeam.get(team.roleId)||[];
|
||||
if(teamCodesOfRole.indexOf(team.teamCode) == -1) teamCodesOfRole.push(team.teamCode);
|
||||
this.roleToTeam.set(team.roleId, teamCodesOfRole);
|
||||
this.setAreaMap(team.teamCode, fromAreaId, team.areaId);
|
||||
|
||||
if(team.isRobot) this.hasRobot.set(team.cityId, team.isRobot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +96,22 @@ class GVGBattleData {
|
||||
team.pointId = pointId;
|
||||
}
|
||||
|
||||
public checkHasRobot(cityId: number) {
|
||||
return this.hasRobot.get(cityId)||false;
|
||||
// 关卡结算
|
||||
public battleEnd(teams: GVGTeamType[]) {
|
||||
for(let team of teams) {
|
||||
let teamMem = this.teams.get(team.teamCode);
|
||||
if(!teamMem) { // 基本不会有没有这个内存的情况,有的话就让他重新计算一次吧
|
||||
this.enterCity(team); continue;
|
||||
}
|
||||
let { areaId: fromAreaId, pointId: fromPointId } = teamMem;
|
||||
teamMem.battleEnd(team);
|
||||
if(fromPointId > 0 && team.pointId == 0) { // 被打得撤离积分点
|
||||
if(this.rolePoints.has(team.roleId) && this.rolePoints.get(team.roleId).has(team.pointId)) {
|
||||
this.rolePoints.get(team.roleId).delete(team.pointId);
|
||||
}
|
||||
}
|
||||
this.setAreaMap(team.teamCode, fromAreaId, team.areaId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +132,7 @@ export async function initTeamToMem() {
|
||||
for(let team of teams) {
|
||||
if(dispatch(team.cityId.toString(), servers)?.id == sid) {
|
||||
let teamObj = getGVGBattleData(team.groupId, team.serverType);
|
||||
teamObj.enterCity([team]);
|
||||
teamObj.enterCity(team);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user