Skip to content

Commit

Permalink
Merge pull request #1302 from dvir001/2024-04-29-LateJoinFix
Browse files Browse the repository at this point in the history
Update VesselListControl.xaml.cs
  • Loading branch information
GreaseMonk authored Apr 29, 2024
2 parents 43fa11d + eb72008 commit 8bfeb99
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions Content.Client/_NF/Latejoin/VesselListControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,43 @@ protected override void Dispose(bool disposing)

private int DefaultComparison(NetEntity x, NetEntity y)
{
var xContainsHop = _gameTicker.JobsAvailable[x].ContainsKey("HeadOfPersonnel");
var yContainsHop = _gameTicker.JobsAvailable[y].ContainsKey("HeadOfPersonnel");
var xContainsSR = _gameTicker.JobsAvailable[x].ContainsKey("StationRepresentative");
var yContainsSR = _gameTicker.JobsAvailable[y].ContainsKey("StationRepresentative");

var xContainsHos = _gameTicker.JobsAvailable[x].ContainsKey("HeadOfSecurity");
var yContainsHos = _gameTicker.JobsAvailable[y].ContainsKey("HeadOfSecurity");
var xContainsSheriff = _gameTicker.JobsAvailable[x].ContainsKey("Sheriff");
var yContainsSheriff = _gameTicker.JobsAvailable[y].ContainsKey("Sheriff");

// Prioritize "HeadOfPersonnel"
switch (xContainsHop)
var xContainsPirateCaptain = _gameTicker.JobsAvailable[x].ContainsKey("PirateCaptain");
var yContainsPirateCaptain = _gameTicker.JobsAvailable[y].ContainsKey("PirateCaptain");

// Prioritize "StationRepresentative"
switch (xContainsSR)
{
case true when !yContainsSR:
return -1;
case false when yContainsSR:
return 1;
}

// If both or neither contain "StationRepresentative", prioritize "Sheriff"
switch (xContainsSheriff)
{
case true when !yContainsHop:
case true when !yContainsSheriff:
return -1;
case false when yContainsHop:
case false when yContainsSheriff:
return 1;
}

// If both or neither contain "HeadOfPersonnel", prioritize "HeadOfSecurity"
switch (xContainsHos)
// If both or neither contain "StationRepresentative", "Sheriff" prioritize "PirateCaptain"
switch (xContainsPirateCaptain)
{
case true when !yContainsHos:
case true when !yContainsPirateCaptain:
return -1;
case false when yContainsHos:
case false when yContainsPirateCaptain:
return 1;
}

// If both or neither contain "HeadOfPersonnel" and "HeadOfSecurity", sort by jobCountComparison
// If both or neither contain "StationRepresentative" and "Sheriff", sort by jobCountComparison
var jobCountComparison = -(int) (_gameTicker.JobsAvailable[x].Values.Sum(a => a ?? 0) -
_gameTicker.JobsAvailable[y].Values.Sum(b => b ?? 0));
var nameComparison = string.Compare(_gameTicker.StationNames[x], _gameTicker.StationNames[y], StringComparison.Ordinal);
Expand Down

0 comments on commit 8bfeb99

Please sign in to comment.