|
|
@@ -264,6 +264,8 @@ async function tryToExecCompositeTask(taskId, taskInfo = {}) {
|
|
|
}
|
|
|
}
|
|
|
lk.log(`最终选择可执行合成数:${finalGroups.length}`);
|
|
|
+ let tmpJsonStr = JSON.stringify(finalGroups, null, 2);
|
|
|
+ lk.log(`详情如下:\n${tmpJsonStr}`);
|
|
|
if (isExecFinalComposite()) {
|
|
|
if (finalGroups.length == 0) {
|
|
|
lk.log('暂无可行的合成组合,请检查');
|
|
|
@@ -347,12 +349,20 @@ function checkMaterialEnough(materialGroup, materialDetails) {
|
|
|
}
|
|
|
|
|
|
function checkPickMaterialForComposite(materialGroup, materialDetails, wantCount) {
|
|
|
- let minCount = 99999;
|
|
|
+ let needNumDict = {};
|
|
|
for (let i = 0; i < materialGroup.length; i++) {
|
|
|
const materialObj = materialGroup[i];
|
|
|
const castingId = materialObj.castingId;
|
|
|
- const ownLst = materialDetails[castingId] || [];
|
|
|
- const maxCount = Math.floor(ownLst.length / materialObj.number);
|
|
|
+ if (!needNumDict[castingId]) {
|
|
|
+ needNumDict[castingId] = materialObj.number;
|
|
|
+ } else {
|
|
|
+ needNumDict[castingId] += materialObj.number;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let minCount = 99999;
|
|
|
+ for (let kid in needNumDict) {
|
|
|
+ const ownLst = materialDetails[kid] || [];
|
|
|
+ const maxCount = Math.floor(ownLst.length / needNumDict[kid]);
|
|
|
if (maxCount < minCount) {
|
|
|
minCount = maxCount;
|
|
|
}
|
|
|
@@ -361,11 +371,16 @@ function checkPickMaterialForComposite(materialGroup, materialDetails, wantCount
|
|
|
let nCompositeGroup = [];
|
|
|
for (let n = 0; n < minCount; n++) {
|
|
|
let resultMaterialLst = [];
|
|
|
+ let interrupt = false;
|
|
|
for (let i = 0; i < materialGroup.length; i++) {
|
|
|
const materialObj = materialGroup[i];
|
|
|
const castingId = materialObj.castingId;
|
|
|
const ownLst = materialDetails[castingId];
|
|
|
const num = materialGroup.number;
|
|
|
+ if (ownLst.length < num) {
|
|
|
+ interrupt = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
let oneMaterial = {
|
|
|
castingId: castingId,
|
|
|
orderList: [],
|
|
|
@@ -381,6 +396,9 @@ function checkPickMaterialForComposite(materialGroup, materialDetails, wantCount
|
|
|
}
|
|
|
resultMaterialLst.push(oneMaterial);
|
|
|
}
|
|
|
+ if (interrupt) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
nCompositeGroup.push(resultMaterialLst);
|
|
|
}
|
|
|
return nCompositeGroup;
|