fix,回滚因为合并修改的文件
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, GOOD_TYPE, HERO_GROW_MAX } from "../../../consts";
|
||||
import { ItemInter } from "../../../pubUtils/interface";
|
||||
import { resResult, parseGoodStr, getRandomByLen, deepCopy, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||
|
||||
import { resResult, parseGoodStr, getRandomByLen, deepCopy, mergeSameGoods, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||
import { addItems, handleCost } from "../../../services/rewardService";
|
||||
import { checkMaterialEnough } from "../../../services/equipService";
|
||||
import { EquipModel, RandSe } from "../../../db/Equip";
|
||||
import { HeroModel, EPlace } from "../../../db/Hero";
|
||||
import { ItemModel } from "../../../db/Item";
|
||||
@@ -465,55 +467,27 @@ export class EquipHandler {
|
||||
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
}
|
||||
|
||||
//宝石合成
|
||||
public async composeJewel(msg: { jewel: number, count: number, consumes: Array<{ id: number, count: number }>, speConsumes: Array<{ id: number, count: number }> }, session: BackendSession) {
|
||||
let { count, consumes, jewel, speConsumes } = msg;
|
||||
//宝石合成(一键放入type:1, 合成type:2)
|
||||
public async composeJewel(msg: { jewel: number, count: number, consumes: Array<{ id: number, count: number }>, type: number }, session: BackendSession) {
|
||||
let { count, consumes, jewel, type } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
let goodInfo = getGoodById(jewel);
|
||||
let { type } = ITID.get(goodInfo.itid);
|
||||
if (type != CONSUME_TYPE.JEWEL)
|
||||
let good = ITID.get(goodInfo.itid);
|
||||
if (good.type != CONSUME_TYPE.JEWEL)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
//检查宝石消耗是否合法TODO
|
||||
let comJewelMap = {};
|
||||
let ways = [deepCopy(speConsumes)];
|
||||
for (let { id, count } of consumes) {
|
||||
let jewelInfo = getJewelById(id);
|
||||
if (!jewelInfo) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
delete comJewelMap[jewelInfo.good_id];
|
||||
comJewelMap[jewelInfo.nextJewelId] = count + (comJewelMap[jewelInfo.nextJewelId] || 0);
|
||||
}
|
||||
if (comJewelMap[jewel] != count || Object.keys(comJewelMap).length != 1)
|
||||
let needConsumes = checkMaterialEnough(consumes, jewel, count);
|
||||
if (!needConsumes)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res = await handleCost(roleId, sid, consumes.concat(speConsumes));
|
||||
let res = await handleCost(roleId, sid, needConsumes);
|
||||
if (!res)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
let result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
||||
return resResult(STATUS.SUCCESS, { goods: result });
|
||||
if (type == 1)
|
||||
return resResult(STATUS.SUCCESS, { goods: result });
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
//宝石卸下
|
||||
@@ -620,5 +594,4 @@ export class EquipHandler {
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { goods: result });
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user