#castle level 1 fight #1
from eventAPI import *
from APIUtils import *

rtCastle1Flag1=0

def fireEvent(e):
   global rtCastle1Flag1
   rtCastle1Flag1 = getTag(e, "rtCastle1Flag1")
   if (rtCastle1Flag1 == 1):
      return 1
   elif (rtCastle1Flag1 == 2):
      showMessage(e, ["The spirits reappear and assault you!"])
   else:
      showMessage(e, ["As you approach the stairs to the second level of the castle, you are assaulted by ghostly figures."], optionInput)
   fightThem(e)
   setTag(e, "rtCastle1Flag1", rtCastle1Flag1)
   if (rtCastle1Flag1 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Angry Spirit", 10, 5, 30), ("Cursed Spirit", 10, 5, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global rtCastle1Flag1
   showMessage(e, ["You emerge triumphant from battle and gain access to the second level of the castle."])
   rtCastle1Flag1 = 1
   setTag(e, "rtCastle1Flag1", rtCastle1Flag1)

def lostFight(e):
   showMessage(e, ["Upon your death, you fall under the power of this cursed place.  Your spirit will now be set to guarding this staircase until some brave adventurers arrive to free you."])

def ranAwayFight(e):
   global rtCastle1Flag1
   showMessage(e, ["As you flee, the spirits fade away."])
   rtCastle1Flag1 = 2
   setTag(e, "rtCastle1Flag1", rtCastle1Flag1)
