Examples of GameException


Examples of org.scotlandyard.engine.GameException


  @Override
  public void setPlayerPosition(final String playerEmail, final String coordinateLabel) throws GameException{
    if(gameStatus!=GameStatus.JUST_CREATED){
      throw new GameException("this method can be used to set players positions before the game has started only");
    }
    if(getPlayer(playerEmail)==null){
      throw new GameException("can not find player ["+playerEmail+"]");
    }
    if(this.getBoardMap()==null){
      throw new GameException("the map has not been set yet");
    }
    final Coordinate coordinate = this.getBoardMap().getCoordinate(coordinateLabel);
    if(coordinate==null){
      throw new GameException("can not find coordinate ["+coordinateLabel+"]");
    }
    final PlayerPosition playerPosition=new PlayerPositionImpl(this, this.getPlayer(playerEmail), this.boardMap.getCoordinate(coordinateLabel));
    this.setPlayerPosition(playerPosition);
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

   * @param user
   * @throws GameException
   */
  public void loginUser(final User user) throws GameException{
    if(user==null){
      throw new GameException("can not add user who is null");
    }
    if(this.getUser(user.getEmail())!=null){
      throw new GameException("this user is already added to the list");
    }
    this.users.put(user.getEmail(), user);
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

   * @throws GameException
   */
  public String startGame(final Game game) throws GameException{
       
        if(game==null){
            throw new GameException("Game can not be found");
        }
       
        if(game.getMrX()==null){
          throw new GameException("Game must have MrX to start");
        }
       
        if(game.getDetectives().size()==0){
          throw new GameException("Game must have at least one detective");
        }
       
       
        game.setGameStatus(GameStatus.STARTED);
       
View Full Code Here

Examples of org.scotlandyard.engine.GameException

   * @throws GameException if the name is not specified
   */
  private BoardMapImpl(final String mapName) throws GameException{
    super();
    if(mapName==null){
      throw new GameException("map name must be specified");
    }
    name = mapName;
    links = new HashSet<Link>();
    coordinates = new HashMap<String, Coordinate>();
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  }

  @Override
  public void consumeTicket() throws GameException{
    if(tickets==0){
      throw new GameException("There is no more tickets of type "+getTransportationMethod().toString()+" to consume");
    }
    --this.tickets;
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

   * @throws GameException if the boardMap is not specified
   */
  public CoordinateImpl(final BoardMap boardMap,final double latitude,final double longtitude) throws GameException{
                super();
    if(boardMap==null){
      throw new GameException("BoardMap must be specified first");
    }
    this.latitude=latitude;
    this.longtitude=longtitude;
    this.boardMap=boardMap;
    this.label=boardMap.getName()+":Coordinate["+latitude+","+longtitude+"]";
View Full Code Here

Examples of org.scotlandyard.engine.GameException

 
  private static BoardMap defaultBoardMap;

  public static BoardMap createBoardMap(final String name) throws GameException{
    if(name==null){
      throw new GameException("Board Map name can not be null");
    }
    BoardMap boardMap = GameEngine.instance().getBoardMaps().get(name);
    if(boardMap==null){
      boardMap = BoardMapImpl.getNewInstance(name);
    }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

      final TransportationMethod transportation,
      final Coordinate coordinateA,
      final Coordinate coordinateB) throws GameException{
    super();
    if(boardMap==null){
      throw new GameException("BoardMap must be specified");
    }
    if(transportation==null){
      throw new GameException("TransportationMethod must be specified");
    }
    if(coordinateA==null){
      throw new GameException("coordinateA must be specified");
    }
    if(coordinateB==null){
      throw new GameException("coordinateB must be specified");
    }



    if(!coordinateA.getBoardMap().equals(coordinateB.getBoardMap())){
      //      System.out.println(coordinateA.getBoardMap());
      //      System.out.println(coordinateB.getBoardMap());
      throw new GameException("coordinateA and coordinateB must be from the same Board Map ");
    }
    if(!boardMap.equals(coordinateB.getBoardMap())){
      throw new GameException("coordinateA and coordinateB Board Map has to be the same as the link BoardMap");
    }

    this.boardMap=boardMap;
    this.transportation = transportation;
    if(coordinateA.compareTo(coordinateB)<0){
View Full Code Here

Examples of org.scotlandyard.engine.GameException

   * </ul>
   */
  public PlayerPositionImpl(final Game game,final Player player,final Coordinate coordinate) throws GameException{
    super();
    if(game==null){// || player==null || coordinate==null){
      throw new GameException("Game has not been initialized");
    }
    if(player==null){
      throw new GameException("Player has not been initialized");
    }
    if(coordinate==null){
      throw new GameException("Position has not been initialized");
    }
    if(game.getBoardMap()==null){
      throw new GameException("the map has not been specified for the game object");
    }
    if(coordinate.getBoardMap()==null){
      throw new GameException("the map has not been specified for the coordinate object");
    }
    if(!game.getBoardMap().equals(coordinate.getBoardMap())){
      throw new GameException("the map for the game has to be the same as the map for the coordinate");
    }
    this.game=game;
    this.player=player;
    this.position=coordinate;
  }
View Full Code Here

Examples of org.scotlandyard.engine.GameException

  }
 
  @Override
  public void addGame(final Game game) throws GameException {
    if (game == null) {
      throw new GameException("Can not add game, argument is null ");
    }
    if (games.get(game.getIdentifier()) != null) {
      throw new GameException("Game identifier is already used. [" + games.get(game.getIdentifier()).toString()+"]");
    }
    games.put(game.getIdentifier(), game);
    if (games.get(game.getIdentifier()) == null) {
      throw new GameException("Can not add game, unkown defect");
    }
  }
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.