#bwdwarves
from eventAPI import *
from APIUtils import *

bwdwarves=0

def fireEvent(e):
   global bwdwarves
   bwdwarves = getTag(e, "bwdwarves")
   if (bwdwarves == 1):
      return 1
   else:
      showMessage(e, ["Your foes seem endless. Their tales unknown. You face a group of angry bloodthirsty dwarves."], optionInput)
   fightThem(e)
   if (bwdwarves == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Dwarf", 30, 7, 20)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global bwdwarves
   showMessage(e, ["Always great warriors are we. Some short dwarf arse we kicked. you say with your best yoda accent."])
   bwdwarves = 1
   setTag(e, "bwdwarves", bwdwarves)

def lostFight(e):
   showMessage(e, ["The dwarves beat you to a pulp and leave you for dead."])

def ranAwayFight(e):
   global bwdwarves
   showMessage(e, ["RUN!"])
   bwdwarves = 0
   setTag(e, "bwdwarves", bwdwarves)
   setExit(e, "maps/bwquadrant3.cfg", 11, 12, 180)
