mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Merge remote-tracking branch 'origin/Development' into Development
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user