Exemplo n.º 1
0
    def test_combat_round_player_first_and_kill(self, mock_input, mock_roll,
                                                mock_output):
        test_char = {
            'name': "Link",
            'coords': (0, 0),
            'max_hp': 10,
            'current_hp': 3,
            'power': 6
        }
        test_monster = {
            'name': "Goblin",
            'max_hp': 5,
            'current_hp': 5,
            'power': 6,
            'backstab': 4
        }
        expected = """You encountered a Goblin!
What would you like to do?
Both players rolled 1! Rolling again...

Link will go first.
Goblin's HP: 5/5
The attack was a success!
Goblin took 5 damage.
Goblin has died!
You killed Goblin!

"""
        combat_round(test_char, test_monster)
        self.assertEqual(expected, mock_output.getvalue())
Exemplo n.º 2
0
    def test_combat_round_flee_with_backstab(self, mock_input, mock_roll,
                                             mock_output):
        test_char = {
            'name': "Link",
            'coords': (0, 0),
            'max_hp': 10,
            'current_hp': 10,
            'power': 6
        }
        test_monster = {
            'name': "Goblin",
            'max_hp': 5,
            'current_hp': 5,
            'power': 6,
            'backstab': 4
        }
        expected = """You encountered a Goblin!
What would you like to do?
You ran away from Goblin successfully.
"""
        combat_round(test_char, test_monster)
        self.assertEqual(expected, mock_output.getvalue())
Exemplo n.º 3
0
    def test_combat_round_invalid_input_then_backstabbed_and_killed(
            self, mock_input, mock_roll, mock_output):
        test_char = {
            'name': "Link",
            'coords': (0, 0),
            'max_hp': 10,
            'current_hp': 3,
            'power': 6
        }
        test_monster = {
            'name': "Goblin",
            'max_hp': 5,
            'current_hp': 5,
            'power': 6,
            'backstab': 4
        }
        expected = """You encountered a Goblin!
What would you like to do?
Goblin backstabbed you for 4 damage!
You died. Game over.
"""
        combat_round(test_char, test_monster)
        self.assertEqual(expected, mock_output.getvalue())