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))
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_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))
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_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_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_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 _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 determine_size(self): '''Set size''' roll = D6.roll(2, -2) if roll >= 10: roll = D6.roll(1, 9) self.size = uwp.Size(roll)