import random, math
monsters = {
"0" : {"Name" :"slime", "HP" : 3, "Speed" : 1, "Attack" : 2, "Evasion" : 5, "element" : "Water", "Move" : "000001002", "PysicalArmor" : 0, "MagicArmor" : 20},
"1" : {"Name" :"Wolf", "HP" : 2, "Speed" : 3, "Attack" : 1, "Evasion" : 10, "element" : "Pysical", "Move" : "001", "PysicalArmor" : 10, "MagicArmor" : 0},
"2" : {"Name" :"Rat", "HP" : 1, "Speed" : 2, "Attack" : 1, "Evasion" : 5, "element" : "Pysical", "Move" : "001", "PysicalArmor" : 5, "MagicArmor" : 0}
}
moves = {
"000" : {"Name" :"bounce", "damage" : 1, "physical" : True, "magic" : False, "accuracy" : 85, "element" : "phisical", "cooldown" : "0", "id" : "000"},
"001" : {"Name" :"chomp", "damage" : 2, "physical" : True, "magic" : False, "accuracy" : 95, "element" : "phisical", "cooldown" : "1", "id" : "001"},
"002" : {"Name" :"fireball", "damage" : 4, "physical" : False, "magic" : True, "accuracy" : 100, "element" : "Fire", "cooldown" : "3", "id" : "002"}
}
eCurent = {"Name" : "", "HP" : 0, "Speed" : 0, "Attack" : 0}
player = {"Name" : "Player", "HP" : 5, "Speed" : 3, "Attack" : 2, "Evasion" : 5, "element" : "Nature", "Move" : "000001002", "PysicalArmor" : 0, "MagicArmor" : 0}
cPlayer = player
aElements = {
"Fire" : {"Water" : False, "Earth" : False, "Nature" : True, "Air" : True, "Fire" : False, "phisical" : False, "Dark" : False, "Light" : False},
"Water" : {"Water" : False, "Earth" : True, "Nature" : False, "Air" : False, "Fire" : True, "phisical" : False, "Dark" : False, "Light" : False},
"Earth" : {"Water" : False, "Earth" : False, "Nature" : False, "Air" : False, "Fire" : True, "phisical" : False, "Dark" : False, "Light" : False},
"Nature" : {"Water" : True, "Earth" : True, "Nature" : False, "Air" : False, "Fire" : False, "phisical" : False, "Dark" : False, "Light" : False},
"Air" : {"Water" : False, "Earth" : True, "Nature" : True, "Air" : False, "Fire" : False, "phisical" : False, "Dark" : False, "Light" : False},
"phisical" : {"Water" : False, "Earth" : False, "Nature" : False, "Air" : False, "Fire" : False, "phisical" : False, "Dark" : False, "Light" : False},
"Dark" : {"Water" : False, "Earth" : False, "Nature" : False, "Air" : False, "Fire" : False, "phisical" : False, "Dark" : False, "Light" : False},
"Light" : {"Water" : False, "Earth" : False, "Nature" : False, "Air" : False, "Fire" : False, "phisical" : False, "Dark" : False, "Light" : False}
}
class cooldown:
def __init__(self, time):
self.time = int(time)
self.done = False
def myfunc(self):
self.time = self.time - 1
if self.time <= 0:
self.done = True
def __str__(self):
return f"{self.time}({self.done})"
def encounter():
global eCurent
ran = str(random.randrange(0,1))
eCurent = monsters[ran]
encounter()
def battle():
global eCurent, cPlayer, moves, aElements
k = ""
hexcode = ""
for i in eCurent["Move"]:
hexcode = hexcode + i
if len(hexcode) == 3:
k = k + moves[hexcode]["Name"] + ", "
hexcode = ""
print(eCurent["Name"], "| HP: ", eCurent["HP"], " Speed: ", eCurent["Speed"], " Attack: ", eCurent["Attack"], " Evasion: ", eCurent["Evasion"], " Moves: ", k)
if eCurent["Speed"] < player["Speed"]:
bTurn()
print("enemyturn")
#Move choser
f = -1
hexcode = ""
for i in eCurent["Move"]:
hexcode = hexcode + i
if len(hexcode) == 3:
if random.randrange(0,100) < (moves[hexcode]["accuracy"] - cPlayer["Evasion"]):
if aElements[moves[hexcode]["element"]][player["element"]] == True:
if aElements[moves[hexcode]["element"]] == "pysical":
d = math.ceil((moves[hexcode]["damage"]*2)*((100-cPlayer["PysicalArmor"])/100))
else:
d = math.ceil((moves[hexcode]["damage"]*2)*((100-cPlayer["MagicArmor"])/100))
else:
if aElements[moves[hexcode]["element"]] == "pysical":
d = math.ceil((moves[hexcode]["damage"])*((100-cPlayer["PysicalArmor"])/100))
else:
d = math.ceil((moves[hexcode]["damage"])*((100-cPlayer["MagicArmor"])/100))
else:
d = 0
if f < d:
f = d
damage = f
move = moves[hexcode]["Name"]
hexcode = ""
print(move, damage)
def bTurn():
global eCurent, cPlayer, moves, aElements
print("playerturn")
k = ""
hexcode = ""
for i in cPlayer["Move"]:
hexcode = hexcode + i
if len(hexcode) == 3:
k = k + moves[hexcode]["Name"] + " "
hexcode = ""
print(cPlayer["Name"], "| HP: ", cPlayer["HP"], " Speed: ", cPlayer["Speed"], " Attack: ", cPlayer["Attack"], " Evasion: ", cPlayer["Evasion"], " Moves: ", k)
p1 = cooldown(moves["002"]["cooldown"])
p1.myfunc()
print(p1)
battle()