Exemplo n.º 1
0
  public int getAvailableTotalPrice() {
    if (number_units == 0 || unit.getPrice() == 0) return 0;

    int amount = castle.getOwner().gold / unit.getPrice();

    if (amount < number_units) return amount * unit.getPrice();
    else return number_units * unit.getPrice();
  }
Exemplo n.º 2
0
 /**
  * Buy 'x' number of units and add it to castle army
  *
  * @param amount number of units to buy
  */
 public void buy(int amount) {
   if (canBuy(amount)) {
     castle.getOwner().gold -= amount * unit.getPrice();
     number_units -= amount;
     castle.addUnitToArmy(unit, amount);
   }
 }
Exemplo n.º 3
0
 public String getEnableDescription(String language) {
   return unit.getEnableDescription(language);
 }
Exemplo n.º 4
0
 public int getUnitId() {
   return unit.getId();
 }
Exemplo n.º 5
0
  public void buyAll() {
    int amount = castle.getOwner().gold / unit.getPrice();

    if (amount >= number_units) buy(number_units);
    else buy(amount);
  }
Exemplo n.º 6
0
 /**
  * Check if player can buy a certain number of this units
  *
  * @param amount number of units that player want to buy
  */
 public boolean canBuy(int amount) {
   int price = amount * unit.getPrice();
   return number_units >= amount && castle.getOwner().gold >= price;
 }
Exemplo n.º 7
0
 /** @return unit position number for show it in castle panel */
 public int getPositionNumber() {
   return unit.getPositionNumber();
 }