✨ feat(编队): 设置副将的时候查看所有编队
This commit is contained in:
73
game-server/app/servers/role/handler/teamHandler.ts
Normal file
73
game-server/app/servers/role/handler/teamHandler.ts
Normal file
@@ -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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1282,4 +1282,11 @@ export enum SERVER_GROUP_FUN_TYPE {
|
|||||||
GVG = 1,
|
GVG = 1,
|
||||||
PVP = 2,
|
PVP = 2,
|
||||||
ARENA = 3,
|
ARENA = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TEAM_TYPE {
|
||||||
|
PVP = 1, // pvp队伍
|
||||||
|
LADDER = 2, // 名将擂台
|
||||||
|
VESTIGE = 3, // 遗迹
|
||||||
|
GVG_BATTLE = 4, // 激战期
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user