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

rtDefendFight5=0

def fireEvent(e):
   global rtDefendFight5
   rtDefendFight5 = getTag(e, "rtDefendFight5")
   if (rtDefendFight5 == 1):
      return 1
   else:
      showMessage(e, ["More reinforcements enter through the breach in the western wall. You are unfortunate to be the first obstacle in their path."])
   fightThem(e)
   if (rtDefendFight5 == 1):
      return 1
   else:
      return 0

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

def wonFight(e):
   global rtDefendFight5
   showMessage(e, ["You must gain control of the breach before more reinforcements arrive!"])
   rtDefendFight5 = 1
   setTag(e, "rtDefendFight5", rtDefendFight5)

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

def ranAwayFight(e):
   showMessage(e, ["You are able to flee from your foes, but this will not stop their destructive rampage."])
