from eventAPI import *
from APIUtils import *

def fireEvent(e):
    if (getTag(e, "lFlagU") != 0):
        return 1
    showMessage(e, ["As soon as you enter this pen, you are assailed by a horde of giant rats."])
    combatRet = combat(e, [("Giant Rat", 8, 2, 10)])
    if (combatRet == 1):
        won(e)
        return 1
    elif (combatRet == 3):
        lost(e)
    else:  
        ran(e)
        return 0

def won(e):
    showMessage(e, ["The pen is now empty of (living) rats. Poor druids, what will they eat now ?",
                    "","Of course, when you're finished with them, that will be the least of their problems..."])
    setTag(e, "lFlagU", 1)

def lost(e):
    showMessage(e, ["The rats feast on your bodies. At least, you can get satisfaction in the knowledge that the rangers and druids won't get their meal."])

def ran(e):
    showMessage(e, ["You barely manage to run away, and bolt the gate behind you. The rats resume their activities."])
    
