diff --git a/game-server/app/servers/role/handler/equipHandler.ts b/game-server/app/servers/role/handler/equipHandler.ts index e468d8a44..1de2fc387 100644 --- a/game-server/app/servers/role/handler/equipHandler.ts +++ b/game-server/app/servers/role/handler/equipHandler.ts @@ -458,27 +458,33 @@ export class EquipHandler { let comJewelMap = {}; let ways = [deepCopy(speConsumes)]; for (let {id, count} of consumes) { - let jewel = getJewelById(id); - if (!jewel) { + let jewelInfo = getJewelById(id); + if (!jewelInfo) { return resResult(STATUS.WRONG_PARMS); } - let copyWays = deepCopy(ways); - ways = []; - count = (count + (comJewelMap[jewel.good_id]||0))/jewel.count; - delete comJewelMap[jewel.good_id]; - let speCount = jewel.specialMaterial.count * count; - for (let id of jewel.specialMaterial.ids) { - for (let way of copyWays) { - let index = _.findIndex(way, {id}); - if (index && way[index].count >= speCount) { - way[index].count = way[index].count - speCount; - ways.push(way); + + count = Math.floor((count + (comJewelMap[jewelInfo.good_id]||0))/jewelInfo.count); + if (count < 1) { + return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); + } + let speCount = jewelInfo.specialMaterial.count * count; + if (jewelInfo.specialMaterial.ids.length) { + let copyWays = deepCopy(ways); + ways = []; + for (let id of jewelInfo.specialMaterial.ids) { + for (let way of copyWays) { + let index = _.findIndex(way, {id}); + if (index && way[index].count >= speCount) { + way[index].count = way[index].count - speCount; + ways.push(way); + } } } + if (!ways.length) + return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); } - if (!ways.length) - return resResult(STATUS.WRONG_PARMS); - comJewelMap[jewel.nextJewelId] = count + (comJewelMap[jewel.nextJewelId]||0); + delete comJewelMap[jewelInfo.good_id]; + comJewelMap[jewelInfo.nextJewelId] = count + (comJewelMap[jewelInfo.nextJewelId]||0); } if (comJewelMap[jewel] != count || Object.keys(comJewelMap).length != 1) return resResult(STATUS.WRONG_PARMS); diff --git a/shared/consts/constModules/itemConst.ts b/shared/consts/constModules/itemConst.ts index f59743497..08a71bace 100644 --- a/shared/consts/constModules/itemConst.ts +++ b/shared/consts/constModules/itemConst.ts @@ -1,6 +1,6 @@ export const IT_TYPE = { BLUEPRT: 28, - JEWEL: 40 + JEWEL: 42 } diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index 9f56c8eac..f8931eb30 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -1,5 +1,5 @@ import { dicHero } from "./dictionary/DicHero"; -import { dicGoods, blueprt, jewels } from "./dictionary/DicGoods"; +import { dicGoods, blueprt, dicJewel } from "./dictionary/DicGoods"; import { dicBlueprtCompose } from "./dictionary/DicBlueprtCompose"; import { dicBlueprtPossibility } from "./dictionary/DicBlueprtPossibility"; import { dicDaily } from "./dictionary/DicDaily"; @@ -67,7 +67,7 @@ export const gameData = { randomEffectPool: dicRandomEffectPool, strengthenCost: dicStrengthenCost, refine: dicRefine, - jewels: jewels, + jewels: dicJewel, dicHeroEquip: dicHeroEquip }; diff --git a/shared/pubUtils/dictionary/DicGoods.ts b/shared/pubUtils/dictionary/DicGoods.ts index 67da4e2a6..544d66490 100644 --- a/shared/pubUtils/dictionary/DicGoods.ts +++ b/shared/pubUtils/dictionary/DicGoods.ts @@ -1,8 +1,9 @@ // 物品表 -import {decodeArrayListStr, readJsonFile, parseReward, parseNumberList, decodeArrayStr} from '../util' +import {decodeArrayListStr, readJsonFile, parseReward, parseNumberList, decodeArrayStr, deepCopy} from '../util' import { FILENAME, IT_TYPE, ABI_TYPE } from '../../consts' import { RewardInter } from '../interface'; const _ = require('lodash'); +const underscore = require('underscore'); export interface SpecialMaterial { readonly ids: number[]; @@ -83,10 +84,9 @@ const DicGoodsKeys: KeysEnum = { count: true, nextJewelId: true, } - +export const dicJewel = new Map(); export const dicGoods = new Map(); export const blueprt = new Map>(); -export const jewels = new Map(); let jewelsMap = {}; arr.forEach(o => { o.goodsAbility = parseAbility(o); @@ -103,20 +103,18 @@ arr.forEach(o => { arr.push(o.good_id); blueprt.set(o.quality, arr); } else if (o.itid == IT_TYPE.JEWEL) { - jewelsMap[o.good_id] = o; + let material = o.composeMaterial[0]; + if (!!material && !!material.id) { + let lastJewel = underscore.findWhere(arr,{good_id:material.id}); + if (!!lastJewel) { + lastJewel.count = material.count; + lastJewel.nextJewelId = o.good_id; + dicJewel.set(lastJewel.good_id, _.pick(lastJewel, Object.keys(DicGoodsKeys))); + } + } } }); -for (let key in jewelsMap) { - let jewel = jewelsMap[key]; - let material = jewel.composeMaterial[0]; - if (!!material && !!material.id) { - let nextJewel = jewelsMap[material.id]; - nextJewel.count = material.count; - nextJewel.nextJewelId = material.id; - jewels.set(jewel.good_id, _.pick(nextJewel, Object.keys(DicGoodsKeys))); - } -} jewelsMap = undefined; arr = undefined;