summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model/GameState.java
blob: 3bd4d949ddf0f3bda0ab99e24261f10b7801d28f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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<Player> players;
	private int activePlayer;
	private StoneHeap gameHeap;

	public GameState() {
		table = new Table();
		players = new ArrayList<Player>();
		players.add(new Player("Player 1", Color.RED));
		players.add(new Player("Player 2", Color.YELLOW));
		players.add(new Player("Player 3", Color.GREEN));
		players.add(new Player("Player 4", 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;
	}
}