#keep level 2 fight #12
from eventAPI import *
from APIUtils import *

rtDarkOne=0

def fireEvent(e):
   global rtDarkOne
   rtDarkOne = getTag(e, "rtDarkOne")
   if (rtDarkOne >= 1):
      return 1
   else:
      fightThem(e)
   return 1

def fightThem(e):
   showMessage(e, ["You enter the room and hear a terrible growling sound.  From the shadows a horrible beast emerges."], optionInput)
   combatRet = combat(e, [("Dark One", 1, 0, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global rtDarkOne
   rtDarkOne = 1
   setTag(e, "rtDarkOne", rtDarkOne)
   showMessage(e, ["You are victorious in battle against the strange beast.", "", "Looking closely it appears to be a cross between a wolf and a dragon."], optionInput)
   showMessage(e, ["Suddenly, the corpse of the slain beast stirs and it comes back to life!", "", "The beast again growls at you and runs out of the broken cage and into the keep."], optionInput)
   showMessage(e, ["You can hear the creature howling as it runs away."], optionInput)
   return 1

def lostFight(e):
   showMessage(e, ["The last sound you hear is the beast howling."])

def ranAwayFight(e):
   global rtDarkOne
   rtDarkOne = 1
   setTag(e, "rtDarkOne", rtDarkOne)
   showMessage(e, ["You turn to flee from the beast.", "", "Before you can escape from the cage, the beast runs past you and out into the keep."], optionInput)
   showMessage(e, ["You can hear the creature howling as it runs away."], optionInput)
