from eventAPI import *
from APIUtils import *

def fireEvent(e):
    if (getTag(e, "lFlagU") == 2):
        return 1
    elif (getTag(e, "lFlagU") == 1):
        showMessage(e, ["As soon as you re-enter the wide tunnel, more ants stop to remove you from their highway."])
    else:
        showMessage(e, ["The narrow tunnel opens into a wider one.",
                        "","This one looks more travelled, which means..."])
    return fight(e)

def fight(e):
    combatRet = combat(e, [("Warrior Ant", 6, 3, 10), ("Fire Ant", 4, 1, 30)])
    if (combatRet == 1):
        won(e)
        return 1
    elif (combatRet == 3):
        lost(e)
    else:
        showMessage(e, ["You retreat to the side tunnel; the ants resume their patrol (or whatever)."])
        setTag(e, "lFlagU", 1)
        return 0

def won(e):
    showMessage(e, ["You're safe now.","","Hmmm, actually you're NOT safe.","",
                    "But you're not dead either.","","For now."])
    setTag(e, "lFlagU", 2)

def lost(e):
    showMessage(e, ["You're dead.","","And that's it..."])
