#keep level 4 fight #1
from eventAPI import *
from APIUtils import *

rtKeep4Flag1=0

def fireEvent(e):
   global rtKeep4Flag1
   rtKeep4Flag1 = getTag(e, "rtKeep4Flag1")
   if (rtKeep4Flag1 == 1):
      return 1
   else:
      showPicture(e, "Wizard")
      showMessage(e, ["As you wander about the upper floor of this tower, you suddenly come face to face with a withered old man.", "", "\"MINE!  This is my room!  You are not allowed here!\""], optionInput)
   fightThem(e)
   if (rtKeep4Flag1 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   showMessage(e, ["With a wave of his hand, the old man summons several demons."], optionInput)
   combatRet = combat(e, [("Mad Summoner", 1, 0, 10), ("Servant of Fire", 5, 2, 10), ("Thirster", 5, 2, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   showMessage(e, ["While searching the remains of the old man, you discover a small pouch containing a few seeds and a note."])
   giveItems(e, ["Magic Seeds", "Stained Note"])
   global rtKeep4Flag1
   rtKeep4Flag1 = 1
   setTag(e, "rtKeep4Flag1", rtKeep4Flag1)

def lostFight(e):
   showMessage(e, ["You should have heeded the warnings."])

def ranAwayFight(e):
   showMessage(e, ["\"You cannot escape me!\""], optionInput)
   fightThem(e)
