|
|
|
|
@@ -4,7 +4,7 @@ import { GVGTeamModel, GVGTeamType, GVGTeamUpdate } from '../../../db/GVGTeam';
|
|
|
|
|
import { GVGUserDataModel } from '../../../db/GVGUserData';
|
|
|
|
|
import { GVGCityModel, GVGCityType } from '../../../db/GVGCity';
|
|
|
|
|
import { Application, BackendSession, ChannelService, HandlerService, pinus } from "pinus";
|
|
|
|
|
import { resResult, genCode } from "../../../pubUtils/util";
|
|
|
|
|
import { resResult, genCode, getRandSingleEelm } from "../../../pubUtils/util";
|
|
|
|
|
import { GVGLeagueModel } from '../../../db/GVGLeague';
|
|
|
|
|
import { getGroupKey, getGVGConfig, getGVGPeriodData, getGVGServerType } from '../../../services/gvg/gvgService';
|
|
|
|
|
import { redisAddBattleScore, battleEndSendMessage, calBattleScoreByCe, checkAreaIsInCity, checkGVGBattleStart, checkMoveStatus, getBattleRanksByCity, getBirthAreaOfCity, getGVGWarId, getOppHeroes, getTechKnifeHurt, getTechReviveMinus, initRobots, pushTeamMoveMessage, getGVGCitiesInfo, leaveCity, refreshTeams, checkEnterCityTime, generNewLineup, getBattleRank, checkSettleStatus } from '../../../services/gvg/gvgBattleService';
|
|
|
|
|
@@ -26,8 +26,8 @@ import { Rank } from '../../../services/rankService';
|
|
|
|
|
import { LeagueRankInfo, RoleRankInfo } from '../../../domain/rank';
|
|
|
|
|
import { addBattleEndRec } from '../../../services/gvg/gvgRecService';
|
|
|
|
|
import { RoleModel } from '../../../db/Role';
|
|
|
|
|
import { GVG } from '../../../pubUtils/dicParam';
|
|
|
|
|
import { sendMessageToGVGAreaByTeamWithSuc } from '../../../services/pushService';
|
|
|
|
|
import { EXTERIOR, GVG } from '../../../pubUtils/dicParam';
|
|
|
|
|
import { sendMessageToGVGAreaByTeamWithSuc, sendMessageToUserWithSuc } from '../../../services/pushService';
|
|
|
|
|
|
|
|
|
|
export default function (app: Application) {
|
|
|
|
|
new HandlerService(app, {});
|
|
|
|
|
@@ -698,4 +698,104 @@ export class GVGBattleHandler {
|
|
|
|
|
await pinus.app.rpc.systimer.systimerRemote.gvgBattleEndSchedule.broadcast();
|
|
|
|
|
return resResult(STATUS.SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async debugAddRobots(msg: { cityId: number, teamCnt: number }, session: BackendSession) {
|
|
|
|
|
const serverId = session.get('serverId');
|
|
|
|
|
const { cityId, teamCnt } = msg;
|
|
|
|
|
|
|
|
|
|
const { configId } = getGVGConfig();
|
|
|
|
|
const groupKey = await getGroupKey(serverId);
|
|
|
|
|
const teamObj = getGVGBattleData(groupKey);
|
|
|
|
|
const teams: any[] = [];
|
|
|
|
|
const areaIds = gameData.gvgCity.get(cityId)?.areaIds||[];
|
|
|
|
|
for(let i = 0; i < teamCnt; i++) {
|
|
|
|
|
let areaId = getRandSingleEelm(areaIds);
|
|
|
|
|
teams.push({ configId, groupKey, roleId: 'test', roleName: 'test' + i, serverId, lv: 100, teamCode: genCode(8), index: 3, leagueCode: 'test', leagueName: 'test' + i, guildCode: 'test', areaId, cityId, pointId: 0, head: EXTERIOR.EXTERIOR_FACE, frame: EXTERIOR.EXTERIOR_FACECASE, spine: EXTERIOR.EXTERIOR_APPEARANCE, durability: 100, maxDurability: 100, restartTime: nowSeconds(), attackTime: nowSeconds(), lockTime: nowSeconds(), startMoveTime: nowSeconds(), stopMoveTime: nowSeconds(), moveCdTime: nowSeconds(), defenseTime: nowSeconds(), lineupCe: 100000 })
|
|
|
|
|
}
|
|
|
|
|
await GVGTeamModel.insertMany(teams);
|
|
|
|
|
teamObj.enterCity(...teams);
|
|
|
|
|
|
|
|
|
|
return resResult(STATUS.SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private moveInterval: NodeJS.Timer;
|
|
|
|
|
private attackInterval: NodeJS.Timer;
|
|
|
|
|
async debugMoveRobots(msg: { cityId: number, frequency: number }, session: BackendSession) {
|
|
|
|
|
const serverId = session.get('serverId');
|
|
|
|
|
const { cityId, frequency } = msg;
|
|
|
|
|
|
|
|
|
|
const { configId } = getGVGConfig();
|
|
|
|
|
const groupKey = await getGroupKey(serverId);
|
|
|
|
|
const teamObj = getGVGBattleData(groupKey);
|
|
|
|
|
const serverNames = await getAllServerName();
|
|
|
|
|
|
|
|
|
|
if(this.moveInterval) {
|
|
|
|
|
clearInterval(this.moveInterval);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let fun = async () => {
|
|
|
|
|
let teams = teamObj.findTeamsByRole('test');
|
|
|
|
|
for(let teamMem of teams) {
|
|
|
|
|
let fromAreaId = teamMem.areaId;
|
|
|
|
|
let dicArea = gameData.gvgArea.get(fromAreaId);
|
|
|
|
|
// 更新内存数据
|
|
|
|
|
let toAreaId = getRandSingleEelm(dicArea.relateArea);
|
|
|
|
|
let team = await GVGTeamModel.startMove(teamMem.teamCode, toAreaId, fromAreaId);
|
|
|
|
|
|
|
|
|
|
// 更新内存数据
|
|
|
|
|
let teamObj = getGVGBattleData(groupKey);
|
|
|
|
|
teamObj.move(teamMem.teamCode, toAreaId, team.fromAreaId, team.startMoveTime, team.stopMoveTime);
|
|
|
|
|
await pushTeamMoveMessage(team);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
await fun();
|
|
|
|
|
this.moveInterval = setInterval(fun, frequency)
|
|
|
|
|
return resResult(STATUS.SUCCESS)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async debugAttacks(msg: { cityId: number, frequency: number }, session: BackendSession) {
|
|
|
|
|
const roleId = session.get('roleId');
|
|
|
|
|
const serverId = session.get('serverId');
|
|
|
|
|
const sid = session.get('sid');
|
|
|
|
|
const { cityId, frequency } = msg;
|
|
|
|
|
|
|
|
|
|
const { configId } = getGVGConfig();
|
|
|
|
|
const groupKey = await getGroupKey(serverId);
|
|
|
|
|
const teamObj = getGVGBattleData(groupKey);
|
|
|
|
|
const serverNames = await getAllServerName();
|
|
|
|
|
|
|
|
|
|
if(this.attackInterval) {
|
|
|
|
|
clearInterval(this.attackInterval);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let fun = async () => {
|
|
|
|
|
for(let areaId of teamObj.findAreas()) {
|
|
|
|
|
let teams = teamObj.findTeamsByArea(areaId);
|
|
|
|
|
let areaTeams = teams.map(team => new GVGTeamInList(team as any));
|
|
|
|
|
await sendMessageToGVGAreaByTeamWithSuc(teamObj.groupKey, areaId, PUSH_ROUTE.GVG_TEAM_ATTACKED, {
|
|
|
|
|
cityId, areaId, attackType: GVG_ATTACK_TYPE.PLAYER, teams: areaTeams
|
|
|
|
|
});
|
|
|
|
|
let myTeams = teams.filter(team => team.roleId == roleId).map(team => new GVGTeamInList(team as any));
|
|
|
|
|
if(myTeams.length > 0) await sendMessageToUserWithSuc(roleId, PUSH_ROUTE.GVG_MY_TEAM_ATTACKED, {
|
|
|
|
|
cityId, areaId, attackType: GVG_ATTACK_TYPE.PLAYER, teams: myTeams
|
|
|
|
|
}, sid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
await fun();
|
|
|
|
|
this.attackInterval = setInterval(fun, frequency)
|
|
|
|
|
return resResult(STATUS.SUCCESS)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async debugStopMoveRobot(msg: { cityId: number }, session: BackendSession) {
|
|
|
|
|
if(this.moveInterval) {
|
|
|
|
|
clearInterval(this.moveInterval);
|
|
|
|
|
}
|
|
|
|
|
if(this.attackInterval) {
|
|
|
|
|
clearInterval(this.attackInterval);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resResult(STATUS.SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|