✨ feat(gvg): 激战期接口详细返回
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { GVGTeamMem } from "../../domain/battleField/gvgBattle";
|
||||
import { GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGTeamModel, GVGTeamType } from "../../db/GVGTeam";
|
||||
import { GVGCityType } from "../../db/GVGCity";
|
||||
import { GVGCityModel, GVGCityType } from "../../db/GVGCity";
|
||||
import { gameData } from "../../pubUtils/data";
|
||||
import { STATUS } from "../../consts";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { DicGVGAreaPoint } from "../../pubUtils/dictionary/DicGVGAreaPoint";
|
||||
import { getGVGBattleData } from "./gvgBattleMemory";
|
||||
import { GVGCityMapInfo } from "../../domain/gvgField/returnData";
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,11 +29,18 @@ export async function getGVGCities(league: GVGLeagueType) {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 获取当前城池状态
|
||||
* 获取当前城池状态
|
||||
* @returns [{cityId: number, guardLeagueCode: string, guardLeagueName: string, teamCnt: number }]
|
||||
*/
|
||||
export async function getGVGCitiesInfo(league: GVGLeagueType): Promise<{cityId: number, guardLeagueName: string, teamCnt: number }[]> {
|
||||
return [];
|
||||
export async function getGVGCitiesInfo(configId: number, groupId: number, serverType: number, league: GVGLeagueType): Promise<{cityId: number, guardLeagueName: string, teamCnt: number }[]> {
|
||||
let cities = await GVGCityModel.findGuardCityByLeague(configId, groupId, serverType);
|
||||
let result: GVGCityMapInfo[] = [];
|
||||
for(let city of cities) {
|
||||
let players = (city.players||[]).filter(cur => cur.leagueCode == league.leagueCode);
|
||||
let obj = new GVGCityMapInfo(city, players.length);
|
||||
result.push(obj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,13 +72,23 @@ export function checkMoveStatus(team: GVGTeamType, cityId: number, areaId: numbe
|
||||
}
|
||||
|
||||
export async function initRobots(groupId: number, serverType: number, cityId: number) {
|
||||
let hasRobot = await GVGTeamModel.checkRobot(groupId, serverType, cityId);
|
||||
if(!hasRobot) {
|
||||
let teamObj = getGVGBattleData(groupId, serverType);
|
||||
if(!teamObj.checkHasRobot(cityId)) {
|
||||
let dicPoints: DicGVGAreaPoint[] = [];
|
||||
let { areaIds = []} = gameData.gvgCity.get(cityId);
|
||||
for(let [_, point] of gameData.gvgAreaPoint) {
|
||||
if(areaIds.indexOf(point.areaId) != -1) dicPoints.push(point);
|
||||
}
|
||||
await GVGTeamModel.initRobots(groupId, serverType, cityId, dicPoints);
|
||||
let teams = await GVGTeamModel.initRobots(groupId, serverType, cityId, dicPoints);
|
||||
teamObj.enterCity(teams);
|
||||
}
|
||||
}
|
||||
|
||||
export function checkAreaIsInCity(cityId: number, areaIds: number[]) {
|
||||
let dicCity = gameData.gvgCity.get(cityId);
|
||||
if(!dicCity) return false;
|
||||
for(let areaId of areaIds) {
|
||||
if(dicCity.areaIds.indexOf(areaId) == -1) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user