装备:合成逻辑修改
This commit is contained in:
@@ -10,7 +10,7 @@ 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, equipTypeToSortAttr } from "../../../consts/constModules/itemConst";
|
||||
import { ITID, SPEICAL_ITEM, QUALITY_TYPE, equipTypeToSortAttr, IT_TYPE } from "../../../consts/constModules/itemConst";
|
||||
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService";
|
||||
|
||||
import { indexOf, findIndex } from 'underscore';
|
||||
@@ -43,7 +43,7 @@ export class EquipHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const serverId: number = session.get('serverId');
|
||||
// 消耗材料
|
||||
// 获得装备
|
||||
let { gid, originalEquip } = msg;
|
||||
@@ -52,16 +52,21 @@ export class EquipHandler {
|
||||
let targetGood = gameData.goods.get(gid);
|
||||
if (!targetGood) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let cost = new Array<ItemInter>();
|
||||
let cost: ItemInter[] = [];
|
||||
let jewels: ItemInter[] = []; // 需要返还的镶嵌在装备上的宝石
|
||||
if (targetGood.suitId > 0) { // 套装
|
||||
cost = cost.concat(targetGood.composeMaterial);
|
||||
let specialMaterial = targetGood.specialMaterial;
|
||||
let costCount = 0;
|
||||
let equips = await EquipModel.getEquips(originalEquip);
|
||||
for (let { id, seqId } of equips) {
|
||||
for (let equip of equips) {
|
||||
let { id, seqId, holes } = equip;
|
||||
if (specialMaterial.ids.includes(id)) {
|
||||
costCount++;
|
||||
cost.push({ id, seqId, count: 1 });
|
||||
for(let { jewel } of holes) {
|
||||
if(jewel > 0) jewels.push({ id: jewel, count: 1});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (specialMaterial.count > costCount) {
|
||||
@@ -77,6 +82,7 @@ export class EquipHandler {
|
||||
let result = await handleCost(roleId, sid, cost);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
await addItems(roleId, roleName, sid, jewels); // 宝石返还
|
||||
let items = [{ id: gid, count: 1 }];
|
||||
let goods = await addItems(roleId, roleName, sid, items);
|
||||
if (targetGood.suitId) {
|
||||
@@ -462,17 +468,24 @@ export class EquipHandler {
|
||||
if (equips.length < originalEquip.length)
|
||||
return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
let goods: Array<{ id: number, count: number }> = [];
|
||||
let jewels: ItemInter[] = []; // 宝石返还
|
||||
for (let equip of equips) {
|
||||
if (!!equip.hid)
|
||||
return resResult(STATUS.EQUIP_IS_EQUIPED_NOT_DECOMPOSE);
|
||||
let goodInfo = getGoodById(equip.id);
|
||||
if (!goodInfo)
|
||||
return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
let holes = equip.holes||[];
|
||||
for(let { jewel } of holes) {
|
||||
jewels.push({ id: jewel, count: 1 });
|
||||
}
|
||||
goods = goods.concat(goodInfo.decomposeItem);
|
||||
}
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
await EquipModel.deleteEquips(originalEquip);
|
||||
this.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equips: originalEquip }), uids);
|
||||
await addItems(roleId, roleName, sid, jewels); // 把原本镶嵌在装备上的宝石返还了
|
||||
let result = await addItems(roleId, roleName, sid, goods);
|
||||
return resResult(STATUS.SUCCESS, { goods: result });
|
||||
}
|
||||
@@ -854,4 +867,69 @@ export class EquipHandler {
|
||||
return resResult(STATUS.SUCCESS, { goods: [{ id: jewel, count }] });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 藏宝图合成
|
||||
* @param {{target: number, original: Array<{id: number, count: number}>}} msg
|
||||
* @param {BackendSession} session
|
||||
* @returns
|
||||
* @memberof ComBattleHandler
|
||||
*/
|
||||
async composeBlueprt(msg: { target: number, original: Array<{id: number, count: number}>}, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
|
||||
const { target, original } = msg;
|
||||
|
||||
// 原材料检查
|
||||
let originalQuality: number, originalSum: number = 0;
|
||||
for(let {id, count} of original) {
|
||||
const goodInfo = gameData.goods.get(id);
|
||||
if(!originalQuality) originalQuality = goodInfo.quality;
|
||||
if(originalQuality != goodInfo.quality) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
}
|
||||
|
||||
if(goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
originalSum += count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const dicCompose = gameData.blurprtCompose.get(originalQuality);
|
||||
if(!dicCompose) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_CANNOT_COMPOSE);
|
||||
}
|
||||
if(originalSum != dicCompose.blueprtNum) {
|
||||
return resResult(STATUS.COM_BLUEPRT_COUNT_ERROR);
|
||||
}
|
||||
|
||||
let dicTargetInfo = gameData.goods.get(target);
|
||||
if(!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
if(dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
|
||||
// 添加寻宝币
|
||||
original.push({
|
||||
id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.TREASURE_POINT),
|
||||
count: dicCompose.coinNum
|
||||
});
|
||||
// 消耗藏宝图和寻宝币
|
||||
|
||||
let costResult = await handleCost(roleId, sid, original);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
const reward = [{id: target, count: 1}];
|
||||
const goods = await addItems(roleId, roleName, sid, reward);
|
||||
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
const { name } = gameData.goods.get(target);
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
}
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.COM_BATTLE_BLUEPRT, 1, true, { quality: dicCompose.targetQuality });
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods, costGold: 0 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user