装备:一键分解装备&碎片

This commit is contained in:
luying
2021-08-03 15:31:45 +08:00
parent a95c99df74
commit 8ba672798a
2 changed files with 37 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import { HeroModel, EPlace } from "../../../db/Hero";
import Role from "../../../db/Role";
import { calPlayerCeAndSave } from "../../../services/playerCeService";
import { getGoodById, gameData } from "../../../pubUtils/data";
import { EQUIP } from "../../../pubUtils/dicParam";
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
import { ITID, QUALITY_TYPE, equipTypeToSortAttr, IT_TYPE, QUENCH_TYPE, REFINE_TYPE } from "../../../consts";
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe, checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe } from "../../../services/equipService";
@@ -530,10 +530,14 @@ export class EquipHandler {
let roleId: string = session.get('roleId');
let roleName: string = session.get('roleName');
let sid: string = session.get('sid');
if(originalEquip.length > BAG.BAG_RESOLVE_UPLIMITED) {
return resResult(STATUS.EQUIP_DECOMPOSE_IS_UPLIMIT);
}
let equips = await EquipModel.getEquips(originalEquip);
if (equips.length < originalEquip.length)
return resResult(STATUS.EQUIP_NOT_FIND);
let goods: Array<{ id: number, count: number }> = [];
let cost: ItemInter[] = [];
let jewels: ItemInter[] = []; // 宝石返还
for (let equip of equips) {
if (!!equip.hid)
@@ -547,15 +551,42 @@ export class EquipHandler {
jewels.push({ id: jewel, count: 1 });
}
goods = goods.concat(goodInfo.decomposeItem);
cost.push({ seqId: equip.seqId });
}
let uids = [{ uid: roleId, sid }];
await EquipModel.deleteEquips(roleId, originalEquip);
this.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equips: originalEquip }), uids);
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 });
}
public async decomposeEquipPiece(msg: { originalPiece: { id: number, count: number }[] }, session: BackendSession) {
let { originalPiece } = msg;
let roleId: string = session.get('roleId');
let roleName: string = session.get('roleName');
let sid: string = session.get('sid');
let goods: ItemInter[] = [];
for (let { id, count } of originalPiece) {
let goodInfo = getGoodById(id);
if (!goodInfo) return resResult(STATUS.DIC_DATA_NOT_FOUND);
let dicItid = ITID.get(goodInfo.itid);
if(!dicItid || dicItid.type != CONSUME_TYPE.PIECE) {
return resResult(STATUS.CONSUME_TYPE_ERR);
}
for(let result of goodInfo.decomposeItem) {
goods.push({ id: result.id, count: result.count * count });
}
}
let costResult = await handleCost(roleId, sid, originalPiece);
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
let result = await addItems(roleId, roleName, sid, goods);
return resResult(STATUS.SUCCESS, { goods: result });
}
//穿戴或卸载装备 1-穿上装备(包括替换) 2-脱下装备
public async putOnOrOff(msg: { eid: number, hid: number, type: number }, session: BackendSession) {
let { eid, hid, type } = msg;

View File

@@ -224,6 +224,7 @@ export const STATUS = {
AP_IS_FULL: { code: 30005, simStr: '满体力不可使用道具' },
ROLE_IS_NOT_INIT: { code: 30006, simStr: '玩家未初始化' },
AP_BUY_TIMES_LACK: { code: 30007, simStr: '购买次数不足' },
CONSUME_TYPE_ERR: { code: 30008, simStr: '道具类型错误' },
// 武将养成通用 30100 - 30199
@@ -281,6 +282,7 @@ export const STATUS = {
EQUIP_REFINE_ERR: { code: 30513, simStr: '该装备等级不足或材料不足' },
EQUIP_RESTRENGTHEN_NOT_PREVIEW: { code: 30514, simStr: '该装备未预览洗练值' },
EQUIP_QUENCH_MAX: { code: 30515, simStr: '该装备不能再淬火' },
EQUIP_DECOMPOSE_IS_UPLIMIT: { code: 30516, simStr: '装备分解数量已达上限' },
//全局养成30600-30699
ROLE_REACH_MAX_TITLE_LEVEL: { code: 30600, simStr: '玩家已达到最高的爵位' },
ROLE_TERAPH_NOT_STRENGTHEN: { code: 30601, simStr: '玩家神像不能强化' },