Ejemplo n.º 1
0
  /** Start the game and interacts with the player for each dungeon */
  public void start() {
    for (int i = 0; i < dungeons.size(); i++) {
      currentDungeon = dungeons.get(i);
      System.out.println("Welcome to the dungeon number " + (i + 1));
      do {
        System.out.println("What do you want to do?");
        System.out.print("> ");
        currentDungeon.interpretCommand(scanner.nextLine().toLowerCase());

      } while (!gameIsFinished());
      if (gameIsWon()) {
        System.out.println("You win the dungeon number" + (i + 1) + " !");
        if (i == dungeons.size() - 1) {
          System.out.println("Congratulation, you've completed all the dungeons !");
        }
      } else {
        System.out.println("You loose!");
        break;
      }
    }
  }
Ejemplo n.º 2
0
 @Test
 public void testInterpretCommand() {
   assertEquals(dungeon.rooms[0], dungeon.currentRoom);
   dungeon.interpretCommand("go north");
   assertEquals(dungeon.rooms[1], dungeon.currentRoom);
 }