diff --git a/game-server/app/servers/role/handler/equipHandler.ts b/game-server/app/servers/role/handler/equipHandler.ts index d9a8a3ee5..98e13e3fb 100644 --- a/game-server/app/servers/role/handler/equipHandler.ts +++ b/game-server/app/servers/role/handler/equipHandler.ts @@ -16,7 +16,7 @@ import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerC import { findIndex, pick } from 'underscore'; import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService"; import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkTaskConditionEquipSuitJewelStage, checkActivityTask } from "../../../services/taskService"; -import { Attribute } from "../../../domain/roleField/attribute"; +import { AttributeCal } from "../../../domain/roleField/attribute"; import { QuenchLogParam } from "../../../domain/roleField/equip"; export default function (app: Application) { @@ -622,7 +622,7 @@ export class EquipHandler { let sortEquips = allEquips.map(equip => { let { id, quality, randRange, ePlaceId } = equip; let { goodsAbility, lvLimited } = gameData.goods.get(id); - let attrObj = new Attribute(); + let attrObj = new AttributeCal(); attrObj.setByMap(goodsAbility, HERO_CE_RATIO + randRange); let ce = attrObj.calEquipCe(); return { id, quality, ce, equip, goodsAbility, lvLimited, ePlaceId } diff --git a/game-server/app/services/expeditionService.ts b/game-server/app/services/expeditionService.ts index efd030308..c8c1e6ccf 100644 --- a/game-server/app/services/expeditionService.ts +++ b/game-server/app/services/expeditionService.ts @@ -4,13 +4,14 @@ import Role, { RoleModel, RoleType } from '../db/Role'; import { PvpDefenseModel } from '../db/PvpDefense'; import { shouldRefresh, calculateSumCE } from '../pubUtils/util'; -import { EXPEDITION_CONST, LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS } from '../consts'; +import { EXPEDITION_CONST, LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS, ABI_TYPE } from '../consts'; import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord'; import { HeroType } from '../db/Hero'; import { gameData } from '../pubUtils/data'; import { getPlayerAttribute, getRobotAttribute } from './pvpService'; import { getTimeFunD } from '../pubUtils/timeUtil'; import { ExpeditionRecordModel } from '../db/ExpeditionRecord'; +import { Attribute } from '../domain/roleField/attribute'; /** * 获取远征关卡列表 @@ -104,7 +105,9 @@ export async function findOrCreateEnemies(roleId: string, myCe: number, expediti cur.hp = getHp.hp; cur.ap = getHp.ap; } else { - cur.hp = enemy.attribute.hp; + let attr = new Attribute(); + attr.setByStr(enemy.attribute); + cur.hp = attr.hp; cur.ap = 0; } enemy["cur"] = cur; @@ -149,7 +152,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number, if(h) { let { star, lv, attr: heroAttrs, ce } = h; let dicHero = gameData.hero.get(hero.actorId); - let newAttribute = getPlayerAttribute(heroAttrs, roleAttrs); + let { attribute } = getPlayerAttribute(heroAttrs, roleAttrs); let heroInfo = { actorId: hero.actorId, actorName: dicHero.name, @@ -157,7 +160,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number, seid:'&', star, spine: 0, - attribute: newAttribute, + attribute, lv, ce }; @@ -195,8 +198,7 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number, if(json.relation == 2) { const { attribute } = json; - let newAttribute = getRobotAttribute(attribute, myCe, robotCe, scale); - let ce = newAttribute.ce; + let { attribute: newAttribute, ce } = getRobotAttribute(attribute, myCe, robotCe, scale); enemyObj.enemies.push({...json, attribute: newAttribute, lv, ce}); allCe += ce; } diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index 1ec3d5912..bb8d83228 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -12,7 +12,7 @@ import { PVPConfigModel } from '../db/SystemConfig' import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil'; import { HeroesRecord } from '../db/PvpRecord'; import { HeroModel } from '../db/Hero'; -import { MainAttrNumber, Attribute, CeAttrData, CeAttrDataRole } from '../domain/roleField/attribute'; +import { CeAttrData, CeAttrDataRole, AttributeCal } from '../domain/roleField/attribute'; import { PvpEnemies, PvpHeroInfo, PvpOtherHeroes } from '../domain/dbGeneral'; import { DicWarJson } from '../pubUtils/dictionary/DicWarJson'; import { findWhere, findIndex } from 'underscore'; @@ -238,9 +238,9 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, mapWarJson: DicWarJ let heroInfo = new PvpHeroInfo(); heroInfo.setHeroInfo(dbHero); heroInfo.setOutIndex(h.order); - let attribute = getPlayerAttribute(dbHero.attr, role.attr); + let { attribute, ce } = getPlayerAttribute(dbHero.attr, role.attr); heroInfo.setAttribute(attribute); - let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, attribute.ce); + let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, ce); heroes.push(enemy); } } else { @@ -282,10 +282,10 @@ async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], ro if (!dicHero) continue; let heroInfo = new PvpHeroInfo(); heroInfo.setRobotInfo(h, myLv, dicHero.initialStars, dicHero.quality); - let attribute = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio); - defCe += attribute.ce + let { attribute, ce } = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio); + defCe += ce; heroInfo.setAttribute(attribute); - let enemy = new PvpEnemies(warJson, heroInfo, 0, attribute.ce); + let enemy = new PvpEnemies(warJson, heroInfo, 0, ce); heroes.push(enemy); } } @@ -528,12 +528,11 @@ export async function findPvpDefAllByRoleId(roleId: string) { */ export function getRobotAttribute(attribute: { id: number, val: number }[], ce: number, enemyCe: number, ratio: number) { - let newAttribute = new Attribute(); + let newAttribute = new AttributeCal(); newAttribute.setByWarJson(attribute, Math.sqrt(ce / enemyCe * ratio)); - let attrJson = newAttribute.getReduceAttributes(); - let resultCe = newAttribute.calCelAndReduce(); - attrJson.ce = resultCe; - return attrJson; + let attrArr = newAttribute.getReduceAttributesToString(); + let newCe = newAttribute.calCelAndReduce(); + return { attribute: attrArr, ce: newCe }; } /** @@ -542,12 +541,11 @@ export function getRobotAttribute(attribute: { id: number, val: number }[], ce: * @param globalCeAttr role表中的globalCeAttr */ export function getPlayerAttribute(heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) { - let newAttribute = new Attribute(); + let newAttribute = new AttributeCal(); newAttribute.setByDbData(roleAttrs, heroAttrs); - let attrJson = newAttribute.getReduceAttributes(); - let resultCe = newAttribute.calCelAndReduce(); - attrJson.ce = resultCe; - return attrJson; + let attribute = newAttribute.getReduceAttributesToString(); + let ce = newAttribute.calCelAndReduce(); + return { attribute, ce }; } /** @@ -556,9 +554,9 @@ export function getPlayerAttribute(heroAttrs: CeAttrData[] = [], roleAttrs: CeAt * @param globalCeAttr */ export function getPlayerMainAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAttrDataRole[]) { - let attribute = getPlayerAttribute(heroAttrs, roleAttrs); - let mainAttributes = new MainAttrNumber(attribute); - + let newAttribute = new AttributeCal(); + newAttribute.setByDbData(roleAttrs, heroAttrs); + let mainAttributes = newAttribute.getReduceMainAttributes(); return mainAttributes; } diff --git a/shared/db/ExpeditionWarRecord.ts b/shared/db/ExpeditionWarRecord.ts index 13c9199b3..1662708d4 100644 --- a/shared/db/ExpeditionWarRecord.ts +++ b/shared/db/ExpeditionWarRecord.ts @@ -55,6 +55,7 @@ export default class ExpeditionWarRecord extends BaseModel { public static async saveRecord(expeditionCode: string, expeditionId: number, params: {roleId: string, battleId: number, enemyFrom: number, enemyId: string, enemies: Array, battleStatus: number}, lean = true) { const doc = new ExpeditionWarRecordModel(); const update = Object.assign(doc.toJSON(), params, {expeditionCode, expeditionId}); + console.log('*****', JSON.stringify(update)); const result: ExpeditionWarRecordType = await ExpeditionWarRecordModel.findOneAndUpdate({ expeditionCode, expeditionId }, update, {new: true, upsert: true}).select('expeditionId battleId battleCode battleStatus enemyFrom enemies enemiesCurHpAp ce').lean(lean); return result; } diff --git a/shared/domain/dbGeneral.ts b/shared/domain/dbGeneral.ts index 50390ad62..52d7bfa84 100644 --- a/shared/domain/dbGeneral.ts +++ b/shared/domain/dbGeneral.ts @@ -1,6 +1,5 @@ import { prop, mongoose, Ref } from '@typegoose/typegoose'; import { DicWarJson } from '../pubUtils/dictionary/DicWarJson'; -import { Attribute } from './roleField/attribute'; import Hero, { HeroType } from '../db/Hero'; import { nowSeconds } from '../pubUtils/timeUtil'; @@ -28,7 +27,7 @@ export class PvpHeroInfo { quality?: number = 0; // 品质 @prop({ required: true, _id: false }) - attribute?: Attribute; // 属性 + attribute?: string; // 属性 setHeroInfo(hero: HeroType) { this.actorId = hero.hid; @@ -47,7 +46,7 @@ export class PvpHeroInfo { this.quality = quality; } - setAttribute(attribute: Attribute) { + setAttribute(attribute: string) { this.attribute = attribute; } diff --git a/shared/domain/roleField/attribute.ts b/shared/domain/roleField/attribute.ts index 27eaaa901..7b117c008 100644 --- a/shared/domain/roleField/attribute.ts +++ b/shared/domain/roleField/attribute.ts @@ -1,6 +1,6 @@ import { prop } from '@typegoose/typegoose'; import { HERO_CE_RATIO, getAtrrNameById, CE_CONST, HERO_SUB_ATTR_RATIO, ABI_TYPE_MAIN } from '../../consts'; -import { reduceCe } from '../../pubUtils/util'; +import { decodeArrayListStr, reduceCe } from '../../pubUtils/util'; // hero表内属性基础格式 export class CeAttrData { @@ -34,107 +34,48 @@ export class CeAttrDataRole { } } -// 主属性 -export class MainAttrNumber { - hp: number = 0; - atk: number = 0; - def: number = 0; - mdef: number = 0; - - constructor(attr: Attribute) { - if(attr.hp) this.hp = attr.hp; - if(attr.atk) this.atk = attr.atk; - if(attr.def) this.def = attr.def; - if(attr.mdef) this.mdef = attr.mdef; - } -} - -export class Attribute { - @prop({ required: false }) - hp: number = 0; - @prop({ required: false }) - atk: number = 0; - @prop({ required: false }) - def: number = 0; - @prop({ required: false }) - mdef: number = 0; - @prop({ required: false }) - speed: number = 0; - @prop({ required: false }) - hit: number = 0; - @prop({ required: false }) - cri: number = 0; - @prop({ required: false }) - flee: number = 0; - @prop({ required: false }) - antCri: number = 0; - @prop({ required: false }) - damageIncrease: number = 0; - @prop({ required: false }) - damageDecrease: number = 0; - @prop({ required: false }) - defIngnore: number = 0; - @prop({ required: false }) - bloodSuck: number = 0; - @prop({ required: false }) - ap: number = 0; - @prop({ required: false }) - damageCri: number = 0; - @prop({ required: false }) - pDamageInc: number = 0; - @prop({ required: false }) - mDamageInc: number = 0; - @prop({ required: false }) - pDamageDec: number = 0; - @prop({ required: false }) - mDemageDec: number = 0; - @prop({ required: false }) - strikeBack: number = 0; - @prop({ required: false }) +export class AttributeCal { + attrs: Map = new Map(); ce?: number = 0; - setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) { + public setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) { for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) { - let attrName = getAtrrNameById(id); let heroAttr = heroAttrs.find(heroAttr => heroAttr.id == id); if(heroAttr) { let { fixUp: heroFix, base: heroBase, ratioUp: heroRatio, equipUp: heroEquip } = heroAttr; let value = this.calAttrValue(roleFix, roleRatio, heroBase, heroFix, heroRatio, heroEquip); - if(attrName in this) this[attrName] = value; + this.attrs.set(id, value); } else { let value = this.calAttrValue(roleFix, roleRatio, 0, 0, 0, 0); - if(attrName in this) this[attrName] = value; + this.attrs.set(id, value); } } for(let { id, base: heroBase, fixUp: heroFix, ratioUp: heroRatio, equipUp: heroEquip } of heroAttrs) { - let attrName = getAtrrNameById(id); let roleAttr = roleAttrs.find(roleAttr => roleAttr.id == id); if(!roleAttr) { let value = this.calAttrValue(0, 0, heroBase, heroFix, heroRatio, heroEquip); - if(attrName in this) this[attrName] = value; + this.attrs.set(id, value); } } } - setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) { + public setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) { for(let {id, val} of attributes) { - let attrName = getAtrrNameById(id); if(ABI_TYPE_MAIN.includes(id)) { - if(attrName in this) this[attrName] = Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO); + this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO)); } else { - if(attrName in this) this[attrName] = Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO); + this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO)); } } } - setByMap( attributes: Map, ratio: number = 1 ) { + public setByMap( attributes: Map, ratio: number = 1 ) { for(let [id, val] of attributes) { - let attrName = getAtrrNameById(id); if(ABI_TYPE_MAIN.includes(id)) { - if(attrName in this) this[attrName] = Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO); + this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO)); } else { - if(attrName in this) this[attrName] = Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO); + this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO)); } } } @@ -143,62 +84,57 @@ export class Attribute { return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio ); } - private getRealSubAttr() { - return { - hit: this.hit / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - cri: this.cri / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - flee: this.flee / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - antCri: this.antCri / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - damageIncrease: this.damageIncrease / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - damageDecrease: this.damageDecrease / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - defIngnore: this.defIngnore / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - damageCri: this.damageCri / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - pDamageInc: this.pDamageInc / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - mDamageInc: this.mDamageInc / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - pDamageDec: this.pDamageDec / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - mDemageDec: this.mDemageDec / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, - strikeBack: this.strikeBack / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO + private getRealAttrToMap() { + let newMap = new Map(); + for(let [id, val] of this.attrs) { + if(ABI_TYPE_MAIN.includes(id)) { // 主属性 + newMap.set(id, val / HERO_CE_RATIO / HERO_CE_RATIO); + } else { + newMap.set(id, val / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO); + } } + return newMap; } - private getRealMainAttr() { - return { - hp: this.hp / HERO_CE_RATIO / HERO_CE_RATIO, - atk: this.atk / HERO_CE_RATIO / HERO_CE_RATIO, - def: this.def / HERO_CE_RATIO / HERO_CE_RATIO, - mdef: this.mdef / HERO_CE_RATIO / HERO_CE_RATIO + private getReduceAttrMap() { + let newMap = new Map(); + for(let [id, val] of this.attrs) { + newMap.set(id, reduceCe(val)); } + return newMap } public getReduceAttributes() { - let newAttr = new Attribute(); - newAttr.hp = reduceCe(this.hp); - newAttr.atk = reduceCe(this.atk); - newAttr.def = reduceCe(this.def); - newAttr.mdef = reduceCe(this.mdef); - newAttr.speed = reduceCe(this.speed); - newAttr.hit = reduceCe(this.hit); - newAttr.cri = reduceCe(this.cri); - newAttr.flee = reduceCe(this.flee); - newAttr.antCri = reduceCe(this.antCri); - newAttr.damageIncrease = reduceCe(this.damageIncrease); - newAttr.damageDecrease = reduceCe(this.damageDecrease); - newAttr.defIngnore = reduceCe(this.defIngnore); - newAttr.bloodSuck = reduceCe(this.bloodSuck); - newAttr.ap = reduceCe(this.ap); - newAttr.damageCri = reduceCe(this.damageCri); - newAttr.pDamageInc = reduceCe(this.pDamageInc); - newAttr.mDamageInc = reduceCe(this.mDamageInc); - newAttr.pDamageDec = reduceCe(this.pDamageDec); - newAttr.mDemageDec = reduceCe(this.mDemageDec); - newAttr.strikeBack = reduceCe(this.strikeBack); - return newAttr; + let attrs = new Attribute(); + attrs.setByMap(this.getReduceAttrMap()); + return attrs; + } + + public getReduceAttributesToArr() { + let arr: {id: number, val: number}[] = []; + for(let [id, val] of this.getReduceAttrMap()) { + arr.push({ id, val }); + } + return arr; + } + + public getReduceAttributesToString() { + let arr = this.getReduceAttributesToArr(); + return arr.map(cur => `${cur.id}&${cur.val}`).join('|'); + } + + public getReduceMainAttributes() { + let attribute = this.getReduceAttributes(); + return attribute.getMainAttr(); } // 战力计算 public calCe() { - let { hp, atk, def, mdef } = this.getRealMainAttr(); - let { cri, flee, damageIncrease, damageDecrease, damageCri } = this.getRealSubAttr(); + let attrMap = this.getRealAttrToMap(); + let attrs = new Attribute(); + attrs.setByMap(attrMap); + + let { hp, atk, def, mdef, cri, flee, damageIncrease, damageDecrease, damageCri } = attrs; let putHit = CE_CONST.PUT_HIT / HERO_SUB_ATTR_RATIO; let putAntCri = CE_CONST.PUT_ANT_CRI / HERO_SUB_ATTR_RATIO; @@ -222,11 +158,66 @@ export class Attribute { // 计算未装备的装备的简易战力公式 public calEquipCe() { - let { hp, atk, def, mdef } = this.getRealMainAttr(); + let attrMap = this.getRealAttrToMap(); + let attrs = new Attribute(); + attrs.setByMap(attrMap); + let { hp, atk, def, mdef } = attrs; return hp * 1 + atk * 3 + def * 2 + mdef * 2; } public calCelAndReduce() { return Math.floor(this.calCe() / HERO_CE_RATIO / HERO_CE_RATIO); } +} + +export class Attribute { + hp: number = 0; + atk: number = 0; + def: number = 0; + mdef: number = 0; + speed: number = 0; + hit: number = 0; + cri: number = 0; + flee: number = 0; + antCri: number = 0; + damageIncrease: number = 0; + damageDecrease: number = 0; + defIngnore: number = 0; + bloodSuck: number = 0; + ap: number = 0; + damageCri: number = 0; + physicaldamageInc: number = 0; + magicdamageInc: number = 0; + physicaldamageDec: number = 0; + magicdamageDec: number = 0; + treatmentInc: number = 0; + treatmentDec: number = 0; + acceptTreatmentInc: number = 0; + acceptTreatmentDec: number = 0; + bloodRebound: number = 0; + strikeBack: number = 0; + + setByMap( attributes: Map ) { + for(let [id, val] of attributes) { + let attrName = getAtrrNameById(id); + if(attrName in this) this[attrName] = val; + } + } + + setByStr(str: string) { // id&val|... + let arr = decodeArrayListStr(str); + for(let [id, val] of arr) { + let attrName = getAtrrNameById(parseInt(id)); + if(attrName in this) this[attrName] = parseInt(val); + } + } + + getMainAttr() { + return { + hp: this.hp, + atk: this.atk, + def: this.def, + mdef: this.mdef + } + } } \ No newline at end of file diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index 08e80faf8..0d9b3dc45 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -57,7 +57,7 @@ import { dicArmyBossRank, loadArmyBossRank } from './dictionary/DicArmyBossRank' import { dicArmyDonate, loadArmyDonate } from './dictionary/DicArmyDonateBoxReward'; import { dicRoleFriend, DicRoleFriend, loadRoleFriend } from "./dictionary/DicRoleFriend"; import { dicRoleFriendLv, loadRoleFriendLv } from "./dictionary/DicRoleFriendLv"; -import { Attribute } from "../domain/roleField/attribute"; +import { AttributeCal } from "../domain/roleField/attribute"; import { dicGuildActivity, DicGuildActivity, loadGuildActivity } from './dictionary/DicGuildActivity'; import { dicGateActivityPoint, loadGateActivityPoint } from './dictionary/DicGateActivityPoint'; import { dicGuildAuction, loadGuildAuction } from './dictionary/DicGuildAuction'; @@ -298,7 +298,7 @@ export function getBossHpByWarId(warId: number) { warInfo.forEach(hero => { let { attribute, dataId, relation, actorId } = hero; if (relation === 2) { - let newAttr = new Attribute(); + let newAttr = new AttributeCal(); newAttr.setByWarJson(attribute, 1); let attrJson = newAttr.getReduceAttributes(); diff --git a/shared/pubUtils/interface.ts b/shared/pubUtils/interface.ts index bd6bda348..6202f0a97 100644 --- a/shared/pubUtils/interface.ts +++ b/shared/pubUtils/interface.ts @@ -1,7 +1,5 @@ // 一些通用的interface定义 -import { Attribute } from "../domain/roleField/attribute"; - export interface RewardInter { id: number; count: number; @@ -45,27 +43,6 @@ export interface oppPlayersInter { rankLv: number; } -export interface oppHeroesDefenseInter { - actorId: number; // 武将id - actorName: string; // 武将名 - dataId: number; // 出兵表唯一id - relation: number; // 地方还是我方 - direction: number; // 方向 - outIndex: number; // 玩家设置的出场顺序,即order字段 - x: number; // 战场x坐标 - y: number; // 战场y坐标 - var: number; // 变量 - lv: number; // 等级 - hide: number; // 是否隐藏 - initial_ai: number; // ai类型 - attribute: Attribute; - star: number; // 星级 - skill: string | number; // 技能 - seid: string; // 技能 - spine: string | number; // 动画 - -} - export interface pvpEndParamInter { hid: number; damage: number; diff --git a/shared/pubUtils/playerCe.ts b/shared/pubUtils/playerCe.ts index d865f587b..41c6a4308 100644 --- a/shared/pubUtils/playerCe.ts +++ b/shared/pubUtils/playerCe.ts @@ -7,7 +7,7 @@ import { HERO_SYSTEM_TYPE, ABI_TYPE, HERO_CE_RATIO, HERO_SUB_ATTR_RATIO, LINEUP_ import { cal, deepCopy, getAllAttrStage, reduceCe } from './util'; import { HeroModel, HeroType, HeroUpdate } from '../db/Hero'; import { RoleModel, RoleType, RoleUpdate } from '../db/Role'; -import { CeAttrData, CeAttrDataRole, Attribute } from '../domain/roleField/attribute'; +import { CeAttrData, CeAttrDataRole, AttributeCal } from '../domain/roleField/attribute'; import { ABI_STAGE, SEID_TYPE } from '../consts'; import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById, getSchoolRateByStar, getScollByStar, getTeraph, getDicSuitByTypeAndLv } from './data'; import { DicSe } from './dictionary/DicSe'; @@ -29,7 +29,7 @@ export async function calPlayerCeAndSave(type: number, roleId: string, originHer let heroAttrs = calPlayerCe(originHero, update, type, args); // 根据操作计算attr的增加 - let newAttr = new Attribute(); + let newAttr = new AttributeCal(); newAttr.setByDbData(roleAttrs, heroAttrs); let heroCe = newAttr.calCe(); // 计算最终战力 let incCe = heroCe - originHero.ce; @@ -70,7 +70,7 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU let allIncCe = 0; for (let hero of heros) { let { attr: heroAttrs } = hero; - let newAttr = new Attribute(); + let newAttr = new AttributeCal(); newAttr.setByDbData(roleAttrs, heroAttrs); let heroCe = newAttr.calCe(); // 计算最终战力