#bwcruemanq2
from eventAPI import *
from APIUtils import *

bwcruemanq2=0

def fireEvent(e):
   global bwcruemanq2
   bwcruemanq2 = getTag(e, "bwcruemanq2")
   if (bwcruemanq2 == 1):
      return 1
   else:
      showMessage(e, ["As you open the door, you hear someone shout, Give me blood men!"], optionInput)
   fightThem(e)
   if (bwcruemanq2 == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global bwcruemanq2
   showMessage(e, ["You triumph over the enemy."])
   bwcruemanq2 = 1
   setTag(e, "bwcruemanq2", bwcruemanq2)

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

def ranAwayFight(e):
   global bwcruemanq2
   showMessage(e, ["RUN!"])
   bwcruemanq2 = 0
   setTag(e, "bwcruemanq2", bwcruemanq2)
   setExit(e, "maps/bwquadrant2.cfg", 30, 13, 0)
