package sfs2x.extensions.games.tictactoe.handlers;

import sfs2x.extensions.games.tictactoe.TicTacToeExtension;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;

/**
 * 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)
	{
		TicTacToeExtension gameExt = (TicTacToeExtension) getParentExtension();
		
		// Check if two players are available and start game
		if (gameExt.getParentRoom().getSize().getUserCount() == 2)
			gameExt.startGame();
	}
}
