improve check

This commit is contained in:
Mashy 2019-10-17 09:33:26 +10:00
parent ea5d908893
commit 245cb603fc

View File

@ -177,12 +177,13 @@ function Vbox(args) {
} }
const combinerItems = combiner.map(j => vbox.bound[j]); const combinerItems = combiner.map(j => vbox.bound[j]);
const combinerCount = countBy(combinerItems, co => co);
const comboHighlight = combinerItems.length > 0 && itemInfo.combos.some(combo => { const comboHighlight = combinerItems.length > 0 && itemInfo.combos.some(combo => {
if (combo.components.includes(v)) { if (combo.components.includes(v)) {
return combinerItems.every(c => { return combinerItems.every(c => {
if (!combo.components.includes(c)) return false; if (!combo.components.includes(c)) return false;
const comboCount = countBy(combo.components, co => co); const comboCount = countBy(combo.components, co => co);
const combinerCount = countBy(combinerItems, co => co);
if (combinerCount[c] > comboCount[c]) return false; if (combinerCount[c] > comboCount[c]) return false;
if (c === v && combinerCount[c] + 1 > comboCount[c]) return false; if (c === v && combinerCount[c] + 1 > comboCount[c]) return false;
return true; return true;
@ -264,12 +265,13 @@ function Vbox(args) {
} }
const combinerItems = combiner.map(j => vbox.bound[j]); const combinerItems = combiner.map(j => vbox.bound[j]);
const combinerCount = countBy(combinerItems, co => co);
const comboHighlight = combinerItems.length > 0 && itemInfo.combos.some(combo => { const comboHighlight = combinerItems.length > 0 && itemInfo.combos.some(combo => {
if (combo.components.includes(v)) { if (combo.components.includes(v)) {
return combinerItems.every(c => { return combinerItems.every(c => {
if (!combo.components.includes(c)) return false; if (!combo.components.includes(c)) return false;
const comboCount = countBy(combo.components, co => co); const comboCount = countBy(combo.components, co => co);
const combinerCount = countBy(combinerItems, co => co);
if (combinerCount[c] > comboCount[c]) return false; if (combinerCount[c] > comboCount[c]) return false;
if (c === v && combinerCount[c] + 1 > comboCount[c]) return false; if (c === v && combinerCount[c] + 1 > comboCount[c]) return false;
return true; return true;