def test_combat_round_character1_miss_character2_hit(self, _, __, ___): char_one = {"Name": "Solar", "Strength": 26, "Intelligence": 25, "Wisdom": 25, "Dexterity": 14, "Constitution": 26, "Charisma": 30, "Inventory": [], "XP": 33000, "Class": "paladin", "Race": "human", "HP": [35, 5]} char_two = {"Name": "Solar2", "Strength": 26, "Intelligence": 25, "Wisdom": 25, "Dexterity": 14, "Constitution": 26, "Charisma": 30, "Inventory": [], "XP": 33000, "Class": "paladin", "Race": "human", "HP": [35, 5]} dnd.combat_round(char_one, char_two) actual = [char_one["HP"][1], char_two["HP"][1]] expected = [2, 5] self.assertEqual(actual, expected)
def test_roll_same_points_multiple_times_p1_attack(self, mock_stdout, mock_roll): actual_1 = { 'Name': 'Dududu', 'Strength': 10, 'Intelligence': 5, 'Wisdom': 5, 'Dexterity': 9, 'Constitution': 12, 'Charisma': 9, 'inventory': [], 'XP': 0, 'class': 'sorcerer', 'Race': 'Human', 'HP': [5, 5] } actual_2 = { 'Name': 'Loki', 'Strength': 5, 'Intelligence': 20, 'Wisdom': 20, 'Dexterity': 6, 'Constitution': 20, 'Charisma': 6, 'inventory': ['The Scepter'], 'XP': 0, 'class': 'sorcerer', 'Race': 'the Frost Giants in Jotunheim', 'HP': [20, 20] } dnd.combat_round(actual_1, actual_2) dnd.print_character(actual_1) dnd.print_character(actual_2) expected = 'Dududu is attacking Loki by 20\nLoki is dead\n' \ 'Name Dududu\nStrength 10\nIntelligence 5\nWisdom 5\nDexterity 9\nConstitution 12\nCharisma 9\n' \ 'inventory []\nXP 0\nclass sorcerer\nRace Human\nHP [5, 5]\n' \ 'Name Loki\nStrength 5\nIntelligence 20\nWisdom 20\nDexterity 6\nConstitution 20\nCharisma 6' \ '\ninventory [\'The Scepter\']\nXP 0\nclass sorcerer\nRace the Frost Giants in ' \ 'Jotunheim\nHP [20, 0]\n' self.assertEqual(mock_stdout.getvalue(), expected)
def test_combat_round_player_one_first_with_retaliation( self, mock_sysout, _, __, ___): character = { "Name": "Xyxy", "Strength": 10, "Dexterity": 8, "Intelligence": 5, "Charisma": 9, "Wisdom": 7, "Constitution": 3, "Inventory": [], "XP": 0, "Class": "monk", "Race": "elf", "HP": [7, 7] } sad_jim = { "Name": "Sad Jim", "Strength": 7, "Dexterity": 8, "Intelligence": 5, "Charisma": 0, # I'm aware this is impossible by normal means, but sad jim is just awful. "Wisdom": 11, "Constitution": 3, "Inventory": [], "XP": 0, "Class": "loser", "Race": "human", "HP": [3, 3] } expected = """Sad Jim took the hit like a real champ but still took 2 damage! Xyxy took the hit like a real champ but still took 2 damage! """ dnd.combat_round(character, sad_jim) self.assertEqual(expected, mock_sysout.getvalue())
def test_combat_round_player_two_first_no_retaliation( self, mock_sysout, _, __, ___): character = { "Name": "Xyxy", "Strength": 10, "Dexterity": 8, "Intelligence": 5, "Charisma": 9, "Wisdom": 7, "Constitution": 3, "Inventory": [], "XP": 0, "Class": "monk", "Race": "elf", "HP": [7, 7] } sad_jim = { "Name": "Sad Jim", "Strength": 7, "Dexterity": 8, "Intelligence": 5, "Charisma": 0, # I'm aware this is impossible by normal means, but sad jim is just awful. "Wisdom": 11, "Constitution": 3, "Inventory": [], "XP": 0, "Class": "loser", "Race": "human", "HP": [3, 3] } expected = """Sad Jim hits Xyxy for 8 damage. Xyxy never stood a chance and now lies dead. """ dnd.combat_round(character, sad_jim) self.assertEqual(expected, mock_sysout.getvalue())