public void testCreatesItemMenuWithItemsCorrectly() {
    _player.addItem(Item.BLOCKABALL);
    _player.addItem(Item.HEALVIAL);
    JMenu menu = _constructor.createItemMenu();
    assertNameAndText(menu, "Items", "Items");

    assertEquals("Number of menus was not correct", 3, menu.getItemCount());

    assertAllItemsHaveNames(menu);

    JMenuItem blockaballItemMenu = getWithName(menu, "BLOCKABALL");
    assertNotNull("Blockaball item menu was not added", blockaballItemMenu);
    assertEquals("Blockaball text was not right", "Blockaball", blockaballItemMenu.getText());
    assertNotNull("Blockaball action was not set", blockaballItemMenu.getAction());
    assertEquals(ItemAction.class, blockaballItemMenu.getAction().getClass());

    JMenuItem healVialItemMenu = getWithName(menu, "HEALVIAL");
    assertNotNull("HealVial item menu was not added", healVialItemMenu);
    assertEquals("HealVial text was not right", "Heal Vial", healVialItemMenu.getText());
    assertNotNull("HealVial action was not set", healVialItemMenu.getAction());
    assertEquals(ItemAction.class, healVialItemMenu.getAction().getClass());

    JMenuItem backItemMenu = getWithName(menu, "Back");
    assertNotNull("Back item menu was not added", backItemMenu);
    assertEquals("Back item text was not right", "Back", backItemMenu.getText());
    assertNotNull("Back action was not set", backItemMenu.getAction());
    assertEquals(BackAction.class, backItemMenu.getAction().getClass());
  }
예제 #2
0
 // determines whether the player is within the grass or not
 public void blockAppear() {
   // if the player is within the bounds of the grass
   if (wildGrass.getAppearanceData().contains(player.getAppearanceData())) {
     // does a wildBlockamon appear?
     wildGrass.wildBlockamonAppearance(
         player.getActiveBlockamon(), player.getX() + player.getWidth(), player.getY());
   }
 }
예제 #3
0
 // creates the player
 private Player createPlayer() {
   IPlayerCreator playerCreator = new PlayerCreator();
   Player player = playerCreator.createNewPlayer();
   generateStartingBlockamon(player);
   player.setLocation(playerXStartingLocation, playerYStartingLocation);
   final String message =
       String.format(_receivedMessageFormat, player.getLeadBlockamon().elementType());
   displayDialog(message, "Block received", JOptionPane.INFORMATION_MESSAGE);
   return player;
 }
  public void testCreatesBlockamonMenuCorrectly() {
    Blockamon blockamon = new Blockamon(ElementType.BUG);
    _player.addToParty(blockamon);
    JMenu menu = _constructor.createBlockamonMenu();

    assertNameAndText(menu, "Blockamon", "Blockamon");

    assertEquals("Number of menu items was not correct", 2, menu.getItemCount());

    JMenuItem blockamonMenuItem = menu.getItem(0);
    assertNameAndText(
        blockamonMenuItem,
        blockamon.elementType() + "0",
        blockamon.name()
            + ", "
            + blockamon.level()
            + ", "
            + blockamon.currentHp()
            + "/"
            + blockamon.maxHp());
    assertNotNull("Blockamon menu action not set", blockamonMenuItem.getAction());
    assertEquals(BlockamonAction.class, blockamonMenuItem.getAction().getClass());

    JMenuItem backItemMenu = menu.getItem(1);
    assertNotNull("Back item menu was not added", backItemMenu);
    assertEquals("Back item text was not right", "Back", backItemMenu.getText());
    assertNotNull("Back action was not set", backItemMenu.getAction());
    assertEquals(BackAction.class, backItemMenu.getAction().getClass());
  }
예제 #5
0
  public void run() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    player = createPlayer();
    playingField.add(player);
    createItemShop();
    createHealingCenter();
    createGrass();
    menu =
        new ControlPanel(
            getPlayer(),
            createSaveWriter(_fileFilter),
            createSaveLoader(_fileFilter),
            getItemShop(),
            getHealingCenter(),
            new WindowDisplay());

    add(menu, BorderLayout.NORTH);
    add(playingField, BorderLayout.CENTER);
    pack();
    player.setVisible(true);
    this.addKeyListener(new KeyListen(this, menu));
    setVisible(true);
    this.repaint();
  }
예제 #6
0
 public void changePlayerImage(Direction direction) {
   player.changeImage(direction);
 }
예제 #7
0
 // moves the player
 public void movePlayer(char aKey) {
   // tells the player to move
   System.out.println("Moving player");
   player.movePlayer(aKey, this.getWidth(), this.getHeight());
 }
예제 #8
0
 public boolean isInHealingStation() {
   return healingCenter.getAppearanceData().contains(player.getAppearanceData());
 }
예제 #9
0
 public boolean isInStore() {
   return itemShop.getAppearanceData().contains(player.getAppearanceData());
 }
예제 #10
0
 // player loses a battle and all blockamon in their party have lost all HealthPoints
 public void playerWhitedOut() {
   player.setLocation(healingCenter.getX(), healingCenter.getY());
   player.healAllBlockamon();
   player.loseMoney();
   playingField.repaint();
 }
예제 #11
0
 private void generateStartingBlockamon(Player player) {
   player.setLeadBlockamon(BlockamonGenerator.generateRandomBlockamon());
 }