#keep level 0 fight #1

from eventAPI import *
from APIUtils import *

rtKeep0Flag1=0

def fireEvent(e):
   global rtKeep0Flag1
   rtKeep0Flag1 = getTag(e, "rtKeep0Flag1")
   if (rtKeep0Flag1 == 1):
      return 1
   elif (rtKeep0Flag1 == 2):
      showMessage(e, ["The spirits reappear and assault you!"])
   else:
      showMessage(e, ["As you enter the room, the air becomes colder.", "", "Suddenly, you are assaulted by a great number of the spirits trapped within this dungeon."], optionInput)
   showMessage(e, ["You hear many voices cry out as if in pain."], optionInput)
   fightThem(e)
   if (rtKeep0Flag1 == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global rtKeep0Flag1
   rtKeep0Flag1 = 1
   setTag(e, "rtKeep0Flag1", rtKeep0Flag1)
   showMessage(e, ["The spirits have been freed from their imprisonment."])

def lostFight(e):
   showMessage(e, ["You have bene defeated and are now trapped for eternity within this dungeon."])

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