combo counts
This commit is contained in:
parent
26054eca73
commit
7cab0a6f18
@ -1,5 +1,6 @@
|
|||||||
const preact = require('preact');
|
const preact = require('preact');
|
||||||
const range = require('lodash/range');
|
const range = require('lodash/range');
|
||||||
|
const countBy = require('lodash/countBy');
|
||||||
const without = require('lodash/without');
|
const without = require('lodash/without');
|
||||||
const { connect } = require('preact-redux');
|
const { connect } = require('preact-redux');
|
||||||
|
|
||||||
@ -262,7 +263,19 @@ function Vbox(args) {
|
|||||||
|
|
||||||
// invalid combo
|
// invalid combo
|
||||||
const combinerItems = combiner.map(j => vbox.bound[j]);
|
const combinerItems = combiner.map(j => vbox.bound[j]);
|
||||||
if (!itemInfo.combos.some(combo => combinerItems.every(c => combo.components.includes(c)))) {
|
const combinerCounts = countBy(combinerItems, c => c);
|
||||||
|
|
||||||
|
// unless some combo
|
||||||
|
// contains every combinerItems
|
||||||
|
// and combinerItems.count of item >= components.count(item)
|
||||||
|
|
||||||
|
if (!itemInfo.combos
|
||||||
|
.some(combo => {
|
||||||
|
const comboCount = countBy(combo.components, c => c);
|
||||||
|
return combinerItems.every(c =>
|
||||||
|
combo.components.includes(c) && comboCount[c] >= combinerCounts[c]
|
||||||
|
);
|
||||||
|
})) {
|
||||||
return combinerChange([i]);
|
return combinerChange([i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user