✨ feat(gvg): 添加队伍快照

This commit is contained in:
luying
2023-02-17 10:59:38 +08:00
parent a838aba8e5
commit 3141566eb3
6 changed files with 50 additions and 10 deletions
@@ -20,6 +20,9 @@ import { pick } from 'underscore';
import { SaveTeamParam, SaveTeamUpdateParam } from '../../../domain/gvgField/gvgDb';
import { GVG_PERIOD, PUSH_ROUTE, STATUS } from '../../../consts';
import { sendMessageToUserWithSuc } from '../../../services/pushService';
import { GVGHeroInfo } from '../../../domain/dbGeneral';
import { ArtifactModel } from '../../../db/Artifact';
import { getHeroesAttributes } from '../../../services/playerCeService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -68,10 +71,29 @@ export class GVGBattleHandler {
let updateParam: SaveTeamUpdateParam = { index, head, spine, frame, configId, groupId, serverType }
if(lineup) {
let attrByHid = await getHeroesAttributes(roleId);
let { isOK, heroes } = await checkBattleHeroesByHid(roleId, lineup.map(cur => cur.actorId));
if(!isOK) return resResult(STATUS.BATTLE_HERO_NOT_FOUND);
let newLineup: GVGHeroInfo[] = [];
for(let { actorId, dataId, order } 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 attr = attrByHid.get(actorId);
if(!attr) continue;
let attribute = attr.getAttributesToString();
heroInfo.setAttribute(attribute);
newLineup.push(heroInfo);
}
}
let lineupCe = heroes.reduce((pre, cur) => pre + cur.ce, 0);
updateParam.lineup = lineup;
updateParam.lineup = newLineup;
updateParam.lineupCe = lineupCe;
}