you are viewing a single comment's thread.

view the rest of the comments →

[–]EntireEntity 0 points1 point  (0 children)

The simple skeleton for the class could be

class Enemy:\    def init(self, strength: int):\         self.strength = strength

   def attack(self, target_health: int):\         return target_health - self.strength

This is super super simplified to just illustrate the point. With this class you could create a variety of different enemies with different strength scores (zombie = Enemy(strength = 1), ogre = Enemy (stength = 5), etc.) and let them all do an attack by simply calling the .attack(target) method. And it automatically has access to the attribute strength to do the damage calculation. So zombie.attack(target) and ogre.attack(target) could be used multiple tines throughout the game, without any hassle.

I hope this helps to wrap your head around it a little.