Dec-12-2017, 03:14 PM
Here one way to handle enemies.
from random import choice class Enemies: enemy = {} def __init__(self, name, health, agility, strength, level, special=None): self.name = name self.health = health self.agility = agility self.strength = strength self.level = level self.special = special # you could simple make another class to handle special Enemies.enemy[name] = self # store the enemy def __repr__(self): line = "Enemy(Name:{0}, Health:{1}, Agility:{2}, Strength:{3}, Level:{4})" return line.format(self.name, self.health, self.agility, self.strength, self.level) def main(): Enemies('Orgre', 100, 20, 60, 2, {'bash': 10, 'swing': 10}) Enemies('Goblin', 50, 40, 35, 1, {'bite': 10}) Enemies('Giant Rat', 40, 55, 30, 1, {'rabies': 20}) # Fight(Enemies.enemy['Goblin']) enemy = choice(list(Enemies.enemy.keys())) # Fight(Enemies.enemy[enemy]) print(Enemies.enemy[enemy]) print(Enemies.enemy.keys()) if __name__ == '__main__': main()
99 percent of computer problems exists between chair and keyboard.