« All Events
6 PM to 8 PM – Python OOP – Gamas
April 5, 2023 @ 6:00 pm - 8:00 pm
Homework
- Similar to dragon.py, create troll.py, water_golem.py.
- Inside troll.py
- Create Troll class that inherits from Monster class.
- override magic_damage method so
- when Troll got hit by earth magic, it will say “Troll is immune to Earth magic. No damage is done.”
- when Troll got hit by fire magic, it will do half damage.
- Inside water_golem.py
- Create WaterGolem class that inherits from Monster class
- override magic_damage method so
- when WaterGolem got hit by water magic, it will say “Water golem is immune to water magic. No damage is done.”
- when WaterGolem got hit by fire magic, it will do double damage.
- Modify monster.py
- Add a new method sword_damage(self, attack_point). Inside the method do reduce the monster.health with attack_point.
- Change the main.sword_attack method to call this monster.sword_damage(player_attack).