diff --git a/game-server/app/servers/guild/handler/gvgBattleHandler.ts b/game-server/app/servers/guild/handler/gvgBattleHandler.ts index 380077928..5e18d2641 100644 --- a/game-server/app/servers/guild/handler/gvgBattleHandler.ts +++ b/game-server/app/servers/guild/handler/gvgBattleHandler.ts @@ -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; } diff --git a/shared/db/GVGBattleRec.ts b/shared/db/GVGBattleRec.ts index 95ac7868d..67c363b02 100644 --- a/shared/db/GVGBattleRec.ts +++ b/shared/db/GVGBattleRec.ts @@ -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 }) diff --git a/shared/db/GVGTeam.ts b/shared/db/GVGTeam.ts index c99491648..d6fe0e813 100644 --- a/shared/db/GVGTeam.ts +++ b/shared/db/GVGTeam.ts @@ -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; diff --git a/shared/domain/dbGeneral.ts b/shared/domain/dbGeneral.ts index b19adc99a..2c3f1135d 100644 --- a/shared/domain/dbGeneral.ts +++ b/shared/domain/dbGeneral.ts @@ -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 }) diff --git a/shared/domain/gvgField/gvgDb.ts b/shared/domain/gvgField/gvgDb.ts index 932836934..9bf1cac60 100644 --- a/shared/domain/gvgField/gvgDb.ts +++ b/shared/domain/gvgField/gvgDb.ts @@ -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 { diff --git a/shared/domain/gvgField/returnData.ts b/shared/domain/gvgField/returnData.ts index f73ad5eb8..6792f50ef 100644 --- a/shared/domain/gvgField/returnData.ts +++ b/shared/domain/gvgField/returnData.ts @@ -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;