summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/turn/ITurnControl.java
blob: 63290d53e95a6896163a707d99c546dded89b1ce (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package jrummikub.control.turn;

import jrummikub.model.GameSettings;
import jrummikub.model.IHand;
import jrummikub.model.ITable;
import jrummikub.util.IEvent;
import jrummikub.view.IView;

/**
 * Interface containing shared methods of human and computer turn control
 * 
 */
public interface ITurnControl {
	/**
	 * Start the turn
	 * 
	 * @param info
	 *          the current turn state
	 * 
	 * @param settings
	 *          the game settings
	 * @param view
	 *          view for user interaction.
	 */
	public void setup(TurnInfo info, GameSettings settings, IView view);

	/**
	 * Get the event that is emitted when the turn is over
	 * 
	 * @return end of turn event
	 */
	public IEvent getEndOfTurnEvent();

	/**
	 * Emitted when the round is aborted and needs to be restarted
	 * 
	 * @return the event
	 */
	public IEvent getRedealEvent();

	/**
	 * Start the turn
	 */
	public void startTurn();

	/**
	 * Abort the turn
	 */
	public void abortTurn();

	/**
	 * The TurnInfo class encapsulates all information concerning the current turn
	 */
	public class TurnInfo {
		private ITable table;
		private IHand hand;
		private boolean hasLaidOut;
		private TurnMode turnMode;

		/**
		 * Creates a new TurnInfo instance
		 * 
		 * @param table
		 *          the current table
		 * @param hand
		 *          the current player's hand
		 * @param hasLaidOut
		 *          has the player laid out yet?
		 * @param turnMode
		 *          the turn mode
		 */
		public TurnInfo(ITable table, IHand hand, boolean hasLaidOut,
				TurnMode turnMode) {
			this.table = table;
			this.hand = hand;
			this.hasLaidOut = hasLaidOut;
			this.turnMode = turnMode;
		}

		/**
		 * Gets the current table
		 * 
		 * @return the table
		 */
		public ITable getTable() {
			return table;
		}

		/**
		 * Gets the current player's hand
		 * 
		 * @return the hand
		 */
		public IHand getHand() {
			return hand;
		}

		/**
		 * Returns if the current player has laid out yet
		 * 
		 * @return if the player has laid out
		 */
		public boolean getLaidOut() {
			return hasLaidOut;
		}

		/**
		 * Gets the current turn's mode
		 * 
		 * @return the turn mode
		 */
		public TurnMode getTurnMode() {
			return turnMode;
		}
	}
}