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

rtDefendFight1=0

def fireEvent(e):
   global rtDefendFight1
   rtDefendFight1 = getTag(e, "rtDefendFight1")
   if (rtDefendFight1 == 1):
      return 1
   else:
      showMessage(e, ["A group of goblins rush towards you. Their gleeful laughter is given a sinister edge when you see the blood upon their weapons."], optionInput)
   fightThem(e)
   if (rtDefendFight1 == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global rtDefendFight1
   showMessage(e, ["The sounds of battle nearby bring you back to your senses. The siege is not yet over!"])
   rtDefendFight1 = 1
   setTag(e, "rtDefendFight1", rtDefendFight1)

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

def ranAwayFight(e):
   global rtDefendFight1
   showMessage(e, ["You flee the battle and the goblins run off to find new victims."])
   rtDefendFight1 = 1
   setTag(e, "rtDefendFight1", rtDefendFight1)
