✨ 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 { SaveTeamParam, SaveTeamUpdateParam } from '../../../domain/gvgField/gvgDb';
import { GVG_PERIOD, PUSH_ROUTE, STATUS } from '../../../consts'; import { GVG_PERIOD, PUSH_ROUTE, STATUS } from '../../../consts';
import { sendMessageToUserWithSuc } from '../../../services/pushService'; 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) { export default function (app: Application) {
new HandlerService(app, {}); new HandlerService(app, {});
@@ -68,10 +71,29 @@ export class GVGBattleHandler {
let updateParam: SaveTeamUpdateParam = { index, head, spine, frame, configId, groupId, serverType } let updateParam: SaveTeamUpdateParam = { index, head, spine, frame, configId, groupId, serverType }
if(lineup) { if(lineup) {
let attrByHid = await getHeroesAttributes(roleId);
let { isOK, heroes } = await checkBattleHeroesByHid(roleId, lineup.map(cur => cur.actorId)); let { isOK, heroes } = await checkBattleHeroesByHid(roleId, lineup.map(cur => cur.actorId));
if(!isOK) return resResult(STATUS.BATTLE_HERO_NOT_FOUND); 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); let lineupCe = heroes.reduce((pre, cur) => pre + cur.ce, 0);
updateParam.lineup = lineup; updateParam.lineup = newLineup;
updateParam.lineupCe = lineupCe; updateParam.lineupCe = lineupCe;
} }
+3 -3
View File
@@ -2,8 +2,8 @@
import BaseModel from "./BaseModel"; import BaseModel from "./BaseModel";
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { genCode } from "../pubUtils/util"; import { genCode } from "../pubUtils/util";
import { LineupHero } from './../domain/roleField/hero';
import { GVGTeamType } from "./GVGTeam"; import { GVGTeamType } from "./GVGTeam";
import { GVGHeroInfo } from "../domain/dbGeneral";
class TeamInfo { class TeamInfo {
@prop({ required: true }) @prop({ required: true })
@@ -42,8 +42,8 @@ class TeamInfo {
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
durability: number; // 耐久 durability: number; // 耐久
@prop({ required: true, type: () => LineupHero, _id: false }) @prop({ required: true, type: () => GVGHeroInfo, _id: false })
lineup: LineupHero[] lineup: GVGHeroInfo[]
} }
@index({ battleCode: 1 }) @index({ battleCode: 1 })
+3 -3
View File
@@ -2,11 +2,11 @@
import BaseModel from "./BaseModel"; import BaseModel from "./BaseModel";
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { genCode } from "../pubUtils/util"; import { genCode } from "../pubUtils/util";
import { LineupHero } from './../domain/roleField/hero';
import { nowSeconds } from "../pubUtils/timeUtil"; import { nowSeconds } from "../pubUtils/timeUtil";
import { GVG } from "../pubUtils/dicParam"; import { GVG } from "../pubUtils/dicParam";
import { DicGVGAreaPoint } from "../pubUtils/dictionary/DicGVGAreaPoint"; import { DicGVGAreaPoint } from "../pubUtils/dictionary/DicGVGAreaPoint";
import { InitTeamParam, SaveTeamUpdateParam } from "../domain/gvgField/gvgDb"; import { InitTeamParam, SaveTeamUpdateParam } from "../domain/gvgField/gvgDb";
import { GVGHeroInfo } from "../domain/dbGeneral";
@index({ roleId: 1, index: 1 }) @index({ roleId: 1, index: 1 })
@index({ teamCode: 1 }) @index({ teamCode: 1 })
@@ -94,8 +94,8 @@ export default class GVGTeam extends BaseModel {
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
leagueScore: number; // 积分 leagueScore: number; // 积分
@prop({ required: true, type: () => LineupHero, _id: false }) @prop({ required: true, type: () => GVGHeroInfo, _id: false })
lineup: LineupHero[]; lineup: GVGHeroInfo[];
@prop({ required: true }) @prop({ required: true })
lineupCe: number; lineupCe: number;
+12
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 { export class Enemies extends PvpHeroInfo {
@prop({ required: true }) @prop({ required: true })
+8 -2
View File
@@ -8,6 +8,7 @@ import { gameData } from "../../pubUtils/data";
import { EXTERIOR, GVG } from "../../pubUtils/dicParam"; import { EXTERIOR, GVG } from "../../pubUtils/dicParam";
import { DicGVGVestige } from "../../pubUtils/dictionary/DicGVGVestige"; import { DicGVGVestige } from "../../pubUtils/dictionary/DicGVGVestige";
import { DicWarJson } from "../../pubUtils/dictionary/DicWarJson"; import { DicWarJson } from "../../pubUtils/dictionary/DicWarJson";
import { GVGHeroInfo, PvpHeroInfo } from "../dbGeneral";
import { LineupHero } from "../roleField/hero"; import { LineupHero } from "../roleField/hero";
export class OppPlayerHeroInfo { export class OppPlayerHeroInfo {
@@ -257,11 +258,16 @@ export interface SaveTeamParam {
lineup?: LineupHero[]; lineup?: LineupHero[];
} }
export interface SaveTeamUpdateParam extends SaveTeamParam { export interface SaveTeamUpdateParam {
lineupCe?: number; index: number;
head: number;
frame: number;
spine: number;
configId: number; configId: number;
groupId: number; groupId: number;
serverType: number; serverType: number;
lineup?: GVGHeroInfo[];
lineupCe?: number;
} }
export interface InitTeamParam { export interface InitTeamParam {
+1 -1
View File
@@ -706,7 +706,7 @@ export class MyTeamInfo {
this.index = team.index; this.index = team.index;
this.head = team.head; this.head = team.head;
this.frame = team.spine; 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.durability = team.durability;
this.maxDurability = team.maxDurability; this.maxDurability = team.maxDurability;
this.restartTime = team.restartTime; this.restartTime = team.restartTime;