✨ feat(gvg): 激战期内存以及玩家移动、挑战操作
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { GVGTeamMem } from "../../domain/battleField/gvgBattle";
|
||||
import { GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGTeamType } from "../../db/GVGTeam";
|
||||
import { GVGTeamModel, GVGTeamType } from "../../db/GVGTeam";
|
||||
import { GVGCityType } from "../../db/GVGCity";
|
||||
import { gameData } from "../../pubUtils/data";
|
||||
import { STATUS } from "../../consts";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { DicGVGAreaPoint } from "../../pubUtils/dictionary/DicGVGAreaPoint";
|
||||
|
||||
|
||||
/**
|
||||
@@ -33,9 +38,38 @@ export async function getGVGCitiesInfo(league: GVGLeagueType): Promise<{cityId:
|
||||
* 获取内存中队伍的数据结构
|
||||
*/
|
||||
export function getGVGTeamMemInfo(team: GVGTeamType): GVGTeamMem {
|
||||
const teamMem = team as GVGTeamMem;
|
||||
const teamMem = new GVGTeamMem(team);
|
||||
teamMem.isMoving = false;
|
||||
teamMem.startMoveTime = 0;
|
||||
teamMem.stopMoveTime = 0;
|
||||
return teamMem;
|
||||
}
|
||||
|
||||
export function getBirthAreaOfCity(city: GVGCityType, leagueCode: string) {
|
||||
let isGuard = city.guardLeague == leagueCode;
|
||||
let dicGVGCity = gameData.gvgCity.get(city.cityId);
|
||||
return isGuard? dicGVGCity.defenseBirth: dicGVGCity.attackBirth;
|
||||
}
|
||||
|
||||
export function checkMoveStatus(team: GVGTeamType, cityId: number, areaId: number) {
|
||||
if(!team) return STATUS.GVG_BATTLE_TEAM_NOT_FOUND;
|
||||
if(team.cityId != cityId) return STATUS.GVG_BATTLE_IS_NOT_IN_CITY;
|
||||
if(team.pointId > 0) return STATUS.GVG_BATTLE_TEAM_IS_SELLTED;
|
||||
if(team.stopMoveTime > 0 && team.stopMoveTime < nowSeconds()) return STATUS.GVG_BATTLE_IS_MOVING;
|
||||
let dicArea = gameData.gvgArea.get(areaId);
|
||||
if(!dicArea) return STATUS.DIC_DATA_NOT_FOUND;
|
||||
if(dicArea.relateArea.indexOf(team.areaId) == -1) return STATUS.GVG_BATTLE_AREA_NOT_RELATE;
|
||||
return STATUS.SUCCESS;
|
||||
}
|
||||
|
||||
export async function initRobots(groupId: number, serverType: number, cityId: number) {
|
||||
let hasRobot = await GVGTeamModel.checkRobot(groupId, serverType, cityId);
|
||||
if(!hasRobot) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user