Skip to content

Commit

Permalink
Merge branch 'master' into add-order-count-infobox
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueSoapTurtle committed Oct 31, 2024
2 parents 956cbab + eb462f3 commit 76afa34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/main/java/work/fking/masteringmixology/PotionComparators.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,19 @@ public static Comparator<PotionOrder> byStation() {
})
.thenComparing(order -> order.potionType().name());
}

public static Comparator<PotionOrder> 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());
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<PotionOrder> comparator;
Expand Down

0 comments on commit 76afa34

Please sign in to comment.