Skip to content

Commit

Permalink
Order by name after ordering by modifier
Browse files Browse the repository at this point in the history
This way it's a bit cleaner to do the potions in order
  • Loading branch information
BlueSoapTurtle committed Oct 29, 2024
1 parent bd744d4 commit e62bc2e
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/main/java/work/fking/masteringmixology/PotionOrderSorting.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
public enum PotionOrderSorting {
VANILLA("Vanilla (random)", null),
// Sort by modifier, in the order CRYSTALISED > HOMOGENOUS > CONCENTRATED
BY_STATION("By station", Comparator.comparingInt(order -> {
switch (order.potionModifier()) {
case CRYSTALISED:
return 0;
case HOMOGENOUS:
return 1;
case CONCENTRATED:
return 2;
default:
return Integer.MAX_VALUE;
}
}));
BY_STATION("By station", Comparator
.comparingInt((PotionOrder order) -> {
switch (order.potionModifier()) {
case CRYSTALISED:
return 0;
case HOMOGENOUS:
return 1;
case CONCENTRATED:
return 2;
default:
return Integer.MAX_VALUE;
}
})
.thenComparing(order -> order.potionType().name()) // Secondary sorting by PotionType name alphabetically
);

private final String name;
private final Comparator<PotionOrder> comparator;
Expand Down

0 comments on commit e62bc2e

Please sign in to comment.