#senrat patrol fight
from eventAPI import *
from APIUtils import *

bwsenratpatrol=0

def fireEvent(e):
   global bwsenratpatrol
   bwsenratpatrol = getTag(e, "bwsenratpatrol")
   if (bwsenratpatrol == 1):
      return 1
   else:
      showMessage(e, ["A patrol of Senrat's stop you. The leader speaks. You are trespassing on our domain. Better say your prayers! The Senrats attack!"], optionInput)
   fightThem(e)
   if (bwsenratpatrol == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global bwsenratpatrol
   showMessage(e, ["You defeat the Senrats."])
   bwsenratpatrol = 1
   setTag(e, "bwsenratpatrol", bwsenratpatrol)

def lostFight(e):
   showMessage(e, ["The Senrats laugh at your defeat."])

def ranAwayFight(e):
   global bwsenratpatrol
   showMessage(e, ["You run like hell and manage to escape."])
   bwsenratpatrol = 0
   setTag(e, "bwsenratpatrol", bwsenratpatrol)
   setExit(e, "maps/bwquadrant1.cfg", 27, 25, 90)