#Alethor's Ring, event 1, main map
# Covers Alethor's Symbol - search clue, followed by retrieval of item
from SDLKeys import SDLK_y, SDLK_n, SDLK_l
from eventAPI import getTag, optionInput, setTag, getPartyCount, hasItem, removeItem
from APIUtils import isclearall, showMessage

def fireEvent(e):
    RingPlt1 = getTag(e, "RingPlt1")
    if (not isclearall(RingPlt1, 0x20)):
        return 1
    i, max = 0, getPartyCount(e)
    hasStaff = 0
    while (i < max):
        if (hasItem(e, i, "Alethor's Staff")):
            hasStaff = 1
            break
        i += 1
    text = ["You see a large door before you, with what appears to be a recessed hole for some sort of large staff.",
         "Written below the hole is the following inscription:",
         "",
         "\"Those who wish to pass must first return the chosen symbol of the warrior here entombed, Alethor the Wise.",
         "",
         "\"The symbol may be found where the great warrior fell, in the Test of Wisdom.\""]
    if (hasStaff):
        optionTexts = ["(Y)es", "(N)o"]
        optionsKeys = [SDLK_y, SDLK_n]
        text.extend(["", "Do you place Alethor's Staff in the hole?"])
    else:
        optionTexts = ["(L)eave the Scene"]
        optionsKeys = [SDLK_l]
    if (optionInput(e, text, optionTexts, optionsKeys) == SDLK_y):
        removeItem(e, i, "Alethor's Staff")
        showMessage(e,
            ["Alethor's Staff is a perfect fit for the recessed portion of the wall.",
             "As you place the Staff in its resting place, the wall begins to glow.",
             "Before your eyes, the wall dissolves, with the Staff, and the way ahead is clear."])
        setTag(e, "RingPlt1", RingPlt1 | 0x20)
    return 0
