diff --git a/game-server/app/servers/role/handler/equipHandler.ts b/game-server/app/servers/role/handler/equipHandler.ts index 3835c7579..d347c380f 100644 --- a/game-server/app/servers/role/handler/equipHandler.ts +++ b/game-server/app/servers/role/handler/equipHandler.ts @@ -4,16 +4,16 @@ import { ItemInter } from "../../../pubUtils/interface"; import { resResult, parseGoodStr, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util"; import { addItems, handleCost, decreaseItems } from "../../../services/rewardService"; -import Equip, { EquipModel, EquipType } from "../../../db/Equip"; +import { EquipModel, EquipType } from "../../../db/Equip"; import { HeroModel, EPlace } from "../../../db/Hero"; import Role from "../../../db/Role"; import { calPlayerCeAndSave } from "../../../services/playerCeService"; -import { getHeroJob, getGoodById, gameData, getHeroEquipByClassId } from "../../../pubUtils/data"; +import { getGoodById, gameData } from "../../../pubUtils/data"; import { EQUIP } from "../../../pubUtils/dicParam"; import { ITID, SPEICAL_ITEM, QUALITY_TYPE, equipTypeToSortAttr, IT_TYPE } from "../../../consts/constModules/itemConst"; -import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService"; +import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe, checkEquipCanPut } from "../../../services/equipService"; -import { indexOf, findIndex } from 'underscore'; +import { 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"; @@ -511,10 +511,7 @@ export class EquipHandler { return resResult(STATUS.WRONG_PARMS); if (goodInfo.lvLimited > hero.lv) return resResult(STATUS.EQUIP_LEVEL_LIMIT); - let { jobid } = gameData.hero.get(hid); - let { job_class } = getHeroJob(jobid); - let { classId } = getHeroEquipByClassId(goodInfo.itid); - if (indexOf(classId, job_class) < 0) + if(checkEquipCanPut(hid, equip.id)) return resResult(STATUS.EQUIP_NOT_EQUIPED_HERO); let index = findIndex(hero.ePlace, { id }); if (index < 0) @@ -560,13 +557,11 @@ export class EquipHandler { 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 { goodsAbility, lvLimited } = 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 } + return { id, quality, ce, equip, goodsAbility, lvLimited, ePlaceId } }); let { ePlace, lv } = hero; @@ -575,8 +570,8 @@ export class EquipHandler { if (!curEPlace.equip) { // 未装备 let sortAttrId = equipTypeToSortAttr.get(curEPlace.id); let sortedAndSuitEquips = sortEquips.filter(equipInfos => { // 筛选可穿的 - let { lvLimited, classId, ePlaceId } = equipInfos; - return lv >= lvLimited && classId.indexOf(dicJob.job_class) != -1 && curEPlace.id == ePlaceId; + let { id, lvLimited, ePlaceId } = equipInfos; + return lv >= lvLimited && checkEquipCanPut(hid, id) && curEPlace.id == ePlaceId; }).sort((a, b) => { // 排序按:战力 => 根据位置看个别属性 => 品质 if (b.ce - a.ce != 0) return b.ce - a.ce; let abilityA = a.goodsAbility.get(sortAttrId) || 0; diff --git a/game-server/app/servers/role/handler/itemHandler.ts b/game-server/app/servers/role/handler/itemHandler.ts index c2434aa64..b66129c5e 100644 --- a/game-server/app/servers/role/handler/itemHandler.ts +++ b/game-server/app/servers/role/handler/itemHandler.ts @@ -8,7 +8,7 @@ import Equip, { EquipModel, EquipType } from "../../../db/Equip"; import { HeroModel, EPlace } from "../../../db/Hero"; import Role, { RoleModel } from "../../../db/Role"; import { calPlayerCeAndSave } from "../../../services/playerCeService"; -import { getHeroJob, getGoodById, gameData, getHeroEquipByClassId } from "../../../pubUtils/data"; +import { gameData } from "../../../pubUtils/data"; import { EQUIP } from "../../../pubUtils/dicParam"; import { ITID, SPEICAL_ITEM, QUALITY_TYPE } from "../../../consts/constModules/itemConst"; import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService"; diff --git a/game-server/app/services/equipService.ts b/game-server/app/services/equipService.ts index 97961d4d6..b6ce70bb6 100644 --- a/game-server/app/services/equipService.ts +++ b/game-server/app/services/equipService.ts @@ -1,7 +1,7 @@ import { mergeSameGoods, deepCopy } from '../pubUtils/util'; import { EquipModel } from "../db/Equip"; import { HeroModel, EPlace, HeroType } from "../db/Hero"; -import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../pubUtils/data"; +import { getHeroJob, getGoodById, gameData, getJewelById } from "../pubUtils/data"; import { calPlayerCeAndSave } from "./playerCeService"; import { HERO_SYSTEM_TYPE, TASK_TYPE } from "../consts"; import { EquipType } from "../db/Equip"; @@ -69,10 +69,7 @@ export async function changeEquip(serverId: number, roleId: string, sid: string, let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力 return res; } - let { jobid } = gameData.hero.get(hid); - let { job_class } = getHeroJob(jobid); - let { classId } = getHeroEquipByClassId(goodInfo.itid); - if (indexOf(classId, job_class) < 0) { + if (checkEquipCanPut(hid, equipA.id)) { let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力 return res; } @@ -132,4 +129,13 @@ export async function dressEquip(serverId: number, roleId: string, sid: string, await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.EQUIP_SUM, 1) return { seqId: equip.seqId, hid: hero.hid, id: equip.id, ePlaceId: equip.ePlaceId }; +} + +export function checkEquipCanPut(hid: number, id: number) { + let dicGood = gameData.goods.get(id); + let dicHero = gameData.hero.get(hid); + let dicJob = gameData.job.get(dicHero.jobid); + if(dicGood.jobLimited != 0 && dicGood.jobLimited != dicJob.job_class) return false; + if(dicGood.charLimited != 0 && dicGood.charLimited != hid) return false; + return true } \ No newline at end of file diff --git a/shared/pubUtils/dictionary/DicGoods.ts b/shared/pubUtils/dictionary/DicGoods.ts index 050eb6884..1fa6c65e9 100644 --- a/shared/pubUtils/dictionary/DicGoods.ts +++ b/shared/pubUtils/dictionary/DicGoods.ts @@ -17,6 +17,10 @@ export interface DicGoods { readonly name: string; // 等级限制 readonly lvLimited: number; + // 职业限制 + readonly jobLimited: number; + // 武将限制 + readonly charLimited: number; // 合成装备需要的碎片数 readonly pieces: number; // 对应的碎片id @@ -97,7 +101,9 @@ const DicGoodsKeys: KeysEnum = { condition: true, timeLimit: true, image_id: true, - gift: true + gift: true, + jobLimited: true, + charLimited: true } export const dicJewel = new Map(); export const dicGoods = new Map();