Exemplo n.º 1
0
 public void useItem(int y, int x) { // uses an item
   Item temp = inventory.itemAt(x, y);
   if (temp == null) return;
   else if (temp.itemID < 5) { // equips equipnent
     inventory.setItem(x, y, equipment.itemAt(0, temp.itemID));
     equipment.setItem(0, temp.itemID, temp);
     calculateStats(); // recalculates player stats
   } else if (temp.itemID == 5) { // uses health potion
     inventory.setItem(x, y, null);
     healHealth((int) (80 + maxHealth * 0.2));
   } else if (temp.itemID == 6) { // uses mana potion
     inventory.setItem(x, y, null);
     healMana((int) (80 + maxMana * 0.2));
   }
 }
Exemplo n.º 2
0
 public void useManaPotion() {
   boolean b = false;
   for (int i = 0; i < 6; i++) {
     for (int j = 0; j < 5; j++) {
       if (inventory.itemAt(i, j) != null && inventory.itemAt(i, j).itemID == 6) {
         inventory.setItem(i, j, null);
         healMana((int) (80 + maxMana * 0.2));
         break;
       }
     }
     if (b) break;
   }
 }