package jrummikub.model;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

/**
 * Mock class for {@link RoundState}
 */
public class MockRoundState implements IRoundState {
	/** */
	public MockTable table;
	/** */
	public ITable setTable;
	/** */
	public List<MockPlayer> players;
	/** */
	public int activePlayer;
	/** */
	public StoneHeap gameHeap;
	/** */
	public IGameSettings gameSettings;

	/** */
	public MockRoundState() {
		table = new MockTable();
		players = new ArrayList<MockPlayer>();
		players.add(new MockPlayer(new PlayerSettings("Player 1", Color.RED)));
		players.add(new MockPlayer(new PlayerSettings("Player 2", Color.YELLOW)));
		players.add(new MockPlayer(new PlayerSettings("Player 3", Color.GREEN)));
		players.add(new MockPlayer(new PlayerSettings("Player 4", Color.BLACK)));
		activePlayer = 0;
		gameHeap = new StoneHeap();
		gameSettings = new GameSettings();
		gameSettings.setInitialMeldThreshold(30);
	}

	@Override
	public ITable getTable() {
		return table;
	}

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

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

	@Override
	public IPlayer getActivePlayer() {
		return players.get(activePlayer);
	}

	@Override
	public StoneHeap getGameHeap() {
		return gameHeap;
	}

	@Override
	public IPlayer getNthNextPlayer(int i) {
		return players.get((activePlayer + i) % players.size());
	}

	@Override
	public void setTable(ITable table) {
		setTable = table;
	}

	@Override
	public IGameSettings getGameSettings() {
		return gameSettings;
	}
}
