/*
 *   Author: Florian Fink, 2014
 *   Based on Code by: veqryn
 *   
 *   This project is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
 *
 *   This project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License along with this project. If not, see http://www.gnu.org/licenses/.
 */
package usergames.othello;

import games.strategy.engine.framework.IGameLoader;
import games.strategy.engine.gamePlayer.IGamePlayer;
import games.strategy.grid.GridGame;
import games.strategy.grid.player.GridGamePlayer;
import games.strategy.grid.ui.GridGameFrame;
import games.strategy.grid.ui.GridGameMenu;
import games.strategy.grid.ui.GridMapData;
import games.strategy.grid.ui.GridMapPanel;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * The loader class for Othello 
 */
public class Othello extends GridGame implements IGameLoader{

	private static final long serialVersionUID = -2545893358753309263L;
	private static final String HUMAN_PLAYER_TYPE = "Human";
	private static final String RANDOM_COMPUTER_PLAYER_TYPE = "Random AI";
	
	@Override
	public Set<IGamePlayer> createPlayers(Map<String, String> players) {
		final Set<IGamePlayer> iplayers = new HashSet<IGamePlayer>();
		for (final String name : players.keySet())
		{
			final String type = players.get(name);
			if (type.equals(HUMAN_PLAYER_TYPE) || type.equals(CLIENT_PLAYER_TYPE))
			{
				final GridGamePlayer player = new GridGamePlayer(name, type);
				iplayers.add(player);
			}
			
			else if (type.equals(RANDOM_COMPUTER_PLAYER_TYPE))
			{
				final RandomOthelloAI ai = new RandomOthelloAI(name, type);
				iplayers.add(ai);
			}
			
			else
			{
				throw new IllegalStateException("Player type not recognized:" + type);
			}
		}
		return iplayers;
	}

	@Override
	public String[] getServerPlayerTypes() {
		return new String[] { HUMAN_PLAYER_TYPE,RANDOM_COMPUTER_PLAYER_TYPE};
	}

	@Override
	protected Class<? extends GridMapData> getGridMapDataClass() {
		return GridMapData.class;
	}

	@Override
	protected Class<? extends GridMapPanel> getGridMapPanelClass() {
		return OthelloMapPanel.class;
	}

	@Override
	protected Class<? extends GridGameMenu<GridGameFrame>> getGridTableMenuClass(){
		return OthelloMenu.class;
	}

	@Override
	public int getSquareWidth()
	{
		return 40;
	}
	
	@Override
	public int getSquareHeight()
	{
		return 40;
	}
	
	@Override
	public int getBevelSize()
	{
		return 30;
	}
	

}