diff --git a/src/main/java/work/fking/masteringmixology/PotionComparators.java b/src/main/java/work/fking/masteringmixology/PotionComparators.java index b14df1f..8f03c72 100644 --- a/src/main/java/work/fking/masteringmixology/PotionComparators.java +++ b/src/main/java/work/fking/masteringmixology/PotionComparators.java @@ -3,7 +3,6 @@ import java.util.Comparator; public class PotionComparators { - // Sort by modifier, in the order CRYSTALISED > HOMOGENOUS > CONCENTRATED // And then by PotionType name alphabetically public static Comparator byStation() { @@ -21,4 +20,19 @@ public static Comparator byStation() { }) .thenComparing(order -> order.potionType().name()); } + + public static Comparator shortestPath() { + return Comparator.comparing(order -> { + switch (order.potionModifier()) { + case CRYSTALISED: + return 1; + case CONCENTRATED: + return 2; + case HOMOGENOUS: + return 3; + default: + throw new IllegalStateException("Unexpected value: " + order.potionModifier().toString()); + } + }); + } } diff --git a/src/main/java/work/fking/masteringmixology/PotionOrderSorting.java b/src/main/java/work/fking/masteringmixology/PotionOrderSorting.java index d0a6ad2..cf0ba86 100644 --- a/src/main/java/work/fking/masteringmixology/PotionOrderSorting.java +++ b/src/main/java/work/fking/masteringmixology/PotionOrderSorting.java @@ -4,7 +4,8 @@ public enum PotionOrderSorting { VANILLA("Vanilla (random)", null), - BY_STATION("By station", PotionComparators.byStation()); + BY_STATION("By station", PotionComparators.byStation()), + SHORTEST_PATH("Shortest Path", PotionComparators.shortestPath()); private final String name; private final Comparator comparator;