from eventAPI import *
from APIUtils import *

def fireEvent(e):
    if ((getTag(e, "lFlagS") & 0x100) == 0):
        return 1
    global k
    k = getTag(e, "kssAD")
    if (k == 0):
        showMessage(e, ["This umm, imposing err, gate bars access to the biggest house in the cavern. It must be the residence of the head honcho.",
                        "","You try the handle, and find the gate is securely locked."])
        setTag(e, "kssAD", 1)
        return 1
    elif (k == 1):
        showMessage(e, ["The gate is still locked."])
        return 1
    elif (k == 2):
        setTag(e, "kssAD", 3)
        return (poseYesNo(e, ["This umm, imposing err, gate provides access to the biggest house in the cavern. It must be the residence of the Arch-Druid.",
                        "","In his precipitation, he's left it slightly ajar.","","Will you enter ?"]) == 0)
    elif (k == 3):
        return (poseYesNo(e, ["The Arch-Druid has retreated to his house. In his precipitation, he's left the gate slightly ajar.","","Will you enter ?"]) == 0)
    else:
        return (poseYesNo(e, ["The gate is still open.","","Will you enter ?"]) == 0)
