summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model/GameState.java
blob: e1bd6f3802725e1923acf9d5940074c04e3d99c3 (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
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 {
	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(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();
	}

	public ITable getTable() {
		return table;
	}

	public int getPlayerCount() {
		return players.size();
	}

	public Player getPlayer(int i) {
		return players.get(i);
	}

	/** Changes the activePlayer to the next {@link Player} in the list */
	public void nextPlayer() {
		activePlayer = (activePlayer + 1) % players.size();
	}

	public Player getActivePlayer() {
		return players.get(activePlayer);
	}

	public StoneHeap getGameHeap() {
		return gameHeap;
	}
}