Package org.scotlandyard.engine.boardmap

Examples of org.scotlandyard.engine.boardmap.Coordinate


    return players;
  }

  @Override
  public Set<Coordinate> getPosssibleMoves(final Player player) {
    final Coordinate coordinate = getPlayerPosition(player);
    final Set<Link> links = boardMap.getLinks(coordinate);
    final Set<Coordinate> positions = new HashSet<Coordinate>();
    for (final Link link : links) {
      positions.add(link.getOtherEnd(coordinate));
    }
View Full Code Here


    }
    if(!playerPosition.getPosition().getBoardMap().equals(this.getBoardMap())){
      throw new GameException("the map of the position ["+playerPosition.getPosition().getBoardMap().getName()+"] is different from the map of the game ["+this.getBoardMap().getName()+"]");
    }

    final Coordinate coordinate = playerPosition.getPosition();
    final Player player = this.getWhoOccupiesPosition(coordinate);

    if(player!=null){
      if(!getMrX().equals(player)){
        throw new GameException("this position has been already occupied by other detective");
View Full Code Here

      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

    return false;
  }
 
  @Override
  public Coordinate getEmptyPosition() {
    Coordinate result=null;
    if(this.playerPositions.size()==this.getBoardMap().getCoordinates().size()){
      return result;
    }
    Iterator<Coordinate>it = this.getBoardMap().getCoordinates().iterator();
    while(result==null){
View Full Code Here

    {
      nodeMap = coords.item(i).getAttributes();

      final double lng = Double.parseDouble(nodeMap.getNamedItem("lng").getNodeValue());
      final double lat = Double.parseDouble(nodeMap.getNamedItem("lat").getNodeValue());
      final Coordinate coord = new CoordinateImpl(this, lng, lat);

      coord.setLabel(nodeMap.getNamedItem("id").getNodeValue());
      /// specification add colour
      coordinates.put(coord.getLabel(),coord);
    }

    final NodeList linkList = doc.getElementsByTagName("link");
    for(int i=0; i < linkList.getLength();i++)
    {
View Full Code Here

    return coordinateB;
  }

  @Override
  public Coordinate getOtherEnd(final Coordinate coordinate) {
    Coordinate temp = null;
    if(coordinate.equals(coordinateA)) {
      temp =  coordinateB;
    } else if(coordinate.equals(coordinateB)){
      temp = coordinateA;
    }
View Full Code Here

    @Override
    public boolean useTokenToMove(final Game game, final Token token, final Link link) throws GameException {
      token.consumeTicket();
      //current position
      final Coordinate position = this.getPosition(game);
      //new position
      final Coordinate toPosition = link.getOtherEnd(position);
      //set the new position
      this.setPosition(game, toPosition);
      //trigger the event move is made
        moveMade(game);
        //if the new position is registered, then everything is fine
View Full Code Here

    GameEngine.instance().getBoardMaps().remove("Auckland");
  }

  @Test  //TODO add description of what the test should do
  public final void testCompareTo() throws Exception{
    Coordinate coordinate2 = new CoordinateImpl(boardMap, latitude, longtitude);
    Assert.assertEquals(coordinate2.compareTo(coordinate),0);
  }
View Full Code Here

    Assert.assertEquals(coordinate2.compareTo(coordinate),0);
  }

  @Test(expected=Exception.class)//TODO add description of what the test should do
  public final void testCoordinateImpl() throws Exception{
    Coordinate c = new CoordinateImpl(null,0,0);
    assertNull(c);
  }
View Full Code Here

    assertNull(c);
  }

  @Test  //TODO add description of what the test should do
  public final void testEqualsObject() throws Exception {
    Coordinate coordinate2 = new CoordinateImpl(boardMap, latitude, longtitude);
    Assert.assertTrue(coordinate2.equals(coordinate));

    Coordinate coordinate3 = new CoordinateImpl(boardMap2, latitude, longtitude);
    Assert.assertFalse(coordinate3.equals(coordinate));
    Assert.assertFalse(coordinate3.equals(coordinate2));

    Coordinate coordinate4 = new CoordinateImpl(boardMap2, latitude, longtitude);
    Assert.assertTrue(coordinate3.equals(coordinate4));

    Assert.assertNotSame(coordinate2.getBoardMap(),coordinate3.getBoardMap());
  }
View Full Code Here

TOP

Related Classes of org.scotlandyard.engine.boardmap.Coordinate

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.