def test_as(self):
     '''Test As'''
     planet = Planet()
     planet.size = uwp.Size(0)
     planet.atmosphere = uwp.Atmosphere(0)
     planet.hydrographics = uwp.Hydrographics(0)
     self.assertTrue('As' in gen_trade_codes(planet))
Beispiel #2
0
    def generate_cargo(self, source_uwp, market_uwp=None, broker_skill=0):
        '''Generate cargo'''
        try:
            self.source_world._load_uwp(source_uwp)  # noqa
        except (ValueError, TypeError):
            raise ValueError('Invalid source UWP {}'.format(source_uwp))
        try:
            assert int(broker_skill) >= 0
            self.broker_skill = int(broker_skill)
        except TypeError:
            raise ValueError('Invalid broker_skill {}'.format(broker_skill))
        self.source_world.mainworld_type = None
        self.source_world.determine_trade_codes()
        self.source_world.trade_codes = self.purge_ce_trade_codes(
            self.source_world.trade_codes)
        self.description = self.select_cargo_name()
        self.determine_cost(self.source_world.trade_codes)
        self.add_detail(self.source_world.trade_codes)

        if market_uwp is not None:
            self.market_world = Planet()
            try:
                self.market_world._load_uwp(market_uwp)  # noqa
            except ValueError:
                raise ValueError('Invalid market UWP {}'.format(market_uwp))
            self.market_world.mainworld_type = None
            self.market_world.determine_trade_codes()
            self.market_world.trade_codes = self.purge_ce_trade_codes(
                self.market_world.trade_codes)
            self.determine_price()
Beispiel #3
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))
 def test_not_fl(self):
     '''Test !Fl'''
     for atm in '0123456789':
         hyd = 0
         planet = Planet()
         planet.atmosphere = uwp.Atmosphere(atm)
         planet.hydrographics = uwp.Hydrographics(hyd)
         self.assertFalse('Fl' in gen_trade_codes(planet))
 def test_not_ic(self):
     '''Test !Ic'''
     for atm in '23456789ABC':
         hyd = 0
         planet = Planet()
         planet.atmosphere = uwp.Atmosphere(atm)
         planet.hydrographics = uwp.Hydrographics(hyd)
         self.assertFalse('Ic' in gen_trade_codes(planet))
 def test_po(self):
     '''Test Po'''
     for atm in '016789ABC':
         for hyd in '456789A':
             planet = Planet()
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.hydrographics = uwp.Hydrographics(hyd)
             self.assertFalse('Po' in gen_trade_codes(planet))
 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))
 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))
 def test_po(self):
     '''Test Po'''
     for atm in '2345':
         for hyd in '0123':
             planet = Planet()
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.hydrographics = uwp.Hydrographics(hyd)
             self.assertTrue('Po' in gen_trade_codes(planet))
 def test_not_va(self):
     '''Test !Va'''
     for atm in '123456789ABC':
         for hyd in '123456789A':
             planet = Planet()
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.hydrographics = uwp.Hydrographics(hyd)
             self.assertFalse('Va' in gen_trade_codes(planet))
 def test_ic(self):
     '''Test Ic'''
     for atm in '01':
         for hyd in '123456789A':
             planet = Planet()
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.hydrographics = uwp.Hydrographics(hyd)
             self.assertTrue('Ic' in gen_trade_codes(planet))
 def test_de(self):
     '''Test De'''
     hyd = 0
     for atm in '23456789':
         planet = Planet()
         planet.atmosphere = uwp.Atmosphere(atm)
         planet.hydrographics = uwp.Hydrographics(hyd)
         self.assertTrue('De' in gen_trade_codes(planet))
 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))
 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))
 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))
 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))
 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))
 def test_he(self):
     '''Test He'''
     for siz in '3456789ABC':
         for atm in '2479ABC':
             for hyd in '012':
                 planet = Planet()
                 planet.size = uwp.Size(siz)
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.hydrographics = uwp.Hydrographics(hyd)
                 self.assertTrue('He' in gen_trade_codes(planet))
 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))
 def test_not_he(self):
     '''Test !He'''
     for siz in '01':
         for atm in '013568':
             for hyd in '3456789A':
                 planet = Planet()
                 planet.size = uwp.Size(siz)
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.hydrographics = uwp.Hydrographics(hyd)
                 self.assertFalse('He' in gen_trade_codes(planet))
 def test_not_wa(self):
     '''Test !Wa'''
     for siz in '012BC':
         for atm in '012ABC':
             for hyd in '0123456789':
                 planet = Planet()
                 planet.size = uwp.Size(siz)
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.hydrographics = uwp.Hydrographics(hyd)
                 self.assertFalse('Wa' in gen_trade_codes(planet))
 def test_not_oc(self):
     '''Test !Oc'''
     for siz in '0123456789':
         for atm in '012':
             hyd = '0123456789'
             planet = Planet()
             planet.size = uwp.Size(siz)
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.hydrographics = uwp.Hydrographics(hyd)
             self.assertFalse('Oc' in gen_trade_codes(planet))
 def test_ga(self):
     '''Test Ga'''
     for siz in '678':
         for atm in '568':
             for hyd in '567':
                 planet = Planet()
                 planet.size = uwp.Size(siz)
                 planet.atmosphere = uwp.Atmosphere(atm)
                 planet.hydrographics = uwp.Hydrographics(hyd)
                 self.assertTrue('Ga' in gen_trade_codes(planet))
 def test_oc(self):
     '''Test Oc'''
     for siz in 'ABCDEF':
         for atm in '3456789ABC':
             hyd = 'A'
             planet = Planet()
             planet.size = uwp.Size(siz)
             planet.atmosphere = uwp.Atmosphere(atm)
             planet.hydrographics = uwp.Hydrographics(hyd)
             self.assertTrue('Oc' in gen_trade_codes(planet))
Beispiel #25
0
 def test_as_json(self):
     '''Test planet.as_json() exporter'''
     planet = Planet()
     jdata = planet.as_json()
     print(jdata)
     p_data = json.loads(jdata)
     self.assertTrue(p_data['uwp'] == planet.uwp())
     self.assertTrue(p_data['trade_codes'] == planet.trade_codes)
     self.assertTrue(p_data['travel_code'] == planet.travel_code)
     self.assertTrue(p_data['bases'] == planet.bases)
     self.assertTrue(p_data['orbit'] == planet.orbit)
     self.assertTrue(p_data['is_mainworld'] == planet.is_mainworld)
Beispiel #26
0
 def test_json_import(self):
     '''Test planet.json_import() importer'''
     jdata = u'{"trade_codes": ["Fl", "Lo"], "travel_code": "", ' +\
         '"is_mainworld": true, "uwp": "D9A6313-3", "orbit": 5, ' +\
         '"bases": "", "mainworld_type": "Planet", ' +\
         '"parent_type": null, "orbit_around_parent": null  }'
     p_data = json.loads(jdata)
     planet = Planet()
     planet.json_import(jdata)
     self.assertTrue(p_data['uwp'] == planet.uwp())
     self.assertTrue(p_data['trade_codes'] == planet.trade_codes)
     self.assertTrue(p_data['travel_code'] == planet.travel_code)
     self.assertTrue(p_data['bases'] == planet.bases)
     self.assertTrue(p_data['orbit'] == planet.orbit)
     self.assertTrue(p_data['is_mainworld'] == planet.is_mainworld)
Beispiel #27
0
 def generate_worlds():
     '''Generate many worlds'''
     planets = []
     for _ in range(0, SAMPLE_SIZE):
         planet = Planet()
         planets.append(planet)
     return planets
Beispiel #28
0
    def __init__(self, name='', location_hex='0000'):
        self.hex = location_hex
        self.name = name
        self.zone = ''
        self.stellar = Primary()
        self.mainworld = Planet()
        self.determine_mw_orbit()

        self.bases = self.determine_bases()
        self.pbg = Pbg(self.mainworld)
        self.allegiance = 'Na'
        self.determine_trade_codes()
        self.determine_x()
        self.nobility = self.determine_nobility()
        self.num_worlds = (self.pbg.belts + self.pbg.gasgiants + D6.roll(1) +
                           1)
        self.determine_travel_zone()
Beispiel #29
0
    def generate_cargo(self, source_uwp, market_uwp=None):
        '''Generate cargo'''
        try:
            self.source_world._load_uwp(source_uwp)
        except ValueError:
            raise ValueError('Invalid source UWP')
        self.source_world.mainworld_type = None
        self.source_world.determine_trade_codes()
        self.description = self.select_cargo_name()
        self.determine_cost(self.source_world.trade_codes)
        self.add_detail(self.source_world.trade_codes)

        if market_uwp is not None:
            self.market_world = Planet()
            try:
                self.market_world._load_uwp(market_uwp)
            except ValueError:
                raise ValueError('Invalid market UWP')
            self.market_world.mainworld_type = None
            self.market_world.determine_trade_codes()
            self.determine_price()
 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))