#hedgemaze fight #1

from eventAPI import *
from APIUtils import *

rtHedgeFlag1=0

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

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

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

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

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