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

def fireEvent(e):
   if (getTag(e, "lFlagU") == 1):
      return 1
   elif (getTag(e, "lFlagU") == 2):
      showMessage(e, ["The bloody remains of the young people you declined to defend lie there.", "", "Shame on you..."])
      setTag(e, "lFlagU", 1)
      return 1
   else:
      showMessage(e, ["As you turn the corner, you see a lone man attempting to defend a young woman from a group of goblins.", "", "The goblins appear to be teasing the young people, but you know that they will soon tire of the game and kill their victims."])
   showMessage(e, ["\"Gods! Please, help us!\"", "", "The goblins have now turned their attention upon you, and they grin wickedly as they begin their attack."])
   return fightThem(e)

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

def wonFight(e):
   showMessage(e, ["The battle over, you see the young man and woman rush into a nearby house.", "", "You hope that they can remain safe."])
   setTag(e, "lFlagU", 1)

def lostFight(e):
   showMessage(e, ["You have fought bravely, but your battle is now over."])

def ranAwayFight(e):
   showMessage(e, ["You flee the battle and leave behind the young man and woman to defend themselves.", "", "Sadly, there is no doubt about the outcome of their struggle..."])
   setTag(e, "lFlagU", 2)
