Package org.scotlandyard.engine

Examples of org.scotlandyard.engine.GameException


             final HttpServletRequest request,
            final GameEngine engine) throws GameException {

    final String gameId=request.getParameter("gameId");
    if(gameId==null || "".equals(gameId.trim())){
      throw new GameException("Game id can not be null");
    }
    game = GameEngine.instance().getLobby().getGame(gameId);
    if(game==null){
      throw new GameException("Game ["+gameId+"] can not be found");
    }
  }
View Full Code Here


            final GameEngine engine) throws GameException {

    final String gameId=request.getParameter("gameId");

    if(gameId==null||"".equals(gameId.trim())){
      throw new GameException("Game id can not be null");
    }
    game = GameEngine.instance().getLobby().getGame(gameId);

  }
View Full Code Here

            final GameEngine engine) throws GameException {

    final String gameId = request.getParameter("gameId");

    if(gameId==null || "".equals(gameId)){
      throw new GameException("Game identifier has not been selected");
    }

    String playerEmail = GameEngine.instance().getUsers().get(getSessionId()).getEmail();


    final Game game =  engine.getLobby().getGame(gameId);
    if(!game.removePlayer(playerEmail)){
      throw new GameException("Player could not be removed");
    }

  }
View Full Code Here


    user = engine.getUsers().get(getSessionId());

    if(user==null){
      throw new GameException("user can not be null");
    }

    //TODO remove this code to allow creation of
    // more than one game in the future
    if(engine.getLobby().getAvailableGames().size()>=1){
      throw new GameException("Can not create more than one game at the moment, will add this feature later");
    }

    String gameId = request.getParameter("gameId");
    String mapId  = request.getParameter("mapName");

    //out.println(gameId);

    if(gameId==null || "".equals(gameId)){
      throw new GameException("game identifier can not be null");
    }

    if(mapId==null || "".equals(mapId)){
      throw new GameException("map can not be null");
    }

    final BoardMap boardMap = engine.getNewBoardMap(mapId);

    //TODO change this to be dynamic map
View Full Code Here

  public void validateRequest(
       final HttpServletRequest request,
      final GameEngine engine) throws GameException {

    if(engine.getUsers().get(getSessionId())==null){
      throw new GameException("user could not be found in the engine");
    }



  }
View Full Code Here

        final GameEngine engine) throws GameException {

    try{
      playerRole = PlayerRole.valueOf(request.getParameter("role"));
    }catch(Exception ex){
      throw new GameException("playing role is not recognized");
    }

    String gameId = request.getParameter("gameId");
    if(gameId==null){
      throw new GameException("gameId is null");
    }

    game = engine.getLobby().getGame(gameId);

    if(game==null){
      throw new GameException("game is not found");
    }

    user = (User)engine.getUsers().get(getSessionId());
    if(user==null){
      throw new GameException("user is null");
    }

    if(game.hasPlayer(user.getEmail()))
    {
      throw new GameException("you are already playing a game");
    }

    if(playerRole==PlayerRole.MrX && game.getMrX()!=null){
      throw new GameException("MrX player has been taken by someone else");
    }
    else if(playerRole==PlayerRole.Detective  && game.getDetectives().size()>=GameEngine.MIXIMUM_NUMBER_OF_DETECTIVES){
        throw new GameException("Sorry, this game is full. try to create another game and play with someone else");
    }

    final Player player;

    if(playerRole==PlayerRole.MrX){
View Full Code Here

    email = request.getParameter("email");
    name  = request.getParameter("name");

    if(email==null || "".equals(email.trim())){
      throw new GameException("email is not provided");
    }

    if(name==null || "".equals(name.trim())){
      throw new GameException("name is not provided");
    }

    user = engine.getUsers().get(getSessionId());

    if(user!=null){
      throw new GameException("user name is not null");
    }

    user = engine.getUser(email);

    if(user!=null){
      throw new GameException("this email is already in use now, try to login by another email");
    }


  }
View Full Code Here

    final String transportationMethod=request.getParameter("transportationMethod");

    final Game game = engine.getLobby().getGame(gameId);

    if(game.isPlayable()==false){
      throw new GameException("the game is still not playable.");
    }

    String position = game.getPlayerPosition(playerEmail);
    Player player=game.getPlayer(playerEmail);
View Full Code Here

TOP

Related Classes of org.scotlandyard.engine.GameException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.