Exemplo n.º 1
0
def main():
    """
    Create a character for Dungeons and Dragons.

    User inputs the length of the name to be generated
    Attributes and inventory are rolled.
    :postcondition: character name, attributes, and inventory will be printed
    """

    # Ask user for the length of their username
    name_length = int(input("Enter the length of your username: "******"Rolling for strength, dexterity, constitution, intelligence, wisdom, charisma..."
    )
    character = lab05.create_character(name_length)

    # Show rolls
    print(
        f"You rolled: {character[1][1]}, {character[2][1]}, {character[3][1]}, {character[4][1]}, {character[5][1]}, {character[6][1]}!"
    )
    print("\n")

    # A list of possible items in the game
    item_list = [
        'Rabadon\'s Deathcap', 'Seraph\'s Embrace', 'Liandry\'s Torment',
        'Morellonomicon', 'Warmog\'s Armor', 'Randuin\'s Omen',
        'Banshee\'s Veil', 'Abyssal\' Mask', 'Infinity Edge',
        'The Bloodthirster', 'Phantom Dancer', 'Rapidfire Cannon',
        'Boots of Lucidity', 'Boots of Swiftness', 'Boots of Alacrity',
        'Mercury Treads'
    ]

    # Show items in the store
    print("--Available items in the store--")
    for item in item_list:
        print(item)
    print("\n")

    # Ask user for how many items they would like
    num_of_items = int(input("How many items would you like? (MAX 16): "))
    print("\n")
    print("----------------------------------------------------")

    # Choose items for the character's inventory using choose_inventory()
    character_items = lab05.choose_inventory(item_list, num_of_items)
    character.append(character_items)

    # Print character info
    lab05.print_character(character)
    return
Exemplo n.º 2
0
 def test_print_character(
     self, mock_stdout
 ):  # a list with these attributes should print expected_output
     expected_output = "Your character is named Test\nYour Strength is 15\n" \
                       "Your Dexterity is 12\nYour Constitution is 14\n" \
                       "Your Intelligence is 6\nYour Wisdom is 10\n" \
                       "Your Charisma is 10\nYou don\'t have any items right now.\n"
     print_character([
         'Test', ['Strength', 15], ['Dexterity', 12], ['Constitution', 14],
         ['Intelligence', 6], ['Wisdom', 10], ['Charisma', 10]
     ])
     self.assertEqual(mock_stdout.getvalue(), expected_output)
Exemplo n.º 3
0
 def test_print_character_no_bag(self, mock_output):
     character = ["Bahedi", ["Strength", 3], ["Dexterity", 6], ["Constitution", 9],
                  ["Intelligence", 12], ["Wisdom", 15], ["Charisma", 18]]
     expected_output = f"Your character's name is {character[0]}.\n" \
                       f"\n" \
                       f"--Attributes--\n" \
                       f"{character[1][0]}: {character[1][1]}\n" \
                       f"{character[2][0]}: {character[2][1]}\n" \
                       f"{character[3][0]}: {character[3][1]}\n" \
                       f"{character[4][0]}: {character[4][1]}\n" \
                       f"{character[5][0]}: {character[5][1]}\n" \
                       f"{character[6][0]}: {character[6][1]}\n"
     print_character(character)
     self.assertEqual(expected_output, mock_output.getvalue())
Exemplo n.º 4
0
 def test_print_character_bag_with_items(self, mock_output):
     character = ["Bahedi", ["Strength", 3], ["Dexterity", 6], ["Constitution", 9],
                  ["Intelligence", 12], ["Wisdom", 15], ["Charisma", 18],
                  ["Boots of Swiftness", "Boots of Lucidity"]]
     expected_output = f"Your character's name is {character[0]}.\n" \
                       f"\n" \
                       f"--Attributes--\n" \
                       f"{character[1][0]}: {character[1][1]}\n" \
                       f"{character[2][0]}: {character[2][1]}\n" \
                       f"{character[3][0]}: {character[3][1]}\n" \
                       f"{character[4][0]}: {character[4][1]}\n" \
                       f"{character[5][0]}: {character[5][1]}\n" \
                       f"{character[6][0]}: {character[6][1]}\n" \
                       f"\n--Inventory--\n" \
                       f"Boots of Swiftness\n" \
                       f"Boots of Lucidity\n"
     print_character(character)
     self.assertEqual(expected_output, mock_output.getvalue())
Exemplo n.º 5
0
def main():
    """
    Drive the program.

    Tests the functions created in this module.
    """

    print('Welcome to the D&D Character Generator!\n')

    name_length = int(
        input('How many syllables should your character\'s name have?: '))
    character_info = create_character(name_length)
    print_character(character_info)

    shop_items = [
        'Sword of Sanctimony', 'Potion of Python', 'Daggers of Deception',
        'Staff of Serenity', 'Juggling Balls of JavaScript',
        'Detonator of Divide-by-Zero', 'Gloves of Genius',
        'Map of Misdirection', 'Crossbow of Courage',
        'Charm of Chris\' Approval', 'Cloak of Confusion',
        'Takashi\'s Donut Box', 'Bottle of Binary', 'Axe of Asking Questions'
    ]

    print('\nToday there are', len(shop_items),
          'shop items available. They are:')
    for i in shop_items:
        print(i)

    item_number = int(input('\nHow many items would you like to purchase?: '))
    item_selection = choose_inventory(shop_items, item_number)

    print('You received these items:')
    for i in item_selection:
        print(i)

    character_info.append(item_selection)
    print('\n~~~ Your final character! ~~~')
    print_character(character_info)