コード例 #1
0
ファイル: DesignBlock.java プロジェクト: runholen/stars
 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;
 }
コード例 #2
0
ファイル: DesignBlock.java プロジェクト: runholen/stars
 public void calculateMassAndFuelCapacity() {
   if (isStarbase) {
     if (isFullDesign) mass = 0;
     fuelCapacity = 0;
   } else {
     if (isFullDesign) mass = Items.ships[hullId].mass;
     fuelCapacity = Items.ships[hullId].fuel;
   }
   if (isFullDesign) {
     for (Slot slot : slots) {
       if (slot.count > 0) {
         int key = (slot.category << 8) | (slot.itemId & 0xFF);
         mass += slot.count * Items.itemMasses.get(key);
         if (slot.category == Items.TechCategory.Mechanical.getMask()) {
           if (slot.itemId == 5) fuelCapacity += slot.count * 250;
           if (slot.itemId == 6) fuelCapacity += slot.count * 500;
         }
         if (slot.category == Items.TechCategory.Electrical.getMask()) {
           if (slot.itemId == 16) fuelCapacity += slot.count * 200;
         }
       }
     }
   }
 }
コード例 #3
0
ファイル: DesignBlock.java プロジェクト: runholen/stars
 @Override
 public void decode() throws Exception {
   if ((decryptedData[0] & 3) != 3) {
     throw new Exception("Unexpected design first byte: " + this);
   }
   if ((decryptedData[0] & 0xF8) != 0) {
     throw new Exception("Unexpected design first byte: " + this);
   }
   isFullDesign = (decryptedData[0] & 0x04) == 0x04;
   if ((decryptedData[1] & 0x02) != 0) {
     throw new Exception("Unexpected design second byte: " + this);
   }
   if ((decryptedData[1] & 0x01) != 0x01) {
     throw new Exception("Unexpected design second byte: " + this);
   }
   isTransferred = (decryptedData[1] & 0x80) == 0x80;
   isStarbase = (decryptedData[1] & 0x40) == 0x40;
   designNumber = (decryptedData[1] & 0x3C) >> 2;
   hullId = decryptedData[2] & 0xFF;
   fuelCapacity = Items.ships[hullId].fuel;
   pic = decryptedData[3] & 0xFF;
   int index;
   if (isFullDesign) {
     if (isStarbase) mass = 0;
     else mass = Items.ships[hullId].mass;
     armor = Util.read16(decryptedData, 4);
     slotCount = decryptedData[6] & 0xFF;
     turnDesigned = Util.read16(decryptedData, 7);
     totalBuilt = Util.read32(decryptedData, 9);
     totalRemaining = Util.read32(decryptedData, 13);
     index = 17;
     slots.clear();
     for (int i = 0; i < slotCount; i++) {
       Slot slot = new Slot();
       slot.category = Util.read16(decryptedData, index);
       index += 2;
       slot.itemId = Util.read8(decryptedData[index++]);
       slot.count = Util.read8(decryptedData[index++]);
       slots.add(slot);
       if (slot.count > 0) {
         int key = (slot.category << 8) | (slot.itemId & 0xFF);
         mass += slot.count * Items.itemMasses.get(key);
         if (slot.category == Items.TechCategory.Mechanical.getMask()) {
           if (slot.itemId == 5) fuelCapacity += slot.count * 250;
           if (slot.itemId == 6) fuelCapacity += slot.count * 500;
         }
         if (slot.category == Items.TechCategory.Electrical.getMask()) {
           if (slot.itemId == 16) fuelCapacity += slot.count * 200;
         }
       }
     }
   } else {
     mass = Util.read16(decryptedData, 4);
     index = 6;
   }
   int nameLen = decryptedData[index];
   nameBytes = new byte[1 + nameLen];
   System.arraycopy(decryptedData, index, nameBytes, 0, 1 + nameLen);
   index += 1 + nameLen;
   if (index != size) {
     throw new Exception("Unexpected design size: " + this);
   }
 }