Ejemplo n.º 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()
Ejemplo n.º 2
0
 def test_tech_level(self):
     '''Test tech level results'''
     planet = Planet()
     for starport in 'ABCX':
         for siz in '01234':
             for atm in '0123ABCDEF':
                 for hyd in '9A':
                     for pop in '123459A':
                         for gov in '05D':
                             planet.starport = starport
                             planet.size = upp.Size(siz)
                             planet.atmosphere = upp.Atmosphere(atm)
                             planet.hydrographics = upp.Hydrographics(hyd)
                             planet.population = upp.Population(pop)
                             planet.government = upp.Government(gov)
                             planet.determine_tech()
                             starport_dm =\
                                 self._starport_dm(planet.starport)
                             siz_dm = self._size_dm(str(planet.size))
                             atm_dm = self._atm_dm(str(planet.atmosphere))
                             hyd_dm = self._hyd_dm(str(
                                 planet.hydrographics))
                             pop_dm = self._pop_dm(str(planet.population))
                             gov_dm = self._gov_dm(str(planet.government))
                             print(
                                 'port: {} siz: {} atm: {} hyd: {} pop: {} gov: {}'
                                 .format(starport_dm, siz_dm, atm_dm,
                                         hyd_dm, pop_dm, gov_dm))
                             tl_dm = starport_dm + siz_dm + atm_dm + hyd_dm
                             tl_dm = tl_dm + pop_dm + gov_dm
                             tech_level = int(planet.tech_level)
                             print('upp: {} TL: {} TL DM: {}'.format(
                                 str(planet), tech_level, tl_dm))
                             self.assertTrue(tech_level -
                                             tl_dm in range(1, 7))
Ejemplo n.º 3
0
 def test_in(self):
     '''Test In'''
     for atm in '3568ABC':
         for pop in '012345678':
             planet = Planet()
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.population = uwp.Population(pop)
             self.assertFalse('In' in gen_trade_codes(planet))
Ejemplo n.º 4
0
 def test_in(self):
     '''Test In'''
     for atm in '012479':
         for pop in '9A':
             planet = Planet()
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.population = uwp.Population(pop)
             self.assertTrue('In' in gen_trade_codes(planet))
Ejemplo n.º 5
0
 def test_ri(self):
     '''Test Ri'''
     for atm in '01234579ABC':
         for pop in '0123459ABCDEF':
             for gov in '012ABCDEF':
                 planet = Planet()
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.population = uwp.Population(pop)
                 planet.government = uwp.Government(gov)
                 self.assertFalse('Ri' in gen_trade_codes(planet))
Ejemplo n.º 6
0
 def test_ri(self):
     '''Test Ri'''
     for atm in '68':
         for pop in '678':
             for gov in '456789':
                 planet = Planet()
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.population = uwp.Population(pop)
                 planet.government = uwp.Government(gov)
                 self.assertTrue('Ri' in gen_trade_codes(planet))
Ejemplo n.º 7
0
 def test_no_ag(self):
     '''Test !Ag'''
     for atm in '0123ABC':
         for hyd in '01239A':
             for pop in '012389ABCDEF':
                 planet = Planet()
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.hydrographics = uwp.Hydrographics(hyd)
                 planet.population = uwp.Population(pop)
                 self.assertFalse('Ag' in gen_trade_codes(planet))
Ejemplo n.º 8
0
 def test_not_di(self):
     '''Test !Di'''
     for pop in '123456789ABCDEF':
         for gov in '123456789ABCDEF':
             for law in '123456789ABCDEFGHJ':
                 planet = Planet()
                 planet.population = uwp.Population(pop)
                 planet.government = uwp.Government(gov)
                 planet.law_level = uwp.LawLevel(law)
                 self.assertFalse('Di' in gen_trade_codes(planet))
Ejemplo n.º 9
0
 def test_ag(self):
     '''Test Ag'''
     for atm in '456789':
         for hyd in '45678':
             for pop in '567':
                 planet = Planet()
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.hydrographics = uwp.Hydrographics(hyd)
                 planet.population = uwp.Population(pop)
                 self.assertTrue('Ag' in gen_trade_codes(planet))
Ejemplo n.º 10
0
 def test_no_na(self):
     '''Test !Na'''
     for atm in '456789ABC':
         for hyd in '456789A':
             for pop in '012345':
                 planet = Planet()
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.hydrographics = uwp.Hydrographics(hyd)
                 planet.population = uwp.Population(pop)
                 self.assertFalse('Na' in gen_trade_codes(planet))
Ejemplo n.º 11
0
 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))
Ejemplo n.º 12
0
 def test_px(self):
     '''Test Px'''
     for atm in '23AB':
         for hyd in '12345':
             for pop in '3456':
                 for law in '6789':
                     # Also need to check MW
                     planet = Planet()
                     planet.atmosphere = uwp.Atmosphere(atm)
                     planet.hydrographics = uwp.Hydrographics(hyd)
                     planet.population = uwp.Population(pop)
                     planet.law_level = uwp.LawLevel(law)
                     self.assertTrue('Px' in gen_trade_codes(planet))
Ejemplo n.º 13
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))
Ejemplo n.º 14
0
 def test_no_px(self):
     '''Test !Px'''
     for atm in '01456789C':
         for hyd in '6789A':
             for pop in '012789ABCDEF':
                 for law in '012345ABCDEF':
                     # Also need to check MW
                     planet = Planet()
                     planet.atmosphere = uwp.Atmosphere(atm)
                     planet.hydrographics = uwp.Hydrographics(hyd)
                     planet.population = uwp.Population(pop)
                     planet.law_level = uwp.LawLevel(law)
                     self.assertFalse('Px' in gen_trade_codes(planet))
Ejemplo n.º 15
0
 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))
Ejemplo n.º 16
0
 def test_ni(self):
     '''Test Ni'''
     for pop in '456':
         planet = Planet()
         planet.population = uwp.Population(pop)
         self.assertTrue('Ni' in gen_trade_codes(planet))
Ejemplo n.º 17
0
 def determine_population(self):
     '''Set population'''
     roll = D6.roll(2, -2)
     if roll == 10:
         roll = D6.roll(2, 3)
     self.population = uwp.Population(roll)
Ejemplo n.º 18
0
 def test_not_lo(self):
     '''Test !Lo'''
     for pop in '0456789ABCDEF':
         planet = Planet()
         planet.population = uwp.Population(pop)
         self.assertFalse('Lo' in gen_trade_codes(planet))
Ejemplo n.º 19
0
 def test_hi(self):
     '''Test Hi'''
     for pop in '9ABCDEF':
         planet = Planet()
         planet.population = uwp.Population(pop)
         self.assertTrue('Hi' in gen_trade_codes(planet))
Ejemplo n.º 20
0
 def test_ph(self):
     '''Test Ph'''
     pop = 8
     planet = Planet()
     planet.population = uwp.Population(pop)
     self.assertTrue('Ph' in gen_trade_codes(planet))
Ejemplo n.º 21
0
 def test_not_ph(self):
     '''Test !Ph'''
     for pop in '012345679ABCDEF':
         planet = Planet()
         planet.population = uwp.Population(pop)
         self.assertFalse('Ph' in gen_trade_codes(planet))
Ejemplo n.º 22
0
 def test_not_hi(self):
     '''Test !Hi'''
     for pop in '012345678':
         planet = Planet()
         planet.population = uwp.Population(pop)
         self.assertFalse('Hi' in gen_trade_codes(planet))
Ejemplo n.º 23
0
 def test_not_ni(self):
     '''Test !Ni'''
     for pop in '0123789ABC':
         planet = Planet()
         planet.population = uwp.Population(pop)
         self.assertFalse('Ni' in gen_trade_codes(planet))
Ejemplo n.º 24
0
 def test_lo(self):
     '''Test Lo'''
     for pop in '123':
         planet = Planet()
         planet.population = uwp.Population(pop)
         self.assertTrue('Lo' in gen_trade_codes(planet))