コード例 #1
0
  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
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 // 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
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 // 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;
 }
コード例 #4
0
  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
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
  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
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 public void changePlayerImage(Direction direction) {
   player.changeImage(direction);
 }
コード例 #7
0
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 // 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
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 public boolean isInHealingStation() {
   return healingCenter.getAppearanceData().contains(player.getAppearanceData());
 }
コード例 #9
0
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 public boolean isInStore() {
   return itemShop.getAppearanceData().contains(player.getAppearanceData());
 }
コード例 #10
0
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 // 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
ファイル: World.java プロジェクト: JackGilliam1/Blockamon
 private void generateStartingBlockamon(Player player) {
   player.setLeadBlockamon(BlockamonGenerator.generateRandomBlockamon());
 }