feat(gvg): 激战期获取挑战对手阵容

This commit is contained in:
luying
2023-02-15 11:38:17 +08:00
parent aa099dddaf
commit 6815bf316a
13 changed files with 1023 additions and 46 deletions

View File

@@ -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
}