#Marias' Ring, event 1, main map
# Covers Marias' 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, 0x200)):
        return 1
    i, max = 0, getPartyCount(e)
    hasBlade = 0
    while (i < max):
        if (hasItem(e, i, "Marias' Blade")):
            hasBlade = 1
            break
        i += 1
    text = ["You see a large door before you, with what appears to be a recessed hole for some sort of long sword.",
         "Written below the hole is the following inscription:",
         "",
         "\"Those who wish to pass must first return the chosen symbol of the warrior here entombed, Marias the Quick.",
         "",
         "\"The symbol may be found where the great warrior fell, in the Test of Bravery.\""]
    if (hasBlade):
        optionText = ["(Y)es", "(N)o"]
        optionsKeys = [SDLK_y, SDLK_n]
        text.extend(["", "Do you place Marias' Blade in the hole?"])
    else:
        optionText = ["(L)eave the Scene"]
        optionsKeys = [SDLK_l]
    if (optionInput(e, text, optionText, optionsKeys) == SDLK_y):
        removeItem(e, i, "Marias' Blade")
        showMessage(e,
            ["Marias' Blade is a perfect fit for the recessed portion of wall.",
             "As you place the Staff in its resting place, the wall begins to glow.",
             "Before your eyes, the wall dissolves, with the Blade, and the way ahead is clear."])
        setTag(e, "RingPlt1", RingPlt1 | 0x200)
    return 0
