#bwspidersq2
from eventAPI import *
from APIUtils import *

bwspidersq2=0

def fireEvent(e):
   global bwspidersq2
   bwspidersq2 = getTag(e, "bwspidersq2")
   if (bwspidersq2 == 1):
      return 1
   else:
      showMessage(e, ["This room is infested with giant spiders"], optionInput)
   fightThem(e)
   if (bwspidersq2 == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global bwspidersq2
   showMessage(e, ["You hack the spiders into bite size pieces."])
   bwspidersq2 = 1
   setTag(e, "bwspidersq2", bwspidersq2)

def lostFight(e):
   showMessage(e, ["The spiders drag your dying bodies off to be eaten."])

def ranAwayFight(e):
   global bwspidersq2
   showMessage(e, ["You back out of the room."])
   bwspidersq2 = 0
   setTag(e, "bwspidersq2", bwspidersq2)
   setExit(e, "maps/bwquadrant2.cfg", 24, 12, 180)
