#bworcchief
from eventAPI import *
from APIUtils import *

bworcchief=0

def fireEvent(e):
   global bworcchief
   bworcchief = getTag(e, "bworcchief")
   if (bworcchief == 1):
      return 1
   else:
      showMessage(e, ["You walk in on a meeting of Orc leaders. They stop talking and turn to confront you."], optionInput)
   fightThem(e)
   if (bworcchief == 1):
      return 1
   else:
      return 0
      
def fightThem(e):
   combatRet = combat(e, [("Orc Chieftain", 5, 2, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global bworcchief
   showMessage(e, ["You have defeated the orcs."])
   bworcchief = 1
   setTag(e, "bworcchief", bworcchief)

def lostFight(e):
   showMessage(e, ["Serves you right for barge in in on us like that! Despicable adventurers!"])

def ranAwayFight(e):
   global bworcchief
   showMessage(e, ["Let's get out of here NOW!"])
   bworcchief = 0
   setTag(e, "bworcchief", bworcchief)
   setExit(e, "maps/bwquadrant2.cfg", 16, 23, 0)
