コード例 #1
0
 def test_choose_inventory_4_n1_print(self, mock_items, mock_output):
     inventory = [
         'Rabadon\'s Deathcap', 'Abyssal\' Mask', 'Rapidfire Cannon',
         'Boots of Lucidity'
     ]
     selection = -1
     expected = "WARNING: The number of items selected is negative.\n"
     choose_inventory(inventory, selection)
     self.assertEqual(expected, mock_output.getvalue())
コード例 #2
0
 def test_choose_inventory_4_2(self, mock_items, mock_output):
     inventory = [
         'Rabadon\'s Deathcap', 'Abyssal\' Mask', 'Rapidfire Cannon',
         'Boots of Lucidity'
     ]
     selection = 2
     self.assertEqual(['Boots of Lucidity', 'Rapidfire Cannon'],
                      choose_inventory(inventory, selection))
コード例 #3
0
 def test_choose_inventory_4_n1_value(self, mock_items, mock_output):
     inventory = [
         'Rabadon\'s Deathcap', 'Abyssal\' Mask', 'Rapidfire Cannon',
         'Boots of Lucidity'
     ]
     selection = -1
     expected = []
     self.assertEqual(expected, choose_inventory(inventory, selection))
コード例 #4
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
コード例 #5
0
ファイル: game_driver.py プロジェクト: Cragzu/comp1510-labs
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)
コード例 #6
0
 def test_empty_values(self):
     self.assertEqual([], choose_inventory([], 0))
コード例 #7
0
 def test_successful(self):
     for i in choose_inventory(['c', 'b', 'd', 'a', 'e'], 3):
         self.assertIn(i, ['a', 'b', 'c', 'd', 'e'])
コード例 #8
0
 def test_greater_selection(self):
     self.assertEqual(['a', 'b', 'c'], choose_inventory(['c', 'a', 'b'], 5))
コード例 #9
0
 def test_equal_selection(self):
     self.assertEqual(['a', 'b', 'c'], choose_inventory(['c', 'a', 'b'], 3))
コード例 #10
0
 def test_negative_selection(self):
     self.assertEqual([], choose_inventory(['c', 'b', 'd', 'a', 'e'], 0))
コード例 #11
0
 def test_choose_inventory_0_0(self, mock_items, mock_output):
     inventory = []
     selection = 0
     expected = []
     self.assertEqual(expected, choose_inventory(inventory, selection))
コード例 #12
0
 def test_choose_inventory_0_4_print(self, mock_items, mock_output):
     inventory = []
     selection = 4
     expected = "WARNING: The number of items selected is larger than the size of the inventory.\n"
     choose_inventory(inventory, selection)
     self.assertEqual(expected, mock_output.getvalue())
コード例 #13
0
 def test_choose_inventory_0_n1_print(self, mock_items, mock_output):
     inventory = []
     selection = -1
     expected = "WARNING: The number of items selected is negative.\n"
     choose_inventory(inventory, selection)
     self.assertEqual(expected, mock_output.getvalue())