Ok so i'm making a text based RPG game but i have a issue with python classes that i'm not sure how to fix I've tried looking up this problem but haven't been able to find any posts that pertain to this maybe i'm looking up the wrong things? i don't know. anyways here's my issue i have this class in a file called unit.py in a folder named subfiles
class Enemy(object):
def __init__(self,name,hp,atk):
self.name = name
self.hp = hp
self.atk = atk
in my main file i have this
from subfiles.unit import *
wolf = Enemy("Wolf", 100, 10)
cow = Enemy("Cow", 50, 0)
NMElist = [wolf,cow]
def gennme():
global NME
##Choose a enemy to fight
NME = random.choice(NMElist)
def attack():
NME.hp -= 10
print NME.hp
attack()
when I run the attack definition it subtracts from the wolf.hp like it should, but that's not exactly what i'm trying to achieve, because the next time a battle comes up against a wolf it will be already dead so how can i have it where wolf = Enemy("Wolf", 100, 10) is just the set out default values and after the battle is over and the wolf is killed, the next time i fight a wolf it loads from the defaults. I hope i'm making sense here i'm sure there's a simple way to achieve this its just evading me perhaps my understanding of how classes work is flawed? anyways I look forward to your responses ans suggestions oh by the way this same thing applies for cow as well as wolf.