def cultivate_plant(self, choice): os.system('cls' if os.name == 'nt' else 'clear') if choice == "1": plant_to_add = MountainAppleTree() potentialHabitatsForAddedPlant = [ mountain for mountain in self.habitats_dict["Mountain"] ] elif choice == "2": plant_to_add = Silversword() potentialHabitatsForAddedPlant = [ grassland for grassland in self.habitats_dict["Grassland"] ] elif choice == "3": plant_to_add = RainbowEucalyptus() potentialHabitatsForAddedPlant = [ forest for forest in self.habitats_dict["Forest"] ] elif choice == "4": plant_to_add = BlueJadeVine() potentialHabitatsForAddedPlant = [ grassland for grassland in self.habitats_dict["Grassland"] ] + [swamp for swamp in self.habitats_dict["Swamp"]] else: print("That is not a valid choice.") return for i, v in enumerate(potentialHabitatsForAddedPlant): print(f'{i + 1}. {type(v).__name__} ({len(v.plants)} plants)') print(f"Where would you like to plant the {plant_to_add.species}?") choice = input("> ") if int(choice) > len(potentialHabitatsForAddedPlant): print("That is not a valid choice.") return targetHabitat = potentialHabitatsForAddedPlant[int(choice) - 1] habitatTargetList = self.habitats_dict[type(targetHabitat).__name__] object_class_plant_to_add = habitatTargetList[habitatTargetList.index( targetHabitat)] if len(object_class_plant_to_add.plants ) < object_class_plant_to_add.plant_limit: object_class_plant_to_add.add_plant(plant_to_add) print( f"You have added an {plant_to_add.species} to {type(targetHabitat).__name__}" ) else: print( "That habitat is already at it's max for animals. Please choose another habitat" )
def cultivate_plant_menu(arboretum): plant = None os.system('cls' if os.name == 'nt' else 'clear') print("1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus Tree") print("4. Blue Jade Vine") print("5. Main Menu") choice = input("Choose plant to culitivate > ") if choice == "1": plant = RainbowTree() if choice == "2": plant = Silversword() if choice == "3": plant = Blue_Jade_Vine() if choice == "4": plant = Mountain_Apple_Tree() # if choice == "5": biome_menu(arboretum, plant) # if choice == "1": # River.add_plant(plant) # if choice == "2": # Coastline.add_plant(plant) # if choice == "3": # Mountain.add_plant(plant) # if choice == "4": # Grassland.add_plant(plant) # if choice == "5": # Swamp.add_plant(plant) # if choice == "6": # Forest.add_plant(plant) # ((((ISSUE: Per README, NEED FUNCTIONALITY THAT WILL PRODUCE THE FOLLOWING WHEN ONE OF THOSE CHOICES ARE MADE)))) # 1. Grassland (5 plants) # 2. Swamp (2 plants) # 3. Swamp (9 plants) # 4. Swamp (0 plants) # Where would you like to plant the Sun Jade Vine? # > _
def add_plant(arboretum): animal = None print("1. Rainbow Eucalyptus Tree") print("2. Silversword") print("3. Mountain Apple Tree") print("4. Blue Jade Fine") choice = input("Choose plant to cultivate > ") if choice == "1": plant = Eucalyptus() elif choice == "2": plant = Silversword() elif choice == "3": plant = Apple() elif choice == "4": plant = BlueJade() else: plant = None print("Not a valid option.") add_plant(arboretum) return if plant: avail = [] for biome in arboretum.biomes: if biome.check_suitability(plant): avail.append(biome) print( f"{len(avail)}. {biome.biome_type.capitalize()}: {biome.name} ({biome.plant_count} plants)" ) option = input("Select biome > ") try: avail[int(option) - 1].add_plant(plant) except OverflowError: print( f"{avail[int(option) -1].name} already has the maximum number of plants." ) add_plant(arboretum) return except IndexError: print("Not a valid option.") add_plant(arboretum) return else: print(f"Added {plant.species} to {avail[int(option) - 1].name}!")
def annex_plants(kehua): os.system('cls' if os.name == 'nt' else 'clear') print("1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus") print("4. Blue Jade Vine") choice = input("Choose your plant > ") new_plant = "" if choice == "1": new_plant = MountainAppleTree() if choice == "2": new_plant = Silversword() if choice == "3": new_plant = RainbowEucalyptus() if choice == "4": new_plant = BlueJadeVine() # We want to print the list of habitats that we are allowed to plant in (amount of plants and habitat) # WE need to make an array of all the habits to loop over allowed_habitats = [] all_habitats = [] # list_of_habitats.extend(kehua.rivers) # list_of_habitats.extend(kehua.swamps) # list_of_habitats.extend(kehua.coastlines) all_habitats.extend(kehua.grasslands) all_habitats.extend(kehua.mountains) # list_of_habitats.extend(kehua.forests) # filtering out habitats to grab the suitable habitats for each plant for habitat in all_habitats: if new_plant.name in habitat.plants_allowed: allowed_habitats.append(habitat) # we are displaying the suitable habitats in menu form so you need a dynamic menu that displays with an index (by number) os.system('cls' if os.name == 'nt' else 'clear') for i, habitat in enumerate(allowed_habitats): print(f'{i+1}. {habitat.__class__.__name__}') choice = input("Chose your habitat > ") selected_habitat = allowed_habitats[choice - 1]
def add_plant(arboretum): clear_screen() plant = None build_plant_menu() plant_choice = input("Choose plant to cultivate > ") if plant_choice == "1": plant = Mountain_Apple_Tree() elif plant_choice == "2": plant = Silversword() elif plant_choice == "3": plant = Rainbow_Eucalyptus_Tree() elif plant_choice == "4": plant = Blue_Jade_Vine() else: print("No plant chosen. Press any key to return to main menu.") input() return clear_screen() build_plant_biome_menu(plant) print() habitat_choice = input("Choose your habitat type > ") #Set reference to chosen habitat try: chosen_habitat = plant.habitats[int(habitat_choice) - 1] except (IndexError, ValueError): input("Invalid input. Returning to main.") return #Print statement if no biomes of that type exist if len(arboretum.biomes[chosen_habitat]) == 0: print( "No biomes of that type exist. Press any key to return to main menu." ) os.system( 'say no biomes of that type exist' if os.name != 'nt' else '') input() return clear_screen() #Loop thru biomes of selected type unless all biomes are at max population # open_biomes = False bad_choices = ["bad choices"] open_biomes = build_individual_biome_menu(arboretum, chosen_habitat, bad_choices) if open_biomes == False: print() print( "All biomes of that type are at maximum population. Press any key to return to main menu." ) input() return print() biome_choice = input("Choose your biome > ") if int(biome_choice) in bad_choices: input( "Told you not to press the button. Now you gotta go to the main menu lol." ) return #Add plant to selected biome try: arboretum.biomes[chosen_habitat][int(biome_choice) - 1].plants.append(plant) except (IndexError, ValueError): input("Invalid input. Returning to main.") return clear_screen() new_home = arboretum.biomes[chosen_habitat][int(biome_choice) - 1] display_plant_report(plant, new_home) input('Press any key to return to main menu.')
def cultivate_plant(arboretum): valid_option = True os.system('cls' if os.name == 'nt' else 'clear') plant = None print("1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus") print("4. Blue Jade Vine") print() print("Choose plant to cultivate.") choice = input("> ") try: if int(choice) > 0 and int(choice) < 5: if choice == "1": plant = MountainAppleTree() if choice == "2": plant = Silversword() if choice == "3": plant = RainbowEucalyptusTree() if choice == "4": plant = BlueJadeVine() except KeyError: os.system('cls' if os.name == 'nt' else 'clear') valid_option = False input( "Please enter a valid option next time. Press enter to return to the main menu..." ) except AttributeError: os.system('cls' if os.name == 'nt' else 'clear') valid_option = False input( "Please enter a valid option next time. Press enter to return to the main menu..." ) except ValueError: os.system('cls' if os.name == 'nt' else 'clear') valid_option = False input( "Please enter a valid option next time. Press enter to return to the main menu..." ) biome = dict() def menu_function(): num = 1 try: int(choice) == int for index, mountain in enumerate(arboretum.mountains): if mountain.max_plants > len(mountain.plants): print(f'{num}. Mountain ({len(mountain.plants)} plants)') biome[num] = arboretum.mountains[index] num += 1 for index, swamp in enumerate(arboretum.swamps): if swamp.max_plants > len(swamp.plants): print(f'{num}. Swamp ({len(swamp.plants)} plants)') biome[num] = arboretum.swamps[index] num += 1 for index, grassland in enumerate(arboretum.grasslands): if grassland.max_plants > len(swamp.plants): print(f'{num}. Grassland ({len(grassland.plants)} plants)') biome[num] = arboretum.grasslands[index] num += 1 for index, forest in enumerate(arboretum.forests): if forest.max_plants > len(forest.plants): print(f'{num}. Forest ({len(forest.plants)} plants)') biome[num] = arboretum.forests[index] num += 1 for index, volcano in enumerate(arboretum.volcano): print(f'{num}. Throw it in the volcano.') biome[num] = arboretum.volcano[index] num += 1 except ValueError: print() error_message = input("Nope. Pick a number.") except KeyError: print() error_message = input("Nope. Pick a number.") except AttributeError: print() error_message = input("Nope. Pick a number.") except UnboundLocalError: error_message = input("Nope. Pick a number.") if valid_option and plant: menu_function() print() print("Where would you like to place the plant?") choice = input("> ") else: print() error_message = input( "Hey, look. This is just irresponsible. Stop it.") try: env = biome[int(choice)] def choice_fn(environment): try: environment.add_plant(plant) except ValueError: os.system('cls' if os.name == 'nt' else 'clear') error_message = input("ValueError. Returning to main menu.") except KeyError: os.system('cls' if os.name == 'nt' else 'clear') error_message = input("Nope. Pick a number.") except AttributeError: os.system('cls' if os.name == 'nt' else 'clear') error_message = input("Nope. Pick a number.") pass choice_fn(env) except ValueError: os.system('cls' if os.name == 'nt' else 'clear') pass except KeyError: os.system('cls' if os.name == 'nt' else 'clear') pass except AttributeError: os.system('cls' if os.name == 'nt' else 'clear') pass except UnboundLocalError: os.system('cls' if os.name == 'nt' else 'clear') pass
def cultivate_plant(arboretum): display_banner() plant = None print("1. Silversword") print("2. Crabgrass") choice = input("Choose plant to cultivate > ") if choice == "1": plant = Silversword() if choice == "2": pass display_banner() def print_habitats(): option_list = [] # biome_list_maker(plant.aquatic and arboretum.rivers, option_list) biome_list_maker(plant.terrestrial and plant.drought_tolerant, arboretum.grasslands, option_list, plant) for index, dic in enumerate(option_list): print(f'{index + 1}. {dic["biome"].print_list_options()}') # print(f'{index + 1}. {dic["biome"].name} ({dic["biome"].plant_count()} {"plant" if dic["biome"].plant_count() == 1 else "plants"})') option_list_length = len(option_list) if option_list_length == 0: print( "All of your Biomes are at maximum capacity please create a new biome!" ) input("\n\nPress any key to go back to the main menu...") else: print(f"{option_list_length + 1}. Main Menu") print("Release the plant into which biome?") choice = input("> ") if int(choice) == option_list_length + 1: return elif choice.isnumeric(): choice_input = int(choice) choice_biome = option_list[choice_input - 1] if choice_input <= option_list_length: choice_biome["biome"].add_plant(plant) else: display_banner() print( f"{choice_input} is not an option. Please choose an option that is available!" ) print_habitats() else: display_banner() print( f"{choice} is not an option. Please choose an option that is available!" ) print_habitats() print_habitats()
def cultivate_plant(arboretum): os.system('cls' if os.name == 'nt' else 'clear') plant = None print("1. Mountain Apple Tree") print("2. Silversword") print("3. Blue Jade Vine") print("4. Rainbow Eucalyptus Tree") choice = input("Choose a plant to cultivate : ") if choice == "1": plant = Apple_Tree() if choice == "2": plant = Silversword() if choice == "3": plant = Blue_Jade_Vine() if choice == "4": plant = Eucalyptus() habitat_list = [] try: if plant.stagnant: habitat_list.extend(arboretum.swamps) except AttributeError: pass try: if plant.mountain_bound: habitat_list.extend(arboretum.mountains) except AttributeError: pass try: if plant.grassland_bound: habitat_list.extend(arboretum.grasslands) except AttributeError: pass try: if plant.forest_bound: habitat_list.extend(arboretum.forests) except AttributeError: pass if len(habitat_list) > 0: for index, habitats in enumerate(habitat_list): plant_list = list() plant_count = list() for species in habitats.plants: plant_list.append(species.species) for plants in set(plant_list): plant_count.append(f"{str(plant_list.count(plants))} {plants}") print( f'{index + 1}. {habitats.type} ({", ".join(plant_count) if len(habitats.plants) > 0 else "No plants here"})' ) print("Release the plant into which habitat?") else: print("There is no habitat for this plant!") choice = input(": ") if len(habitat_list[int(choice) - 1].plants) < habitat_list[int(choice) - 1].max_plants: habitat_list[int(choice) - 1].plants.append(plant) else: print( "**** That Habitat is not large enough **** \n **** Please choose another one ****" ) for index, habitats in enumerate(habitat_list): print( f'{index + 1}. {habitats.type} ({len(habitats.plants)} plants)' ) print("Release the plant into which Habitat?") choice = input(": ")
def step_one(): os.system('cls' if os.name == 'nt' else 'clear') # Build a list of appropriate environment instances # based on the duck-type checks of the environments' # add_plant methods def determine_environs(plant_instance): # Starting a list of appropriate environments appropriate_environs = [] # check if there are instances of the environment if len(arboretum.coastlines) > 0: # use the test_plant method, which will return true if # the plant is valid for that environment if arboretum.coastlines[0].test_plant(plant_instance): appropriate_environs.append(arboretum.coastlines) if len(arboretum.forests) > 0: if arboretum.forests[0].test_plant(plant_instance): appropriate_environs.append(arboretum.forests) if len(arboretum.grasslands) > 0: if arboretum.grasslands[0].test_plant(plant_instance): appropriate_environs.append(arboretum.grasslands) if len(arboretum.mountains) > 0: if arboretum.mountains[0].test_plant(plant_instance): appropriate_environs.append(arboretum.mountains) if len(arboretum.rivers) > 0: if arboretum.rivers[0].test_plant(plant_instance): appropriate_environs.append(arboretum.rivers) if len(arboretum.swamps) > 0: if arboretum.swamps[0].test_plant(plant_instance): appropriate_environs.append(arboretum.swamps) return appropriate_environs #Present menu options header(title) print("1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus Tree") print("4. Blue Jade Vine") print("0. Return to main menu") #Present and handle choice choice = input("Choose plant to cultivate > ") plant = "" # If choice is not an integer, it will be handled by the except: try: choice = int(choice) # This should not really be a hard-coded range, # but for the purposes of this exercise, it won't change if choice >= 0 and choice <= 4: if choice == 1: plant = MountainAppleTree() elif choice == 2: plant = Silversword() elif choice == 3: plant = RainbowEucalyptusTree() elif choice == 4: plant = BlueJadeVine() elif choice == 0: return 0 else: input( "There are no appropriate environments for that plant. Press ENTER to choose a new plant. > " ) step_one() #build a list of environment appropriate environ instances environs = determine_environs(plant) # move on to step two, with # the appropriate environ instances # and selected plant instance if len(environs) > 0: step_two(environs, plant) else: input( "There are no appropriate environments for that plant. Press ENTER to choose a new plant. > " ) step_one() else: input(f"Choose a valid option. Hit ENTER to try again. >") step_one() except ValueError: input(f"Choose a valid option. Hit ENTER to try again. >") step_one()
def cultivate_plant(arboretum): print("1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus Tree") print("4. Blue Jade Vine") print("5. Cancel") choice = input("\nChoose a plant to cultivate > \n") if choice == "1": if len(arboretum.mountains) > 0: #Create Instance of the plant mountain_apple_tree = Mtn_Apple_Tree() #Function that takes the plant instance as the argument def sub_menu_1(plant): #A loop that creates the menu options from the list of mountains inside our arboretum object for index, mountain in enumerate(arboretum.mountains): try: print(f'{index + 1}. Mountain ({len(mountain.plants)} plants)') except: pass print(f'x. cancel') choice = input("\nWhere would you like to plant the Mountain Apple Tree > \n") if choice == "x": pass #if the user input is a number greater than the number of choices provided then print error elif int(choice) > len(arboretum.mountains): print(f'Invalid Entry. Please choose from menu.') sub_menu_1(plant) #Selects the correct mountain from the list and adds the instance of plant using the add_plant method on the mountain object else: arboretum.mountains[int(choice) - 1].add_plant(plant, sub_menu_1) #Calls the function sub_menu_1(mountain_apple_tree) #Ensures that a user cannot select to add a plant without adding a biome else: print(f'\nThere are no biomes available for this plant! Please annex one.\n') #The same logic is used for every choice besides choice 4 and 5 elif choice == "2": if len(arboretum.grasslands) > 0: silversword = Silversword() def sub_menu_2(plant): for index, grassland in enumerate(arboretum.grasslands): try: print(f'{index + 1}. Grassland ({len(grassland.plants)} plants)') except: pass print(f'x. cancel') choice = input("\nWhere would you like to plant the Silversword > \n") if choice == "x": pass elif int(choice) > len(arboretum.grasslands): print(f'Invalid Entry. Please choose from menu.') sub_menu_2(plant) else: arboretum.grasslands[int(choice) - 1].add_plant(plant, sub_menu_2) sub_menu_2(silversword) else: print(f'\nThere are no biomes available for this plant! Please annex one.\n') elif choice == "3": if len(arboretum.forests) > 0: rainbow_tree = Rainbow_Tree() def sub_menu_3(plant): for index, forest in enumerate(arboretum.forests): try: print(f'{index + 1}. Forest ({len(forest.plants)} plants)') except: pass print(f'x. cancel') choice = input("\nWhere would you like to plant the Rainbow Eucalyptus Tree > \n") if choice == "x": pass elif int(choice) > len(arboretum.forests): print(f'Invalid Entry. Please choose from menu.') sub_menu_3(plant) else: arboretum.forests[int(choice) - 1].add_plant(plant, sub_menu_3) sub_menu_3(rainbow_tree) else: print(f'\nThere are no biomes available for this plant! Please annex one.\n') #Choice 4 is a plant that could go into mutliple biomes elif choice == "4": if len(arboretum.swamps) or len(arboretum.grasslands) > 0: #Creates the instance of the plant blue_jade = Blue_Jade() #Function that takes the plant instance as an argument def sub_menu_4(plant): #Loop trickery to get the correct numbering for the list when there are two types of biomes to account for num = 1 for swamp in arboretum.swamps: try: print(f'{num}. {swamp.name} ({len(swamp.plants)} plants)') num += 1 except: pass for grassland in arboretum.grasslands: try: print(f'{num}. {grassland.name} ({len(grassland.plants)} plants)') num += 1 except: pass print(f'x. cancel') choice = input("\nWhere would you like to plant the Blue Jade Vine > \n") #Caculation the length of the swamp list by itself and with the grassland list swamp_length = len(arboretum.swamps) both = swamp_length + len(arboretum.grasslands) if choice == "x": pass #the length of both list is used for input validation elif int(choice) > both: print(f'Invalid Entry. Please choose from menu.') sub_menu_4(plant) elif int(choice) <= swamp_length: arboretum.swamps[int(choice) - 1].add_plant(plant, sub_menu_4) #the length of the swamp list is used to calculate what index number the chosen swamp is at else: arboretum.grasslands[int(choice) - swamp_length - 1].add_plant(plant, sub_menu_4) #The function is called and the instance is passed in sub_menu_4(blue_jade) else: print(f'\nThere are no biomes available for this plant! Please annex one.\n') elif choice == "5": pass #Tricky input validation else: print(f'\nThis is not a valid input\n')
def add_plant(Arboretum): plant = None print("") print("1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus Tree") print("4. Blue Jade Vine") print("") choice = input("Choose plant to cultivate > ") if choice == "1": plant = MountainAppleTree() print("") print(plant) input("Press enter to continue...") if choice == "2": plant = Silversword() print("") print(plant) input("Press enter to continue...") if choice == "3": plant = RainbowEucalyptusTree() print("") print(plant) input("Press enter to continue...") if choice == "4": plant = BlueJadeVine() print("") print(plant) input("Press enter to continue...") biomes = [Arboretum.rivers, Arboretum.grasslands, Arboretum.swamps, Arboretum.mountains, Arboretum.forests] options = [] for environment in biomes: for biome in environment: options.append(biome) for index, option in enumerate(options): print("") print(f'{index + 1}. {option} ({len(option.plants)} plants)') if len(options) > 0: print("") print(f"Where would you like to plant {plant}?") choice = input("> _") options[int(choice) - 1].add_plant(plant) else: print("") print("There have been no biomes annexed yet") print("") input("Press enter to continue")
def cultivate_plant(arboretum): compatible_biomes = [] plant = None print("1. Rainbow Eucalyptus Tree") print("2. Silversword") print("3. Mountain Apple Tree") print("4. Blue Jade Vine") choice = input("\nChoose plant to cultivate > ") if choice == "1": plant = Rainbow_Eucalyptus_Tree() elif choice == "2": plant = Silversword() elif choice == "3": plant = Mountain_Apple_Tree() elif choice == "4": plant = Blue_Jade_Vine() else: input( "\nThat was a bad input, try again next time, fool! \nPress any key to return to the menu..." ) return if isinstance(plant, Clay_Soil): for plant_in_list in arboretum.mountains: compatible_biomes.append(plant_in_list) if isinstance(plant, Loamy_Soil): for plant_in_list in arboretum.forests: compatible_biomes.append(plant_in_list) if isinstance(plant, Marsh_Soil): for plant_in_list in arboretum.swamps: compatible_biomes.append(plant_in_list) if isinstance(plant, Silt_Soil): for plant_in_list in arboretum.grasslands: compatible_biomes.append(plant_in_list) for index, biome in enumerate(compatible_biomes): print(f'{index + 1}. {biome.name} ({len(biome.plants)} plants)') def add_plant(choice): if choice == "": input("Press any key to return to the menu...") return try: if choice != "" and int(choice) <= len( compatible_biomes) and compatible_biomes[ int(choice) - 1].exceed_max(plant) == False: print("**** That biome is not large enough ****") print("**** Please choose another one ****") for index, biome in enumerate(compatible_biomes): print( f'{index + 1}. {biome.name} ({len(biome.plants)} plants)' ) choice = input("Cultivate the plant into which biome? >") add_plant(choice) elif choice != "" and int(choice) <= len(compatible_biomes): return else: input( "\nThat was a bad input, try again next time, fool! \nPress any key to return to the menu..." ) return except ValueError: input( "\nThat was a bad input, try again next time, fool! \nPress any key to return to the menu..." ) return if compatible_biomes == []: input( "Sorry, there are no compatible biomes in which to cultivate this plant. \nPlease annex a biome in menu option 1. \nPress any key to continue..." ) return choice = input("Cultivate the plant into which biome? >") add_plant(choice)
def add_plant(Arboretum): plant = None os.system('cls' if os.name == 'nt' else 'clear') print("\u001b[47m\u001b[30;1m+-++-++-++-++-++-++-++-+") print("+ A D D A P L A N T +") print("+-++-++-++-++-++-++-++-+\u001b[0m\n") print("\u001b[32m1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus Tree") print("4. Blue Jade Vine\u001b[0m\n") choice = input("Choose plant to cultivate > ") if choice == "1": plant = MountainAppleTree() print("") print(plant) input("Press enter to continue...") if choice == "2": plant = Silversword() print("") print(plant) input("Press enter to continue...") if choice == "3": plant = RainbowEucalyptusTree() print("") print(plant) input("Press enter to continue...") if choice == "4": plant = BlueJadeVine() print("") print(plant) input("Press enter to continue...") biomes = [ Arboretum.rivers, Arboretum.grasslands, Arboretum.swamps, Arboretum.mountains, Arboretum.forests ] options = [] for environment in biomes: for biome in environment: if len(biome.plants) < biome.plant_capacity: options.append(biome) for index, option in enumerate(options): print("") print(f'{index + 1}. {option} ({len(option.plants)} plants)') if len(options) > 0: print("") print(f"Where would you like to plant {plant}?") choice = input("> _") options[int(choice) - 1].add_plant(plant) else: print("") print("There have been no biomes annexed yet") print("") input("Press enter to continue")
def cultivate_plant(arboretum): plant = None print("1. Mountain Apple Tree") print("2. Silversword") print("3. Rainbow Eucalyptus Tree") print("4. Blue Jade Vine") choice = input("Choose plant to cultivate > ") if choice == "1": plant = MountainTree() new_list = [] if len(arboretum.mountains) > 0: for index, mountain in enumerate(arboretum.mountains): new_list.append({"index": index, "id": mountain.id, "type": "Mountain", "plants": mountain.plants, "plant_max": mountain.plant_max }) valid = False while valid == False: choice = print_biome(new_list) valid = check_capacity(choice) if choice["type"] == "Mountain" and valid: arboretum.mountains[int(choice["index"])].add_plant((plant)) if choice == "2": plant = Silversword() new_list = [] if len(arboretum.grasslands) > 0: for index, grassland in enumerate(arboretum.grasslands): new_list.append({"index": index, "id": grassland.id, "type": "Grassland", "plants": grassland.plants, "plant_max": grassland.plant_max }) valid = False while valid == False: choice = print_biome(new_list) valid = check_capacity(choice) if choice["type"] == "Grassland" and valid: arboretum.grasslands[int(choice["index"])].add_plant((plant)) if choice == "3": plant = RainbowTree() new_list = [] if len(arboretum.forests) > 0: for index, forest in enumerate(arboretum.forests): new_list.append({"index": index, "id": forest.id, "type": "Forest", "plants": forest.plants, "plant_max": forest.plant_max }) valid = False while valid == False: choice = print_biome(new_list) valid = check_capacity(choice) if choice["type"] == "Forest" and valid: arboretum.forests[int(choice["index"])].add_plant((plant)) if choice == "4": plant = BlueVine() new_list = [] if len(arboretum.grasslands) > 0: for index, grassland in enumerate(arboretum.grasslands): new_list.append({"index": index, "id": grassland.id, "type": "Grassland", "plants": grassland.plants, "plant_max": grassland.plant_max }) if len(arboretum.swamps) > 0: for index, swamp in enumerate(arboretum.swamps): new_list.append({"index": index, "id": swamp.id, "type": "Swamp", "plants": swamp.plants, "plant_max": swamp.plant_max }) valid = False while valid == False: choice = print_biome(new_list) valid = check_capacity(choice) if choice["type"] == "Grassland" and valid: arboretum.grasslands[int(choice["index"])].add_plant((plant)) elif choice["type"] == "Swamp" and valid: arboretum.swamps[int(choice["index"])].add_plant((plant))