import random, math
class enemy:
def __init__(self, Name, HP, Speed, Evasion, Element, Move, PhysicalArmor, MagicArmor, Mana):
self.Name = Name
self.HP = HP
self.Speed = Speed
self.Evasion = Evasion
self.Element = Element
self.Move = Move
self.PhysicalArmor = PhysicalArmor
self.MagicArmor = MagicArmor
self.Mana = Mana
def Attack(self, target):
global Moves
Target = []
for h in target:
if h.HP >= 0:
Target.append(h)
if len(Target) > 0:
f = -1
Th = 0
Chioce = ""
for i in self.Move:
d = 0
if self.Mana - i.ManaCost > -1:
if len(Target) > 1:
if i.Area == True:
for h in Target:
if random.randrange(0,100) < (i.Accuracy):
d = Damage_Calc(i,h, d)
elif i.Area == False:
Th = Target[0].HP
for h in Target:
if Th >= h.HP*(1/aElements[i.Element][h.Element]):
Th = h.HP*(1/aElements[i.Element][h.Element])
Chioce = h
else:
print("Error")
pass
else:
Chioce = Target[0]
d = Damage_Calc(i, Chioce, d)
if f < d:
f = d
d = 0
M = i.ManaCost
damage = f
move = i
elif f == d:
if i.ManaCost < M:
f = d
d = 0
M = i.ManaCost
damage = f
move = i
print(move.Name, f, self.Mana)
if move.Area == True:
if self.Mana - move.ManaCost > -1:
for h in Target:
if random.randrange(0,100) < (move.Accuracy - h.Evasion):
h.HP = h.HP - math.ceil((move.Damage*aElements[move.Element][h.Element])*((100-h.PhysicalArmor)/100))
else:
print("Miss")
else:
pass
self.Mana = self.Mana - move.ManaCost
else:
if self.Mana - move.ManaCost > -1:
if random.randrange(0,100) < (move.Accuracy - Chioce.Evasion):
Chioce.HP = Chioce.HP - math.ceil((move.Damage*aElements[move.Element][Chioce.Element])*((100-Chioce.PhysicalArmor)/100))
else:
print("Miss")
else:
pass
self.Mana = self.Mana - move.ManaCost
else:
print("There is nohting to fight")
def Damage_Calc(i,h, d):
if random.randrange(0,100) < (i.Accuracy):
if i.Element == "Physical":
d = d + math.ceil((i.Damage*aElements[i.Element][h.Element])*((100-h.PhysicalArmor)/100))
else:
d = d + math.ceil((i.Damage*aElements[i.Element][h.Element])*((100-h.MagicArmor)/100))
else:
d = 0
return d
class Moves:
def __init__(self, Name, Damage, Element, Accuracy, Cooldown, ManaCost, Area):
self.Name = Name
self.Damage = Damage
self.Element = Element
self.Accuracy = Accuracy
self.Cooldown = Cooldown
self.ManaCost = ManaCost
self.Area = Area
class Player(enemy):
pass
def Attack(self, target):
print("Chose your move")
for h in self.Move:
print(h.Name)
Choice = (input().capitalize)
print(Choice)
Target = []
for h in target:
if h.HP >= 0:
Target.append(h)
aElements = {
"Fire" : {"Water" : 0.5, "Earth" : 0.5, "Nature" : 2, "Air" : 2, "Fire" : 0.5, "Physical" : 1, "Dark" : 1, "Light" : 1},
"Water" : {"Water" : 0.5, "Earth" : 2, "Nature" : -0.5, "Air" : 1, "Fire" : 2, "Physical" : 1, "Dark" : 1, "Light" : 1},
"Earth" : {"Water" : 1, "Earth" : 1, "Nature" : 0.5, "Air" : 0, "Fire" : 2, "Physical" : 1, "Dark" : 1, "Light" : 1},
"Nature" : {"Water" : 2, "Earth" : 2, "Nature" : 1, "Air" : 0.2, "Fire" : 0, "Physical" : 1, "Dark" : 1, "Light" : 1},
"Air" : {"Water" : 1, "Earth" : 2, "Nature" : 1, "Air" : 0.5, "Fire" : 2, "Physical" : 1, "Dark" : 1, "Light" : 1},
"Physical" : {"Water" : 1, "Earth" : 1, "Nature" : 1, "Air" : 1, "Fire" : 1, "Physical" : 1, "Dark" : 1, "Light" : 1},
"Dark" : {"Water" : 1, "Earth" : 1, "Nature" : 1, "Air" : 1, "Fire" : 1, "Physical" : 1, "Dark" : 1, "Light" : 1},
"Light" : {"Water" : 1, "Earth" : 1, "Nature" : 1, "Air" : 1, "Fire" : 1, "Physical" : 1, "Dark" : 1, "Light" : 1}
}
Fireblast = Moves("Fireblast", 5, "Fire", 80, 2, 2, True)
Fireball = Moves("Fireball", 4, "Fire", 95, 2, 2, True)
Fireshot = Moves("Fireshot", 4, "Fire", 90, 2, 1, False)
Jump = Moves("Jump", 2, "Physical", 100, 1, 0, False)
slime = enemy("Slime", 8, 1, 5, "Water", [Fireball, Fireshot, Jump], 5, 15, 3)
wolf = enemy("Wolf", 3, 1, 5, "Physical", [Fireshot, Jump], 5, 15, 1)
rat = enemy("Rat", 8, 1, 5, "Physical", [Fireshot, Jump], 5, 15, 1)
player = Player("Error", 3, 1, 5, "Pysical", [Fireball, Fireshot, Jump], 5, 15, 3)
#player.Attack(wolf)
print(slime.Move[1].Cooldown, wolf.Move[0].Cooldown)
slime.Move[1].Cooldown = 1
print(slime.Move[1].Cooldown, wolf.Move[0].Cooldown)
print("Wolf: ",wolf.HP,"Rat: ", rat.HP,"Slime: ", slime.HP)
slime.Attack([wolf, slime, rat])
print("Wolf: ",wolf.HP,"Rat: ", rat.HP,"Slime: ", slime.HP)
slime.Attack([wolf, slime, rat])
print("Wolf: ",wolf.HP,"Rat: ", rat.HP,"Slime: ", slime.HP)
slime.Attack([wolf, slime, rat])
print("Wolf: ",wolf.HP,"Rat: ", rat.HP,"Slime: ", slime.HP)