✨ feat(副将): pvp相关副将设置
This commit is contained in:
@@ -30,6 +30,7 @@ import { ArtifactModel } from "../../db/Artifact";
|
||||
import { getHeroesAttributes } from "../playerCeService";
|
||||
import { CounterModel } from "../../db/Counter";
|
||||
import { getGroupIdOfServer } from "../serverService";
|
||||
import { LineupHero } from "../../domain/roleField/hero";
|
||||
|
||||
/**
|
||||
* 获取本联军上周占领的城池
|
||||
@@ -200,16 +201,18 @@ export async function refreshTeams(configId: number, groupKey: string, roleId: s
|
||||
return teams
|
||||
}
|
||||
|
||||
export async function generNewLineup(roleId: string, heroes: HeroType[], lineup: { actorId: number, dataId: number, order: number }[]) {
|
||||
export async function generNewLineup(roleId: string, heroes: HeroType[], lineup: { actorId: number, dataId: number, order: number, subHid?: number }[]) {
|
||||
let attrByHid = await getHeroesAttributes(roleId);
|
||||
let newLineup: GVGHeroInfo[] = [], newLineupCe = 0;
|
||||
for(let { actorId, dataId, order } of lineup) {
|
||||
for(let { actorId, dataId, order, subHid } of lineup) {
|
||||
let hero = heroes.find(cur => cur.hid == actorId);
|
||||
if(hero) {
|
||||
let artifact = hero.artifact? await ArtifactModel.findbySeqId(roleId, hero.artifact): null;
|
||||
let heroInfo = new GVGHeroInfo();
|
||||
heroInfo.setHeroInfo(hero, artifact, []);
|
||||
heroInfo.setDataId(dataId, order);
|
||||
let subHero = heroes.find(cur => cur.hid == subHid);
|
||||
if(subHero) heroInfo.setSubHero(subHero);
|
||||
|
||||
let attr = attrByHid.get(actorId);
|
||||
if(!attr) continue;
|
||||
@@ -860,4 +863,36 @@ async function dispatchTeam(groupKey: string, cityId: number) {
|
||||
let servers = pinus.app.getServersByType('guild');
|
||||
let sid = (await dispatch(redisClient(), `${groupId}_${cityId}`, servers, 'guild'))?.id;
|
||||
return sid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询队伍中的武将是否可以使用
|
||||
* @param roleId
|
||||
* @param index
|
||||
* @param lineup
|
||||
* @returns
|
||||
*/
|
||||
export async function checkGVGLineupWhenSave(roleId: string, index: number, lineup: LineupHero[]) {
|
||||
const teams = await GVGTeamModel.findByRole(roleId, '-_id index lineup');
|
||||
for(let { actorId, subHid } of lineup) {
|
||||
let dicHero = gameData.hero.get(actorId);
|
||||
if(!dicHero || dicHero.urType != 1) return STATUS.HERO_CAN_NOT_SET_SUB;
|
||||
|
||||
for(let team of teams) {
|
||||
// 查actorId没有在其他队伍中使用
|
||||
if(team.index != index) {
|
||||
let hasActor = team.lineup.find(hero => hero.actorId == actorId);
|
||||
if(hasActor) return STATUS.GVG_TEAM_HERO_DUPLICATE;
|
||||
}
|
||||
// 查actorId没有在其他队伍作为副将
|
||||
let hasActorIsSubHero = team.lineup.find(hero => hero.subHid == actorId);
|
||||
if(hasActorIsSubHero) return STATUS.GVG_TEAM_HERO_USED_AS_SUB_HERO;
|
||||
// 查副将
|
||||
if(subHid) {
|
||||
let hasSubHero = team.lineup.find(hero => hero.actorId == subHid);
|
||||
if(hasSubHero) return STATUS.GVG_TEAM_SUB_HERO_DUPLICATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return STATUS.SUCCESS
|
||||
}
|
||||
Reference in New Issue
Block a user