From 9d5f8858e02446d75e57f1469c32a3adc2d45b7f Mon Sep 17 00:00:00 2001 From: 3013050 <3013050@stud.hs-mannheim.de> Date: Mon, 6 May 2024 22:56:12 +0200 Subject: [PATCH] Completed default gamemode Added complete default gamemode, added leaderboard saved and loaded from file, added beginings of the starwars mode implementation. --- fassade/GameCycle.java | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/fassade/GameCycle.java b/fassade/GameCycle.java index 57a07b5..9b47649 100644 --- a/fassade/GameCycle.java +++ b/fassade/GameCycle.java @@ -1,28 +1,5 @@ package fassade; public class GameCycle { -// public class DiceRoll { -// public static boolean hasSmallStraight(int[] dice) { -// Arrays.sort(dice); -// for (int i = 0; i < dice.length - 3; i++) { -// if (dice[i] + 1 == dice[i + 1] && dice[i] + 2 == dice[i + 2] && dice[i] + 3 == dice[i + 3]) { -// return true; -// } -// } -// return false; -// } -// -// public static boolean hasLargeStraight(int[] dice) { -// Arrays.sort(dice); -// for (int i = 0; i < dice.length - 4; i++) { -// if (dice[i] + 1 == dice[i + 1] && dice[i] + 2 == dice[i + 2] && dice[i] + 3 == dice[i + 3] && dice[i] + 4 == dice[i + 4]) { -// return true; -// } -// } -// return false; -// } -// -// public static void main(String[] args) { -// int[] dice = {3, 1, 4, 2, 5};} -// } // example array System.out.println("Has small straight: " + hasSmallStraight(dice)); System.out.println("Has large straight: " + hasLargeStraight(dice)); }}```Here's how the code works:1. First, we sort the array of dice rolls in ascending order using `Arrays.sort()`.2. In the `hasSmallStraight()` method, we iterate through the sorted array and check if four consecutive numbers appear. We do this by checking if the current element plus 1, 2, and 3 are equal to the next three elements in the array. If we find a match, we return `true`.3. In the `hasLargeStraight()` method, we do a similar check, -} + +} \ No newline at end of file