#Elemental Gallery empty pillar
from eventAPI import *
from APIUtils import *

rtpillar=0

def fireEvent(e):
   global rtpillar
   rtpillar = getTag(e, "rtpillar")
   if (rtpillar == 3):
      return 1
   elif (rtpillar == 2):
      returnVisit(e)
   elif (rtpillar == 0):
      firstVisit(e)
   elif (firstHasItem(e, "Elemental Heart") >= 0):
      replaceHeart(e)
   if (rtpillar == 0):
      return 0
   else:
      return 1

def firstVisit(e):
   showMessage(e, ["Just as you were told there is a pillar here.", "", "It is an imense carved column with what appear to be contained areas of elemental essence.", "", "As you look closely you can see that the essences are actually portals and that the center of the column is hollow."])
   if (poseYesNo(e, ["You recall that the item was supposed to be contained within the pillar.  Will you reach inside?"])):
      showMessage(e, ["As you reach inside there is an audible click.  You have sprung a trap!", "", "You can feel the elemental essences swirling around your arm inside the pillar and you are unable to pull free.  Seconds pass and nothing else happens.  Slowly, the grip on your arm is released.  It appears as though this trap is broken.", "", "Feeling around inside, you find nothing."])
      rtpillar=1
      setTag(e, "rtpillar", rtpillar)
   return 1


def returnVisit(e):
   showMessage(e, ["You attempt to again reach the Elemental Heart, but are unable to force past the portal of elemental essence.", "", "You are confident that the Elemental Heart will remain secure within."])
   rtpillar=3
   setTag(e, "rtpillar", rtpillar)


def replaceHeart(e):
   if (poseYesNo(e, ["As you pass by the pillar, the Elemental Heart that you recovered from flame reacts as if it is attempting to push you away from the pillar", "", "Will you place the Elemental Heart back into the pillar where it was once kept?"])):
      showMessage(e, ["With great effort, you push the Elemental Heart into the center of the pillar.", "", "Upon releasing the object, you are forciably pushed back from the pillar."])
      holder = firstHasItem(e, "Elemental Heart")
      removeItem(e, holder, "Elemental Heart")
      rtpillar=2
      setTag(e, "rtpillar", rtpillar)
   return 0

