From fc665499d025507af5308f350f0e1e4be8c7deed Mon Sep 17 00:00:00 2001 From: Jakob Date: Thu, 9 Jan 2025 13:55:49 +0100 Subject: [PATCH] New Pokergame now also gets started correctly --- Poker_PR1/src/core/Main.java | 2 +- Poker_PR1/src/game/PokerGame.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Poker_PR1/src/core/Main.java b/Poker_PR1/src/core/Main.java index 2cfd9b6..3dd1908 100644 --- a/Poker_PR1/src/core/Main.java +++ b/Poker_PR1/src/core/Main.java @@ -21,7 +21,7 @@ public class Main { bb.put(new ConsolePokerPlayer("Jakob4"), 10f); bb.put(new ConsolePokerPlayer("Jakob5"), 10f); - PokerGame game = new PokerGame(new ConsoleBroadcaster(), 1, bb, 0); + PokerGame game = new PokerGame(new ConsoleBroadcaster(), 2, bb, 0); game.start(); diff --git a/Poker_PR1/src/game/PokerGame.java b/Poker_PR1/src/game/PokerGame.java index f10ed66..4e93dcd 100644 --- a/Poker_PR1/src/game/PokerGame.java +++ b/Poker_PR1/src/game/PokerGame.java @@ -295,14 +295,13 @@ public class PokerGame { while (running && (!areAllBetsEqual() || !allPlayersHaveActed())) { - System.out.println("DEBUG"); + System.out.println("DEBUG:"); System.out.println("Are all bets equal?: " + areAllBetsEqual()); System.out.println("Have all players acted: " + allPlayersHaveActed()); PokerPlayer actingPlayer = players[playerActing]; //correct action check - for (PokerPlayer player : betsThisRound.keySet()) { boolean folded = false; @@ -697,9 +696,9 @@ public class PokerGame { private void endGame() { + rounds--; if (rounds > 0) { - rounds--; LinkedHashMap newbbPerPlayer = new LinkedHashMap<>(); @@ -721,8 +720,7 @@ public class PokerGame { } } - - //schwierig wenn unten Leute wegfallen und es nochmal der gleiche Dealer ist oder es sogar zur�ck geht + int newdealerPosition = dealerPosition + 1; if (newdealerPosition >= newbbPerPlayer.size()) { @@ -730,7 +728,9 @@ public class PokerGame { } - new PokerGame(new ConsoleBroadcaster(), rounds, newbbPerPlayer, newdealerPosition); + PokerGame nextGame = new PokerGame(new ConsoleBroadcaster(), rounds, newbbPerPlayer, newdealerPosition); + + nextGame.start(); } else { caster.allRoundsPlayed();