#Hedze Maze fight #3
from eventAPI import *
from APIUtils import *

rtHedgeFlag3=0

def fireEvent(e):
   global rtHedgeFlag3
   rtHedgeFlag3 = getTag(e, "rtHedgeFlag3")
   if (rtHedgeFlag3 == 1):
      return 1
   elif (rtHedgeFlag3 == 2):
      showMessage(e, ["The camp defenders were waiting for your return."])
   else:
      showMessage(e, ["You come upon a squalid camp full of goblins and orcs.", "", "Though taken by surprise, the inhabitants are quick to grab weapons and rush you."], optionInput)
   fightThem(e)
   setTag(e, "rtHedgeFlag3", rtHedgeFlag3)
   if (rtHedgeFlag3 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Garden Gnome", 5, 4, 30), ("Orc Fury", 10, 4, 10), ("High Orc Chieftan", 1, 0, 20)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global rtHedgeFlag3
   showMessage(e, ["The camp is quiet following the noise of the battle.", "", "After a thourough search you find a few usable items."], optionInput)
   chest(e, -1, 0, 5821, [], dice(1, 4, 1), "treasure")
   rtHedgeFlag3 = 1
   setTag(e, "rtHedgeFlag3", rtHedgeFlag3)

def lostFight(e):
   showMessage(e, ["The goblins and orcs cheer in triumph as the last of your party falls."])

def ranAwayFight(e):
   global rtHedgeFlag3
   showMessage(e, ["There is no pursuit from the camp.  Behind you, the alarmed defenders prepare for another assault."])
   rtHedgeFlag3 = 2
   setTag(e, "rtHedgeFlag3", rtHedgeFlag3)
