예제 #1
0
                    "Invalid input. Ensure that it follows Name:Value format eg. Gold Pieces:100"
                )
            else:
                coins[name] = value
        World.economy = World.Money(coins)
        print(World.economy)

    def createLocation(self):
        """Creates a location in the World.locations list"""
        name = input("Input the name of the location: ")
        Type = input(
            "Input the type of location it is eg. city, farmhouse, cave: ")
        notes = ""
        print(f"Input notes about {name}. Enter an empty line to enter")
        while line := input():
            notes += line + "\n"
        World.locations.append(World.Location(name, Type, notes))

    def printLocation(self):
        """Lists out the locations in the World.locations list
        Let's the user view one of the locations"""
        if not World.locations:
            print(
                "There are no locations. Please Create one before viewing locations"
            )
            return
        for i, location in enumerate(World.locations):
            print(f"{i+1})\t{location.name}")
        x = int(input("Input a number to view a location: ")) - 1
        print(World.locations[x])