#defend fight #7
from eventAPI import *
from APIUtils import *

def fireEvent(e):
   if (getTag(e, "lFlagU") == 2):
      return 1
   elif (getTag(e, "lFlagU") == 1):
      showMessage(e, ["The goblins were at least smart enough to leave a guard at the door."])
   else:
      showMessage(e, ["As you approach the door, you startle a lone goblin emerging from within.", "", "The creature quicky disappears back inside and you can hear high pitched yelling and squealing."], optionInput)
   return fightThem(e)

def fightThem(e):
   showMessage(e, ["Goblins begin to pour out of the tavern and into the street.", "", "It looks like you've managed to start a drunken brawl."])
   combatRet = combat(e, [("Goblin", 10, 2, 10)])
   if (combatRet == 1):
      wonFight(e)
      return 1
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)
      return 0

def wonFight(e):
   showMessage(e, ["The last goblin staggers and finally falls over dead."])
   setTag(e, "lFlagU", 2)

def lostFight(e):
   showMessage(e, ["Satisfied that you are most assuredly dead, the goblins decide that a celebration is in order. Brew is on the house!"])

def ranAwayFight(e):
   showMessage(e, ["You hastily retreat, but vow to avenge the fallen kegs within!", "", "Oh, What shall happen if the city's beer supply is lost to the invading goblins? Dark days, I assure you..."])
   setTag(e, "lFlagU", 1)
