#hedgemaze fight #2

from eventAPI import *
from APIUtils import *

rtHedgeFlag2=0

def fireEvent(e):
   global rtHedgeFlag2
   rtHedgeFlag2 = getTag(e, "rtHedgeFlag2")
   if (rtHedgeFlag2 == 1):
      return 1
   elif (rtHedgeFlag2 == 2):
      showMessage(e, ["The keep guardians rush you!"])
   else:
      showMessage(e, ["As you enter the courtyard of the Eastern Keep, you are assaulted by the keep guardians."], optionInput)
   fightThem(e)
   setTag(e, "rtHedgeFlag2", rtHedgeFlag2)
   if (rtHedgeFlag2 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Gold Golem", 1, 0, 10), ("Silver Golem", 1, 0, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global rtHedgeFlag2
   showMessage(e, ["You defeat the guardians and gain access to the Eastern Keep!"])
   rtHedgeFlag2 = 1
   setTag(e, "rtHedgeFlag2", rtHedgeFlag2)

def lostFight(e):
   showMessage(e, ["The keep guardians cut off your head and place it upon a pike outside the coutyard as a warning to others."])

def ranAwayFight(e):
   global rtHedgeFlag2
   showMessage(e, ["You flee the keep courtyard.  The keep guardians return to their original positions."])
   rtHedgeFlag2 = 2
   setTag(e, "rtHedgeFlag2", rtHedgeFlag2)
