碎片合成bug

This commit is contained in:
mamengke01
2020-12-21 17:39:23 +08:00
parent 3cd0dc902e
commit a330ad557c
4 changed files with 37 additions and 33 deletions
@@ -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);