package sfs2x.extensions.games.tictactoe.handlers;

import sfs2x.extensions.games.tictactoe.TicTacToeExtension;

import com.smartfoxserver.v2.core.ISFSEvent;
import com.smartfoxserver.v2.exceptions.SFSException;
import com.smartfoxserver.v2.extensions.BaseServerEventHandler;

/**
 * This handler receives the signal that a spectator turned into a player.
 */
public class OnSpectatorToPlayerHandler extends BaseServerEventHandler
{
	@Override
	public void handleServerEvent(ISFSEvent event) throws SFSException
	{
		TicTacToeExtension gameExt = (TicTacToeExtension) getParentExtension();
		
		// Check if two players are available and start game
		if (gameExt.getParentRoom().getSize().getUserCount() == 2)
			gameExt.startGame();
	}
}
