Beispiel #1
0
  public void testPlayerMayNotMoveToOccupiedHallway() {
    // GIVEN
    // a GameBoard with Professor Plum on his start spot
    // and some other player is on the hallway he must move to
    CluePlayer profPlum = new CluePlayer();
    profPlum.setClueCharacter(ClueCharacter.ProfPlum);
    profPlum.setLocation(profPlum.getClueCharacter().getName());

    CluePlayer msScarlet = new CluePlayer();
    msScarlet.setClueCharacter(ClueCharacter.MsScarlett);
    msScarlet.setLocation("Library-Study");

    List<CluePlayer> players = new Vector<CluePlayer>();
    players.add(profPlum);
    players.add(msScarlet);

    GameBoard gameBoard = new GameBoard(players);

    // WHEN
    // system asks GameBoard where professor plum may move
    List<GameBoardSpace> possibleMoves = gameBoard.getPossibleMoves(profPlum);

    // THEN
    // GameBoard says there are no possible spaces
    assertEquals(0, possibleMoves.size());
  }
Beispiel #2
0
  public void testPlayerMayNotMoveFromHallwayToStartSpace() {
    // GIVEN
    // a game board with Professor Plum at the hallway adjacent to his start spot
    CluePlayer profPlum = new CluePlayer();
    profPlum.setClueCharacter(ClueCharacter.ProfPlum);
    profPlum.setLocation(profPlum.getClueCharacter().getName());

    List<CluePlayer> players = new Vector<CluePlayer>();
    GameBoard board = new GameBoard(players);

    // WHEN
    // system asks is plum may go to start space
    boolean canTravelToStartSpace =
        board.isPlayerAbleToMoveToSpace(profPlum, board.getSpaceById(ClueCharacter.ProfPlumID));

    // THEN
    assertFalse(canTravelToStartSpace);
  }
Beispiel #3
0
  public void testProfPlumMayMoveFromStartToHallway() {
    // GIVEN
    // a game board with Professor Plum at his start spot
    CluePlayer profPlum = new CluePlayer();
    profPlum.setClueCharacter(ClueCharacter.ProfPlum);
    profPlum.setLocation(profPlum.getClueCharacter().getName());

    List<CluePlayer> players = new Vector<CluePlayer>();
    GameBoard gameBoard = new GameBoard(players);

    // WHEN
    // system asks board where Plum can go
    List<GameBoardSpace> possibleMoves = gameBoard.getPossibleMoves(profPlum);

    // THEN
    // board returns HallwaySpace between Study and Library
    assertEquals(1, possibleMoves.size());
    assertEquals("Library-Study", possibleMoves.get(0).getSpaceId());
  }
Beispiel #4
0
  public void testPlayerMayUseSecretPassage() {
    // GIVEN
    // a GameBoard where professor plum is in the study
    CluePlayer profPlum = new CluePlayer();
    profPlum.setClueCharacter(ClueCharacter.ProfPlum);
    profPlum.setLocation(Room.STUDY);

    List<CluePlayer> players = new Vector<CluePlayer>();
    players.add(profPlum);
    GameBoard gameBoard = new GameBoard(players);

    // WHEN
    // system asks if professor plum may move to kitchen a la passage
    boolean mayMoveToConservatory =
        gameBoard.isPlayerAbleToMoveToSpace(profPlum, gameBoard.getSpaces().get(Room.KITCHEN));

    // THEN
    // GameBoard says yes
    assertTrue(mayMoveToConservatory);
  }