package jrummikub.model; import java.awt.Color; import java.util.ArrayList; import java.util.List; /** Class managing the overall and momentary GameState */ public class GameState implements IGameState { private ITable table; private List players; private int activePlayer; private StoneHeap gameHeap; public GameState() { table = new Table(); players = new ArrayList(); players.add(new Player(Color.red)); players.add(new Player(Color.yellow)); players.add(new Player(Color.green)); players.add(new Player(Color.black)); activePlayer = 0; gameHeap = new StoneHeap(); } @Override public ITable getTable() { return table; } @Override public int getPlayerCount() { return players.size(); } @Override public IPlayer getPlayer(int i) { return players.get(i); } /** Changes the activePlayer to the next {@link Player} in the list */ @Override public void nextPlayer() { activePlayer = (activePlayer + 1) % players.size(); } @Override public IPlayer getActivePlayer() { return players.get(activePlayer); } @Override public StoneHeap getGameHeap() { return gameHeap; } }