from eventAPI import *
from APIUtils import *

def fireEvent(e):
    k = getTag(e, "kssCrypt")
    if (k > 20):
        return 1
    elif (k == 0):
        showMessage(e,["You spot a piece of parchment on the ground. As you bend to examine it, a gust of wind carries it away."])
        setTag(e, "kssCrypt", 1)
        return 1
    elif (k == 1):
        showMessage(e,["Your eyes fall on a familiar piece of parchment.",
                       "","Before you can do anything, the wind catches it and soon, it's gone again."])
        setTag(e, "kssCrypt", 2)
        return 1
    elif (dice(1, k, 0) > 8):
        showMessage(e,["You spy the obnoxious piece of parchment, caught on a thorny bush.",
                       "Quick as lightning, you snatch it, hopeful that it will lead to treasure.", "",
                       "However, it turns out to be a mere flyer, and a cryptic one at that."])
        showMessage(e,["'"'YE CRYPT SHOPPE'"'", "", "We're now open:", "To see our stock,",
                       "Thrice have to run", "Around the clock...", "", "",
                       "As you ponder this message, the parchment falls from your hands; soon the wind picks it up and carries it away."])
        setTag(e, "kssCrypt", 21)
        return 1
    if (dice(1, 3, 0) > 1):
        showMessage(e,["Once again, you spot the elusive parchment;",
                       "","Once again, the wind blows it away."])
    else:
        showMessage(e,["A parchment, my friend, is blowing in the wind;",
                       "a parchment is blowing in the wind."])
    k += 1
    if (k < 21):
        setTag(e, "kssCrypt", k)
    return 1
