diff --git a/game-server/app/servers/role/handler/equipHandler.ts b/game-server/app/servers/role/handler/equipHandler.ts index 90d592032..75dd62bc7 100644 --- a/game-server/app/servers/role/handler/equipHandler.ts +++ b/game-server/app/servers/role/handler/equipHandler.ts @@ -1,5 +1,5 @@ import { Application, BackendSession } from "pinus"; -import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE } from "../../../consts"; +import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE, HERO_CE_RATIO } from "../../../consts"; import { ItemInter } from "../../../pubUtils/interface"; import { resResult, parseGoodStr, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util"; @@ -10,12 +10,13 @@ import Role from "../../../db/Role"; import { calPlayerCeAndSave } from "../../../services/playerCeService"; import { getHeroJob, getGoodById, gameData, getHeroEquipByClassId } from "../../../pubUtils/data"; import { EQUIP } from "../../../pubUtils/dicParam"; -import { ITID, SPEICAL_ITEM, QUALITY_TYPE } from "../../../consts/constModules/itemConst"; +import { ITID, SPEICAL_ITEM, QUALITY_TYPE, equipTypeToSortAttr } from "../../../consts/constModules/itemConst"; import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService"; import { indexOf, findIndex } 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"; export default function (app: Application) { return new EquipHandler(app); @@ -528,6 +529,66 @@ export class EquipHandler { return resResult(STATUS.SUCCESS, { curEquips: curEquips }); } + // 一次性装备上 + public async putOnOnce(msg: { hid: number }, session: BackendSession) { + let { hid } = msg; + let roleId: string = session.get('roleId'); + const serverId = session.get('serverId'); + let sid: string = session.get('sid'); + let funcs: number[] = session.get('funcs'); + let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId); + if (!hero) return resResult(STATUS.HERO_NOT_FIND); + let dicHero = gameData.hero.get(hid); + if(!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND); + let dicJob = gameData.job.get(dicHero.jobid); + + + let allEquips = await EquipModel.findNotWearEquips(roleId); + let sortEquips = allEquips.map(equip => { + let { id, quality, randRange, ePlaceId } = equip; + let { goodsAbility, lvLimited, itid } = gameData.goods.get(id); + let attrObj = new Attribute(); + attrObj.setByMap(goodsAbility, HERO_CE_RATIO + randRange); + let ce = attrObj.calEquipCe(); + let { classId } = getHeroEquipByClassId(itid); + + return { id, quality, ce, equip, goodsAbility, lvLimited, classId, ePlaceId } + }); + let { ePlace, lv } = hero; + + let curEquips: Array<{ seqId: number, hid: number }> = []; + for(let curEPlace of ePlace) { + if(!curEPlace.equip) { // 未装备 + let sortAttrId = equipTypeToSortAttr.get(curEPlace.id); + let sortedAndSuitEquips = sortEquips.filter(equipInfos => { // 筛选可穿的 + let { lvLimited, classId, ePlaceId } = equipInfos; + return lvLimited >= lv && classId.indexOf(dicJob.job_class) != -1 && curEPlace.id == ePlaceId; + }).sort((a, b) => { // 排序按:战力 => 根据位置看个别属性 => 品质 + if(b.ce - a.ce != 0) return b.ce - a.ce; + let abilityA = a.goodsAbility.get(sortAttrId)||0; + let abilityB = b.goodsAbility.get(sortAttrId)||0; + if( abilityA - abilityB != 0) return abilityB - abilityA; + return b.quality - a.quality; + }); + + if(sortedAndSuitEquips.length > 0) { + let { equip } = sortedAndSuitEquips.shift(); + let curEquip = await dressEquip(serverId, roleId, sid, hero,equip, funcs); + if(!!curEquip) curEquips.push(curEquip); + } + + } + } + + //任务 + //英雄满装备且都镶嵌相同阶数的宝石 + let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero) + if (isTask) { + await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel }) + } + return resResult(STATUS.SUCCESS, { curEquips }); + } + //装备打孔 public async digHole(msg: { eid: number, id: number }, session: BackendSession) { let { eid, id } = msg; diff --git a/game-server/app/services/equipService.ts b/game-server/app/services/equipService.ts index be4dc6f5d..ca53dc0e3 100644 --- a/game-server/app/services/equipService.ts +++ b/game-server/app/services/equipService.ts @@ -109,7 +109,7 @@ export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, he // 任务 await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, -1, true, {}); await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [-1]); - return { seqId: equip.seqId, hid: 0 }; + return { seqId: equip.seqId, hid: 0, id: equip.id, ePlaceId: equip.ePlaceId }; } /** * 穿戴装备并重算战力 @@ -131,5 +131,5 @@ export async function dressEquip(serverId: number, roleId: string, sid: string, await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.EQUIP_QUALITY, 1, { quality: equip.quality }) await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.EQUIP_SUM, 1) - return { seqId: equip.seqId, hid: hero.hid }; + return { seqId: equip.seqId, hid: hero.hid, id: equip.id, ePlaceId: equip.ePlaceId }; } \ No newline at end of file diff --git a/game-server/config/clientProtos.ts b/game-server/config/clientProtos.ts index 138f0617a..47170c955 100644 --- a/game-server/config/clientProtos.ts +++ b/game-server/config/clientProtos.ts @@ -103,16 +103,16 @@ module.exports = { "required uInt32 type": 2, "repeated Material material": 3 }, - "role.heroHandler.starUp": { - "required uInt32 hid": 1, - "required uInt32 star": 2, - "required uInt32 starStage": 3 - }, - "role.heroHandler.wakeUp": { - "required uInt32 hid": 1, - "required uInt32 colorStar": 2, - "required uInt32 colorStarStage": 3 - }, + // "role.heroHandler.starUp": { + // "required uInt32 hid": 1, + // "required uInt32 star": 2, + // "required uInt32 starStage": 3 + // }, + // "role.heroHandler.wakeUp": { + // "required uInt32 hid": 1, + // "required uInt32 colorStar": 2, + // "required uInt32 colorStarStage": 3 + // }, "role.heroHandler.qualityUp": { "required uInt32 hid": 1, "required uInt32 quality": 2 diff --git a/shared/consts/constModules/abilityConst.ts b/shared/consts/constModules/abilityConst.ts index aa1686ab3..f3bb61476 100644 --- a/shared/consts/constModules/abilityConst.ts +++ b/shared/consts/constModules/abilityConst.ts @@ -48,7 +48,7 @@ export enum ABI_TYPE{ ABI_MDAMAGE_INC = 20, /**物伤减免 */ ABI_PDAMAGE_DEC = 21, - /**物伤减免 */ + /**法伤减免 */ ABI_MDAMAGE_DEC = 22, /**反击伤害 */ ABI_STRIKE_BACK = 23, @@ -117,8 +117,13 @@ export const HERO_ATTR = { 14: "damageDecrease", // 伤害减免等级 15: "defIngnore", // 忽视防御等级 16: "bloodSuck", // 吸血等级 - 17: "damageCri", // 暴击伤害 - 18: "ap" // 暴击伤害 + 17: "ap", // 怒气 + 18: "damageCri", // 暴击伤害 + 19: "pdamageInc", // 物伤加深 + 20: "mdamageInc", // 法伤加深 + 21: "pdamageDec", // 物伤减免 + 22: "mdamageDec", // 法伤减免 + 23: "strikeBack", // 反击伤害 }; export const ABI_TYPE_TO_STAGE = new Map([ diff --git a/shared/consts/constModules/itemConst.ts b/shared/consts/constModules/itemConst.ts index b459b1b8b..6297127d0 100644 --- a/shared/consts/constModules/itemConst.ts +++ b/shared/consts/constModules/itemConst.ts @@ -1,3 +1,5 @@ +import { ABI_TYPE } from "./abilityConst"; + export const IT_TYPE = { BLUEPRT: 28, EQUIP_PIECE: 40, @@ -67,6 +69,15 @@ export enum EQUIP_TYPE { END = 6 } +export const equipTypeToSortAttr = new Map([ + [ EQUIP_TYPE.WEAPON, ABI_TYPE.ABI_ATK ], + [ EQUIP_TYPE.CLOTHES, ABI_TYPE.ABI_HP ], + [ EQUIP_TYPE.SHOES, ABI_TYPE.ABI_ATK ], + [ EQUIP_TYPE.CAP, ABI_TYPE.ABI_HP ], + [ EQUIP_TYPE.ACCESSORY, ABI_TYPE.ABI_DEF ], + [ EQUIP_TYPE.BOOK, ABI_TYPE.ABI_MDEF ] +]); + export enum JEWEL_TYPE { WEAPON = 42, // 神兵(武器) CLOTHES = 43, // 宝甲(上装) diff --git a/shared/db/Equip.ts b/shared/db/Equip.ts index 1d8dfc256..fd73234a9 100644 --- a/shared/db/Equip.ts +++ b/shared/db/Equip.ts @@ -99,6 +99,12 @@ export default class Equip extends BaseModel { return equip; } + + public static async findNotWearEquips(roleId: string) { + const equips: EquipType[] = await EquipModel.find({ roleId, hid: 0 }).lean(); + return equips; + } + public static async deleteAccount(roleId: string) { let result = await EquipModel.deleteMany({ roleId }); return result; diff --git a/shared/domain/roleField/attribute.ts b/shared/domain/roleField/attribute.ts index ce3e924cf..27eaaa901 100644 --- a/shared/domain/roleField/attribute.ts +++ b/shared/domain/roleField/attribute.ts @@ -128,6 +128,17 @@ export class Attribute { } } + 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); + } else { + if(attrName in this) this[attrName] = Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO); + } + } + } + private calAttrValue(roleFix: number = 0, roleRatio: number = 0, heroBase: number = 0, heroFix: number = 0, heroRatio: number = 0, heroEquip: number = 0) { return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio ); } @@ -209,6 +220,12 @@ export class Attribute { return ce > 0? ce: 1; } + // 计算未装备的装备的简易战力公式 + public calEquipCe() { + let { hp, atk, def, mdef } = this.getRealMainAttr(); + return hp * 1 + atk * 3 + def * 2 + mdef * 2; + } + public calCelAndReduce() { return Math.floor(this.calCe() / HERO_CE_RATIO / HERO_CE_RATIO); }