#bwskeletons
from eventAPI import *
from APIUtils import *

bwskeletons=0

def fireEvent(e):
   global bwskeletons
   bwskeletons = getTag(e, "bwskeletons")
   if (bwskeletons == 1):
      return 1
   else:
      showMessage(e, ["As you open the door, a group of undead draw their weapons and attack."], optionInput)
   fightThem(e)
   if (bwskeletons == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global bwskeletons
   showMessage(e, ["After you kick their bony arses you brush off the dust from your armor."])
   bwskeletons = 1
   setTag(e, "bwskeletons", bwskeletons)

def lostFight(e):
   showMessage(e, ["You are now as dead as the skeletons that you battled."])

def ranAwayFight(e):
   global bwskeletons
   showMessage(e, ["The skeletons taunt you by flaping their armbones like chicken wings, as you and your cowardly crew flee from battle."])
   bwskeletons = 0
   setTag(e, "bwskeletons", bwskeletons)
   setExit(e, "maps/bwquadrant1.cfg", 11, 24, 180)
