装备:分解装备获得奖励合起来

This commit is contained in:
luying
2021-08-09 16:12:47 +08:00
parent e045c304ac
commit fbe9e08aa1
5 changed files with 21 additions and 18 deletions
@@ -3,7 +3,7 @@ import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SY
import { ItemInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr } from "../../../pubUtils/util";
import { addItems, handleCost, decreaseItems } from "../../../services/rewardService";
import { addItems, handleCost, decreaseItems, combineItems } from "../../../services/rewardService";
import { EquipModel, EquipType } from "../../../db/Equip";
import { HeroModel, EPlace } from "../../../db/Hero";
import Role from "../../../db/Role";
@@ -59,7 +59,7 @@ export class EquipHandler {
cost = cost.concat(targetGood.composeMaterial);
let specialMaterial = targetGood.specialMaterial;
let costCount = 0;
let equips = await EquipModel.getEquips(originalEquip);
let equips = await EquipModel.getEquips(roleId, originalEquip);
for (let equip of equips) {
let { id, seqId, holes } = equip;
if (specialMaterial.ids.includes(id)) {
@@ -532,7 +532,7 @@ export class EquipHandler {
if(originalEquip.length > BAG.BAG_RESOLVE_UPLIMITED) {
return resResult(STATUS.EQUIP_DECOMPOSE_IS_UPLIMIT);
}
let equips = await EquipModel.getEquips(originalEquip);
let equips = await EquipModel.getEquips(roleId, originalEquip);
if (equips.length < originalEquip.length)
return resResult(STATUS.EQUIP_NOT_FIND);
let goods: Array<{ id: number, count: number }> = [];
@@ -547,7 +547,9 @@ export class EquipHandler {
let holes = equip.holes || [];
for (let { jewel } of holes) {
jewels.push({ id: jewel, count: 1 });
if(jewel) {
jewels.push({ id: jewel, count: 1 });
}
}
goods = goods.concat(goodInfo.decomposeItem);
cost.push({ seqId: equip.seqId, id: equip.id, count: 1 });
@@ -555,9 +557,10 @@ export class EquipHandler {
let costResult = await handleCost(roleId, sid, cost); // 删掉装备
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
await addItems(roleId, roleName, sid, jewels); // 把原本镶嵌在装备上的宝石返还了
let result = await addItems(roleId, roleName, sid, goods);
return resResult(STATUS.SUCCESS, { goods: result });
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
}