fix: make the job filter work better
This commit is contained in:
parent
400af0810f
commit
36195a3e9f
|
@ -102,6 +102,16 @@ namespace BetterPartyFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure the number of total slots with possibles joins is at least the number of jobs
|
||||||
|
// note that this doesn't make sure it's joinable, see below
|
||||||
|
var numSlots = jobs
|
||||||
|
.Aggregate((acc, x) => acc.Union(x).ToHashSet())
|
||||||
|
.Count;
|
||||||
|
|
||||||
|
if (numSlots < jobs.Length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// loop through each unique pair of jobs
|
// loop through each unique pair of jobs
|
||||||
for (var i = 0; i < jobs.Length; i++) {
|
for (var i = 0; i < jobs.Length; i++) {
|
||||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||||
|
@ -115,12 +125,13 @@ namespace BetterPartyFinder {
|
||||||
|
|
||||||
// check if the slots either job can join have overlap
|
// check if the slots either job can join have overlap
|
||||||
var overlap = a.Intersect(b);
|
var overlap = a.Intersect(b);
|
||||||
if (!overlap.Any()) {
|
if (overlap.Count() != 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is overlap, check the difference between the sets
|
// if there is overlap, check the difference between the sets
|
||||||
// if there is no difference, the party can't be joined
|
// if there is no difference, the party can't be joined
|
||||||
|
// note that if the overlap is more than one slot, we don't need to check
|
||||||
var difference = a.Except(b);
|
var difference = a.Except(b);
|
||||||
if (!difference.Any()) {
|
if (!difference.Any()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue