import random
import time

en = [ "Orc", "Goblin", "Minotaur", "Troll", "Dragon" ]

global enhp
global enatk
global endef
global enmov
global endt
global enexp
pso = [] 

def player() :
    global php, pdef, pexp, pg, a, s, pmh, pso 
    php = 50 
    sac = input( "Choose a [s]word or an [a]xe " )
    if sac == "s" :
        print( "You choose to pick up the sword, and leave the axe. " )
        s = 1
        time.sleep(1)
    elif sac == "a" :
        print( "You choose to pick up the axe, and leave the sword. " )
        a = 1
        time.sleep(1)
    else :
        print( "You choose to leave both weapons, and fight with your fists. " )
        time.sleep(1.5)
    pdef = 13
    pexp = 0
    pg = 50
    pmh = 50
    psc = input( "What spell would you like to choose? [i]ce or [h]eal? " )
    if psc == "i" :
        print( "You decided to take the ice spell" )
        pso.append( "ice" )
    elif psc == "h" :
        print( "You decided to take the healing spell" )
        pso.append( "healing" )

def gob() :
    global enhp, enatk, endef, enmov, endt, enexp, eng
    enhp =  80
    enatk = 0
    endef = 10
    enmov = random.randint( 1, 18 ) 
    endt = "Scimitar/Piercing" 
    enexp = 30 
    eng = 50
    print( "You are face-to-face with a sneaky goblin " )


def orc() :
    global enhp, enatk, endef, enmov, endt, enexp, eng
    enhp = 100
    enatk = 1
    endef = 13
    enmov = random.randint(1, 20)
    endt = "Axe/Slashing"
    enexp = 50
    eng = 100
    print( "You are face-to-face with an angry orc " )

def mino() :
    global enhp, enatk, endef, enmov, endt, enexp, eng
    enhp = 150
    enatk = 1 
    endef = 14
    enmov = random.randint( 5, 35 )
    endt = "Horns/Bludgeoning"
    enexp = 100
    eng = 250
    print( "You are standing before an enraged minotaur" )

def trol() :
    global enhp, enatk, endef, enmov, endt, enexp, eng
    enhp = 250
    enatk = 2 
    endef = 15
    enmov = random.randint( 8,45 )
    endt = "Club/Bludgeoning"
    enexp = 300
    eng = 500
    print( "You are standing before a furious dragon " )

def drag() :
    global enhp, enatk, endef, enmov, endt, enexp, eng
    enhp = 1000
    enatk = 5
    endef = 17
    enmov = [ "bite and claws", "fireball" ]
    enexp = 1000
    eng = 3000

player()
n = input( "What is your name Warrior? " )
print( "Welcome to the arena", n + "!" )
time.sleep(1)
print( "You wait with bated breath for your opponent to breach the mighty doors before you." )
time.sleep(2)
enN = random.choice( en )
if enN == "Orc" :
    print( "You watch with horror as an", enN, "steps out of the gates" )
else :
    print( "You watch with horror as a", enN, "steps out of the gates" )
    
if enN == "Goblin" :
    gob()
elif enN == "Orc" :
    orc()
elif enN == "Minotaur" :
    mino()
elif enN == "Troll" :
    trol() 
elif enN == "Dragon" :
    drag()

print( "Possible actions: " )
print( "  [s]attack with your sword" )
print( "  [a]attack with your axe" )
print( "  [p]drink a healing potion" )
print( "  [m]attack with magic" )
print( "  [d]defend with your shield" )

c = input( "Your choice? " )

def p_sword() :
    global sd
    sd = s * random.randint( 1, 20 )
    print( "You swing your sword. . . " )
    print( "You deal the", enN, sd, "damage" )

def p_axe() :
    global ad
    ad = a * random.randint( 5, 40 )
    print( "You swing your axe. . . " )
    print( "You deal the", enN, ad, "damage" )
    
def p_potion() :
    global php 
    pha = pmh * 0.5 
    php = php + pha
    while php > pmh :
        php = php - 1

def p_magic() :
    global frozen, php
    print( "Your spell choices are", pso )
    pmc = input( "Type the name of the spell youd like to cast! " )
    s_s = pmc 
    if pmc == "ice" and s_s in pso :
        print( "You cast an Ice spell, stopping the enemy's next attack. " )
        frozen = 1
    elif pmc == "healing" and s_s in pso :
        print( "You cast a healing spell, healing yourself for", sha, "health points" )
        php = php + sha
        if php > pmh :
            php = php - 1

def heal_s() :
    global sha, pexp
    if pexp % 10 == 0 :
        sha = sha + 5

def p_defend() :
    global enhp, php
    print( "You choose to defend with your sheild. . . " )
    dc = random.randint( 1, 2 )
    if dc == 1 :
        print( "You raise your sheild and deflect the blow " )
        time.sleep(1)
        print( "The rebounding blow deals the", enN, enD, "damage") 
        enhp = enhp - enD
    elif dc == 2 :
        print( "You raise your shield too slowly to defend yourself" )
        print( "You take", enD, "damage" )
        php = php - enD 

if c == "s" : 
    p_sword() 
elif c == "a" :
    p_axe()
elif c == "p" :
    p_potion 
elif c == "m" :
    p_magic()
elif c == "d" :
    p_defend

def e_turn() :
    if enN ==