@Override
  public void activate(Game g) {
    // TODO complete consiliarius
    // Player can pick up all his character cards and lay them again.
    // Dump board to an array...
    // Better idea. Create an array of 6 ints, this will hold the new
    // positions of each card. i.e. array[0] = 4 means that the card at
    // index 0 will be moved to index 4.

    // That seems to cause problems, dump board to an array,read off titles
    // of all those who aren't null (or no card). "Please enter new
    // location for x", stores new index at current index in array. Gives
    // this to player.board.
    super.setUI(g.getUI());
    Player current = g.getCurrentPlayer();
    String[] cardArray = current.dumpBoard();
    int[] newCardLocations = new int[cardArray.length];
    for (int i = 0; i < cardArray.length; i++) {
      if (cardArray[i] == null || super.isBuilding(cardArray[i])) {
        newCardLocations[i] = -1;
      } else {
        System.out.println("Please enter a new location for card " + cardArray[i]);
        newCardLocations[i] = UI.getInt(0, 6);
      }
    }
    current.reshuffleBoard(newCardLocations);
  }
Пример #2
0
  public static void main(String[] args) {
    UI ui = UI.getInstance();
    AnimalManager animalManager = AnimalManager.getInstance();
    animalManager.load();

    int menu = 0;
    do {
      ui.print("[1] List Animals\n[2] Add Animal\n[3] Remove Animal\n[X] Exit\n");

      switch (ui.getInput("").substring(0).toUpperCase()) {
        case "1":
          ui.print("\n");
          ui.print(animalManager);
          ui.print("\n");
          break;

        case "2":
          ui.print("\n");
          animalManager.add(
              new Animal(
                  ui.getInput("Name"),
                  ui.getInt("# of Legs"),
                  ui.getInt("# of Arms"),
                  ui.getInt("# of Tails"),
                  ui.getBool("Burrows[y/N]"),
                  ui.getBool("Swims[y/N]"),
                  ui.getBool("Flies[y/N]")));
          ui.print("\n");
          break;

        case "3":
          ui.print("\nWhich one? (0 to cancel)\n");
          ui.print(animalManager);
          while (!animalManager.remove(ui.getInt(""))) ; // gets user input until valid
          ui.print("\n");
          break;

        case "X":
          menu = -1;
          break;
      }
    } while (menu != -1);
  }