Package org.scotlandyard.engine

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


   * @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

 
  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

      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

   * </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

  }
 
  @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

  }

  @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

   * @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

        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

  }

  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

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.