def test_choose_inventory_entire_stock_min(self):
     self.assertEqual(choose_inventory(shop(), 12), [
         '100 Ball Barrings', '2 Health Potion', '50ft of Rope',
         "An Adventurer's Kit", 'Broad Sword', 'Chain-mail Armour',
         'Cloth Robes', 'Iron Dagger', 'Leather Armour',
         'One Week of Provisions', 'Shield', 'War Axe'
     ])
Exemple #2
0
 def test_print_inventory_actual(self, mock_stdout):
     expected_output = "Ugad's items: 2 Health Potion, Broad Sword, Broad Sword, Chain-mail Armour, Iron Dagger, \n"
     actual_value = print_items([
         'Name', 'Ugad', 'Strength', '14', 'Dexterity', '8', 'Constitution',
         '8', 'Intelligence', '15', 'Wisdom', '9', 'Charisma', '12',
         [
             '2 Health Potion', 'Broad Sword', 'Broad Sword',
             'Chain-mail Armour', 'Iron Dagger'
         ]
     ], shop(), 5)
     self.assertEqual(expected_output, mock_stdout.getvalue())
def main():
    print(
        "\nYou stroll into a store, blood pumping as the idea of adventure fills your mind.\n"
    )
    print('"Welcome to Orvishs Odds and Ends" calls a voice by the counter.\n')
    bought = int(input('"How many items can I interest you with?" '))
    inventory_chosen = choose_inventory(shop(), bought)
    choose_inventory_messages(shop(), inventory_chosen, bought)
    print(
        "\nAs you walk out of Orvishs Odds and Ends you notice a broken mirror leaning on the building wall.\n"
    )
    print(
        "Looking in the miror at your reflection, a thought crosses your mind. 'I need a name for myself!'\n"
    )
    name = int(
        input(
            "'Not something terribly long. How many syllables? I know! How about' "
        ))
    character = create_character(name)
    print("'", name, "is the perfect amount! Now the letters.'\n")
    print(
        "As you sit there, concentrating really hard you decide on your adventuring name, "
        "as well as calculating your different attributes and items you own.\n"
    )
    print_character(character)
    add_items_to_character(character, inventory_chosen)
    print_items(character, shop(), bought)
    input("Press Enter to Continue")
    if bought <= 0:
        print(
            "\nYour heart races even more as you step out through the town's gate, "
            "ready to start your first adventure.\nBut as you step through the gate, a Gigantic Ancient White Dragon"
            " flies overhead, breathing intense frost all over the town, including yourself.\nFrozen to death, "
            "your corpse sits there, becoming a decoration for the dragons lair."
        )
    elif bought > 0:
        print(
            "\nYour head starts to race with the idea of adventure.'Just through this ally is the front gate of town!"
            "' you think to yourself.\nSuddenly, a sharp pain is felt in the back of your neck as you get jumped "
            "by multiple thiefs.\n'Look at all this loot he has!' is the last thing you hear before you fall to the "
            "dark abyss of death.")
 def test_choose_inventory_armoured_up(self, mock_random):
     self.assertEqual(choose_inventory(shop(), 2),
                      ['Chain-mail Armour', 'Chain-mail Armour'])
 def test_choose_inventory_the_floor_is_ball_barrings(self, mock_random):
     self.assertEqual(choose_inventory(shop(), 5), [
         '100 Ball Barrings', '100 Ball Barrings', '100 Ball Barrings',
         '100 Ball Barrings', '100 Ball Barrings'
     ])
 def test_choose_inventory_worried_wizard(self, mock_random):
     self.assertEqual(choose_inventory(shop(), 5), [
         '2 Health Potion', '2 Health Potion', '2 Health Potion',
         '2 Health Potion', '2 Health Potion'
     ])
 def test_choose_inventory_dagger_dagger_dagger(self, mock_random):
     self.assertEqual(choose_inventory(shop(), 3),
                      ['Iron Dagger', 'Iron Dagger', 'Iron Dagger'])
 def test_choose_inventory_dual_wield_axes(self, mock_random):
     self.assertEqual(choose_inventory(shop(), 2), ['War Axe', 'War Axe'])
 def test_choose_inventory_one_input(self, mock_random):
     self.assertEqual(choose_inventory(shop(), 1), ['Broad Sword'])
 def test_choose_inventory_zero_input(self):
     self.assertEqual(choose_inventory(shop(), 0), [])
 def test_choose_inventory_negative_input(self):
     self.assertEqual(choose_inventory(shop(), -12), [])