import hw8enemies as hw8e
import hw8heroes as hw8h
c = (0)
while True :
if c == (0):
print(" Gymnastic woman Wrestler Alien ")
print("HP : 60 70 65")
print("Attack : 7 HP 15 HP 11 HP ")
print("Defend : 13 HP 7 HP 9 HP")
c = c+(1)
while True:
cc = input("Choose character by entering name : ")
if cc.lower() == ("gymnastic woman"):
hw8e.char = hw8h.Heroes(60.0,60.0,7.0,13.0,3)
elif cc.lower() == ("wrestler"):
hw8e.char = hw8h.Heroes(70.0,70,0,15.0,7.0,3)
elif cc.lower() == ("alien"):
hw8e.char = hw8h.Heroes(65.0,65.0,11.0,9.0,3)
while True:
lvl = (0)
while True :
if lvl == (0):
hw8h.e1 = hw8e.Enemy(60,60,8,10,1,True)
while lvl == (0):
t = True
print("\nYou have %s HP" %hw8e.char.h)
print("And the enemy has %s HP" %hw8h.e1.h)
hw8h.Heroes.attack(hw8e.char.h,hw8e.char.a)
hw8e.Enemy.HP(hw8h.e1.h,t)
if t == False :
hw8e.char.h = hw8e.char.H1
lvl = (1)
break
hw8e.Enemy.defendlogic(hw8h.e1.dfe,hw8h.e1.h,hw8h.e1.h1)
hw8e.Enemy.attack(hw8h.e1.h,hw8h.e1.h1,hw8h.e1.a)
hw8h.Heroes.HP(hw8e.char.h)
if hw8h.ggo == True :
break
if hw8h.ggo == True :
break
if hw8h.ggo == True :
break
if hw8h.ggo == True :
break
if hw8h.ggo == True :
break
class H:
def __init__(self,h):
self.h = h
e1 = H(100)
e2 = H(100)
e3 = H(100)
lvl = (0)
class Heroes :
# h = health , H1 = initial health , a = max attack , d = defend , dfe = defend #count
def __init__(self,h,H1,a,d,dfe):
self.h = h
self.a = a
self.d = d
self.H1 = H1
self.dfe = dfe
go = False
global ggo
ggo = go
def HP(h):
if h
Подробнее здесь: [url]https://stackoverflow.com/questions/79195939/enemy-hp-going-negative[/url]
Мои проблемы: здоровье врага становится отрицательным, и атака должна нанести урон атакующему, но они не работают, вот код: main: [code]import hw8enemies as hw8e import hw8heroes as hw8h c = (0) while True : if c == (0): print(" Gymnastic woman Wrestler Alien ") print("HP : 60 70 65") print("Attack : 7 HP 15 HP 11 HP ") print("Defend : 13 HP 7 HP 9 HP") c = c+(1) while True: cc = input("Choose character by entering name : ") if cc.lower() == ("gymnastic woman"): hw8e.char = hw8h.Heroes(60.0,60.0,7.0,13.0,3) elif cc.lower() == ("wrestler"): hw8e.char = hw8h.Heroes(70.0,70,0,15.0,7.0,3) elif cc.lower() == ("alien"): hw8e.char = hw8h.Heroes(65.0,65.0,11.0,9.0,3) while True: lvl = (0) while True : if lvl == (0): hw8h.e1 = hw8e.Enemy(60,60,8,10,1,True) while lvl == (0): t = True print("\nYou have %s HP" %hw8e.char.h) print("And the enemy has %s HP" %hw8h.e1.h) hw8h.Heroes.attack(hw8e.char.h,hw8e.char.a) hw8e.Enemy.HP(hw8h.e1.h,t) if t == False : hw8e.char.h = hw8e.char.H1 lvl = (1) break hw8e.Enemy.defendlogic(hw8h.e1.dfe,hw8h.e1.h,hw8h.e1.h1) hw8e.Enemy.attack(hw8h.e1.h,hw8h.e1.h1,hw8h.e1.a) hw8h.Heroes.HP(hw8e.char.h) if hw8h.ggo == True : break if hw8h.ggo == True : break if hw8h.ggo == True : break if hw8h.ggo == True : break if hw8h.ggo == True : break
[/code] hw8heroes: [code]class H: def __init__(self,h): self.h = h e1 = H(100) e2 = H(100) e3 = H(100) lvl = (0) class Heroes : # h = health , H1 = initial health , a = max attack , d = defend , dfe = defend #count def __init__(self,h,H1,a,d,dfe): self.h = h self.a = a self.d = d self.H1 = H1 self.dfe = dfe