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 MockEvent redealEvent = 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 MockEvent1<String> participantLeftEvent = new MockEvent1<String>();
	/** */
	public MockEvent connectionLostEvent = 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;
	/** */
	public boolean startRoundCalled;

	@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 IEvent getRedealEvent() {
		return redealEvent;
	}

	@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 IEvent1<String> getParticipantLeftEvent() {
		return participantLeftEvent;
	}

	@Override
	public IEvent getConnectionLostEvent() {
		return connectionLostEvent;
	}

	@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() {
		startRoundCalled = true;
	}

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

	}

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

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

	}
}
