示例#1
0
 def test_create_character_1(self, mock_letter, mock_roll):
     syllables = 1
     expected = [
         "Ba", ["Strength", 1], ["Dexterity", 2], ["Constitution", 3],
         ["Intelligence", 4], ["Wisdom", 5], ["Charisma", 6]
     ]
     self.assertEqual(expected, create_character(syllables))
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
示例#3
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)
示例#4
0
 def test_following_lists(self):
     for i in range(1, len(create_character(
             4))):  # every list item after first should be a list
         self.assertIsInstance((create_character(4))[i], list)
示例#5
0
 def test_starting_name(self):  # check if first item in list is string
     self.assertIsInstance((create_character(3))[0], str)
示例#6
0
 def test_length(self):
     self.assertEqual(len(create_character(2)), 7)