summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/RoundControl.java
blob: cce61604755fe25bdad1d1d5451d5b87de676ce0 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package jrummikub.control;

import java.util.Set;

import jrummikub.model.IGameState;
import jrummikub.model.IHand;
import jrummikub.model.ITable;
import jrummikub.model.Position;
import jrummikub.model.Stone;
import jrummikub.util.IListener;
import jrummikub.view.IView;

public class RoundControl {
	private IGameState gameState;
	private IView view;
	private ITable clonedTable;

	public RoundControl(IGameState gameState, IView view) {
		this.gameState = gameState;
		this.view = view;
	}

	public void startRound() {
		deal();

		view.getStartTurnEvent().add(new IListener() {

			@Override
			public void handle() {
				startTurn();
			}
		});
		view.enableStartTurnPanel(true);
		clonedTable = (ITable) gameState.getTable().clone();
		view.getTablePanel().setStoneSets(clonedTable);
	}

	private void startTurn() {
		TurnControl turnControl = new TurnControl(gameState.getActivePlayer()
				.getHand(), clonedTable, view);
		turnControl.getEndOfTurnEvent().add(new IListener() {

			@Override
			public void handle() {
				endOfTurn();
			}
		});
		// turnControl.startTurn();
	}

	void deal() {
		for (int i = 0; i < gameState.getPlayerCount(); i++) {
			IHand hand = gameState.getPlayer(i).getHand();
			for (int j = 0; j < 7; j++) {
				hand.drop(gameState.getGameHeap().drawStone(), new Position(j,
						0));
				hand.drop(gameState.getGameHeap().drawStone(), new Position(j,
						1));
			}
		}
	}

	private void endOfTurn() {

	}

	static Set<Stone> tableDifference(ITable oldTable, ITable newTable) {
		return null;
	}

	private void resetTable() {

	}

	private void preparePlayerTurn() {

	}

	private void dealStone() {

	}
}