#Olias plot events
from eventAPI import getTag, setTag, playSpecAudio, showPicture, optionInput, giveItems, callEvent, removeItem
from APIUtils import showMessage, poseYesNo, firstHasItem, setExit

def fireEvent(e):
    OliasPlt = getTag(e, "OliasPlt1")
    if(OliasPlt < 3):
        blocked(e)
        return 0
    if(OliasPlt > 5):
        return 1
    showPicture(e, "Olias")
    if(OliasPlt == 3):
        firstTowerMeet(e)
    elif(OliasPlt == 4):
        return getToTower(e)
    else: #OliasPlt == 5
        youDidItYay(e)
    return 0

def blocked(e):
    showMessage(e,
        ["You walk straight into some kind of translucent force, hard as stone.",
         "You decide it best to leave for now and return once you've found a way to continue through here"])

def firstTowerMeet(e):
    showMessage(e,
       ["\"Greetings friends, I'm glad to see you.",
        "Within these walls, the ExorArcanists are entrenched, plotting their schemes to expand their power and dominance over our town and lands",
        "I will play Soul Sources long enough for you to enter, and wait here for your return, so that I might open the barrier again when you come back",
        "I'll stay here as long as you need,  Even though this isn't quite as fun as the Green Bard's wine and women.",
        "Good luck Heros."])
    setTag(e,"OliasPlt1", 4)
    getToTower(e)

def getToTower(e):
    if(poseYesNo(e,["Are you ready to go into the tower?"])):
        setExit(e, "maps/renibister.cfg", 2, 37, 0)
        return 0
    else:
        return 1

def youDidItYay(e):
    showMessage(e,
        ["You're alive! When I saw that blast of light emanate from the top of the tower, I feared the worst for you friends.",
         "What's that? It was a ring of some kind? Lost Souls? You MUST absolutely report this to Yeodaugh immediately, he'll know what to do",
         "I fear that my loitering around this tower may have raised suspicion, I think it wise for me to lay low for a few weeks",
         "Until I see you next friends, be well"])
    setTag(e, "OliasPlt1", 6)
