#bworchome
from eventAPI import *
from APIUtils import *

bworchome=0

def fireEvent(e):
   global bworchome
   bworchome = getTag(e, "bworchome")
   if (bworchome == 1):
      return 1
   else:
      showMessage(e, ["A large orc raises his head and snarls. How dare you break into our home!"], optionInput)
   fightThem(e)
   if (bworchome == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Orc", 14, 2, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global bworchome
   showMessage(e, ["You finish off slaughtering the orcs."])
   bworchome = 1
   setTag(e, "bworchome", bworchome)

def lostFight(e):
   showMessage(e, ["That'll teach you to break into my home! You adventuring bastards!"])

def ranAwayFight(e):
   global bworchome
   showMessage(e, ["You manage to get away."])
   bworchome = 0
   setTag(e, "bworchome", bworchome)
   setExit(e, "maps/bwquadrant1.cfg", 13, 29, 0)
