寻宝:增加每个武将伤害的统计

This commit is contained in:
luying
2022-05-27 18:38:08 +08:00
parent 3737c888fd
commit 393e93224e
5 changed files with 28 additions and 8 deletions

View File

@@ -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]));

View File

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

View File

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

View File

@@ -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 {

View File

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