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

rtCastle2Flag1=0

def fireEvent(e):
   global rtCastle2Flag1
   rtCastle2Flag1 = getTag(e, "rtCastle2Flag1")
   if (rtCastle2Flag1 == 1):
      return 1
   else:
      showMessage(e, ["You have entered what is obviously the main barracks for the castle guard.", "", "You might have made a mistake by entering here."], optionInput)
   fightThem(e)
   setTag(e, "rtCastle2Flag1", rtCastle2Flag1)
   if (rtCastle2Flag1 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Greenguard", 10, 5, 30), ("Redguard", 10, 5, 10), ("Blackguard", 10, 5, 10), ("Captain of the Guard", 1, 0, 20)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global rtCastle2Flag1
   showMessage(e, ["You view the wreckage and carnage of your battle.  What a mess!","",
                   "One of the Greenguards was wearing an intriguing cloth, which you retrieve."])
   giveItems(e, ["Saurian Ceremonial Drape"])
   rtCastle2Flag1 = 1
   setTag(e, "rtCastle2Flag1", rtCastle2Flag1)

def lostFight(e):
   showMessage(e, ["The last sound you here is the laughter of the guards."])

def ranAwayFight(e):
   global rtCastle2Flag1
   showMessage(e, ["Your attempt to flee is thwarted by the guards.  Worse yet, it appears that reinforcements have arrived."], optionInput)
   fightThem(e)
