#bwgoblinsq2
from eventAPI import *
from APIUtils import *

bwgoblinsq2=0

def fireEvent(e):
   global bwgoblinsq2
   bwgoblinsq2 = getTag(e, "bwgoblinsq2")
   if (bwgoblinsq2 == 1):
      return 1
   else:
      showMessage(e, ["This room reeks of goblins. Looks like your nose is right."], optionInput)
   fightThem(e)
   if (bwgoblinsq2 == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global bwgoblinsq2
   showMessage(e, ["The goblins are defeated."])
   bwgoblinsq2 = 1
   setTag(e, "bwgoblinsq2", bwgoblinsq2)

def lostFight(e):
   showMessage(e, ["One goblin smiles and says, 'they'll make for a fine adventurer stew' mwuahahahahaha!"])

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