Browse Source

add turns

main
fdai7920 11 months ago
parent
commit
50e8421ba3
  1. 32
      src/main/java/de/hsfulda/onses/services/PlayerService.java

32
src/main/java/de/hsfulda/onses/services/PlayerService.java

@ -6,6 +6,8 @@ import java.util.ArrayList;
public class PlayerService {
private int currentTurn = 0; // 0-3
private int totalTurns = 0; // 1-4
private final ArrayList<Player> playerList = new ArrayList<>();
public ArrayList<Player> getPlayerList() {
@ -13,9 +15,9 @@ public class PlayerService {
}
public void addPlayerToList(Player player) {
playerList.add(player);
totalTurns++;
}
// button on gui activates it
public void addOpponents(int amount) {
for (int i=0; i<amount; i++)
@ -24,4 +26,32 @@ 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;
}
public int getCurrentTurn() {
return currentTurn;
}
public PlayerService setCurrentTurn(int currentTurn) {
this.currentTurn = currentTurn;
return this;
}
public int getTotalTurns() {
return totalTurns;
}
public PlayerService setTotalTurns(int totalTurns) {
this.totalTurns = totalTurns;
return this;
}
}
Loading…
Cancel
Save