diff --git a/game-server/app/servers/battle/handler/comBattleHandler.ts b/game-server/app/servers/battle/handler/comBattleHandler.ts index 120a1d906..a8394105c 100644 --- a/game-server/app/servers/battle/handler/comBattleHandler.ts +++ b/game-server/app/servers/battle/handler/comBattleHandler.ts @@ -447,7 +447,7 @@ export class ComBattleHandler { * @returns * @memberof ComBattleHandler */ - async action(msg: {teamCode: string, bossHurts: Array<{dataId: number, hurtHp: number}>, killed: number[], curRnd: number}, session: BackendSession) { + async action(msg: {teamCode: string, bossHurts: Array<{hid: number, dataId: number, hurtHp: number}>, killed: number[], curRnd: number}, session: BackendSession) { let roleId = session.get('roleId'); let { teamCode, killed, bossHurts, curRnd } = msg; let teamStatus = this.teamMap.get(teamCode); @@ -461,6 +461,7 @@ export class ComBattleHandler { } } // 重置总血量,计算真实伤害 + const roleSt = teamStatus.findMemberByRoleId(roleId); let actBossHurts: {dataId: number, hurtHp: number}[] = []; let totalHurtHp = 0; teamStatus.bossHpArr.forEach(boss => { @@ -476,11 +477,13 @@ export class ComBattleHandler { totalHurtHp = cal.add(totalHurtHp, boss.curHp); boss.curHp = 0; } + if(bh.hid) { + roleSt.addHeroDamage(bh.hid, deltaHp); + } } } }); // 更新玩家武将阵亡情况,计算玩家总伤害 - const roleSt = teamStatus.roleStatus.find(st => st.roleId === roleId); roleSt.totalDmg = cal.add(roleSt.totalDmg, totalHurtHp); if (killed && killed.length) { roleSt.killed = Array.from(new Set([...roleSt.killed, ...killed])); diff --git a/game-server/app/services/battleService.ts b/game-server/app/services/battleService.ts index 8ab9d9599..2d13a46f9 100644 --- a/game-server/app/services/battleService.ts +++ b/game-server/app/services/battleService.ts @@ -570,14 +570,14 @@ export function getRandRobot(cnt = 1, withAttr = false) { for (let hero of warInfo) { if (hero && hero.relation === 2 && hero.actorId) { let dicHero = gameData.hero.get(hero.actorId); - heroes.push({ - id: hero.actorId, + heroes.push(new ComRoleStatusHero({ + hid: hero.actorId, skinId: hero.actorId, star: hero.star||dicHero.initialStars, colorStar: 0, lv: hero.lv, quality: dicHero.quality - }); + })); } } robots.push(heroes); diff --git a/game-server/app/services/comBattleService.ts b/game-server/app/services/comBattleService.ts index 2c6b6e18b..b411f905e 100644 --- a/game-server/app/services/comBattleService.ts +++ b/game-server/app/services/comBattleService.ts @@ -7,7 +7,7 @@ import { EquipPrintDropType, EquipPrintDropModel } from './../db/EquipPrintDrop' import { STATUS } from './../consts/statusCode'; import { COM_TEAM_STATUS, FRIEND_DROP_TYPE, COM_BTL_CONST, FRIEND_DROP_MAX } from './../consts'; import { RoleStatus, ComBattleTeamModel, ComBattleTeamType } from './../db/ComBattleTeam'; -import { getRandEelm, getRandValue, resResult, ratioReward, getRandValueByMinMax, getRandEelmWithWeight, getRobotInfo } from "../pubUtils/util"; +import { getRandEelm, getRandValue, resResult, ratioReward, getRandValueByMinMax, getRandEelmWithWeight, getRobotInfo, getRandSingleEelm } from "../pubUtils/util"; import { getRandRobot } from "./battleService"; import { Channel, ChannelService, pinus } from 'pinus'; import { TREASURE, EXTERIOR } from '../pubUtils/dicParam'; @@ -256,15 +256,18 @@ export function updateRobotHurt(teamStatus: MemComBtlTeam, roleSt: RoleStatus) { let eachHurtHp = robotEachHurt(teamStatus.bossHp, teamStatus.bossHpArr.length); let robotTotalHurt = 0; let actBossHurts = []; + let hero = getRandSingleEelm(roleSt.heroes); for (let boss of teamStatus.bossHpArr) { if (boss.curHp === 0) continue; if (boss.curHp >= eachHurtHp) { actBossHurts.push({ dataId: boss.dataId, hurtHp: eachHurtHp }); robotTotalHurt += eachHurtHp; boss.curHp -= eachHurtHp; + hero.addDamage(eachHurtHp); } else if (boss.curHp > 0) { // 丢弃溢出的伤害 actBossHurts.push({ dataId: boss.dataId, hurtHp: boss.curHp }); robotTotalHurt += boss.curHp; + hero.addDamage(boss.curHp); boss.curHp = 0; } break; diff --git a/shared/db/ComBattleTeam.ts b/shared/db/ComBattleTeam.ts index 0cf14309d..446bd3a93 100644 --- a/shared/db/ComBattleTeam.ts +++ b/shared/db/ComBattleTeam.ts @@ -2,7 +2,6 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; import { EXTERIOR } from '../pubUtils/dicParam'; import { ItemReward } from '../domain/dbGeneral'; -import { HeroType } from './Hero'; export class ComRoleStatusHero { @prop({ required: true }) @@ -17,7 +16,9 @@ export class ComRoleStatusHero { colorStar: number; @prop({ required: true }) lv: number; - constructor(hero: HeroType) { + @prop({ required: true }) + damage: number = 0; + constructor(hero: { hid: number, skinId: number, quality: number, star: number, colorStar: number, lv: number }) { this.id = hero.hid; this.skinId = hero.skinId; this.quality = hero.quality; @@ -25,6 +26,10 @@ export class ComRoleStatusHero { this.colorStar = hero.colorStar; this.lv = hero.lv; } + + addDamage(damage: number) { + this.damage += damage; + } } export class RoleStatus { @@ -106,6 +111,11 @@ export class RoleStatus { this.frdRatio += frdRatio; } } + + addHeroDamage(hid: number, damage: number) { + let hero = this.heroes.find(cur => cur.id == hid); + if(hero) hero.addDamage(damage); + } } export class BossHp { diff --git a/shared/domain/battleField/ComBattleTeamField.ts b/shared/domain/battleField/ComBattleTeamField.ts index 36e722211..cba0bcf7d 100644 --- a/shared/domain/battleField/ComBattleTeamField.ts +++ b/shared/domain/battleField/ComBattleTeamField.ts @@ -43,4 +43,8 @@ export class MemComBtlTeam extends ComBattleTeam { this.blacklist = []; this.sid = sid; } + + findMemberByRoleId(roleId: string) { + return this.roleStatus.find(cur => cur.roleId == roleId); + } };