#keep level 4 observation tower #2
from eventAPI import *
from APIUtils import *

rtKeep4Tower2=0

def fireEvent(e):
   global rtKeep4Tower2
   rtKeep4Tower2 = getTag(e, "rtKeep4Tower2")
   if (rtKeep4Tower2 == 1):
      return 1
   elif (rtKeep4Tower2 == 2):
      showMessage(e, ["Your enemies return!"])
   else:
      showMessage(e, ["You are assaulted by a particularly large group of monsters.  The lead orc appears to be possessed."], optionInput)
   fightThem(e)
   if (rtKeep4Tower2 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Zombified Orc Fury", 12, 4, 10), ("Demon Dog", 8, 3, 10), ("Demonic Shadow", 5, 3, 10), ("High Orc Chieftan", 1, 0, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global rtKeep4Tower2
   global rtKeep1TowerFlag
   rtKeep1TowerFlag = getTag(e, "rtKeep1TowerFlag")
   showMessage(e, ["You have reached the top of the observation tower, but the ladder to the observation deck is broken."])
   rtKeep4Tower2 = 1
   rtKeep1TowerFlag = 8
   setTag(e, "rtKeep4Tower2", rtKeep4Tower2)
   setTag(e, "rtKeep1TowerFlag", rtKeep1TowerFlag)

def lostFight(e):
   showMessage(e, ["It seems that you aren't as powerful as you thought you were."])

def ranAwayFight(e):
   global rtKeep4Tower2
   showMessage(e, ["You hear laughter as you flee your enemies."])
   rtKeep4Tower2 = 2
   setTag(e, "rtKeep4Tower2", rtKeep4Tower2)
