From c376d8f34507a55cac76bf3a41fa39c7bfb04456 Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 2 Feb 2024 11:31:07 +0100 Subject: [PATCH] refactoring: currentTurn to boolean 2PlayerChange --- .../de/hsfulda/onses/services/PlayerService.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/services/PlayerService.java b/src/main/java/de/hsfulda/onses/services/PlayerService.java index b9d0123..ff9f869 100644 --- a/src/main/java/de/hsfulda/onses/services/PlayerService.java +++ b/src/main/java/de/hsfulda/onses/services/PlayerService.java @@ -6,8 +6,8 @@ import java.util.ArrayList; public class PlayerService { - private int currentTurn = 0; // 0-3 - private int totalTurns = 0; // 1-4 + private boolean currentTurn = true; // true --> real player, false --> Bot + private int totalTurns = 0; private final ArrayList playerList = new ArrayList<>(); public ArrayList getPlayerList() { @@ -19,22 +19,18 @@ public class PlayerService { } - // decides which Player is currently at their turn -> 0 = main Player (skip -> 2x nextTurn()) - // possible: at start of game random int generator from 0-max to decide who starts first - // currentTurn = 2 --> player.getPlayerList(currentTurn) --> Bot 2 (Player 3) public void nextTurn() { - if (currentTurn != totalTurns-1) currentTurn++; - else currentTurn = 0; + currentTurn = !currentTurn; } - public int getCurrentTurn() { + public boolean getCurrentTurn() { return currentTurn; } - public PlayerService setCurrentTurn(int currentTurn) { + public PlayerService setCurrentTurn(boolean currentTurn) { this.currentTurn = currentTurn; return this; }