feat: handle one player per job

This commit is contained in:
Anna 2021-04-19 10:17:28 -04:00
parent 1ca1519cc7
commit fc5228eec6
2 changed files with 24 additions and 3 deletions

View File

@ -38,7 +38,7 @@
<PackageReference Include="DalamudPackager" Version="1.2.1" />
<PackageReference Include="Fody" Version="6.5.1" PrivateAssets="all" />
<PackageReference Include="ILMerge.Fody" Version="1.16.0" PrivateAssets="all" />
<PackageReference Include="XivCommon" Version="1.1.0" />
<PackageReference Include="XivCommon" Version="1.3.0" />
</ItemGroup>
</Project>

View File

@ -96,8 +96,29 @@ namespace BetterPartyFinder {
var wanted = filter.Jobs[idx];
for (var i = 0; i < listing.SlotsAvailable; i++) {
// if the slot isn't already full and the job can fit into it, add it to the set
if (present[i] == 0 && slots[i][wanted]) {
// if the slot is already full or the job can't fit into it, skip
if (present[i] != 0 || !slots[i][wanted]) {
continue;
}
// check for one player per job
if (listing[SearchAreaFlags.OnePlayerPerJob]) {
// make sure at least one job in the wanted set isn't taken
foreach (var possibleJob in (JobFlags[]) Enum.GetValues(typeof(JobFlags))) {
if (!wanted.HasFlag(possibleJob)) {
continue;
}
var job = possibleJob.ClassJob(this.Plugin.Interface.Data);
if (present.Contains((byte) job.RowId)) {
continue;
}
jobs[idx].Add(i);
break;
}
} else {
// not one player per job
jobs[idx].Add(i);
}
}