From 9e789cc645c7c1fdb6f10731181c6ec29efd72eb Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sat, 30 Oct 2021 14:33:15 +0200 Subject: [PATCH] Fixes. --- src/main/java/fr/aminelouveaau/cartes/model/Number.java | 2 +- .../fr/aminelouveaau/cartes/model/api/SortingResult.java | 2 ++ .../java/fr/aminelouveaau/cartes/service/GameService.java | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/main/java/fr/aminelouveaau/cartes/model/api/SortingResult.java diff --git a/src/main/java/fr/aminelouveaau/cartes/model/Number.java b/src/main/java/fr/aminelouveaau/cartes/model/Number.java index 5fe15a6..5af81da 100644 --- a/src/main/java/fr/aminelouveaau/cartes/model/Number.java +++ b/src/main/java/fr/aminelouveaau/cartes/model/Number.java @@ -1,5 +1,5 @@ package fr.aminelouveaau.cartes.model; public enum Number { - ACE, KING, QUEEN, JACK, TEN, NINE, HEIGHT, SEVEN, SIX, FIXE, FOUR, THREE, TWO + ACE, KING, QUEEN, JACK, TEN, NINE, HEIGHT, SEVEN, SIX, FIVE, FOUR, THREE, TWO } diff --git a/src/main/java/fr/aminelouveaau/cartes/model/api/SortingResult.java b/src/main/java/fr/aminelouveaau/cartes/model/api/SortingResult.java new file mode 100644 index 0000000..1a958f2 --- /dev/null +++ b/src/main/java/fr/aminelouveaau/cartes/model/api/SortingResult.java @@ -0,0 +1,2 @@ +package fr.aminelouveaau.cartes.model.api;public class SortingResult { +} diff --git a/src/main/java/fr/aminelouveaau/cartes/service/GameService.java b/src/main/java/fr/aminelouveaau/cartes/service/GameService.java index 2314db7..531dfb0 100644 --- a/src/main/java/fr/aminelouveaau/cartes/service/GameService.java +++ b/src/main/java/fr/aminelouveaau/cartes/service/GameService.java @@ -18,6 +18,7 @@ public class GameService { private List numberOrder; private Stack deck = new Stack<>(); + private Comparator comparator; @PostConstruct public void init() { @@ -47,10 +48,13 @@ public class GameService { } private void generateOrders() { - List shapeOrder = Arrays.asList(Shape.values()); + shapeOrder = Arrays.asList(Shape.values()); Collections.shuffle(shapeOrder); - List numberOrder = Arrays.asList(Number.values()); + numberOrder = Arrays.asList(Number.values()); Collections.shuffle(numberOrder); + + comparator = Comparator.comparing((Card c) -> shapeOrder.indexOf(c.getShape())) + .thenComparing(c -> numberOrder.indexOf(c.getNumber())); } }