Completed default gamemode

Added complete default gamemode, added leaderboard saved and loaded from file, added beginings of the starwars mode implementation.
main
Victor Hans-Georg Waitz 2024-05-06 22:56:12 +02:00
parent e2604101bf
commit 9d5f8858e0
1 changed files with 2 additions and 25 deletions

View File

@ -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,
}