Esempio n. 1
0
 @Override
 public String checkFixable() {
   if (null == unit) {
     return null;
   }
   if (isSalvaging()) {
     // check for armor
     if (unit.getEntity().getArmorForReal(loc, false) > 0
         || (unit.getEntity().hasRearArmor(loc)
             && unit.getEntity().getArmorForReal(loc, true) > 0)) {
       return "must salvage armor in this location first";
     }
     // you can only salvage a location that has nothing left on it
     int systemRepairable = 0;
     for (int i = 0; i < unit.getEntity().getNumberOfCriticals(loc); i++) {
       CriticalSlot slot = unit.getEntity().getCritical(loc, i);
       // ignore empty & non-hittable slots
       if ((slot == null) || !slot.isEverHittable()) {
         continue;
       }
       // we don't care about the final critical hit to the system
       // in locations because that just represents the location destruction
       if (slot.getType() == CriticalSlot.TYPE_SYSTEM) {
         if (slot.isRepairable()) {
           if (systemRepairable > 0) {
             return "Repairable parts in "
                 + unit.getEntity().getLocationName(loc)
                 + " must be salvaged or scrapped first.";
           } else {
             systemRepairable++;
           }
         }
       } else if (slot.isRepairable()) {
         return "Repairable parts in "
             + unit.getEntity().getLocationName(loc)
             + " must be salvaged or scrapped first.";
       }
     }
     // protomechs only have system stuff in the crits, so we need to also
     // check for mounted equipment separately
     for (Mounted m : unit.getEntity().getEquipment()) {
       if (m.isRepairable() && (m.getLocation() == loc || m.getSecondLocation() == loc)) {
         return "Repairable parts in "
             + unit.getEntity().getLocationName(loc)
             + " must be salvaged or scrapped first."
             + m.getName();
       }
     }
   }
   return null;
 }