Esempio n. 1
0
 @Override
 public String printWeightMisc() {
   String turretString =
       !tank.hasNoTurret()
           ? StringUtil.makeLength("Turret:", getPrintSize() - 5)
               + TestEntity.makeWeightString(getTankWeightTurret())
               + "\n"
           : "";
   String dualTurretString =
       !tank.hasNoDualTurret()
           ? StringUtil.makeLength("Front Turret:", getPrintSize() - 5)
               + TestEntity.makeWeightString(getTankWeightDualTurret())
               + "\n"
           : "";
   return turretString
       + dualTurretString
       + (getTankWeightLifting() != 0
           ? StringUtil.makeLength("Lifting Equip:", getPrintSize() - 5)
               + TestEntity.makeWeightString(getTankWeightLifting())
               + "\n"
           : "")
       + (getWeightPowerAmp() != 0
           ? StringUtil.makeLength("Power Amp:", getPrintSize() - 5)
               + TestEntity.makeWeightString(getWeightPowerAmp())
               + "\n"
           : "");
 }
Esempio n. 2
0
  public boolean correctCriticals(StringBuffer buff) {
    Vector<Mounted> unallocated = new Vector<Mounted>();
    boolean correct = true;

    for (Mounted mount : tank.getMisc()) {
      if (mount.getLocation() == Entity.LOC_NONE && !(mount.getType().getCriticals(tank) == 0)) {
        unallocated.add(mount);
      }
    }
    for (Mounted mount : tank.getWeaponList()) {
      if (mount.getLocation() == Entity.LOC_NONE) {
        unallocated.add(mount);
      }
    }
    for (Mounted mount : tank.getAmmo()) {
      int ammoType = ((AmmoType) mount.getType()).getAmmoType();
      if ((mount.getLocation() == Entity.LOC_NONE)
          && (mount.getUsableShotsLeft() > 1 || ammoType == AmmoType.T_CRUISE_MISSILE)) {
        unallocated.add(mount);
      }
    }

    if (!unallocated.isEmpty()) {
      buff.append("Unallocated Equipment:\n");
      for (Mounted mount : unallocated) {
        buff.append(mount.getType().getInternalName()).append("\n");
      }
      correct = false;
    }

    return correct;
  }
Esempio n. 3
0
 @Override
 public float getWeightControls() {
   if (tank.hasNoControlSystems()) {
     return 0;
   } else {
     return TestEntity.ceilMaxHalf(tank.getWeight() / 20.0f, getWeightCeilingControls());
   }
 }
Esempio n. 4
0
 protected static Structure getStructure(Tank tank) {
   if (tank.isSupportVehicle()) {
     return new SupportVeeStructure(tank);
   }
   int type = EquipmentType.T_STRUCTURE_STANDARD;
   if (tank.getStructureType() == 1) {
     type = EquipmentType.T_STRUCTURE_ENDO_STEEL;
   }
   return new Structure(type, tank.isSuperHeavy(), tank.getMovementMode());
 }
Esempio n. 5
0
 public float getTankWeightLifting() {
   switch (tank.getMovementMode()) {
     case HOVER:
     case VTOL:
     case HYDROFOIL:
     case SUBMARINE:
     case WIGE:
       return TestEntity.ceilMaxHalf(tank.getWeight() / 10.0f, getWeightCeilingLifting());
     default:
       return 0f;
   }
 }
Esempio n. 6
0
  public float getTankWeightDualTurret() {
    float weight = 0f;

    // For omni vees, the base chassis sets a turret weight
    if (tank.isOmni() && tank.getBaseChassisTurret2Weight() >= 0) {
      weight = tank.getBaseChassisTurret2Weight();
    } else {
      // For non-omnis, count up the weight of eq in the turret
      for (Mounted m : tank.getEquipment()) {
        if ((m.getLocation() == tank.getLocTurret2()) && !(m.getType() instanceof AmmoType)) {
          weight += m.getType().getTonnage(tank);
        }
      }
      // Turrets weight 10% of the weight of weapons in them
      weight = weight / 10.0f;
    }
    return TestEntity.ceilMaxHalf(weight, getWeightCeilingTurret());
  }
Esempio n. 7
0
  private int getTankCountHeatLaserWeapons() {
    int heat = 0;
    for (Mounted m : tank.getWeaponList()) {
      WeaponType wt = (WeaponType) m.getType();
      if ((wt.hasFlag(WeaponType.F_LASER) && (wt.getAmmoType() == AmmoType.T_NA))
          || wt.hasFlag(WeaponType.F_PPC)
          || wt.hasFlag(WeaponType.F_PLASMA)
          || wt.hasFlag(WeaponType.F_PLASMA_MFUK)
          || (wt.hasFlag(WeaponType.F_FLAMER) && (wt.getAmmoType() == AmmoType.T_NA))) {
        heat += wt.getHeat();
      }
      // laser insulator reduce heat by 1, to a minimum of 1
      if (wt.hasFlag(WeaponType.F_LASER)
          && (m.getLinkedBy() != null)
          && !m.getLinkedBy().isInoperable()
          && m.getLinkedBy().getType().hasFlag(MiscType.F_LASER_INSULATOR)) {
        heat -= 1;
        if (heat == 0) {
          heat++;
        }
      }

      if ((m.getLinkedBy() != null)
          && (m.getLinkedBy().getType() instanceof MiscType)
          && m.getLinkedBy().getType().hasFlag(MiscType.F_PPC_CAPACITOR)) {
        heat += 5;
      }
    }
    for (Mounted m : tank.getMisc()) {
      MiscType mtype = (MiscType) m.getType();
      // mobile HPGs count as energy weapons for construction purposes
      if (mtype.hasFlag(MiscType.F_MOBILE_HPG)) {
        heat += 20;
      }
      if (mtype.hasFlag(MiscType.F_RISC_LASER_PULSE_MODULE)) {
        heat += 2;
      }
      if (mtype.hasFlag(MiscType.F_VIRAL_JAMMER_DECOY)
          || mtype.hasFlag(MiscType.F_VIRAL_JAMMER_DECOY)) {
        heat += 12;
      }
    }
    return heat;
  }
Esempio n. 8
0
  @Override
  public StringBuffer printEntity() {
    StringBuffer buff = new StringBuffer();
    buff.append("Tank: ").append(tank.getDisplayName()).append("\n");
    buff.append("Found in: ").append(fileString).append("\n");
    buff.append(printTechLevel());
    buff.append(printSource());
    buff.append(printShortMovement());
    if (correctWeight(buff, true, true)) {
      buff.append("Weight: ")
          .append(getWeight())
          .append(" (")
          .append(calculateWeight())
          .append(")\n");
    }

    buff.append(printWeightCalculation()).append("\n");
    printFailedEquipment(buff);
    return buff;
  }
Esempio n. 9
0
 @Override
 public float getWeightPowerAmp() {
   if (!engine.isFusion() && (engine.getEngineType() != Engine.FISSION)) {
     int weight = 0;
     for (Mounted m : tank.getWeaponList()) {
       WeaponType wt = (WeaponType) m.getType();
       if (wt.hasFlag(WeaponType.F_ENERGY)
           && !(wt instanceof CLChemicalLaserWeapon)
           && !(wt instanceof VehicleFlamerWeapon)) {
         weight += wt.getTonnage(tank);
       }
       if ((m.getLinkedBy() != null)
           && (m.getLinkedBy().getType() instanceof MiscType)
           && m.getLinkedBy().getType().hasFlag(MiscType.F_PPC_CAPACITOR)) {
         weight += ((MiscType) m.getLinkedBy().getType()).getTonnage(tank);
       }
     }
     return TestEntity.ceil(weight / 10f, getWeightCeilingPowerAmp());
   }
   return 0;
 }
Esempio n. 10
0
 private static Armor[] getArmor(Tank tank) {
   Armor[] armor;
   if (!tank.hasPatchworkArmor()) {
     armor = new Armor[1];
     int type = tank.getArmorType(1);
     int flag = 0;
     if (tank.isClanArmor(1)) {
       flag |= Armor.CLAN_ARMOR;
     }
     armor[0] = new Armor(type, flag);
     return armor;
   } else {
     armor = new Armor[tank.locations()];
     for (int i = 0; i < tank.locations(); i++) {
       int type = tank.getArmorType(1);
       int flag = 0;
       if (tank.isClanArmor(1)) {
         flag |= Armor.CLAN_ARMOR;
       }
       armor[i] = new Armor(type, flag);
     }
   }
   return armor;
 }
Esempio n. 11
0
 public TestTank(Tank tank, TestEntityOption options, String fileString) {
   super(options, tank.getEngine(), getArmor(tank), getStructure(tank));
   this.tank = tank;
   this.fileString = fileString;
 }
Esempio n. 12
0
 @Override
 public String getName() {
   return "Tank: " + tank.getDisplayName();
 }
Esempio n. 13
0
  @Override
  public boolean correctEntity(StringBuffer buff, int ammoTechLvl) {
    boolean correct = true;
    if (skip()) {
      return true;
    }
    if (!correctWeight(buff)) {
      buff.insert(0, printTechLevel() + printShortMovement());
      buff.append(printWeightCalculation()).append("\n");
      correct = false;
    }
    if (!engine.engineValid) {
      buff.append(engine.problem.toString()).append("\n\n");
      correct = false;
    }
    if (tank.hasWorkingMisc(MiscType.F_ARMORED_MOTIVE_SYSTEM)
        && !((tank.getMovementMode() == EntityMovementMode.WHEELED)
            || (tank.getMovementMode() == EntityMovementMode.TRACKED)
            || (tank.getMovementMode() == EntityMovementMode.HOVER)
            || (tank.getMovementMode() == EntityMovementMode.HYDROFOIL)
            || (tank.getMovementMode() == EntityMovementMode.NAVAL)
            || (tank.getMovementMode() == EntityMovementMode.SUBMARINE)
            || (tank.getMovementMode() == EntityMovementMode.WIGE))) {
      buff.append("Armored Motive system and incompatible movemement mode!\n\n");
      correct = false;
    }
    if (tank.getFreeSlots() < 0) {
      buff.append("Not enough item slots available! Using ");
      buff.append(Math.abs(tank.getFreeSlots()));
      buff.append(" slot(s) too many.\n\n");
      correct = false;
    }
    int armorLimit = (int) (((tank.getWeight() * 7) / 2) + 40);
    if (tank.getTotalOArmor() > armorLimit) {
      buff.append("Armor exceeds point limit for ");
      buff.append(tank.getWeight());
      buff.append("-ton vehicle: ");
      buff.append(tank.getTotalOArmor());
      buff.append(" points > ");
      buff.append(armorLimit);
      buff.append(".\n\n");
      correct = false;
    }
    if (tank instanceof VTOL) {
      if (!tank.hasWorkingMisc(MiscType.F_MAST_MOUNT)) {
        for (Mounted m : tank.getEquipment()) {
          if (m.getLocation() == VTOL.LOC_ROTOR) {
            buff.append("rotor equipment must be placed in mast mount");
            correct = false;
          }
        }
      }
      if (tank.getOArmor(VTOL.LOC_ROTOR) > VTOL_MAX_ROTOR_ARMOR) {
        buff.append(tank.getOArmor(VTOL.LOC_ROTOR));
        buff.append(
            " points of VTOL rotor armor exceed " + VTOL_MAX_ROTOR_ARMOR + "-point limit.\n\n");
        correct = false;
      }
    }
    for (Mounted m : tank.getMisc()) {
      if (m.getType().hasFlag(MiscType.F_COMBAT_VEHICLE_ESCAPE_POD)) {
        if (m.getLocation()
            != (tank instanceof SuperHeavyTank ? SuperHeavyTank.LOC_REAR : Tank.LOC_REAR)) {
          buff.append("combat vehicle escape pod must be placed in rear");
          correct = false;
        }
      }
    }
    for (int loc = 0; loc < tank.locations(); loc++) {
      int count = 0;
      for (Mounted misc : tank.getMisc()) {
        if ((misc.getLocation() == loc) && misc.getType().hasFlag(MiscType.F_MANIPULATOR)) {
          count++;
        }
      }
      if (count > 2) {
        buff.append("max of 2 manipulators per location");
        correct = false;
        break;
      }
    }

    if (showFailedEquip() && hasFailedEquipment(buff)) {
      correct = false;
    }
    if (hasIllegalTechLevels(buff, ammoTechLvl)) {
      correct = false;
    }
    if (hasIllegalEquipmentCombinations(buff)) {
      correct = false;
    }
    // only tanks with fusion engine can be vacuum protected
    if (!(tank.getEngine().isFusion()
            || (tank.getEngine().getEngineType() == Engine.FUEL_CELL)
            || (tank.getEngine().getEngineType() == Engine.SOLAR)
            || (tank.getEngine().getEngineType() == Engine.BATTERY)
            || (tank.getEngine().getEngineType() == Engine.FISSION)
            || (tank.getEngine().getEngineType() == Engine.NONE))
        && !tank.doomedInVacuum()) {
      buff.append("Vacuum protection requires fusion engine.\n");
      correct = false;
    }

    if (!correctCriticals(buff)) {
      correct = false;
    }
    return correct;
  }