Examples of GameException


Examples of org.scotlandyard.engine.GameException

  }

  @Override
  public void removeGame(final String gameId) throws GameException {
    if (gameId == null || games.get(gameId) == null) {
      throw new GameException(
          "Can not remove game, argument is null or not found in the collection");
    }
    games.remove(gameId);
    if (games.get(gameId) != null) {
      throw new GameException("Can not remove game, unkown defect");
    }
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

   * @throws GameException
   */
  public JsonPlayer(Player player,Game game) throws GameException{
    this();
    if(player==null){
      throw new GameException("player can not be null");
    }
    if(game==null){
      throw new GameException("game can not be null");
    }
    if(game.hasPlayer(player.getEmail())==false){
      throw new GameException("this player is not a memeber of the supplied game");
    }
    if(player.getPosition(game)==null){
      throw new GameException("this player position is unnkown");
    }
    this.name=player.getName();
    this.email=player.getEmail();
    this.position=player.getPosition(game).getLabel();
    this.hasTurn=player.equals(game.getTurn());
View Full Code Here

Examples of org.scotlandyard.engine.GameException

        final GameEngine engine) throws GameException {

    final GamePlayersJsonContainer gpjc = new GamePlayersJsonContainer();

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

    if(game.getMrX()!=null){
      gpjc.mrx=getJsonPlayer(game.getMrX(), game);
    }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  }

  public JsonPlayer getJsonPlayer(Player player,Game game) throws GameException{
    JsonPlayer jsonPlayer = new JsonPlayer();
    if(player==null){
      throw new GameException("player can not be null");
    }
    if(game==null){
      throw new GameException("game can not be null");
    }
    if(game.hasPlayer(player.getEmail())==false){
      throw new GameException("this player is not a memeber of the supplied game");
    }
    if(player.getPosition(game.getIdentifier())==null){
      throw new GameException("this player position is unnkown");
    }
    jsonPlayer.name=player.getName();
    jsonPlayer.email=player.getEmail();
    jsonPlayer.position=player.getPosition(game.getIdentifier());
    jsonPlayer.hasTurn=player.getEmail().equals(game.getWhoIsTurnPlayerEmail());
View Full Code Here

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

Examples of org.scotlandyard.engine.GameException

            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

Examples of org.scotlandyard.engine.GameException

            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

Examples of org.scotlandyard.engine.GameException


    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

Examples of org.scotlandyard.engine.GameException

  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

Examples of org.scotlandyard.engine.GameException

        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
TOP
Copyright © 2018 www.massapi.com. 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.