示例#1
0
    def __init__(self, system=None):
        self.starport = '?'
        self.size = uwp.Size()
        self.atmosphere = uwp.Atmosphere()
        self.hydrographics = uwp.Hydrographics()
        self.biosphere = uwp.Biosphere()
        self.population = uwp.Population()
        self.government = uwp.Government()
        self.law_level = uwp.LawLevel()
        self.tech_level = uwp.TechLevel()

        self.trade_codes = []
        self.travel_code = ''
        self.bases = ''
        self.is_mainworld = True
        self.orbit = ''
        self.system = system
        self.mainworld_type = None
        self.parent_type = None
        self.orbit_around_parent = None

        self.determine_starport()
        self.determine_size()
        self.determine_atmosphere()
        self.determine_hydrographics()
        self.determine_population()
        self.determine_government()
        self.determine_law()
        self.determine_tech()
        # self.determine_trade_codes()
        self.determine_mainworld_type()
示例#2
0
 def determine_tech(self):
     '''Set tech level'''
     mod = 0
     mod += self._mod_starport()
     mod += self._mod_physical()
     mod += self._mod_population()
     LOGGER.debug('determine_tech(): mod = %s', mod)
     roll = D6.roll(1, mod, floor=0)
     LOGGER.debug('TL result = %s', roll)
     self.tech_level = uwp.TechLevel(roll)
 def test_ba(self):
     '''Test Ba'''
     pop = 0
     gov = 0
     law = 0
     tl = 0
     planet = Planet()
     planet.population = uwp.Population(pop)
     planet.government = uwp.Government(gov)
     planet.law_level = uwp.LawLevel(law)
     planet.tech_level = uwp.TechLevel(tl)
     self.assertTrue('Ba' in gen_trade_codes(planet))
示例#4
0
 def _load_uwp(self, uwp_data):
     '''Set planetary data from UWP'''
     try:
         self.starport = str(uwp_data[0])
         self.size = uwp.Size(str(uwp_data[1]))
         self.atmosphere = uwp.Atmosphere(str(uwp_data[2]))
         self.hydrographics = uwp.Hydrographics(str(uwp_data[3]))
         self.population = uwp.Population(str(uwp_data[4]))
         self.government = uwp.Government(str(uwp_data[5]))
         self.law_level = uwp.LawLevel(str(uwp_data[6]))
         self.tech_level = uwp.TechLevel(str(uwp_data[8]))
     except (IndexError, ValueError):
         raise ValueError('Invalid UWP {}'.format(uwp_data))
 def test_not_ba(self):
     '''Test !Ba'''
     for pop in '123456789A':
         for gov in '123456789AB':
             for law in '123456789A':  # Assume the rest are OK
                 for tech in '123456':  # Assume the rest are OK
                     for starport in 'ABCD':
                         planet = Planet()
                         planet.starport = starport
                         planet.population = uwp.Population(pop)
                         planet.government = uwp.Government(gov)
                         planet.law_level = uwp.LawLevel(law)
                         planet.tech_level = uwp.TechLevel(tech)
                         self.assertFalse('Ba' in gen_trade_codes(planet))
 def test_no_lt(self):
     '''Test !Lt'''
     for tech_level in '56789ABCDEF':
         planet = Planet()
         planet.tech_level = uwp.TechLevel(tech_level)
         self.assertFalse('Lt' in gen_trade_codes(planet))
 def test_no_ht(self):
     '''Test !Ht'''
     for tech_level in '0123456778AB':
         planet = Planet()
         planet.tech_level = uwp.TechLevel(tech_level)
         self.assertFalse('Ht' in gen_trade_codes(planet))
 def test_lt(self):
     '''Test Lt'''
     for tech_level in '01234':
         planet = Planet()
         planet.tech_level = uwp.TechLevel(tech_level)
         self.assertTrue('Lt' in gen_trade_codes(planet))
 def test_ht(self):
     '''Test Ht'''
     for tech_level in 'CDEF':
         planet = Planet()
         planet.tech_level = uwp.TechLevel(tech_level)
         self.assertTrue('Ht' in gen_trade_codes(planet))