Skip to content

Commit

Permalink
Make EqualSorter null-check style more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirtol committed Aug 1, 2020
1 parent d02ee6c commit d16bf05
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
7 changes: 1 addition & 6 deletions PartyScreenEnhancements/Comparers/AlphabetComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM
result = StringComparer.CurrentCulture.Compare(x.Name.ToString(), y.Name.ToString());

if (result == 0)
{
if (EqualSorter != null)
{
return EqualSorter.Compare(x, y);
}
}
return EqualSorter?.Compare(x, y) ?? 0;

return result;
}
Expand Down
3 changes: 2 additions & 1 deletion PartyScreenEnhancements/Comparers/LevelComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM
{
if (Descending ? x.Character.Level > y.Character.Level : y.Character.Level > x.Character.Level) return -1;

if (x.Character.Level == y.Character.Level) return EqualSorter?.Compare(x, y) ?? 0;
if (x.Character.Level == y.Character.Level)
return EqualSorter?.Compare(x, y) ?? 0;

return 1;
}
Expand Down
3 changes: 2 additions & 1 deletion PartyScreenEnhancements/Comparers/NumberComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM
{
if (Descending ? x.Number > y.Number : y.Number > x.Number) return -1;

if (x.Number == y.Number) return EqualSorter?.Compare(x, y) ?? 0;
if (x.Number == y.Number)
return EqualSorter?.Compare(x, y) ?? 0;

return 1;
}
Expand Down
12 changes: 4 additions & 8 deletions PartyScreenEnhancements/Comparers/TrueTierComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,13 @@ protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM
{
return 1;
}

if (x.Character.Tier == y.Character.Tier)
{
if (EqualSorter != null)
{
return EqualSorter.Compare(x, y);
}
return 0;
}else
{
return -1;
return EqualSorter?.Compare(x, y) ?? 0;
}

return -1;
}
}
}
4 changes: 1 addition & 3 deletions PartyScreenEnhancements/Comparers/TypeComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM

if (y.Character.GetFormationClass(PartyBase.MainParty) == x.Character.GetFormationClass(PartyBase.MainParty))
{
if (EqualSorter != null)
return EqualSorter.Compare(x, y);
return 0;
return EqualSorter?.Compare(x, y) ?? 0;
}

return -1;
Expand Down
3 changes: 2 additions & 1 deletion PartyScreenEnhancements/Comparers/UpgradeableComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM
: y.Troop.NumberReadyToUpgrade > x.Troop.NumberReadyToUpgrade) return -1;


if (y.Troop.NumberReadyToUpgrade == x.Troop.NumberReadyToUpgrade) return EqualSorter?.Compare(x, y) ?? 0;
if (y.Troop.NumberReadyToUpgrade == x.Troop.NumberReadyToUpgrade)
return EqualSorter?.Compare(x, y) ?? 0;

return 1;
}
Expand Down
3 changes: 2 additions & 1 deletion PartyScreenEnhancements/Comparers/WoundedComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ protected override int localCompare(ref PartyCharacterVM x, ref PartyCharacterVM

if (Descending ? x.Troop.WoundedNumber > y.Troop.WoundedNumber : y.Troop.WoundedNumber > x.Troop.WoundedNumber) return -1;

if (x.Troop.WoundedNumber == y.Troop.WoundedNumber) return EqualSorter?.Compare(x, y) ?? 0;
if (x.Troop.WoundedNumber == y.Troop.WoundedNumber)
return EqualSorter?.Compare(x, y) ?? 0;

return 1;
}
Expand Down

0 comments on commit d16bf05

Please sign in to comment.