diff --git a/src/main/java/work/fking/masteringmixology/PotionComparators.java b/src/main/java/work/fking/masteringmixology/PotionComparators.java index b14df1f..fd7f6ba 100644 --- a/src/main/java/work/fking/masteringmixology/PotionComparators.java +++ b/src/main/java/work/fking/masteringmixology/PotionComparators.java @@ -21,4 +21,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;