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

rtDefendFight3=0

def fireEvent(e):
   global rtDefendFight3
   rtDefendFight3 = getTag(e, "rtDefendFight3")
   if (rtDefendFight3 == 2):
      return 1
   elif (rtDefendFight3 == 1):
      showMessage(e, ["There is a large group of goblins holding position just ahead of you. With some unseen signal, the battle begins."])
   else:
      showMessage(e, ["A large group of goblins is now finishing off the last of a squadron of rennibister defenders. They don't even pause to rest as they rush towards you."], optionInput)
   fightThem(e)
   if (rtDefendFight3 == 2):
      return 1
   else:
      return 0

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

def wonFight(e):
   global rtDefendFight3
   showMessage(e, ["You think that this was likely the main force within the city. Still you feel that caution is warranted."])
   rtDefendFight3 = 2
   setTag(e, "rtDefendFight3", rtDefendFight3)

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

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