I want to create classes in a loop. I've found this question: How do you create different variable names while in a loop?. But I want to associate a variable to a class, I can't use a list for that or a dictionary. How would I do so?
class Enemy():
def __init__(self, type_):
if type_ == 'demon':
self.hp = random.randint(90, 110)
self.dmg = [20, 40]
self.dodge = 4
loot_chance = random.randint(0, 10)
if loot_chance <= 8:
self.loot = loot(['hp', 'dmg'])
if loot_chance == 9:
self.loot = loot(['hp'])
else:
self.loot = loot(['dmg'])
I want to do this more efficiently:
enemy0 = Enemy('demon')
enemy1 = Enemy('demon')
enemy2 = Enemy('demon')
enemy3 = Enemy('demon')
enemy4 = Enemy('demon')
...