#guard dogs fight
from eventAPI import *
from APIUtils import *

bwq2dogs=0

def fireEvent(e):
   global bwq2dogs
   bwq2dogs = getTag(e, "bwq2dogs")
   if (bwq2dogs == 1):
      return 1
   else:
      showMessage(e, ["As you enter the room, an alarm goes off. Seconds later you are greeted by a pack of wild dogs. They attack."], optionInput)
   fightThem(e)
   if (bwq2dogs == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global bwq2dogs
   showMessage(e, ["The guard dogs lay dead at your feet. You gather your party and continue on."])
   bwq2dogs = 1
   setTag(e, "bwq2dogs", bwq2dogs)

def lostFight(e):
   showMessage(e, ["The dogs make a nice meal out of you."])

def ranAwayFight(e):
   global bwq2dogs
   showMessage(e, ["You manage to get away."])
   bwq2dogs = 0
   setExit(e, "maps/bwquadrant2.cfg", 22, 30, 270)
   setTag(e, "bwq2dogs", bwq2dogs)
