// Path: server/brownshome/scriptwars/server/Server.java
// public class Server {
// 	public static final Logger LOG = Logger.getLogger("brownshome.scriptwars.server");
// 	
// 	private static volatile boolean stop = false;
// 	
// 	public static void initialize() {
// 		try {
// 			GameType.addType(TankGame.class, Difficulty.EASY);
// 		} catch (GameCreationException gce) {
// 			Server.LOG.log(Level.SEVERE, "Improperly built game files.", gce);
// 		}
// 	}
// 	
// 	public static Collection<GameType> getGames() {
// 		return GameType.getGameTypes();
// 	}
// 
// 	public static void shutdown() {
// 		stop = true;
// 		UDPConnectionHandler.instance().closeConnectionHandler();
// 		TCPConnectionHandler.instance().closeConnectionHandler();
// 		MemoryConnectionHandler.instance().closeConnectionHandler();
// 	}
// 	
// 	public static boolean shouldStop() {
// 		return stop;
// 	}
// }


import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Function;
import java.util.logging.Level;
import brownshome.scriptwars.connection.*;
import brownshome.scriptwars.server.Server;
		
		if(!playerIDPool.isRequested(player.getSlot())) {
			throw new InvalidIDException();
		}
		
		playerIDPool.makeActive(player.getSlot());
		players[player.getSlot()] = player;
		
		activePlayers.add(player);
		
		if(state == GameState.WAITING && !isJudgeGame)
			start();
		
		if(isJudgeGame) {
			synchronized(this) {
				notifyAll();
			}
		}
		
		onPlayerChange();
	}
	
	/** This is the main method that is called from the game thread
	 * 
	 *  This method is synchronised on the game object, making it so that no network operations can occur while the game is not sleeping
	 * 
	 *  FOR INTERNAL USE ONLY */
	private synchronized void gameLoop() {
		int tickCount = 0;

// Path: server/brownshome/scriptwars/server/Server.java
// public class Server {
// 	public static final Logger LOG = Logger.getLogger("brownshome.scriptwars.server");
// 	
// 	private static volatile boolean stop = false;
// 	
// 	public static void initialize() {
// 		try {
// 			GameType.addType(TankGame.class, Difficulty.EASY);
// 		} catch (GameCreationException gce) {
// 			Server.LOG.log(Level.SEVERE, "Improperly built game files.", gce);
// 		}
// 	}
// 	
// 	public static Collection<GameType> getGames() {
// 		return GameType.getGameTypes();
// 	}
// 
// 	public static void shutdown() {
// 		stop = true;
// 		UDPConnectionHandler.instance().closeConnectionHandler();
// 		TCPConnectionHandler.instance().closeConnectionHandler();
// 		MemoryConnectionHandler.instance().closeConnectionHandler();
// 	}
// 	
// 	public static boolean shouldStop() {
// 		return stop;
// 	}
// }


// Path: server/brownshome/scriptwars/game/Game.java
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Function;
import java.util.logging.Level;
import brownshome.scriptwars.connection.*;
import brownshome.scriptwars.server.Server;

		
		if(!playerIDPool.isRequested(player.getSlot())) {
			throw new InvalidIDException();
		}
		
		playerIDPool.makeActive(player.getSlot());
		players[player.getSlot()] = player;
		
		activePlayers.add(player);
		
		if(state == GameState.WAITING && !isJudgeGame)
			start();
		
		if(isJudgeGame) {
			synchronized(this) {
				notifyAll();
			}
		}
		
		onPlayerChange();
	}
	
	/** This is the main method that is called from the game thread
	 * 
	 *  This method is synchronised on the game object, making it so that no network operations can occur while the game is not sleeping
	 * 
	 *  FOR INTERNAL USE ONLY */
	private synchronized void gameLoop() {
		int tickCount = 0;

		while((!isFinite() || tickCount++ < lifeSpan) && !Server.shouldStop()) {