Cannot pass the 1st test and don't know why...
I guess I fail the first test, and I don't actually understand why. When I follow the prints, it all looks pretty logical to me, and I don't get where exactly it went wrong. My code is attached if you want to take a look. But most probably the logic is what I did not understand.
The test:
unit_1 = Warrior() unit_2 = Vampire() weapon_1 = Weapon(-10, 5, 0, 40, 0) weapon_2 = Sword() # h +5 a +2 unit_1.equip_weapon(weapon_1) unit_2.equip_weapon(weapon_2) print(fight(unit_1, unit_2)) assert (fight(unit_1, unit_2)) == True
Outputs:
- Warrior equipped weapon <__main__.Weapon object at 0x7faa62e91c90> now health is 40 and max health is 40 - Vampire equipped weapon <__main__.Sword object at 0x7faa62e91cc0> now health is 55 and max health is 55 - Vampire is attacked 10 45 55 - Warrior is attacked 6 34 40 - Vampire is healed by vampirism 50 % 48 55 - Vampire is attacked 10 38 55 - Warrior is attacked 6 28 40 - Vampire is healed by vampirism 50 % 41 55 - Vampire is attacked 10 31 55 - Warrior is attacked 6 22 40 - Vampire is healed by vampirism 50 % 34 55 - Vampire is attacked 10 24 55 - Warrior is attacked 6 16 40 - Vampire is healed by vampirism 50 % 27 55 - Vampire is attacked 10 17 55 - Warrior is attacked 6 10 40 - Vampire is healed by vampirism 50 % 20 55 - Vampire is attacked 10 10 55 - Warrior is attacked 6 4 40 - Vampire is healed by vampirism 50 % 13 55 - Vampire is attacked 10 3 55 - Warrior is attacked 6 -2 40 - Vampire is healed by vampirism 50 % 6 55 - False
task.the-weapons