From c6f4dbffe3df206108556936d6a17a3d72132a83 Mon Sep 17 00:00:00 2001 From: Katchan <35238981+KatchanNve@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:00:53 +0100 Subject: [PATCH] Add random choose method in the Cardinal enum --- .../src/main/java/fr/lnl/game/server/utils/Cardinal.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/fr/lnl/game/server/utils/Cardinal.java b/server/src/main/java/fr/lnl/game/server/utils/Cardinal.java index b7dab95..3b8ff91 100644 --- a/server/src/main/java/fr/lnl/game/server/utils/Cardinal.java +++ b/server/src/main/java/fr/lnl/game/server/utils/Cardinal.java @@ -8,5 +8,11 @@ public enum Cardinal { NORTH_EAST, NORTH_WEST, SOUTH_EAST, - SOUTH_WEST + SOUTH_WEST; + + public static Cardinal getRandom() { + return values()[(int) (Math.random() * values().length)]; + } } + +