@@ 34,13 34,55 @@ class Base(PlanetsData):
'build_torptype',
'build_torpcount',
'unused')
+
+class Planet(PlanetsData):
+ """List of player's planets"""
+ # No FILENAME, but typically: PDATAx.DAT or PDATAx.DIS (x=player)
+ # No COUNT, but maximum 500
+ PACK_LENGTH = 85
+ PACK_FORMAT = '<hh 3s hhh iiiiiiiiiii hhhhhhhhh i hhh'
+ FIELDS = ('owner',
+ 'id',
+ 'friendlycode',
+ 'mines',
+ 'factories',
+ 'defense',
+ 'surface_fuel',
+ 'surface_tritanium',
+ 'surface_duranium',
+ 'surface_molybdenum',
+ 'clans',
+ 'supplies',
+ 'credits',
+ 'ground_fuel',
+ 'ground_tritanium',
+ 'ground_duranium',
+ 'ground_molybdenum',
+ 'density_fuel',
+ 'density_tritanium',
+ 'density_duranium',
+ 'density_molybdenum',
+ 'tax_colonist',
+ 'tax_natives',
+ 'happiness_colonist',
+ 'happiness_natives',
+ 'native_government',
+ 'native_clans',
+ 'native_race',
+ 'temperature',
+ 'build_base')
+
+ def unpack(self, data):
+ PlanetsData.unpack(self, data)
+ # Fix temperature, which is inverted (value 0 = temp 100)
+ self.temperature = 100 - self.temperature
class Ship(PlanetsData):
"""List of player's ships"""
# No FILENAME, but typically: SHIPx.DAT or SHIPx.DIS (x=player)
- # No COUNT, but normally maximum 500 and absolute max of 999
+ # No COUNT, but normally maximum 500 and absolute max of 999 (host999)
PACK_LENGTH = 107
- PACK_FORMAT = '<hh3shhhhhhhhhhhhhhhhhhh20shhhhhhhhhhhhhhhhhhhhh'
+ PACK_FORMAT = '<hh 3s hhhhhhhhhhhhhhhhhhh 20s hhhhhhhhhhhhhhhhhhhhh'
FIELDS = ('id',
'owner',
'friendlycode',
@@ 84,4 126,4 @@ class Ship(PlanetsData):
'transfer_supplies',
'transfer_id',
'intercept_id',
- 'money')
No newline at end of file
+ 'credits')
No newline at end of file
@@ 3,7 3,7 @@ Class for parsing RST (result) files.
"""
import struct
-from player import Base, Ship
+from player import Base, Planet, Ship
class InvalidResultFile(Exception):
"""Exception raised when the RST file is invalid or corrupt"""
@@ 43,6 43,8 @@ class ResultFile(object):
# Read standard data
f.seek(cls.pointers['ships'])
cls.data['ships'] = Ship.read(f, has_count=True)
+ f.seek(cls.pointers['planets'])
+ cls.data['planets'] = Planet.read(f, has_count=True)
f.seek(cls.pointers['bases'])
cls.data['bases'] = Base.read(f, has_count=True)
# Return gathered data