parameters: (star_type, orbit, planet_density, galaxy_shape)
return_statement: return planet_size
docstring: Calculate planet size for a potential new planet based on planet density setup option, star type and orbit number.
docstring_summary: Calculate planet size for a potential new planet based on planet density setup option, star type and orbit number.
docstring_tokens: Calculate planet size for a potential new planet based on planet density setup option star type and orbit number .
function: def calc_planet_size(star_type, orbit, planet_density, galaxy_shape):
      """
      Calculate planet size for a potential new planet based on planet density setup option, star type and orbit number.
      """
      # try to pick a planet size by making a series of "rolls" (1-100)
      # for each planet size, and take the highest modified roll
      planet_size = fo.planetSize.unknown
      try:
          max_roll = 0
          for size in planet_sizes_all:
              roll = random.randint(1, 100) + base_chance_of_planet(planet_density, galaxy_shape, star_type, orbit, size)
              if max_roll < roll:
                  max_roll = roll
                  planet_size = size
      except:  # noqa: E722
          # in case of an error play it safe and set planet size to invalid
          planet_size = fo.planetSize.unknown
          util.report_error("Python calc_planet_size: Pick planet size failed" + str(sys.exc_info()[1]))
  
      # if we got an invalid planet size (for whatever reason),
      # just select one randomly from the global tuple based
      # only on the planet density setup option
      if planet_size == fo.planetSize.unknown:
          if random.randint(1, 10) <= planet_density:
              planet_size = random.choice(planet_sizes)
          else:
              planet_size = fo.planetSize.noWorld
  
      return planet_size
function_tokens: def calc_planet_size ( star_type , orbit , planet_density , galaxy_shape ) : # try to pick a planet size by making a series of "rolls" (1-100) # for each planet size, and take the highest modified roll planet_size = fo . planetSize . unknown try : max_roll = 0 for size in planet_sizes_all : roll = random . randint ( 1 , 100 ) + base_chance_of_planet ( planet_density , galaxy_shape , star_type , orbit , size ) if max_roll < roll : max_roll = roll planet_size = size except : # noqa: E722 # in case of an error play it safe and set planet size to invalid planet_size = fo . planetSize . unknown util . report_error ( "Python calc_planet_size: Pick planet size failed" + str ( sys . exc_info ( ) [ 1 ] ) ) # if we got an invalid planet size (for whatever reason), # just select one randomly from the global tuple based # only on the planet density setup option if planet_size == fo . planetSize . unknown : if random . randint ( 1 , 10 ) <= planet_density : planet_size = random . choice ( planet_sizes ) else : planet_size = fo . planetSize . noWorld return planet_size