diff --git a/game-server/app/servers/role/handler/teamHandler.ts b/game-server/app/servers/role/handler/teamHandler.ts new file mode 100644 index 000000000..98fbc5600 --- /dev/null +++ b/game-server/app/servers/role/handler/teamHandler.ts @@ -0,0 +1,73 @@ +import { Application, BackendSession, ChannelService, HandlerService } from "pinus"; +import { STATUS, TEAM_TYPE } from "../../../consts"; +import { gameData } from "../../../pubUtils/data"; +import { resResult } from "../../../pubUtils/util"; +import { PVPConfigModel } from "../../../db/PvpConfig"; +import { PvpSaveDataModel } from "../../../db/PvpSaveData"; +import { LadderMatchModel } from "../../../db/LadderMatch"; +import { GVGVestigeRankModel } from "../../../db/GVGVestigeRank"; +import { GVGTeamModel } from "../../../db/GVGTeam"; + + + +export default function (app: Application) { + new HandlerService(app, {}); + return new TeamHandler(app); +} + +export class TeamHandler { + channelService: ChannelService; + constructor(private app: Application) { + } + + // 获取每个编队里的武将 + async getTeamHeroes(msg: { }, session: BackendSession) { + const roleId = session.get('roleId'); + + const teams: { type: number, heroes: number[] }[] = []; + + let pvpConfig = await PVPConfigModel.findCurPVPConfig(); + if(pvpConfig) { + let saveDatas = await PvpSaveDataModel.findByRoleId(roleId); + let heroes: number[] = []; + for(let warId of (pvpConfig.warIds||[])) { + let dicWar = gameData.war.get(warId); + if(dicWar && dicWar.selectView == 1) { + let curSaveData = saveDatas.find(cur => cur.warId == warId); + let defenseHeroes = curSaveData?.heroes||[]; + for(let { actorId } of defenseHeroes) heroes.push(actorId); + } + } + teams.push({ type: TEAM_TYPE.PVP, heroes }); + } + + let ladderData = await LadderMatchModel.findByRoleId(roleId); + if(ladderData && ladderData.defense) { + let heroes: number[] = []; + let defenseHeroes = ladderData.defense?.heroes||[]; + for(let { actorId } of defenseHeroes) heroes.push(actorId); + teams.push({ type: TEAM_TYPE.LADDER, heroes }); + } + + let vestigeData = await GVGVestigeRankModel.findAllByRole(roleId); + if(vestigeData) { + let heroes: number[] = []; + for(let { lineup = [] } of vestigeData) { + for(let { actorId } of lineup) heroes.push(actorId); + } + teams.push({ type: TEAM_TYPE.VESTIGE, heroes }); + } + + let gvgBattleTeams = await GVGTeamModel.findByRole(roleId, '-_id lineup'); + if(gvgBattleTeams) { + let heroes: number[] = []; + for(let { lineup = [] } of gvgBattleTeams) { + for(let { actorId } of lineup) heroes.push(actorId); + } + teams.push({ type: TEAM_TYPE.GVG_BATTLE, heroes }); + } + + + return resResult(STATUS.SUCCESS, { teams }); + } +} \ No newline at end of file diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 120db76bb..344ddfe2b 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -1282,4 +1282,11 @@ export enum SERVER_GROUP_FUN_TYPE { GVG = 1, PVP = 2, ARENA = 3, +} + +export enum TEAM_TYPE { + PVP = 1, // pvp队伍 + LADDER = 2, // 名将擂台 + VESTIGE = 3, // 遗迹 + GVG_BATTLE = 4, // 激战期 } \ No newline at end of file