from eventAPI import *
from APIUtils import *

def fireEvent(e):
    global kssPlot
    kssPlot = getTag(e, "kssPlot")
    if (kssPlot == 1):
        return first(e)
    elif (kssPlot == 2):
        return second(e)
    else:
        return 1
               
def first(e):
    showMessage(e, ["As you approach these humanoids, their leader, a bearded man with flowing robes, greets you:","",
                    "\"Aaah, visitors ! We have less and less of them, though we've made sure the clues we left in the Arcanium are less than elliptic...\""])
    showMessage(e, ["\"Mayhap the wilderness has become more dangerous ? Such a shame, such a shame...","","It's been a long time since we last had fresh meat...",
                    "","Anyway, we'd like to invite you to dinner.\""])
    showMessage(e, ["As they ready for battle, you belatedly wonder whether this might be a trap."])
    combatRet = combat(e, [("Druid", 1, 0, 60),("Ranger",6, 0, 30)])
    if (combatRet == 1):
        won(e)
        return 1
    elif (combatRet == 3):
        lost(e)
    else:
        ran(e)
        return 0

def second(e):
    showMessage(e, ["When they see you approaching, the druid and rangers resume their battle stances."])
    combatRet = combat(e, [("Druid", 1, 0, 60),("Ranger",6, 0, 30)])
    if (combatRet == 1):
        won(e)
        return 1
    elif (combatRet == 3):
        lost(e)
    else:
        ran(e)
        return 0

def won(e):
    showMessage(e, ["The bloody remains of your welcoming committee litter the ground."])
    setTag(e, "kssPlot", 3)

def lost(e):
    showMessage(e, ["I have some bad news, and some good news:","","The bad news is, you're dead.","","What's good is YOU, with some seasoning, roasting, and a cactus sauce..."])

def ran(e):
    showMessage(e, ["You flee in terror, and they resume their wait.","","After all, where can you go ?"])
    setTag(e, "kssPlot", 2)
