コード例 #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();
  }
コード例 #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);
   }
 }
コード例 #3
0
 public String getEnableDescription(String language) {
   return unit.getEnableDescription(language);
 }
コード例 #4
0
 public int getUnitId() {
   return unit.getId();
 }
コード例 #5
0
  public void buyAll() {
    int amount = castle.getOwner().gold / unit.getPrice();

    if (amount >= number_units) buy(number_units);
    else buy(amount);
  }
コード例 #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;
 }
コード例 #7
0
 /** @return unit position number for show it in castle panel */
 public int getPositionNumber() {
   return unit.getPositionNumber();
 }