#Script for Collegium of Magika
#Helps make Power Crystal
from eventAPI import *
from APIUtils import *

def fireEvent(e):
    global kssCrystal
    showPicture(e, "Magika")
    if ((getTag(e, "kssCrystal") == 0) and (firstHasItem(e, "Strange Crystal") >= 0)):
        showMessage(e,
            ["You show the crystal to the Masters. They take it from you and retreat to one of ther arcane laboratories.",
             "","Several hours later, they return it to you:"])
        showMessage(e,
            ["\"It seems to have been used to store magical energies.",
             "Landru might be able to help you devise a way to build new crystals.",
             "If you manage to do that, be sure to bring us one.\"","","You assure them you will and take your leave."])
        setTag(e, "kssCrystal", 1)
        tickGame(e, 1000)
        return 0
    elif ((getTag(e, "kssCrystal") == 3) and (firstHasItem(e, "Power Crystal") >= 0)):
        showMessage(e,
            ["You bring your freshly crafted Power Crystal to the Collegium.","",
             "One of the Masters takes it, thanking you profusely:","",
             "\"This will greatly help advance our research.\""])
        removeItem(e, firstHasItem(e, "Power Crystal"), "Power Crystal")
        showMessage(e,
            ["He traces mystical symbols in the air with his hands.","",
             "You feel refreshed and energized.","","","You thank him and leave."])
        x, c = 0, getPartyCount(e)
        while (x < c):
            modifyXP(e, x, 150000)
            modifyHP(e, x, 1000)
            modifySP(e, x, 1000)
            x += 1
        setTag(e, "kssCrystal", 4)
        return 0
    else:
        callEvent(e, 1003, ["-1", "-1", "-1"])
        return 0 


    


