Fixes.
This commit is contained in:
parent
7ebea34f12
commit
9e789cc645
@ -1,5 +1,5 @@
|
|||||||
package fr.aminelouveaau.cartes.model;
|
package fr.aminelouveaau.cartes.model;
|
||||||
|
|
||||||
public enum Number {
|
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
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
package fr.aminelouveaau.cartes.model.api;public class SortingResult {
|
||||||
|
}
|
@ -18,6 +18,7 @@ public class GameService {
|
|||||||
private List<Number> numberOrder;
|
private List<Number> numberOrder;
|
||||||
|
|
||||||
private Stack<Card> deck = new Stack<>();
|
private Stack<Card> deck = new Stack<>();
|
||||||
|
private Comparator<Card> comparator;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -47,10 +48,13 @@ public class GameService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateOrders() {
|
private void generateOrders() {
|
||||||
List<Shape> shapeOrder = Arrays.asList(Shape.values());
|
shapeOrder = Arrays.asList(Shape.values());
|
||||||
Collections.shuffle(shapeOrder);
|
Collections.shuffle(shapeOrder);
|
||||||
List<Number> numberOrder = Arrays.asList(Number.values());
|
numberOrder = Arrays.asList(Number.values());
|
||||||
Collections.shuffle(numberOrder);
|
Collections.shuffle(numberOrder);
|
||||||
|
|
||||||
|
comparator = Comparator.comparing((Card c) -> shapeOrder.indexOf(c.getShape()))
|
||||||
|
.thenComparing(c -> numberOrder.indexOf(c.getNumber()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user