def test_attack_hp_below_0(self, mock_roll, mock_output):
     player_1 = {
         "Name": "Ophelia",
         "Class": "monk",
         "Race": "elf",
         "HP": [8, 8],
         "Strength": 3,
         "Dexterity": 3,
         "Constitution": 3,
         "Intelligence": 3,
         "Wisdom": 3,
         "Charisma": 3,
         "XP": 0,
         "Inventory": ["Boots of Swiftness", "Boots of Alacrity"]
     }
     player_3 = {
         "Name": "Blake",
         "Class": "sorcerer",
         "Race": "human",
         "HP": [6, 0],
         "Strength": 3,
         "Dexterity": 3,
         "Constitution": 3,
         "Intelligence": 3,
         "Wisdom": 3,
         "Charisma": 3,
         "XP": 0,
         "Inventory": ["Boots of Swiftness", "Boots of Alacrity"]
     }
     expected = f"Blake is dead!\n"
     attack(player_3, player_1)
     self.assertEqual(expected, mock_output.getvalue())
 def test_attack_success(self, mock_roll, mock_output):
     player_1 = {
         "Name": "Ophelia",
         "Class": "monk",
         "Race": "elf",
         "HP": [8, 8],
         "Strength": 3,
         "Dexterity": 3,
         "Constitution": 3,
         "Intelligence": 3,
         "Wisdom": 3,
         "Charisma": 3,
         "XP": 0,
         "Inventory": ["Boots of Swiftness", "Boots of Alacrity"]
     }
     player_2 = {
         "Name": "Peachy",
         "Class": "monk",
         "Race": "elf",
         "HP": [8, 4],
         "Strength": 3,
         "Dexterity": 3,
         "Constitution": 3,
         "Intelligence": 3,
         "Wisdom": 3,
         "Charisma": 3,
         "XP": 0,
         "Inventory": ["Boots of Swiftness", "Boots of Alacrity"]
     }
     expected = "Peachy's HP: 4/8\n" \
                "The attack was a success!\n" \
                "Peachy took 1 damage.\n" \
                "Peachy's HP: 3/8\n\n"
     attack(player_1, player_2)
     self.assertEqual(expected, mock_output.getvalue())
Esempio n. 3
0
 def test_attack_miss_output(self, mock_roll_die, mock_stdout):
     bad_fighter = {
         "Name": "Monoza",
         "Class": "sorcerer",
         "HP": 1,
         "Strength": 12,
         "Dexterity": 12,
         "Constitution": 3,
         "Intelligence": 9,
         "Wisdom": 9,
         "Charisma": 18,
         "XP": 0,
         "Inventory": ["The Elder Wand"]
     }
     good_defender = {
         "Name": "Bagiko",
         "Class": "bard",
         "HP": 4,
         "Strength": 12,
         "Dexterity": 18,
         "Constitution": 15,
         "Intelligence": 9,
         "Wisdom": 6,
         "Charisma": 9,
         "XP": 0,
         "Inventory": ["The Unicorn Horn", "The Belmont Whip"]
     }
     expected_output = "Monoza strikes!\n" \
                       "Monoza missed!\n"
     dungeonsanddragons.attack(bad_fighter, good_defender)
     self.assertEqual(mock_stdout.getvalue(), expected_output)
Esempio n. 4
0
 def test_attack_hit_defender_lives_output(self, mock_roll_die,
                                           mock_stdout):
     good_fighter = {
         "Name": "Kelabi",
         "Class": "barbarian",
         "HP": 10,
         "Strength": 15,
         "Dexterity": 12,
         "Constitution": 6,
         "Intelligence": 9,
         "Wisdom": 9,
         "Charisma": 12,
         "XP": 0,
         "Inventory": ["The Sphere of Annihilation"]
     }
     bad_defender = {
         "Name": "Helano",
         "Class": "sorcerer",
         "HP": 6,
         "Strength": 9,
         "Dexterity": 10,
         "Constitution": 9,
         "Intelligence": 12,
         "Wisdom": 12,
         "Charisma": 8,
         "XP": 0,
         "Inventory": ["The Unicorn Horn", "The Belmont Whip"]
     }
     expected_output = "Kelabi strikes!\n" \
                       "Helano has taken a 5 point hit!\n"\
                       "Helano's HP has dropped to 1.\n"
     dungeonsanddragons.attack(good_fighter, bad_defender)
     self.assertEqual(mock_stdout.getvalue(), expected_output)
Esempio n. 5
0
 def test_attack_hit(self, mock_roll_die):
     attacker = {
         'Name': 'Attacker',
         'Race': 'dwarf',
         'Class': 'bard',
         'HP': [7, 7],
         'Strength': 14,
         'Dexterity': 9,
         'Constitution': 6,
         'Intelligence': 11,
         'Wisdom': 13,
         'Charisma': 9,
         'XP': 0,
         'Inventory': []
     }
     defender = {
         'Name': 'Defender',
         'Race': 'dwarf',
         'Class': 'bard',
         'HP': [7, 7],
         'Strength': 14,
         'Dexterity': 1,
         'Constitution': 6,
         'Intelligence': 11,
         'Wisdom': 13,
         'Charisma': 9,
         'XP': 0,
         'Inventory': []
     }
     self.assertGreater(attack(attacker, defender), 0)
Esempio n. 6
0
 def test_attack_miss(self, mock_roll_die):
     bad_fighter = {
         "Name": "Monoza",
         "Class": "sorcerer",
         "HP": 1,
         "Strength": 12,
         "Dexterity": 12,
         "Constitution": 3,
         "Intelligence": 9,
         "Wisdom": 9,
         "Charisma": 18,
         "XP": 0,
         "Inventory": ["The Elder Wand"]
     }
     good_defender = {
         "Name": "Bagiko",
         "Class": "bard",
         "HP": 4,
         "Strength": 12,
         "Dexterity": 18,
         "Constitution": 15,
         "Intelligence": 9,
         "Wisdom": 6,
         "Charisma": 9,
         "XP": 0,
         "Inventory": ["The Unicorn Horn", "The Belmont Whip"]
     }
     defender_after_attack = dungeonsanddragons.attack(
         bad_fighter, good_defender)
     self.assertTrue(good_defender["HP"] == defender_after_attack["HP"])
Esempio n. 7
0
 def test_attack_hit_defender_dies(self, mock_roll_die):
     good_fighter = {
         "Name": "Kelabi",
         "Class": "barbarian",
         "HP": 10,
         "Strength": 15,
         "Dexterity": 12,
         "Constitution": 6,
         "Intelligence": 9,
         "Wisdom": 9,
         "Charisma": 12,
         "XP": 0,
         "Inventory": ["The Sphere of Annihilation"]
     }
     bad_defender = {
         "Name": "Helano",
         "Class": "sorcerer",
         "HP": 1,
         "Strength": 9,
         "Dexterity": 3,
         "Constitution": 9,
         "Intelligence": 12,
         "Wisdom": 12,
         "Charisma": 8,
         "XP": 0,
         "Inventory": ["The Unicorn Horn", "The Belmont Whip"]
     }
     defender_after_attack = dungeonsanddragons.attack(
         good_fighter, bad_defender)
     self.assertTrue(defender_after_attack["HP"] <= 0)