Exemplo n.º 1
0
     def read_population(data, population):
         colonists = {0x02: [], 0x03: [], 0x82: []}
         for i in range(population):
             offset = 0x0C + (4 * i)
             t = (lbx.read_char(data, offset) & 0x80) + (lbx.read_char(data, offset + 1) & 3)
 		colonists[t].append({
                 'a':	lbx.read_char(data, offset),
                 'b':	lbx.read_char(data, offset + 1),
                 'c':	lbx.read_char(data, offset + 2),
                 'd':	lbx.read_char(data, offset + 3),
                 'r1':	(lbx.read_char(data, offset) & 0x70) >> 4,
                 'race':	(lbx.read_char(data, offset) & 0x07)
             })
         return colonists
Exemplo n.º 2
0
 def read_population(data, population):
     colonists = {0x02: [], 0x03: [], 0x82: []}
     for i in range(population):
         offset = 0x0C + (4 * i)
         t = (lbx.read_char(data, offset)
              & 0x80) + (lbx.read_char(data, offset + 1) & 3)
         colonists[t].append({
             'a':
             lbx.read_char(data, offset),
             'b':
             lbx.read_char(data, offset + 1),
             'c':
             lbx.read_char(data, offset + 2),
             'd':
             lbx.read_char(data, offset + 3),
             'r1': (lbx.read_char(data, offset) & 0x70) >> 4,
             'race': (lbx.read_char(data, offset) & 0x07)
         })
     return colonists
Exemplo n.º 3
0
    def import_from_moo2(self, data):
        def read_population(data, population):
            colonists = {0x02: [], 0x03: [], 0x82: []}
            for i in range(population):
                offset = 0x0C + (4 * i)
                t = (lbx.read_char(data, offset)
                     & 0x80) + (lbx.read_char(data, offset + 1) & 3)
                colonists[t].append({
                    'a':
                    lbx.read_char(data, offset),
                    'b':
                    lbx.read_char(data, offset + 1),
                    'c':
                    lbx.read_char(data, offset + 2),
                    'd':
                    lbx.read_char(data, offset + 3),
                    'r1': (lbx.read_char(data, offset) & 0x70) >> 4,
                    'race': (lbx.read_char(data, offset) & 0x07)
                })
            return colonists

        # end func read_population

#	print "Colony::load_from_moo2()"
#	print "	data length: %i" % len(data)
#	self.colony_id			= colony_id
        self.set_owner(lbx.read_char(data, 0x000))
        #        print("     Colony::import_from_moo2() ... self.__owner = %i" % self.__owner)
        self.allocated_to = lbx.read_char(data, 0x001)
        self.set_planet_id(lbx.read_char(data, 0x002))
        #        print("     Colony::import_from_moo2() ... self.planet_id = %i" % self.planet_id)
        self.__officer = lbx.read_short_int(data, 0x004),  # not used ?
        self.__is_outpost = lbx.read_char(data, 0x006)
        #        print("     Colony::import_from_moo2() ... self.__is_outpost = %i" % self.__is_outpost)
        self.__morale = lbx.read_char(
            data, 0x007) * 5  # Morale value is stored as divided by 5
        self.__pollution = lbx.read_short_int(data, 0x008)
        self.set_population(lbx.read_char(data, 0x00a))
        print("     Colony::import_from_moo2() ... self.__population = %i" %
              self.get_population())
        self.assignment = lbx.read_char(data, 0x00b)
        #			0x00 = Agricultural Colony
        #			0x01 = Industrial Colony
        #			0x02 = Research Colony
        #			0xff = (balanced?) Colony
        #		0x00c ~ 0x0b3		colonists
        self.colonists = read_population(data, self.get_population())
        self.__pop_raised = [
            lbx.read_short_int(data, 0x0B4),  # race 0
            lbx.read_short_int(data, 0x0B6),  # race 1
            lbx.read_short_int(data, 0x0B8),  # race 2
            lbx.read_short_int(data, 0x0BA),  # race 3
            lbx.read_short_int(data, 0x0BC),  # race 4
            lbx.read_short_int(data, 0x0BE),  # race 5
            lbx.read_short_int(data, 0x0C0),  # race 6
            lbx.read_short_int(data, 0x0C2),  # race 7
            lbx.read_short_int(data, 0x0C4),  # androids
            lbx.read_short_int(data, 0x0C6)  # natives
        ]
        self.__pop_grow = [
            lbx.read_short_int(data, 0x0C8),  # race 0
            lbx.read_short_int(data, 0x0CA),  # race 1
            lbx.read_short_int(data, 0x0CC),  # race 2
            lbx.read_short_int(data, 0x0CE),  # race 3
            lbx.read_short_int(data, 0x0D0),  # race 4
            lbx.read_short_int(data, 0x0D2),  # race 5
            lbx.read_short_int(data, 0x0D4),  # race 6
            lbx.read_short_int(data, 0x0D6),  # race 7
            lbx.read_short_int(data, 0x0D8),  # androids
            lbx.read_short_int(data, 0x0DA)  # natives
        ]
        self.n_turns_existed = ord(data[0x0DC])  # bookeeping
        self.food2_per_farmer = ord(
            data[0x0DD])  # Food per farmer in half-units of food
        self.industry_per_worker = ord(data[0x0DE])
        self.research_per_scientist = ord(data[0x0DF])
        self.max_farms = ord(data[0x0E0])
        self.__max_population = ord(data[0x0E1])
        self.climate = ord(data[0x0E2])
        self.ground_strength = lbx.read_short_int(data,
                                                  0x0E3)  # calculated for ai
        self.space_strength = lbx.read_short_int(data,
                                                 0x0E5)  # calculated for ai
        self.set_food(lbx.read_short_int(
            data, 0x0E7))  # total food = food - population
        self.set_industry(lbx.read_short_int(data, 0x0E9))
        self.set_research(lbx.read_short_int(data, 0x0EB))
        #		0x0ed		?

        self.__build_queue = []
        for i in range(0, 14, 2):
            production_id = ord(data[0x115 + i])
            if production_id < 0xFF:
                self.__build_queue.append({
                    'production_id': production_id,
                    'flags': ord(data[0x115 + i + 1])
                })

#		0x115		building item #0				# 0x0b = colony base??? 0xf9 = spy? 0xfd = housing 0xfe = trade goods
#			0x0b = colony base
#			0xf9 = spy
#			0xfd = housing
#			0xfe = trade goods
#			0xff = nothing
#		0x116		?
#		0x117		building item #1				# 0x0b = colony base??? 0xf9 = spy?
#		0x118		?
#		0x119		building item #2				# 0x0b = colony base??? 0xf9 = spy?
#		0x11a		?
#		0x11b		building item #3				# 0x0b = colony base??? 0xf9 = spy?
#		0x11c		?
#		0x11d		building item #4				# 0x0b = colony base??? 0xf9 = spy?
#		0x11e		?
#		0x11f		building item #5				# 0x0b = colony base??? 0xf9 = spy?
#		0x120		?
#		0x121		building item #6				# 0x0b = colony base??? 0xf9 = spy?
#		0x122		?
        self.marines = lbx.read_char(data, 0x130)
        self.armors = lbx.read_char(data, 0x132)
        self.__buildings = []
        for b_id in range(1, 49):
            offset = 0x136 + b_id
            #            self.buildings.append(ord(data[offset]))
            if ord(data[offset]):
                self.__buildings.append(b_id)
Exemplo n.º 4
0
    def import_from_moo2(self, data):

        def read_population(data, population):
            colonists = {0x02: [], 0x03: [], 0x82: []}
            for i in range(population):
                offset = 0x0C + (4 * i)
                t = (lbx.read_char(data, offset) & 0x80) + (lbx.read_char(data, offset + 1) & 3)
    		colonists[t].append({
                    'a':	lbx.read_char(data, offset),
                    'b':	lbx.read_char(data, offset + 1),
                    'c':	lbx.read_char(data, offset + 2),
                    'd':	lbx.read_char(data, offset + 3),
                    'r1':	(lbx.read_char(data, offset) & 0x70) >> 4,
                    'race':	(lbx.read_char(data, offset) & 0x07)
                })
            return colonists
        # end func read_population

#	print "Colony::load_from_moo2()"
#	print "	data length: %i" % len(data)
#	self.colony_id			= colony_id
        self.set_owner(lbx.read_char(data,  0x000))
#        print("     Colony::import_from_moo2() ... self.__owner = %i" % self.__owner)
        self.allocated_to	= lbx.read_char(data,  0x001)
        self.set_planet_id(lbx.read_char(data,  0x002))
#        print("     Colony::import_from_moo2() ... self.planet_id = %i" % self.planet_id)
        self.__officer		= lbx.read_short_int(data, 0x004),   # not used ?
        self.__is_outpost	= lbx.read_char(data,  0x006)
#        print("     Colony::import_from_moo2() ... self.__is_outpost = %i" % self.__is_outpost)
        self.__morale		= lbx.read_char(data,  0x007) * 5 # Morale value is stored as divided by 5
        self.__pollution	= lbx.read_short_int(data, 0x008)
        self.set_population(lbx.read_char(data,  0x00a))
        print("     Colony::import_from_moo2() ... self.__population = %i" % self.get_population())
        self.assignment		= lbx.read_char(data,  0x00b)
#			0x00 = Agricultural Colony
#			0x01 = Industrial Colony
#			0x02 = Research Colony
#			0xff = (balanced?) Colony
#		0x00c ~ 0x0b3		colonists
        self.colonists		= read_population(data, self.get_population())
        self.__pop_raised		= [
                                    lbx.read_short_int(data, 0x0B4),	# race 0
                                    lbx.read_short_int(data, 0x0B6),	# race 1
                                    lbx.read_short_int(data, 0x0B8),	# race 2
                                    lbx.read_short_int(data, 0x0BA),	# race 3
                                    lbx.read_short_int(data, 0x0BC),	# race 4
                                    lbx.read_short_int(data, 0x0BE),	# race 5
                                    lbx.read_short_int(data, 0x0C0),	# race 6
                                    lbx.read_short_int(data, 0x0C2),	# race 7
                                    lbx.read_short_int(data, 0x0C4),	# androids
                                    lbx.read_short_int(data, 0x0C6)	# natives
                                ]
        self.__pop_grow		= [
                                    lbx.read_short_int(data, 0x0C8),	# race 0
                                    lbx.read_short_int(data, 0x0CA),	# race 1
                                    lbx.read_short_int(data, 0x0CC),	# race 2
                                    lbx.read_short_int(data, 0x0CE),	# race 3
                                    lbx.read_short_int(data, 0x0D0),	# race 4
                                    lbx.read_short_int(data, 0x0D2),	# race 5
                                    lbx.read_short_int(data, 0x0D4),	# race 6
                                    lbx.read_short_int(data, 0x0D6),	# race 7
                                    lbx.read_short_int(data, 0x0D8),	# androids
                                    lbx.read_short_int(data, 0x0DA)	# natives
                                ]
        self.n_turns_existed		= ord(data[0x0DC])	# bookeeping
        self.food2_per_farmer		= ord(data[0x0DD])	# Food per farmer in half-units of food
        self.industry_per_worker	= ord(data[0x0DE])
        self.research_per_scientist	= ord(data[0x0DF])
        self.max_farms			= ord(data[0x0E0])
        self.__max_population		= ord(data[0x0E1])
        self.climate			= ord(data[0x0E2])
        self.ground_strength		= lbx.read_short_int(data, 0x0E3)	# calculated for ai
        self.space_strength		= lbx.read_short_int(data, 0x0E5)	# calculated for ai
        self.set_food(lbx.read_short_int(data, 0x0E7))	# total food = food - population
        self.set_industry(lbx.read_short_int(data, 0x0E9))
        self.set_research(lbx.read_short_int(data, 0x0EB))
#		0x0ed		?

        self.__build_queue = []
        for i in range(0, 14, 2):
            production_id = ord(data[0x115 + i])
            if production_id < 0xFF:
                self.__build_queue.append({'production_id': production_id, 'flags': ord(data[0x115 + i + 1])})
        
#		0x115		building item #0				# 0x0b = colony base??? 0xf9 = spy? 0xfd = housing 0xfe = trade goods
#			0x0b = colony base
#			0xf9 = spy
#			0xfd = housing
#			0xfe = trade goods
#			0xff = nothing
#		0x116		?
#		0x117		building item #1				# 0x0b = colony base??? 0xf9 = spy?
#		0x118		?
#		0x119		building item #2				# 0x0b = colony base??? 0xf9 = spy?
#		0x11a		?
#		0x11b		building item #3				# 0x0b = colony base??? 0xf9 = spy?
#		0x11c		?
#		0x11d		building item #4				# 0x0b = colony base??? 0xf9 = spy?
#		0x11e		?
#		0x11f		building item #5				# 0x0b = colony base??? 0xf9 = spy?
#		0x120		?
#		0x121		building item #6				# 0x0b = colony base??? 0xf9 = spy?
#		0x122		?
        self.marines			= lbx.read_char(data, 0x130)
        self.armors			= lbx.read_char(data, 0x132)
        self.__buildings			= []
        for b_id in range(1, 49):
    	    offset = 0x136 + b_id
#            self.buildings.append(ord(data[offset]))
            if ord(data[offset]):
                self.__buildings.append(b_id)