import random
mobs = {
"enemys": {
"Stray Dog": {
"health": 3,
"strenth": 2,
"dexterity": 1,
},
"Hobo": {
"health": 4,
"strenth": 2,
"dexterity": 2,
},
"Mugger": {
"health": 5,
"strenth": 2,
"dexterity": 2,
},
"Cop": {
"health": 7,
"strenth": 3,
"dexterity": 2,
},
"Ninja": {
"health": 9,
"strenth": 2,
"dexterity": 4,
}
},
"Player": {
"phealth": 100,
"pstrength": 1,
"pdexterity": 1,
"pconstitution": 1,
},
}
levelrn = 3
phealth = mobs["Player"]["phealth"]
pstrength = mobs["Player"]["pstrength"]
pdexterity = mobs["Player"]["pdexterity"]
pconstitution = mobs["Player"]["pconstitution"]
ehealth = 0
estrength = 0
edexterity = 0
curenemy = ""
def level():
global levelrn
global pconstitution
global pstrength
global pdexterity
global curenemy
global ehealth
global edexterity
global estrength
global phealth
levelrn =3
print("Level " + str(levelrn) + "\n---------")
print("Health: " + str(phealth))
print("Strenth: " + str(pstrength))
print("Dexterity: " + str(pdexterity))
print("Constitution: " + str(pconstitution))
if levelrn == 1:
curenemy = "Stray Dog"
elif levelrn == 2:
curenemy = "Hobo"
elif levelrn == 3:
curenemy = "Mugger"
elif levelrn == 4:
curenemy = "Cop"
elif levelrn == 5:
curenemy = "Ninja"
estrength = mobs["enemys"][curenemy]["strenth"]
edexterity = mobs["enemys"][curenemy]["dexterity"]
ehealth = mobs["enemys"][curenemy]["health"]
print("You find your self pitted against a " + curenemy + ".")
print("Choose One\n----------\nAttack!")
userin = input()
if userin == "Attack" or "A" or "a" or "attack":
if pdexterity > edexterity:
pgdex()
else:
pldex()
def pgdex():
pdamage = random.randrange(1, 3)
print("You dealt " + str(pdamage) + " damage!")
global ehealth
ehealth -= pdamage
pldex()
def pldex():
if mobs["enemys"][curenemy]["strenth"] == estrength:
edamage = random.randrange(estrength - 1, estrength + 1)
print("You took " + str(edamage) + " damage!")
global phealth
phealth -= edamage
print("Hp: " + phealth)
pgdex()
level()
This is the output of the code:
Level 1
---------
Health: 100
Strength: 1
Dexterity: 0
Constitution: 1
You find yourself pitted against a Stray Dog
Choose One
---------
Attack
It is supposed to run the level at 3 and the "Stray Dog" is supposed to be a "Mugger".
Also the dexterity and constitution and strength arent changing.