#eastern keep floor 1 gateway
from eventAPI import *
from APIUtils import *

rtkeep1Gateway = 0

def fireEvent(e):
   global rtkeep1Gateway
   global rtkeep1Fire
   global rtkeep1Earth
   global rtkeep1Water
   global rtkeep1Air
   rtkeep1Fire = getTag(e, "rtkeep1Fire")
   rtkeep1Earth = getTag(e, "rtkeep1Earth")
   rtkeep1Water = getTag(e, "rtkeep1Water")
   rtkeep1Air = getTag(e, "rtkeep1Air")
   clearPicture(e)
   showMessage(e, ["The floor vibrates with magical energy.", "", "You notice four gems embeded into the tile beneath your feet."])
   text = ["You closely examine the tile."]
   if (rtkeep1Fire == 2):
      text.extend(["", "The red gem is glowing."])
   if (rtkeep1Earth == 2):
      text.extend(["", "The brown gem is glowing."])
   if (rtkeep1Water == 2):
      text.extend(["", "The blue gem is glowing."])
   if (rtkeep1Air == 2):
      text.extend(["", "The white gem is glowing."])
   if ((rtkeep1Fire != 2) and (rtkeep1Earth != 2) and (rtkeep1Water != 2) and (rtkeep1Air != 2)):
      text.extend(["", "You see nothing out of the ordinary."])
   showMessage(e, text)
   if ((rtkeep1Fire == 2) and (rtkeep1Earth == 2) and (rtkeep1Water == 2) and (rtkeep1Air == 2)):
      openGateway(e)
   if (rtkeep1Gateway == 1):
      return 0
   else:
      return 1

def openGateway(e):
   global rtkeep1Gateway
   showMessage(e, ["The vibration increases until the entire world seems to shake.", "", "A rift appears before you."])
   showPicture(e, "Blue_Vortex")
   if (poseYesNo(e, ["There is no indication as to where this gateway will lead.", "", "Will you enter?"])):
      rtkeep1Gateway = 1
      setExit(e, "maps/rtetherplane.cfg", 20, 14, 0)
   return 0