def release_animal(arboretum): os.system('cls' if os.name == 'nt' else 'clear') animal = None placement = None print("1. Gold Dust Day Gecko") print("2. Nene Goose") print("3. Kīkākapu") print("4. Ope'ape'a") print("5. Pueo") print("6. River Dolphin") print("7. Happy Face Spider") print("8. Ulae") choice = input("Choose animal to release > ") if choice == "1": animal = GoldDustDayGecko() arboretum.gold_dust_day_gecko.append(animal) placement = "gecko" if choice == "2": animal = NeneGoose() arboretum.nene_goose.append(animal) placement = "goose" if choice == "3": animal = Kikakapu() arboretum.kikakapu.append(animal) placement = "kikakapu" if choice == "4": animal = Opeapea() arboretum.opeapea.append(animal) placement = "opeapea" if choice == "5": animal = Pueo() arboretum.pueo.append(animal) placement = "pueo" if choice == "6": animal = RiverDolphin() arboretum.river_dolphins.append(animal) placement = "river_dolphin" if choice == "7": animal = HappyFaceSpider() arboretum.happy_face_spider.append(animal) placement = "spider" if choice == "8": animal = Ulae() arboretum.ulae.append(animal) placement = "ulae" choose_environment(arboretum, animal, placement)
def feed_animal_menu(arboretum): os.system('cls' if os.name == 'nt' else 'clear') animal = None print("1. Gold Dust Day Gecko") print("2. River Dolphin") print("3. Nene Goose") print("4. Kīkākapu") print("5. Pueo") print("6. 'Ulae") print("7. Ope'ape'a") print("8. Happy-Face Spider") print() print("Choose an animal to feed.") choice = input("> ") try: int(choice) == int if int(choice) > 0 and int(choice) < 9: if choice == "1": animal = GoldDustDayGecko() feed_animal(animal) if choice == "2": animal = RiverDolphin() feed_animal(animal) if choice == "3": animal = NeneGoose() feed_animal(animal) if choice == "4": animal = Kikakapu() feed_animal(animal) if choice == "5": animal = Pueo() feed_animal(animal) if choice == "6": animal = Ulae() feed_animal(animal) if choice == "7": animal = Opeapea() feed_animal(animal) if choice == "8": animal = HappyFaceSpider() feed_animal(animal) else: input("Please select a valid entry, the animals are hungry. Press any key to return to the main menu... ") except ValueError: print() error_message = input("Animals can't eat letters. Press any key to return to the main menu... ") except IndexError: print() error_message = input("Please select a valid entry, the animals are hungry. Press any key to return to the main menu... ")
def release_animal(arboretum): build_release_animal_menu() animal = None choice = input("Choose animal to release > ") if choice == "1": animal = GoldDustDayGecko() if choice == "2": animal = RiverDolphin() if choice == "3": animal = NeneGoose() if choice == "4": animal = Kikakapu() if choice == "5": animal = Pueo() if choice == "6": animal = Ulae() if choice == "7": animal = Opeapea() if choice == "8": animal = HappyFacedSpider() build_biome_choices(animal, arboretum, True)
def release_animal(arboretum): valid_option = True os.system('cls' if os.name == 'nt' else 'clear') animal = None print("1. Gold Dust Day Gecko") print("2. River Dolphin") print("3. Nene Goose") print("4. Kīkākapu") print("5. Pueo") print("6. 'Ulae") print("7. Ope'ape'a") print("8. Happy-Face Spider") print() print("Choose animal.") choice = input("> ") try: if int(choice) > 0 and int(choice) < 9: if choice == "1": animal = GoldDustDayGecko() if choice == "2": animal = RiverDolphin() if choice == "3": animal = NeneGoose() if choice == "4": animal = Kikakapu() if choice == "5": animal = Pueo() if choice == "6": animal = Ulae() if choice == "7": animal = Opeapea() if choice == "8": animal = HappyFaceSpider() else: pass 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 if int(choice) > 0 and int(choice) < 9: for index, river in enumerate(arboretum.rivers): if river.max_animals > len(river.animals): print(f'{num}. River ({len(river.animals)} animals)') biome[num] = arboretum.rivers[index] num += 1 for index, mountain in enumerate(arboretum.mountains): if mountain.max_animals > len(mountain.animals): print( f'{num}. Mountain ({len(mountain.animals)} animals)' ) biome[num] = arboretum.mountains[index] num += 1 for index, swamp in enumerate(arboretum.swamps): if swamp.max_animals > len(swamp.animals): print(f'{num}. Swamp ({len(swamp.animals)} animals)') biome[num] = arboretum.swamps[index] num += 1 for index, grassland in enumerate(arboretum.grasslands): if grassland.max_animals > len(grassland.animals): print( f'{num}. Grassland ({len(grassland.animals)} animals)' ) biome[num] = arboretum.grasslands[index] num += 1 for index, forest in enumerate(arboretum.forests): if forest.max_animals > len(forest.animals): print(f'{num}. Forest ({len(forest.animals)} animals)') biome[num] = arboretum.forests[index] num += 1 for index, coastline in enumerate(arboretum.coastlines): if coastline.max_animals > len(coastline.animals): print( f'{num}. Coastline ({len(coastline.animals)} animals)' ) biome[num] = arboretum.coastlines[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 KeyError: os.system('cls' if os.name == 'nt' else 'clear') 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') 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') input( "Please enter a valid option next time. Press enter to return to the main menu..." ) if valid_option: menu_function() print() print("Where would you like to place the animal?") choice = input("> ") try: env = biome[int(choice)] def choice_fn(environment): try: environment.add_animal(animal) except ValueError: os.system('cls' if os.name == 'nt' else 'clear') input( "The environment is not suitable for that animal. Press any key to continue..." ) pass except KeyError: os.system('cls' if os.name == 'nt' else 'clear') input( "The environment is not suitable for that animal. Press any key to continue..." ) pass except AttributeError: os.system('cls' if os.name == 'nt' else 'clear') input( "The environment is not suitable for that animal. Press any key to continue..." ) pass choice_fn(env) except ValueError: pass except KeyError: pass except AttributeError: pass
def release_animal(arboretum, wrong_choice): """ Prompts user to create an Animal to release into an Enviornment. """ animal = None if wrong_choice != True: print_header() print() print(f'{add_color("1.", "bright_cyan")} Gold Dust Day Gecko') print(f'{add_color("2.", "bright_cyan")} Hawaiian Happy-Face Spider') print(f'{add_color("3.", "bright_cyan")} Kīkākapu') print(f'{add_color("4.", "bright_cyan")} Nene Goose') print(f'{add_color("5.", "bright_cyan")} Ope\'ape\'a') print(f'{add_color("6.", "bright_cyan")} Pueo') print(f'{add_color("7.", "bright_cyan")} River Dolphin') print(f'{add_color("8.", "bright_cyan")} \'Ulae') print() print( f'{add_color("Select an animal to release", "WARNING")}{CLColors.ENDC}' ) choice = input("> ") if choice == "1": animal = GoldDustDayGecko() elif choice == "2": animal = HawaiianHappyFaceSpider() elif choice == "3": animal = Kikakapu() elif choice == "4": animal = NeneGoose() elif choice == "5": animal = OpeApeA() elif choice == "6": animal = Pueo() elif choice == "7": animal = RiverDolphin() elif choice == "8": animal = RiverDolphin() else: wrong_choice = True clear() print( f'{add_color(f"{choice} is not an animal. Please make another selection.", "FAIL")}' ) print() release_animal(arboretum, wrong_choice) print(f'Getting the {animal.species} ready...') loading_sequence() time.sleep(1.5) clear() print(f'{add_color("Available Biomes:", "HEADER")}') print() biome_list = list() for index, coastline in enumerate(arboretum.coastlines): biome_list.append(coastline) for index, forest in enumerate(arboretum.forests): biome_list.append(forest) for index, grassland in enumerate(arboretum.grasslands): biome_list.append(grassland) for index, mountain in enumerate(arboretum.mountains): biome_list.append(mountains) for index, river in enumerate(arboretum.rivers): biome_list.append(river) for index, swamp in enumerate(arboretum.swamps): biome_list.append(swamp) for index, biome in enumerate(biome_list): print( f'{add_color(f"{index + 1}.", "bright_cyan")} {biome.name} {type(biome).__name__} [{str(biome.id)[:8]}]: ({len(biome.animals)} animals)' ) print() print() print( f'{add_color(f"Release the {animal.species} into which biome?", "WARNING")}' ) choice = input("> ") # check if choice selected exists as an index on the biome_list if (int(choice) - 1) < len(biome_list): biome = biome_list[int(choice) - 1] biome.add_animal(animal) print() print( f'Releasing the {animal.species} into the {biome.name} {type(biome).__name__}...' ) loading_sequence() time.sleep(1.5)
def release_animal(arboretum): biome_list = arboretum.rivers + arboretum.swamps + arboretum.grasslands + \ arboretum.forests + arboretum.coastlines + arboretum.mountains print("+-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-") print("+ C H O O S E A N I M A L F O R R E L E A S E +") print("+-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-") print('1. Gold Dust Day Gecko') print('2. Happy Faced Spider') print('3. Kikakapu') print('4. Nene Goose') print('5. Opeapea') print('6. Pueo') print('7. River Dolphin') print('8. Ulae') choice = input("Choose animal to release > ") if choice == "1": gold_dust_day_gecko = GoldDustDayGecko() arboretum.gold_dust_day_geckos.append(gold_dust_day_gecko) animal = river_dolphin if choice == "2": happy_faced_spider = HappyFacedSpider() if choice == "3": kikakapu = Kikakapu() if choice == "4": nene_goose = NeneGoose() if choice == "5": opeapea = Opeapea() if choice == "6": pueo = Pueo() if choice == "7": river_dolphin = RiverDolphin() arboretum.river_dolphins.append(river_dolphin) animal = river_dolphin if choice == "8": ulae = Ulae() print("Release the animal into which biome?") counter = 0 for river in arboretum.rivers: print(f'{counter + 1}. River [{river.id}]') counter += 1 for swamp in arboretum.swamps: print(f'{counter + 1}. Swamp [{swamp.id}]') counter += 1 for grassland in arboretum.grasslands: print(f'{counter + 1}. Grassland [{grassland.id}]') counter += 1 for forest in arboretum.forests: print(f'{counter + 1}. Forest [{forest.id}]') counter += 1 for coastline in arboretum.coastlines: print(f'{counter + 1}. Coastline [{coastline.id}]') counter += 1 for mountain in arboretum.mountains: print(f'{counter + 1}. Mountain [{mountain.id}]') counter += 1 choice = int(input("> ")) biome_list[choice - 1].add_animal(animal) print( f"{animal.species} [{animal.id}] was added to {biome_list[choice - 1].name} [{biome_list[choice - 1].id}]" ) input('Press enter to continue...')
def release_animal(arboretum): animal = None print_banner() print("ANIMAL RELEASE OPTIONS:") print("") print("1. Gold Dust Day Gecko") print("2. River Dolphin") print("3. Nene Goose") print("4. Kīkākapu") print("5. Pueo") print("6. 'Ulae") print("7. Ope'ape'a") print("8. Happy-Face Spider") print("") choice = input("Choose an animal to release >> ") if choice == "1": animal = GoldDustDayGecko() if choice == "2": animal = RiverDolphin() if choice == "3": animal = NeneGoose() if choice == "4": animal = Kikakapu() if choice == "5": animal = Pueo() if choice == "6": animal = Ulae() if choice == "7": animal = Opeapea() if choice == "8": animal = HawaiianHappyFaceSpider() # Get all biome lists biomes = [ arboretum.rivers, arboretum.coastlines, arboretum.swamps, arboretum.grasslands, arboretum.mountains, arboretum.forests ] # Create empty options list of available biome environments options = [] # iterate biome lists and add available environments to options list for biome in biomes: for environment in biome: if len(environment.animals) < environment.animal_max: options.append(environment) # iterate options list to create menu options for index, option in enumerate(options): print(f'{index + 1}. {option} ({len(option.animals)} animals)') # Handle if user has no options if len(options) > 0: # prompt user to place animal print("Release the animal into which biome?") choice = input("> ") # TODO check input is a valid option if int(choice) > 0 and int(choice) <= len(options) + 1: # place animal in selected biome list animal.age = animal.release_age options[int(choice) - 1].add_animal(animal) else: print("Invalid Entry") input("\n\nPress enter to continue...") else: print("No biomes available for this animal.") print("Select a different animal or annex a new biome.") input("\n\nPress enter to continue...")
def step_1(): os.system('cls' if os.name == 'nt' else 'clear') header("Release Animal") arboretum_biome_selection = [] arboretum_biome_selection.append(arboretum.rivers) arboretum_biome_selection.append(arboretum.swamps) arboretum_biome_selection.append(arboretum.coastlines) arboretum_biome_selection.append(arboretum.forests) arboretum_biome_selection.append(arboretum.mountains) arboretum_biome_selection.append(arboretum.grasslands) def all(arboretum_biome_selection): for biome in arboretum_biome_selection: if len(biome) == 0: return False else: return True all(arboretum_biome_selection) if all(arboretum_biome_selection) == False: input( "No habitats annexed. Press enter to return to the main menu..." ) return 0 else: print('1. Gold Dust Day Gecko') print('2. River Dolphin') print('3. Nene Goose') print('4. Kīkākapu') print('5. Pueo') print("6. 'Ulae") print("7. Ope'ape'a") print("8. Happy-Face Spider") print("0. Return to main menu") animal = None choice = input("Choose animal to release > ") if choice == "0": return 0 if choice == "1": print("Enter age for Gold Dust Day Gecko : ") answer1 = int(input()) print("Enter name for Gold Dust Day Gecko : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = GoldDustDayGecko(answer1, answer2) step_2(animal) if choice == "2": print("Enter age for River Dolphin : ") answer1 = int(input()) print("Enter name for River Dolphin : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = RiverDolphin(answer1, answer2) step_2(animal) if choice == "3": print("Enter age for Nene Goose : ") answer1 = int(input()) print("Enter name for Nene Goose : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = NeneGoose(answer1, answer2) step_2(animal) if choice == "4": print("Enter age for Kikakapu : ") answer1 = int(input()) print("Enter name for Kikakapu : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = Kikakapu(answer1, answer2) step_2(animal) if choice == "5": print("Enter age for Pueo : ") answer1 = int(input()) print("Enter name for Pueo : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = Pueo(answer1, answer2) step_2(animal) if choice == "6": print("Enter age for Ulae : ") answer1 = int(input()) print("Enter name for Ulae : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = Ulae(answer1, answer2) step_2(animal) if choice == "7": print("Enter age for Opeapea : ") answer1 = int(input()) print("Enter name for Opeapea : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = Opeapea(answer1, answer2) step_2(animal) if choice == "8": print("Enter age for Hawaiian Happy Face Spider : ") answer1 = int(input()) print("Enter name for Hawaiian Happy Face Spider : ") answer2 = input() if answer1 is not "" and answer2 is not "": animal = HawaiianHappyFaceSpider(answer1, answer2) step_2(animal)
def release_animal(arboretum): clear_screen() biomes_exist = check_for_biomes(arboretum) if not biomes_exist: return animal = None build_menu() choice = input("Choose animal to release > ") if choice == "1": animal = GoldDustDayGecko() elif choice == "2": animal = RiverDolphin() elif choice == "3": animal = NeneGoose() elif choice == "4": animal = Kikakapu() elif choice == "5": animal = Pueo() elif choice == "6": animal = Ulae() elif choice == "7": animal = Opeapea() elif choice == "8": animal = HawaiianHappyfaceSpider() elif choice.upper() == "Q": return else: input('Invalid input. Return to main menu.') return clear_screen() # setup dict and display ONLY biomes that the animal choice can go in based on requirements choice_dict = dict() build_species_biome_option_menu(arboretum, animal, choice_dict) # user selects biome type if not choice_dict: input('No biomes created that this animal can live in.\nPress any key and [Enter] to return to main menu to add one.') return print(f'Select a biome type to release the {animal.species} into.') choice = input("> ") # check for valid input choice and return to releas_animal menu if not try: biome_type = choice_dict[int(choice) - 1] except (KeyError, ValueError): input("Invalid input. Return to main menu.") # release_animal(arboretum) return # if valid choice, clear screen and proceed with selecting a biome clear_screen() biome_dict = dict() build_biome_menu(arboretum, biome_dict, biome_type) # print(biome_dict) # if ALL biomes of this type full, return to main menu after notification if not biome_dict: print(f'All biomes of this type are at max animal capacity.\nAnnex a new {biome_type[:-1]} habitat from the main menu.') os.system('say All biomes of this type are at max capacity' if os.name != 'nt' else '') input(' >> ') return print(f'Select the specific {biome_type[:-1]} to release the animal!') choice = input("> ") try: new_home = biome_dict[int(choice) - 1] # this gets the input choice and converts back to zero-indexed choice except (KeyError, ValueError, TypeError): input("Invalid input. Return to main menu.") # release_animal(arboretum) return if len(new_home.animals) < new_home.max_animals: new_home.animals.append(animal) os.system(f'say you just added a {animal.species} to your {new_home.name}' if os.name != 'nt' else '') else: print('No space for this animal. Press any key to show all the animals in this biome.') os.system(f'say no space for this animal' if os.name != 'nt' else '') input(' >> ') clear_screen() show_biome_animals(new_home) input('\nPress any key to return to main menu >>') return
def release_animal(self, choice): if choice == "1": animal_to_add = GoldDustDayGecko() potentialHabitatsForAddedAnimal = [ forest for forest in self.habitats_dict["Forest"] ] elif choice == "2": animal_to_add = RiverDolphin() potentialHabitatsForAddedAnimal = [ river for river in self.habitats_dict["River"] ] + [coastline for coastline in self.habitats_dict["Coastline"]] elif choice == "3": animal_to_add = NeneGoose() potentialHabitatsForAddedAnimal = [ grassland for grassland in self.habitats_dict["Grassland"] ] elif choice == "4": animal_to_add = Kikakapu() potentialHabitatsForAddedAnimal = [ river for river in self.habitats_dict["River"] ] + [swamp for swamp in self.habitats_dict["Swamp"]] elif choice == "5": animal_to_add = Pueo() potentialHabitatsForAddedAnimal = [ grassland for grassland in self.habitats_dict["Grassland"] ] + [forest for forest in self.habitats_dict["Forest"]] elif choice == "6": animal_to_add = Ulae() potentialHabitatsForAddedAnimal = [ coastline for coastline in self.habitats_dict["Coastline"] ] elif choice == "7": animal_to_add = Opeapea() potentialHabitatsForAddedAnimal = [ forest for forest in self.habitats_dict["Forest"] ] + [mountain for mountain in self.habitats_dict["Mountain"]] elif choice == "8": animal_to_add = HappyFaceSpider() potentialHabitatsForAddedAnimal = [ swamp for swamp in self.habitats_dict["Swamp"] ] else: print("That is not a valid choice.") return for i, v in enumerate(potentialHabitatsForAddedAnimal): valid_habitat = len(v.animals) < v.animal_limit if not valid_habitat: print('') else: print( f'{i + 1}. {type(v).__name__} ({len(v.animals)} animals)') # Prompts the user to select a habitat print(f"\nWhere would you like to release the {animal_to_add.species}") choice = input("> ") if int(choice) > len(potentialHabitatsForAddedAnimal): print("That is not a valid choice.") return targetHabitat = potentialHabitatsForAddedAnimal[int(choice) - 1] habitatTargetList = self.habitats_dict[type(targetHabitat).__name__] object_class_animal_to_add = habitatTargetList[habitatTargetList.index( targetHabitat)] if len(object_class_animal_to_add.animals ) < object_class_animal_to_add.animal_limit: object_class_animal_to_add.add_animal(animal_to_add) print( f"You have added an {animal_to_add.species} to {type(targetHabitat).__name__}" ) else: print( "That habitat is already at it's max for animals. Please choose another habitat" )
def feed_animal(self, choice): os.system('cls' if os.name == 'nt' else 'clear') if choice == "1": animal_to_feed = GoldDustDayGecko() elif choice == "2": animal_to_feed = RiverDolphin() elif choice == "3": animal_to_feed = NeneGoose() elif choice == "4": animal_to_feed = Kikakapu() elif choice == "5": animal_to_feed = Pueo() elif choice == "6": animal_to_feed = Ulae() elif choice == "7": animal_to_feed = Opeapea() elif choice == "8": animal_to_feed = HappyFaceSpider() else: print("No no. Feed something else.") return for i, v in enumerate(animal_to_feed.prey): print(f'{i + 1}. {v}') print("Which prey do you want to feed the animal?") choice = input("> ") targetPrey = animal_to_feed.prey[int(choice) - 1] animal_to_feed.feed(targetPrey)