feat(gvg): 添加队伍快照

This commit is contained in:
luying
2023-02-14 21:24:50 +08:00
parent a838aba8e5
commit 3141566eb3
6 changed files with 50 additions and 10 deletions

View File

@@ -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;
}

View File

@@ -2,8 +2,8 @@
import BaseModel from "./BaseModel";
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { genCode } from "../pubUtils/util";
import { LineupHero } from './../domain/roleField/hero';
import { GVGTeamType } from "./GVGTeam";
import { GVGHeroInfo } from "../domain/dbGeneral";
class TeamInfo {
@prop({ required: true })
@@ -42,8 +42,8 @@ class TeamInfo {
@prop({ required: true, default: 0 })
durability: number; // 耐久
@prop({ required: true, type: () => LineupHero, _id: false })
lineup: LineupHero[]
@prop({ required: true, type: () => GVGHeroInfo, _id: false })
lineup: GVGHeroInfo[]
}
@index({ battleCode: 1 })

View File

@@ -2,11 +2,11 @@
import BaseModel from "./BaseModel";
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { genCode } from "../pubUtils/util";
import { LineupHero } from './../domain/roleField/hero';
import { nowSeconds } from "../pubUtils/timeUtil";
import { GVG } from "../pubUtils/dicParam";
import { DicGVGAreaPoint } from "../pubUtils/dictionary/DicGVGAreaPoint";
import { InitTeamParam, SaveTeamUpdateParam } from "../domain/gvgField/gvgDb";
import { GVGHeroInfo } from "../domain/dbGeneral";
@index({ roleId: 1, index: 1 })
@index({ teamCode: 1 })
@@ -94,8 +94,8 @@ export default class GVGTeam extends BaseModel {
@prop({ required: true, default: 0 })
leagueScore: number; // 积分
@prop({ required: true, type: () => LineupHero, _id: false })
lineup: LineupHero[];
@prop({ required: true, type: () => GVGHeroInfo, _id: false })
lineup: GVGHeroInfo[];
@prop({ required: true })
lineupCe: number;

View File

@@ -93,6 +93,18 @@ export class PvpHeroInfo {
}
}
export class GVGHeroInfo extends PvpHeroInfo {
@prop({ required: false })
outIndex?: number = 0; // 程序将信息存入数组顺序
@prop({ required: false })
dataId?: number = 0; // 对应出兵表dataId
setDataId(dataId: number, order: number) {
this.dataId = dataId;
this.outIndex = order;
}
}
// 远征敌军
export class Enemies extends PvpHeroInfo {
@prop({ required: true })

View File

@@ -8,6 +8,7 @@ import { gameData } from "../../pubUtils/data";
import { EXTERIOR, GVG } from "../../pubUtils/dicParam";
import { DicGVGVestige } from "../../pubUtils/dictionary/DicGVGVestige";
import { DicWarJson } from "../../pubUtils/dictionary/DicWarJson";
import { GVGHeroInfo, PvpHeroInfo } from "../dbGeneral";
import { LineupHero } from "../roleField/hero";
export class OppPlayerHeroInfo {
@@ -257,11 +258,16 @@ export interface SaveTeamParam {
lineup?: LineupHero[];
}
export interface SaveTeamUpdateParam extends SaveTeamParam {
lineupCe?: number;
export interface SaveTeamUpdateParam {
index: number;
head: number;
frame: number;
spine: number;
configId: number;
groupId: number;
serverType: number;
lineup?: GVGHeroInfo[];
lineupCe?: number;
}
export interface InitTeamParam {

View File

@@ -706,7 +706,7 @@ export class MyTeamInfo {
this.index = team.index;
this.head = team.head;
this.frame = team.spine;
this.lineup = team.lineup;
this.lineup = team.lineup.map(({ actorId, dataId, outIndex }) => ({ actorId, dataId, order: outIndex }));
this.durability = team.durability;
this.maxDurability = team.maxDurability;
this.restartTime = team.restartTime;