#Mage Tower riddle portal
from eventAPI import showPicture, tickGame, setExit
from APIUtils import poseYesNo, showMessage
import mtowerRiddles

def fireEvent(e):
    portalNum = 3
    canGo = 0
    wrongPortal = 0

    if(not mtowerRiddles.alreadySolved(e, portalNum)):
        showMessage(e, 
            ["As you push forward, your Raven Beacon begins to slowly light up.",
             "A Laneraven appears!"])
        showPicture(e, "Laneraven")
        if(mtowerRiddles.checkCorrectRiddle(e, portalNum)):
            canGo = mtowerRiddles.askRiddle(e, portalNum)
        else:
            wrongPortal = 1
    else:
        canGo = 1 

    if(canGo and not wrongPortal):
        showPicture(e, "Red_Vortex")
        if (poseYesNo(e,
            ["There is a RED portal here.",
             "Do you step into it?"])):
            tickGame(e, 10)
            setExit(e, "maps/mage1.cfg", 10, 9, 0)
    elif (wrongPortal):
        showMessage(e, ["You must pass another test before you can be tried here."])
    elif (not canGo):
        showMessage(e, ["Incorrect! come back when you have learned more!"])
    return 0
