Merge remote-tracking branch 'origin/Development' into Development

This commit is contained in:
ramollia
2025-11-27 18:50:12 +01:00
5 changed files with 35 additions and 34 deletions

View File

@@ -1,26 +1,25 @@
package org.toop.game;
public abstract class TurnBasedGame extends Game {
private final int turns;
private int currentTurn;
private final int playerCount; // How many players are playing
private int turn = 0; // What turn it is in the game
protected TurnBasedGame(int rowSize, int columnSize, int turns) {
protected TurnBasedGame(int rowSize, int columnSize, int playerCount) {
super(rowSize, columnSize);
assert turns >= 2;
this.turns = turns;
this.playerCount = playerCount;
}
protected TurnBasedGame(TurnBasedGame other) {
super(other);
turns = other.turns;
currentTurn = other.currentTurn;
playerCount = other.playerCount;
turn = other.turn;
}
protected void nextTurn() {
currentTurn = (currentTurn + 1) % turns;
turn += 1;
}
public int getCurrentTurn() {
return currentTurn;
return turn % playerCount;
}
}