✨ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { getGVGBattleData } from "./gvgBattleMemory";
|
||||
import { GVGCityMapInfo } from "../../domain/gvgField/returnData";
|
||||
import { pick } from "underscore";
|
||||
import { GVG } from "../../pubUtils/dicParam";
|
||||
import { GVGHeroInfo, PvpEnemies, PvpHeroInfo } from "../../domain/dbGeneral";
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,7 +89,7 @@ export async function initRobots(confidId: number, groupId: number, serverType:
|
||||
robotTeams = await GVGTeamModel.initRobots(confidId, groupId, serverType, cityId, updateDicPoints);
|
||||
// 存入内存
|
||||
let teamObj = getGVGBattleData(groupId, serverType);
|
||||
teamObj.enterCity(robotTeams);
|
||||
teamObj.enterCity(...robotTeams);
|
||||
}
|
||||
return robotTeams;
|
||||
}
|
||||
@@ -108,14 +109,40 @@ export function calBattleScoreByCe(isSuccess: boolean, lineupCe: number) {
|
||||
return isSuccess? winScore: 0;
|
||||
}
|
||||
|
||||
// 计算打投石车/守卫的得分
|
||||
export function calLeagueScore(team: GVGTeamType) {
|
||||
return 0
|
||||
}
|
||||
|
||||
export async function teamBreak(city: GVGCityType, team: GVGTeamType) {
|
||||
if(team.durability > 0) return team
|
||||
let areaId = getBirthAreaOfCity(city, team.leagueCode);
|
||||
team = await GVGTeamModel.teamBreak(team.teamCode, team.isRobot, team.maxDurability, areaId);
|
||||
return team;
|
||||
}
|
||||
|
||||
export function getGVGWarId(defenseTeam: GVGTeamType) {
|
||||
if(!defenseTeam.isRobot) return GVG.GVG_CITY_BGMAP_GKID; // 玩家防守地图
|
||||
if(!defenseTeam.isCatapult) return GVG.GVG_CATAPULT_WARJSON; // 投石车使用
|
||||
return GVG.GVG_ROBOT_WARJSON; // 据点守卫使用
|
||||
}
|
||||
|
||||
export function getOppHeroes(warId: number, isRobot: boolean, lineup: GVGHeroInfo[]) {
|
||||
let heroes: PvpEnemies[] = [];
|
||||
const dicWar = gameData.war.get(warId);
|
||||
if(!dicWar) { console.error(`warId ${warId} not found`); return [] }
|
||||
const dicWarJson = gameData.warJson.get(dicWar.dispatchJsonId)||[];
|
||||
for(let warJson of dicWarJson) {
|
||||
if(!isRobot) {
|
||||
let heroInfo = lineup.find(cur => cur.dataId == warJson.dataId);
|
||||
if(!heroInfo) continue;
|
||||
let hero = new PvpEnemies(warJson, heroInfo);
|
||||
heroes.push(hero);
|
||||
} else {
|
||||
if(warJson.relation == 2) {
|
||||
let dicHero = gameData.hero.get(warJson.actorId);
|
||||
if(!dicHero) continue;
|
||||
let heroInfo = new PvpHeroInfo();
|
||||
heroInfo.setRobotInfo(dicHero, warJson.lv);
|
||||
let hero = new PvpEnemies(warJson, heroInfo);
|
||||
heroes.push(hero);
|
||||
}
|
||||
}
|
||||
}
|
||||
return heroes
|
||||
}
|
||||
Reference in New Issue
Block a user