def test_red_zone_gov_law(self): '''Test gov+law >= 22 => red TZ''' system = System() system.mainworld.government = uwp.Government('C') system.mainworld.law_level = uwp.LawLevel('D') system.determine_travel_zone() self.assertTrue(system.zone == 'R')
def test_green_zone_gov_law(self): '''Test gov+law < 20 => green TZ''' system = System() system.mainworld.government = uwp.Government('2') system.mainworld.law_level = uwp.LawLevel('5') system.determine_travel_zone() self.assertTrue(system.zone == '')
def test_amber_zone_gov_law(self): '''Test gov+law in [20,21] => amber TZ''' system = System() system.mainworld.government = uwp.Government('A') system.mainworld.law_level = uwp.LawLevel('B') system.determine_travel_zone() self.assertTrue(system.zone == 'A')
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()
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_rez_zone_starport_x_flag(self): '''Test starport X => no red TZ (flag=False)''' system = System() system.mainworld.starport = 'X' system.mainworld.government = uwp.Government('2') system.mainworld.law_level = uwp.LawLevel('5') system.determine_travel_zone(False) self.assertFalse(system.zone == 'R')
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_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_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_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))
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 determine_government(self): '''Set government''' roll = FLUX.flux() + int(self.population) roll = min(roll, 15) roll = max(roll, 0) self.government = uwp.Government(roll)