#Alethor's Ring, event 2, main map
# Covers Alethor's Riddle - pretty much just asks the question ;-)
from eventAPI import getTag, showPicture, optionInput, stringInput, setTag, giveItems
from APIUtils import isclearall, issetall, showMessage

def fireEvent(e):
    RingPlt1 = getTag(e, "RingPlt1")
    if (not isclearall(RingPlt1, 0x40)):
        return 0
    if (not issetall(RingPlt1, 0x30)):
        return 0
    showPicture(e, "Elf_Male")
    answer = stringInput(e,
        ["A ghostly image of an Elf appears before you.",
         "With great dignity, the apparition begins to speak:",
         "",
         "\"I am all that is left of Alethor the Wise."
         "",
         "\"Before I may tell you more, I must know that you've fully completed the task at which I failed.",
         "Tell me, why did I seek the Cloak of the True Hero?\""])
    if (answer.lower() == "love"):
        showMessage(e,
            ["The image of the Elf continues:",
             "",
             "\"Thank you brave heroes for finishing what I could not!",
             "As you know, I entered the trial, hoping to win the Cloak of the True Hero.",
             "Once completing the first two tests, which I chose to be the Tests of Valor and Bravery, I assumed that I had won the contest, for I had always found tests of Wisdom easy.",
             "This time, however, that was not to be the case.",
             "I was unable to complete my quest, and have been trapped here ever since, waiting for someone to succeed where I had failed, that I might be freed.",
             "",
             "\"As a token of my appreciation, accept this Ring.",
             "It will serve as one of three keys you will need to win access to the Cloak and complete your quest.",
             "Now, Farewell!  I go to be with my beloved.\""])
        giveItems(e, ["Alethor's Ring"])
        setTag(e, "RingPlt1", (RingPlt1 | 0xC0))
    else:
        showMessage(e, ["The apparition disappears in a cloud of dense smoke, leaving you with the sense that you answered incorrectly."])
    return 0
