@@ 7,7 7,7 @@ import struct
from common import PlanetsData
class BeamSpec(PlanetsData):
- """List of buildable starship beam weapons"""
+ """List of starship beam weapons"""
COUNT = 10
PACK_LENGTH = 36
name = ''
@@ 21,18 21,85 @@ class BeamSpec(PlanetsData):
damage = 0
def unpack(self, data):
+ (self.name, self.cost, self.tritanium, self.duranium, self.molybdenum,
+ self.mass, self.tech, self.kill, self.damage) = struct.unpack(
+ '< 20s h h h h h h h h', data)
+ self.name = self.name.rstrip()
+
+class EngSpec(PlanetsData):
+ """List of starship engines"""
+ COUNT = 9
+ PACK_LENGTH = 66
+ name = ''
+ cost = 0
+ tritanium = 0
+ duranium = 0
+ molybdenum = 0
+ tech = 0
+ mileage = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
+
+ def unpack(self, data):
if len(data) is not self.PACK_LENGTH:
raise ValueError('Binary data passed has incorrect length')
- (self.name,
- self.cost,
- self.tritanium,
- self.duranium,
- self.molybdenum,
- self.mass,
- self.tech,
- self.kill,
- self.damage) = struct.unpack('< 20s h h h h h h h h', data)
+ # Reinitialize mileage dict or it will not be seen as instance variable
+ self.mileage = {}
+ (self.name, self.cost, self.tritanium, self.duranium, self.molybdenum,
+ self.tech, self.mileage[1], self.mileage[2], self.mileage[3],
+ self.mileage[4], self.mileage[5], self.mileage[6],
+ self.mileage[7], self.mileage[8], self.mileage[9]) = struct.unpack(
+ '< 20s h h h h h i i i i i i i i i', data)
self.name = self.name.rstrip()
- def __str__(self):
- return self.name
No newline at end of file
+class HullSpec(PlanetsData):
+ """List of starship hulls"""
+ # No COUNT, but typically 105 objects in default HULLSPEC.DAT
+ PACK_LENGTH = 60
+ name = ''
+ picture = 0
+ damaged = 0 # Unused field for picture of damaged ship
+ tritanium = 0
+ duranium = 0
+ molybdenum = 0
+ fueltank = 0
+ crew = 0
+ engines = 0
+ mass = 0
+ tech = 0
+ cargo = 0
+ fighterbays = 0
+ torpedolaunchers = 0
+ beams = 0
+ cost = 0
+
+ def unpack(self, data):
+ if len(data) is not self.PACK_LENGTH:
+ raise ValueError('Binary data passed has incorrect length')
+ (self.name, self.picture, self.damaged, self.tritanium, self.duranium,
+ self.molybdenum, self.fueltank, self.crew, self.engines, self.mass,
+ self.tech, self.cargo, self.fighterbays, self.torpedolaunchers,
+ self.beams, self.cost) = struct.unpack(
+ '< 30s h h h h h h h h h h h h h h h', data)
+ self.name = self.name.rstrip()
+
+class TorpSpec(PlanetsData):
+ """List of starship torpedo weapons"""
+ COUNT = 10
+ PACK_LENGTH = 38
+ name = ''
+ torpedo_cost = 0
+ launcher_cost = 0
+ tritanium = 0
+ duranium = 0
+ molybdenum = 0
+ mass = 0
+ tech = 0
+ kill = 0
+ damage = 0
+
+ def unpack(self, data):
+ if len(data) is not self.PACK_LENGTH:
+ raise ValueError('Binary data passed has incorrect length')
+ (self.name, self.torpedo_cost, self.launcher_cost, self.tritanium,
+ self.duranium, self.molybdenum, self.mass, self.tech, self.kill,
+ self.damage) = struct.unpack('< 20s h h h h h h h h h', data)
+ self.name = self.name.rstrip()
No newline at end of file