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

rtKeep3Tower2=0

def fireEvent(e):
   global rtKeep3Tower2
   rtKeep3Tower2 = getTag(e, "rtKeep3Tower2")
   if (rtKeep3Tower2 == 1):
      return 1
   elif (rtKeep3Tower2 == 2):
      showMessage(e, ["Your enemies return!"])
   else:
      showMessage(e, ["You come upon a group of monsters."], optionInput)
   fightThem(e)
   if (rtKeep3Tower2 == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Demon Dog", 20, 3, 10), ("Zombified Orc Fury", 4, 4, 10)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global rtKeep3Tower2
   global rtKeep1TowerFlag
   rtKeep1TowerFlag = getTag(e, "rtKeep1TowerFlag")
   showMessage(e, ["You are free to continue your battle through the tower."])
   rtKeep3Tower2 = 1
   rtKeep1TowerFlag = 6
   setTag(e, "rtKeep3Tower2", rtKeep3Tower2)
   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 rtKeep3Tower2
   showMessage(e, ["You hear laughter as you flee your enemies."])
   rtKeep3Tower2 = 2
   setTag(e, "rtKeep3Tower2", rtKeep3Tower2)
