Ejemplo n.º 1
0
 public int getPrt() {
   if (isTransferred) return -1;
   if (hullId == 3) return PlayerBlock.PRT.IS; // Super Freighter
   if (hullId == 8) return PlayerBlock.PRT.WM; // Battle Cruiser
   if (hullId == 10) return PlayerBlock.PRT.WM; // Dreadnought
   if (hullId == 12) return PlayerBlock.PRT.SS; // Rogue
   if (hullId == 14) return PlayerBlock.PRT.HE; // Mini-Colony Ship
   if (hullId == 18) return PlayerBlock.PRT.SS; // Stealth Bomber
   if (hullId == 25) return PlayerBlock.PRT.IS; // Fuel Transport
   if (hullId == 27) return PlayerBlock.PRT.SD; // Mini Mine Layer
   if (hullId == 28) return PlayerBlock.PRT.SD; // Super Mine Layer
   if (hullId == 31) return PlayerBlock.PRT.HE; // Meta Morph
   if (hullId == 36) return PlayerBlock.PRT.AR; // Death Star
   if (!isFullDesign) return -1;
   boolean isOrSd = true;
   for (Slot slot : slots) {
     if (slot.count == 0) continue;
     if (slot.category == Items.TechCategory.Orbital.getMask()) {
       if (slot.itemId == 1 || slot.itemId == 4 || slot.itemId == 5 || slot.itemId == 6)
         return PlayerBlock.PRT.IT;
       if (slot.itemId == 7 || slot.itemId == 8 || slot.itemId == 10 || slot.itemId == 11)
         return PlayerBlock.PRT.PP;
       if (slot.itemId == 13 || slot.itemId == 14 || slot.itemId == 15) return PlayerBlock.PRT.PP;
     } else if (slot.category == Items.TechCategory.BeamWeapon.getMask()) {
       if (slot.itemId == 2) return PlayerBlock.PRT.IS;
       if (slot.itemId == 14) return PlayerBlock.PRT.WM;
       if (slot.itemId == 16) return PlayerBlock.PRT.WM;
     } else if (slot.category == Items.TechCategory.Bomb.getMask()) {
       if (slot.itemId == 9) return PlayerBlock.PRT.CA;
     } else if (slot.category == Items.TechCategory.MiningRobot.getMask()) {
       if (slot.itemId == 7) return PlayerBlock.PRT.CA;
     } else if (slot.category == Items.TechCategory.MineLayer.getMask()) {
       if (slot.itemId != 1 && slot.itemId != 7) return PlayerBlock.PRT.SD;
       if (slot.itemId == 7) isOrSd = true;
     } else if (slot.category == Items.TechCategory.Mechanical.getMask()) {
       if (slot.itemId == 1) return PlayerBlock.PRT.AR;
     } else if (slot.category == Items.TechCategory.Electrical.getMask()) {
       if (slot.itemId == 0 || slot.itemId == 3) return PlayerBlock.PRT.SS;
       if (slot.itemId == 8 || slot.itemId == 11) return PlayerBlock.PRT.IS;
       if (slot.itemId == 13) return PlayerBlock.PRT.HE;
       if (slot.itemId == 14) return PlayerBlock.PRT.SD;
       if (slot.itemId == 15) return PlayerBlock.PRT.IS;
       if (slot.itemId == 16) return PlayerBlock.PRT.IT;
     } else if (slot.category == Items.TechCategory.Shield.getMask()) {
       if (slot.itemId == 3) return PlayerBlock.PRT.IS;
       if (slot.itemId == 4) return PlayerBlock.PRT.SS;
     } else if (slot.category == Items.TechCategory.Scanner.getMask()) {
       if (slot.itemId == 5 || slot.itemId == 6 || slot.itemId == 14) return PlayerBlock.PRT.SS;
     } else if (slot.category == Items.TechCategory.Armor.getMask()) {
       if (slot.itemId == 6) return PlayerBlock.PRT.IS;
       if (slot.itemId == 7) return PlayerBlock.PRT.SS;
     }
   }
   if (isOrSd) return -2;
   return -1;
 }
Ejemplo n.º 2
0
 public static DesignBlock fromDesignString(
     boolean isStarbase, int designNumber, boolean isRs, String designString, String name)
     throws Exception {
   DesignBlock designBlock = new DesignBlock();
   designBlock.isFullDesign = true;
   String[] parts = designString.split(",");
   byte hull = Items.getHullIdOfUserString(parts[0]);
   designBlock.isStarbase = isStarbase;
   designBlock.designNumber = designNumber;
   designBlock.hullId = hull;
   designBlock.pic = 4 * hull;
   if (hull == 29) designBlock.pic = 4 * 31; // No idea why these pics are swapped
   else if (hull == 31) designBlock.pic = 4 * 29;
   designBlock.armor = Items.ships[hull].armor;
   designBlock.slotCount = Items.ships[hull].slotCount;
   designBlock.slots = new ArrayList<DesignBlock.Slot>();
   for (int slot = 0; slot < designBlock.slotCount; slot++) {
     if (parts.length <= slot + 1) {
       designBlock.slots.add(new Slot());
       continue;
     }
     int slotSize = Items.ships[hull].slotSizes[slot];
     Slot slotInfo = Items.getSlotOfUserString(parts[slot + 1]);
     if (slotInfo.count < 0 || slotInfo.count > slotSize) slotInfo.count = slotSize;
     Integer armor = Items.itemArmors.get((slotInfo.category << 8) | slotInfo.itemId);
     if (armor != null) {
       if (isRs && slotInfo.category == Items.TechCategory.Armor.getMask()) {
         designBlock.armor += slotInfo.count * (armor / 2);
       } else {
         designBlock.armor += slotInfo.count * armor;
       }
     }
     designBlock.slots.add(slotInfo);
   }
   designBlock.nameBytes = Util.encodeStringForStarsFile(name);
   designBlock.encode();
   return designBlock;
 }