#bwspidersq4
from eventAPI import *
from APIUtils import *

bwspidersq4=0

def fireEvent(e):
   global bwspidersq4
   bwspidersq4 = getTag(e, "bwspidersq4")
   showPicture(e, "Giant_Spider")
   if (bwspidersq4 == 1):
      return 1
   else:
      showMessage(e, ["You stumble upon a room full o'spiders."], optionInput)
   fightThem(e)
   if (bwspidersq4 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Giant Spider", 55, 0, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global bwspidersq4
   showMessage(e, ["You wade through the bodies of the fallen spiders."])
   bwspidersq4 = 1
   setTag(e, "bwspidersq4", bwspidersq4)

def lostFight(e):
   showMessage(e, ["The spiders drag your corpses away."])

def ranAwayFight(e):
   global bwspidersq4
   showMessage(e, ["You run as quickly as possible and escape battle."])
   bwspidersq4 = 0
   setTag(e, "bwspidersq4", bwspidersq4)
   setExit(e, "maps/bwquadrant4.cfg", 13, 29, 90)