✨ feat(gvg): 进驻积分点
This commit is contained in:
@@ -75,6 +75,17 @@ class GVGBattleData {
|
||||
}
|
||||
}
|
||||
|
||||
private setRolePoints(roleId: string, fromPointId: number, pointId: number) {
|
||||
if(fromPointId > 0 && pointId == 0) { // 被打得撤离积分点
|
||||
if(this.rolePoints.has(roleId) && this.rolePoints.get(roleId).has(pointId)) {
|
||||
this.rolePoints.get(roleId).delete(pointId);
|
||||
}
|
||||
} else if (fromPointId == 0 && pointId > 0) {
|
||||
if(!this.rolePoints.has(roleId)) this.rolePoints.set(roleId, new Set());
|
||||
this.rolePoints.get(roleId).add(pointId);
|
||||
}
|
||||
}
|
||||
|
||||
public move(teamCode: string, areaId: number, fromAreaId: number, startMoveTime: number, stopMoveTime: number) {
|
||||
let team = this.teams.get(teamCode);
|
||||
if(!team) return;
|
||||
@@ -90,11 +101,13 @@ class GVGBattleData {
|
||||
}
|
||||
|
||||
// 队伍入驻积分点
|
||||
public teamSettle(teamCode: string, pointId: number) {
|
||||
let team = this.teams.get(teamCode);
|
||||
if(!team) return;
|
||||
team.pointId = pointId;
|
||||
}
|
||||
public teamSettle(roleId: string, teamCode: string, pointId: number) {
|
||||
let teamMem = this.teams.get(teamCode);
|
||||
if(!teamMem) return;
|
||||
let { pointId: fromPointId } = teamMem;
|
||||
this.setRolePoints(roleId, fromPointId, pointId);
|
||||
teamMem.pointId = pointId;
|
||||
}
|
||||
|
||||
// 关卡结算
|
||||
public battleEnd(teams: GVGTeamType[]) {
|
||||
@@ -105,11 +118,7 @@ class GVGBattleData {
|
||||
}
|
||||
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.setRolePoints(team.roleId, fromPointId, team.pointId);
|
||||
this.setAreaMap(team.teamCode, fromAreaId, team.areaId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export function checkMoveStatus(team: GVGTeamType, cityId: number, areaId: numbe
|
||||
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;
|
||||
if(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;
|
||||
@@ -145,4 +145,19 @@ export function getOppHeroes(warId: number, isRobot: boolean, lineup: GVGHeroInf
|
||||
}
|
||||
}
|
||||
return heroes
|
||||
}
|
||||
|
||||
export function checkGVGBattleStart(roleId: string, attackTeam: GVGTeamType, defenseTeam: GVGTeamType) {
|
||||
|
||||
if(!attackTeam || !defenseTeam) return STATUS.GVG_BATTLE_TEAM_INVALID;
|
||||
if(attackTeam.roleId != roleId) return STATUS.GVG_TEAM_IS_NOT_MINE;
|
||||
if(attackTeam.leagueCode == defenseTeam.leagueCode) return STATUS.GVG_SAME_LEAGUE_CANNOT_ATTACK;
|
||||
if(attackTeam.areaId != defenseTeam.areaId) return STATUS.GVG_TEAM_NOT_SAME_AREA;
|
||||
|
||||
if(attackTeam.attackTime > nowSeconds()) return STATUS.GVG_TEAM_ATTACKING;
|
||||
if(defenseTeam.defenseTime > nowSeconds() || defenseTeam.lockTime > nowSeconds()) return STATUS.GVG_TEAM_DEFENSEING;
|
||||
if(attackTeam.durability <= 0) return STATUS.GVG_ATTACK_TEAM_BROKEN;
|
||||
if(defenseTeam.durability <= 0) return STATUS.GVG_DEFENSE_TEAM_BROKEN;
|
||||
|
||||
return STATUS.SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user