#bwskeletonsq2
from eventAPI import *
from APIUtils import *

bwskeletonsq2=0

def fireEvent(e):
   global bwskeletonsq2
   bwskeletonsq2 = getTag(e, "bwskeletonsq2")
   if (bwskeletonsq2 == 1):
      return 1
   else:
      showMessage(e, ["You stumble upon a group of skeletons armed to the teeth."], optionInput)
   fightThem(e)
   if (bwskeletonsq2 == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global bwskeletonsq2
   showMessage(e, ["You smash the undead to pieces."])
   bwskeletonsq2 = 1
   setTag(e, "bwskeletonsq2", bwskeletonsq2)

def lostFight(e):
   showMessage(e, ["You are defeated."])

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