package sfs3.extensions.examples.tictactoe.handlers;

import com.smartfoxserver.bitswarm.data.TransportType;
import com.smartfoxserver.entities.User;
import com.smartfoxserver.entities.data.ISFSObject;
import com.smartfoxserver.extensions.BaseClientRequestHandler;

import sfs3.extensions.examples.tictactoe.TicTacToeExtension;

/**
 * This handler receives the "restart" request from a player after the game end.
 */
public class RestartHandler extends BaseClientRequestHandler
{
	@Override
	public void handleClientRequest(User user, ISFSObject params, TransportType type)
	{
		TicTacToeExtension gameExt = (TicTacToeExtension) getParentExtension();
		
		// Check if two players are available and start game
		if (gameExt.getParentRoom().getSize().getUserCount() == 2)
			gameExt.startGame();
	}
}
