summaryrefslogtreecommitdiffstats
path: root/mock/jrummikub/control/network/MockConnectionControl.java
blob: 8428fd67b0f396d8078d353422700eb4e6075479 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
package jrummikub.control.network;

import java.awt.Color;
import java.util.UUID;

import jrummikub.control.RoundControl.InvalidTurnInfo;
import jrummikub.model.IRoundState;
import jrummikub.model.ITable;
import jrummikub.util.GameData;
import jrummikub.util.IEvent;
import jrummikub.util.IEvent1;
import jrummikub.util.IEvent2;
import jrummikub.util.MockEvent;
import jrummikub.util.MockEvent1;
import jrummikub.util.MockEvent2;
import jrummikub.view.LoginError;

/** */
public class MockConnectionControl implements IConnectionControl {
	/** */
	public String nickname;
	/** */
	public MockEvent connectedEvent = new MockEvent();
	/** */
	public MockEvent1<LoginError> connectionFailedEvent = new MockEvent1<LoginError>();
	/** */
	public MockEvent1<GameData> gameOfferEvent = new MockEvent1<GameData>();
	/** */
	public MockEvent1<UUID> gameWithdrawalEvent = new MockEvent1<UUID>();
	/** */
	public MockEvent1<String> gameJoinEvent = new MockEvent1<String>();
	/** */
	public MockEvent1<String> gameLeaveEvent = new MockEvent1<String>();
	/** */
	public MockEvent1<Boolean> gameJoinAckEvent = new MockEvent1<Boolean>();
	/** */
	public MockEvent2<String, Color> changeColorEvent = new MockEvent2<String, Color>();
	/** */
	public MockEvent gameStartEvent = new MockEvent();
	/** */
	public MockEvent roundStartEvent = new MockEvent();
	/** */
	public MockEvent1<ITable> tableUpdateEvent = new MockEvent1<ITable>();
	/** */
	public MockEvent2<IRoundState, InvalidTurnInfo> turnEndEvent = new MockEvent2<IRoundState, InvalidTurnInfo>();
	/** */
	public MockEvent1<IRoundState> roundStateUpdateEvent = new MockEvent1<IRoundState>();
	/** */
	public MockEvent nextPlayerEvent = new MockEvent();
	/** */
	public MockEvent turnStartEvent = new MockEvent();
	/** */
	public GameData currentGame;
	/** */
	public GameData offeredGame;
	/** */
	public boolean connected;
	/** */
	public boolean failOnConnect;
	/** */
	public GameData joinedGame;
	/** */
	public Color playerColor;
	/** */
	public boolean turnStarted;
	/** */
	public boolean turnEnded;
	/** */
	public boolean nextPlayer;

	@Override
	public String getNickname() {
		return nickname;
	}

	@Override
	public void connect() {
		if (failOnConnect) {
			connectionFailedEvent.emit(LoginError.UNKNOWN_ERROR);
		} else {
			connected = true;
			connectedEvent.emit();
		}
	}

	@Override
	public void disconnect() {
		connected = false;
	}

	@Override
	public IEvent getConnectedEvent() {
		return connectedEvent;
	}

	@Override
	public IEvent1<LoginError> getConnectionFailedEvent() {
		return connectionFailedEvent;
	}

	@Override
	public IEvent1<GameData> getGameOfferEvent() {
		return gameOfferEvent;
	}

	@Override
	public IEvent1<UUID> getGameWithdrawalEvent() {
		return gameWithdrawalEvent;
	}

	@Override
	public IEvent1<String> getGameJoinEvent() {
		return gameJoinEvent;
	}

	@Override
	public IEvent1<String> getGameLeaveEvent() {
		return gameLeaveEvent;
	}

	@Override
	public IEvent1<Boolean> getGameJoinAckEvent() {
		return gameJoinAckEvent;
	}

	@Override
	public IEvent2<String, Color> getChangeColorEvent() {
		return changeColorEvent;
	}

	@Override
	public IEvent getGameStartEvent() {
		return gameStartEvent;
	}

	@Override
	public IEvent getRoundStartEvent() {
		return roundStartEvent;
	}

	@Override
	public IEvent1<ITable> getTableUpdateEvent() {
		return tableUpdateEvent;
	}

	@Override
	public IEvent2<IRoundState, InvalidTurnInfo> getTurnEndEvent() {
		return turnEndEvent;
	}

	@Override
	public IEvent getTurnStartEvent() {
		return turnStartEvent;
	}

	@Override
	public IEvent1<IRoundState> getRoundStateUpdateEvent() {
		return roundStateUpdateEvent;
	}

	@Override
	public IEvent getNextPlayerEvent() {
		return nextPlayerEvent;
	}

	@Override
	public void offerGame(GameData data) {
		offeredGame = data;
	}

	@Override
	public void withdrawGame() {
		// TODO Auto-generated method stub
	}

	@Override
	public GameData getCurrentGame() {
		return currentGame;
	}

	@Override
	public void setCurrentGame(GameData game) {
		currentGame = game;
	}

	@Override
	public void joinGame(GameData game) {
		currentGame = game;
		joinedGame = game;
	}

	@Override
	public void leaveGame() {
		// TODO Auto-generated method stub

	}

	@Override
	public void ackJoinGame(String recipient, boolean ack) {
		// TODO Auto-generated method stub

	}

	@Override
	public void changeColor(Color color) {
		playerColor = color;
	}

	@Override
	public void startGame() {
		// TODO Auto-generated method stub

	}

	@Override
	public void updateTable(ITable table) {
		// TODO Auto-generated method stub

	}

	@Override
	public void endTurn(IRoundState state, InvalidTurnInfo invalidTurnInfo) {
		turnEnded = true;
	}

	@Override
	public void startTurn() {
		turnStarted = true;
	}

	@Override
	public void startRound() {
		// TODO Auto-generated method stub

	}

	@Override
	public void updateRoundState(IRoundState roundState) {
		// TODO Auto-generated method stub

	}

	@Override
	public void nextPlayer() {
		nextPlayer = true;
	}
}