#GUARD PARDON 
from eventAPI import getTag, setTag, showPicture, optionInput, removeItem, giveItems
from APIUtils import firstHasItem, showMessage, removeAllItems
from SDLKeys import SDLK_w, SDLK_r, SDLK_y, SDLK_n, SDLK_t
import genericBarracks

def fireEvent(e):
    lFlagU = getTag(e, "lFlagU")
    letterHolder = firstHasItem(e, "Letter to Dorukan")
    if (letterHolder < 0):
        genericBarracks.fireEvent(e)
        return 0
    showPicture(e, "Guard_of_Rennibister")
    showMessage(e,
        ["The guards glare harshly at you, their hands itching on the handles of their weapons..."])
    lFlagU = 1
    if (optionInput(e,
        ["\"What business do YOU have here?\""],
        ["(W)e seek a pardon", "(R)un away!"], [SDLK_w, SDLK_r]) == SDLK_r):
        setTag(e, "lFlagU", lFlagU)
        return 0
    if (optionInput(e,
        ["\"A Pardon?",
         "",
         "\"Do you have evidence that would clear your names from our roster?\""],
        ["(Y)es we do.", "(N)o we don't"], [SDLK_y, SDLK_n]) == SDLK_n):
        setTag(e, "lFlagU", lFlagU)
        return 0
    removeItem(e, letterHolder, "Letter to Dorukan")
    removeAllItems(e, "Unknown Vial (Red)")
    showMessage(e,
        ["\"Let's see it!\"",
         "",
         "Before you can react, small hands silently remove the note and the vials from your packs.",
         "",
         "A small young female obscured by a dark hood, whisks around you and hands the items to the brooding Guard...",
         "",
         "The guard inspects the note... and etches something down on another piece of parchment."])
    optionInput(e,
        ["\"ExA! What in the blazes is that?\"",
         "",
         "The veiled girl whispers something in the Guards ear.",
         "",
         "\"Ah... So they are working with this Latruin character now. We'll deal with them soon enough.\"",
         "",
         "\"Your party is granted a pardon. Take this scroll and keep it on you at all times.\""],
        ["(T)ake the pardon and leave."], [SDLK_t])
    giveItems(e, ["Guard Pardon"])
    setTag(e, "GuardPlt1", getTag(e, "GuardPlt1") | 1)
    setTag(e, "lFlagU", lFlagU)
    return 0
