#bwgoblinsq2nd
from eventAPI import *
from APIUtils import *

bwgoblinsq2nd=0

def fireEvent(e):
   global bwgoblinsq2nd
   bwgoblinsq2nd = getTag(e, "bwgoblinsq2nd")
   if (bwgoblinsq2nd == 1):
      return 1
   else:
      showMessage(e, ["You are assaulted by goblins."], optionInput)
   fightThem(e)
   if (bwgoblinsq2nd == 1):
      return 1
   else:
      return 0

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

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

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

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