#bwsenrats and dogs
from eventAPI import *
from APIUtils import *

bwsrdg=0

def fireEvent(e):
   global bwsrdg
   bwsrdg = getTag(e, "bwsrdg")
   if (bwsrdg == 1):
      return 1
   else:
      showMessage(e, ["As you push the door open you are assaulted by a group of senrats shouting \"You're not supposed to be in here!\" The senrats have guard dogs with them."], optionInput)
   fightThem(e)
   if (bwsrdg == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Senrat", 15, 2, 20), ("Wild Dog", 15, 0, 10) ])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global bwsrdg
   showMessage(e, ["You defeat the mutts and their vermin masters."])
   bwsrdg = 1
   setTag(e, "bwsrdg", bwsrdg)

def lostFight(e):
   showMessage(e, ["The dogs chew you to pieces as their senrat masters watch and laugh."])

def ranAwayFight(e):
   global bwsrdg
   showMessage(e, ["We're outta here!"])
   bwsrdg = 0
   setTag(e, "bwsrdg", bwsrdg)
   setExit(e, "maps/bwquadrant4.cfg", 11, 19, 180)
