package sfs3.extensions.examples.tictactoe.handlers;

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

import sfs3.extensions.examples.tictactoe.TicTacToeExtension;

/**
 * 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();
	}
}
