✨ feat(gvg): 投石车攻击对手范围调整
This commit is contained in:
@@ -15,7 +15,7 @@ import { gameData, getReviveGold } from '../../../pubUtils/data';
|
||||
import { getAllServerName } from '../../../services/redisService';
|
||||
import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
|
||||
import { SaveTeamParam, SaveTeamUpdateParam } from '../../../domain/gvgField/gvgDb';
|
||||
import { GVG_AREA_TYPE, GVG_ITEM, GVG_PERIOD, GVG_REC_TYPE, ITEM_CHANGE_REASON, PUSH_ROUTE, REDIS_KEY, STATUS } from '../../../consts';
|
||||
import { GVG_AREA_TYPE, GVG_ATTACK_TYPE, GVG_ITEM, GVG_PERIOD, GVG_REC_TYPE, ITEM_CHANGE_REASON, PUSH_ROUTE, REDIS_KEY, STATUS } from '../../../consts';
|
||||
import { GVGHeroInfo } from '../../../domain/dbGeneral';
|
||||
import { ArtifactModel } from '../../../db/Artifact';
|
||||
import { getHeroesAttributes } from '../../../services/playerCeService';
|
||||
@@ -561,7 +561,7 @@ export class GVGBattleHandler {
|
||||
|
||||
await battleEndSendMessage(groupKey, cityId, defenseTeam, attackTeam);
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, defenseTeam.areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId, areaId: defenseTeam.areaId, attackType: 2, teams: [new GVGTeamInList(defenseTeam), new GVGTeamInList(attackTeam)]
|
||||
cityId, areaId: defenseTeam.areaId, attackType: GVG_ATTACK_TYPE.KNIFE, teams: [new GVGTeamInList(defenseTeam), new GVGTeamInList(attackTeam)]
|
||||
});
|
||||
return resResult(STATUS.SUCCESS, { curTeam: new MyTeamInfo(attackTeam), oppTeam: new MyTeamInfo(defenseTeam) });
|
||||
}
|
||||
@@ -645,13 +645,11 @@ export class GVGBattleHandler {
|
||||
const points = await GVGCityAreaPointModel.findByConfig(configId, groupKey);
|
||||
|
||||
let result: { cityId: number, guardLeagueName: string, areas: { areaId: number, points: { pointId: number, guardLeagueName: string }[] }[] }[] = [];
|
||||
for(let [ cityId, { mapType, areaIds }] of gameData.gvgCity) {
|
||||
for(let [ cityId, { mapType, battleAreaIds }] of gameData.gvgCity) {
|
||||
if(mapType != serverType) continue;
|
||||
let city = cities.find(cur => cur.cityId == cityId);
|
||||
let areas: { areaId: number, points: {pointId: number, guardLeagueName: string }[]}[] = [];
|
||||
for(let areaId of areaIds) {
|
||||
let dicArea = gameData.gvgArea.get(areaId);
|
||||
if(!dicArea || (dicArea.areaType != GVG_AREA_TYPE.BIG && dicArea.areaType != GVG_AREA_TYPE.MIDDLE && dicArea.areaType != GVG_AREA_TYPE.SMALL) ) continue;
|
||||
for(let areaId of battleAreaIds) {
|
||||
let pointIds = gameData.gvgPointByAreaId.get(areaId)||[];
|
||||
let pointArrs: { pointId: number, guardLeagueName: string }[] = [];
|
||||
for(let pointId of pointIds) {
|
||||
|
||||
@@ -33,18 +33,14 @@ class GVGBattleData {
|
||||
return teams.slice(0, 20);
|
||||
}
|
||||
|
||||
public findCatapultAttackTeam(areaIds: number[], leagueCode: string) {
|
||||
let teamsByArea = new Map<number, string[]>();
|
||||
for(let areaId of areaIds) {
|
||||
let teams: string[] = [];
|
||||
let teamCodes = this.areaToTeams.get(areaId)||new Set();
|
||||
for(let teamCode of teamCodes) {
|
||||
let team = this.teams.get(teamCode);
|
||||
if(team && team.leagueCode != leagueCode && !team.isRobot) teams.push(teamCode);
|
||||
}
|
||||
teamsByArea.set(areaId, teams);
|
||||
public findCatapultAttackTeam(areaId: number, leagueCode: string) {
|
||||
let teams: string[] = [];
|
||||
let teamCodes = this.areaToTeams.get(areaId)||new Set();
|
||||
for(let teamCode of teamCodes) {
|
||||
let team = this.teams.get(teamCode);
|
||||
if(team && team.leagueCode != leagueCode && !team.isRobot) teams.push(teamCode);
|
||||
}
|
||||
return teamsByArea;
|
||||
return teams;
|
||||
}
|
||||
|
||||
public leaveCity(roleId: string) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGTeamModel, GVGTeamType, GVGTeamUpdate } from "../../db/GVGTeam";
|
||||
import { GVGCityModel, GVGCityType } from "../../db/GVGCity";
|
||||
import { gameData, getGVGBattleRankReward } from "../../pubUtils/data";
|
||||
import { GVG_AREA_TYPE, GVG_BATTLE_RANK_TYPE, GVG_PERIOD, GVG_TECH_TYPE, MAIL_TYPE, PUSH_ROUTE, REDIS_KEY, STATUS } from "../../consts";
|
||||
import { GVG_AREA_TYPE, GVG_ATTACK_TYPE, GVG_BATTLE_RANK_TYPE, GVG_PERIOD, GVG_POINT_TYPE, GVG_TECH_TYPE, MAIL_TYPE, PUSH_ROUTE, REDIS_KEY, STATUS } from "../../consts";
|
||||
import { getTimeFun, nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { DicGVGAreaPoint } from "../../pubUtils/dictionary/DicGVGAreaPoint";
|
||||
import { getGVGBattleData, getGVGBattleMap } from "./gvgBattleMemory";
|
||||
@@ -24,6 +24,7 @@ import { addCityGuardMessage } from "./gvgRecService";
|
||||
import { GVGUserDataModel } from "../../db/GVGUserData";
|
||||
import { RoleModel } from "../../db/Role";
|
||||
import { getFightTimeByPeriod } from "./gvgFightService";
|
||||
import { getRandSingleEelm } from "../../pubUtils/util";
|
||||
|
||||
/**
|
||||
* 获取本联军上周占领的城池
|
||||
@@ -114,13 +115,16 @@ export async function initRobots(configId: number, groupKey: string, city: GVGCi
|
||||
if(guardLeague) return [];
|
||||
let robotTeams = await GVGTeamModel.findRobotTeams(groupKey, cityId);
|
||||
let updateDicPoints: DicGVGAreaPoint[] = [];
|
||||
let { areaIds = []} = gameData.gvgCity.get(cityId);
|
||||
for(let [_, point] of gameData.gvgAreaPoint) {
|
||||
if(point.type != 1) continue;
|
||||
if(areaIds.indexOf(point.areaId) == -1) continue;
|
||||
let robotTeam = robotTeams.find(team => team.pointId == point.pointId);
|
||||
if(!robotTeam || (!robotTeam.isBroken && robotTeam.configId != configId) ) {
|
||||
updateDicPoints.push(point);
|
||||
let { battleAreaIds = []} = gameData.gvgCity.get(cityId);
|
||||
for(let areaId of battleAreaIds) {
|
||||
let pointIds = gameData.gvgPointByAreaId.get(areaId)||[];
|
||||
for(let pointId of pointIds) {
|
||||
let dicPoint = gameData.gvgAreaPoint.get(pointId);
|
||||
if(!dicPoint || dicPoint.type != GVG_POINT_TYPE.ROBOT) continue;
|
||||
let robotTeam = robotTeams.find(team => team.pointId == dicPoint.pointId);
|
||||
if(!robotTeam || (!robotTeam.isBroken && robotTeam.configId != configId) ) {
|
||||
updateDicPoints.push(dicPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(updateDicPoints.length > 0) {
|
||||
@@ -298,12 +302,14 @@ export async function initCatapult(cityId: number, groupKey: string, leagueCode:
|
||||
}
|
||||
if(hasCatapult) {
|
||||
let updateDicPoints: DicGVGAreaPoint[] = [];
|
||||
let { areaIds = []} = gameData.gvgCity.get(cityId);
|
||||
for(let [_, point] of gameData.gvgAreaPoint) {
|
||||
|
||||
if(point.type != 2) continue;
|
||||
if(areaIds.indexOf(point.areaId) == -1) continue;
|
||||
updateDicPoints.push(point);
|
||||
let { catapultAreaIds = []} = gameData.gvgCity.get(cityId);
|
||||
for(let areaId of catapultAreaIds) {
|
||||
let pointIds = gameData.gvgPointByAreaId.get(areaId)||[];
|
||||
for(let pointId of pointIds) {
|
||||
let dicPoint = gameData.gvgAreaPoint.get(pointId);
|
||||
if(!dicPoint || dicPoint.type != GVG_POINT_TYPE.CATAPULT) continue;
|
||||
updateDicPoints.push(dicPoint);
|
||||
}
|
||||
}
|
||||
|
||||
let lv = gameData.war.get(GVG.GVG_CATAPULT_WARJSON)?.level||50;
|
||||
@@ -320,26 +326,26 @@ export async function catapultHurt() {
|
||||
for(let [_key, teamObj] of getGVGBattleMap()) {
|
||||
let teams = teamObj.findCatapult();
|
||||
for(let catapult of teams) {
|
||||
if(catapult.isBroken) continue;
|
||||
let dicArea = gameData.gvgArea.get(catapult.areaId);
|
||||
let relateArea = dicArea?.relateArea||[];
|
||||
let teamCodeByArea = teamObj.findCatapultAttackTeam(relateArea, catapult.leagueCode);
|
||||
let dicGVGCity = gameData.gvgCity.get(catapult.cityId);
|
||||
for(let [ areaId, teamCodes ] of teamCodeByArea) {
|
||||
let teams = await GVGTeamModel.attackByCatapult(teamCodes, catapult.captapultAtk, dicGVGCity.attackBirth);
|
||||
teamObj.battleEnd(teams);
|
||||
if(teams.length > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(teamObj.groupKey, areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: 1, teams: teams.map(team => new GVGTeamInList(team))
|
||||
});
|
||||
await sendMessageToGVGCityWithSuc(teamObj.groupKey, catapult.cityId, PUSH_ROUTE.GVG_SPINE_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: 1, teams: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
||||
});
|
||||
for(let team of teams) {
|
||||
await pushTeamBeHurtMessage(team);
|
||||
if(team.curTeamBreak && team.originPointId > 0) {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, teamObj.groupKey, team.originPointId);
|
||||
}
|
||||
let dicGVGCity = gameData.gvgCity.get(catapult?.cityId);
|
||||
let battleAreaIds = dicGVGCity?.battleAreaIds||[]
|
||||
if(!catapult || catapult.isBroken || !dicGVGCity || battleAreaIds.length <= 0) continue;
|
||||
let areaId = getRandSingleEelm(battleAreaIds);
|
||||
let teamCodes = teamObj.findCatapultAttackTeam(areaId, catapult.leagueCode);
|
||||
console.log('##### targetAreaId', catapult.teamCode, areaId);
|
||||
|
||||
let teams = await GVGTeamModel.attackByCatapult(teamCodes, catapult.captapultAtk, dicGVGCity.attackBirth);
|
||||
teamObj.battleEnd(teams);
|
||||
if(teams.length > 0) {
|
||||
await sendMessageToGVGAreaByTeamWithSuc(teamObj.groupKey, areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: GVG_ATTACK_TYPE.CATAPULT, teams: teams.map(team => new GVGTeamInList(team))
|
||||
});
|
||||
await sendMessageToGVGCityWithSuc(teamObj.groupKey, catapult.cityId, PUSH_ROUTE.GVG_SPINE_ATTACKED, {
|
||||
cityId: catapult.cityId, areaId, attackType: GVG_ATTACK_TYPE.CATAPULT, teams: teams.map(team => new GVGAttackSpine(team, catapult.captapultAtk))
|
||||
});
|
||||
for(let team of teams) {
|
||||
await pushTeamBeHurtMessage(team);
|
||||
if(team.curTeamBreak && team.originPointId > 0) {
|
||||
await GVGCityAreaPointModel.leavePoint(configId, teamObj.groupKey, team.originPointId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -532,7 +538,7 @@ export async function battleEndSendMessage(groupKey: string, cityId: number, def
|
||||
let areaId = defenseTeam.curTeamBreak? defenseTeam.fromAreaId: defenseTeam.areaId;
|
||||
// 推送伤害
|
||||
await sendMessageToGVGAreaByTeamWithSuc(groupKey, areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
||||
cityId, areaId, attackType: 3, teams: [new GVGTeamInList(defenseTeam), new GVGTeamInList(attackTeam)]
|
||||
cityId, areaId, attackType: GVG_ATTACK_TYPE.PLAYER, teams: [new GVGTeamInList(defenseTeam), new GVGTeamInList(attackTeam)]
|
||||
});
|
||||
await pushTeamBeHurtMessage(defenseTeam, attackTeam);
|
||||
await pushTeamBeHurtMessage(attackTeam);
|
||||
|
||||
@@ -155,9 +155,23 @@ export enum GVG_AREA_TYPE {
|
||||
}
|
||||
|
||||
export const GVG_CATAPULT = 'catapult';
|
||||
export const GVG_ROBOT = 'robot';
|
||||
|
||||
export enum GVG_BATTLE_RANK_TYPE {
|
||||
PLAYER = 1,
|
||||
GUILD = 2, // 废弃
|
||||
LEAGUE = 3
|
||||
}
|
||||
|
||||
// 据点上的守卫类型
|
||||
export enum GVG_POINT_TYPE {
|
||||
NO = 0,
|
||||
ROBOT = 1, // 守卫者
|
||||
CATAPULT = 2, // 投石车
|
||||
}
|
||||
|
||||
export enum GVG_ATTACK_TYPE {
|
||||
CATAPULT = 1, // 投石车
|
||||
KNIFE = 2, // 道具
|
||||
PLAYER = 3, // 玩家
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { EXTERIOR, GVG } from "../pubUtils/dicParam";
|
||||
import { DicGVGAreaPoint } from "../pubUtils/dictionary/DicGVGAreaPoint";
|
||||
import { InitTeamParam, SaveTeamUpdateParam } from "../domain/gvgField/gvgDb";
|
||||
import { GVGHeroInfo } from "../domain/dbGeneral";
|
||||
import { GVG_CATAPULT } from "../consts";
|
||||
import { GVG_CATAPULT, GVG_ROBOT } from "../consts";
|
||||
|
||||
@index({ roleId: 1, index: 1 })
|
||||
@index({ teamCode: 1 })
|
||||
@@ -215,7 +215,7 @@ export default class GVGTeam extends BaseModel {
|
||||
let teams: GVGTeamType[] = [];
|
||||
for(let { pointId, areaId, name, head, spine, ce, durability } of dicPoints) {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ groupKey, cityId, areaId, pointId }, {
|
||||
$setOnInsert: {teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, isRobot: true, lv, isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', leagueCode: '', leagueName: '', fromAreaId: areaId,
|
||||
$setOnInsert: {teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, isRobot: true, lv, isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', leagueCode: '', leagueName: '', fromAreaId: areaId, roleId: GVG_ROBOT,
|
||||
}, $set: { configId, durability }
|
||||
}, { new: true, upsert: true }).lean();
|
||||
teams.push(team);
|
||||
@@ -235,7 +235,7 @@ export default class GVGTeam extends BaseModel {
|
||||
let team: GVGTeamType = await GVGTeamModel.findOneAndUpdate({ groupKey, cityId, areaId, pointId }, {
|
||||
$setOnInsert: {
|
||||
teamCode: genCode(8), maxDurability: durability, roleName: name, head, spine, frame: EXTERIOR.EXTERIOR_FACECASE, lineupCe: ce, lv, leagueCode, leagueName, captapultAtk: atk,
|
||||
isRobot: true, isCatapult: true, isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', fromAreaId: areaId,
|
||||
isRobot: true, isCatapult: true, isBroken: false, startMoveTime: 0, stopMoveTime: 0, guildCode: '', fromAreaId: areaId, roleId: GVG_CATAPULT,
|
||||
}, $set: { configId, durability }
|
||||
}, { new: true, upsert: true }).lean();
|
||||
teams.push(team);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// GVG城池
|
||||
import { FILENAME } from '../../consts'
|
||||
import { FILENAME, GVG_AREA_TYPE } from '../../consts'
|
||||
import { parseNumberList, readFileAndParse } from '../util'
|
||||
|
||||
export interface DicGVGArea {
|
||||
@@ -26,7 +26,7 @@ export interface DicGVGArea {
|
||||
}
|
||||
|
||||
export const dicGVGArea = new Map<number, DicGVGArea>();
|
||||
export const dicGVGCity = new Map<number, { cityType: number, mapType: number, areaIds: number[], defenseBirth: number, attackBirth: number, cityName: string }>();
|
||||
export const dicGVGCity = new Map<number, { cityType: number, mapType: number, battleAreaIds: number[], catapultAreaIds: number[], areaIds: number[], defenseBirth: number, attackBirth: number, cityName: string }>();
|
||||
export function loadGVGArea() {
|
||||
dicGVGArea.clear();
|
||||
dicGVGCity.clear();
|
||||
@@ -35,11 +35,14 @@ export function loadGVGArea() {
|
||||
arr.forEach(o => {
|
||||
o.relateArea = parseNumberList(o.relateArea);
|
||||
if(!dicGVGCity.has(o.cityId)) {
|
||||
dicGVGCity.set(o.cityId, { cityType: o.cityType, mapType: o.mapType, areaIds: [], defenseBirth: 0, attackBirth: 0, cityName: o.cityName });
|
||||
dicGVGCity.set(o.cityId, { cityType: o.cityType, mapType: o.mapType, battleAreaIds: [], catapultAreaIds: [], areaIds: [], defenseBirth: 0, attackBirth: 0, cityName: o.cityName });
|
||||
}
|
||||
if(o.areaType == GVG_AREA_TYPE.BIG || o.areaType == GVG_AREA_TYPE.MIDDLE || o.areaType == GVG_AREA_TYPE.SMALL)
|
||||
dicGVGCity.get(o.cityId)?.battleAreaIds.push(o.areaId);
|
||||
if(o.areaType == GVG_AREA_TYPE.CATAPULT) dicGVGCity.get(o.cityId)?.catapultAreaIds.push(o.areaId);
|
||||
if(o.areaType == GVG_AREA_TYPE.DEFENSER) dicGVGCity.get(o.cityId).defenseBirth = o.areaId;
|
||||
if(o.areaType == GVG_AREA_TYPE.ATTACKER) dicGVGCity.get(o.cityId).attackBirth = o.areaId;
|
||||
dicGVGCity.get(o.cityId)?.areaIds.push(o.areaId);
|
||||
if(o.areaType == 1) dicGVGCity.get(o.cityId).defenseBirth = o.areaId;
|
||||
if(o.areaType == 2) dicGVGCity.get(o.cityId).attackBirth = o.areaId;
|
||||
dicGVGArea.set(o.areaId, o);
|
||||
});
|
||||
arr = undefined;
|
||||
|
||||
Reference in New Issue
Block a user