#Catacomb Plot event, combat with to get the Akanubis Amulet of S'Amoht
from eventAPI import getTag, setTag, giveItems, optionInput, combat
from APIUtils import isclearall, showMessage

CataFlag2 = 0

def fireEvent(e):
    global CataFlag2
    CataFlag2 = getTag(e, "CataFlag2")
    if (CataFlag2 == 1):
        return 1
    elif (CataFlag2 == 2):
        showMessage(e,
            ["Dirty warm-body, you'll never have our treasure!"])
    else:
        showMessage(e,
            ["From the shadows of the crypt, you hear an icy, crackling voice.",
             "Life! I smell life in our dark home. Don't let the living ones near our treasure!",
             "From out of nowhere the living dead appear, seeking to add you to their ranks."],
            optionInput)
    fightThem(e)
    setTag(e, "CataFlag2", CataFlag2)
    return 0


def fightThem(e):
    combatRet = combat(e, [("Wight", 8, 0, 20), ("Landvaettir", 4, 0, 20), ("Wraith", 3, 0, 30), ("Lich", 1, 0, 60)])
    if (combatRet == 1):
        wonCataFight(e)
    elif (combatRet == 3):
        lostCataFight(e)
    else:
        defeatedCataFight(e)

def wonCataFight(e):
    global CataFlag2
    showMessage(e, 
        ["As the last of the undead crumples before your might,",
         "You breath a short sigh of relief, and begin to look for the amulet Yeodaugh spoke of."])
    showMessage(e,
        ["Underneath a gory mess of rotting sinew and moldy bone, you find what you seek!"])
    giveItems(e, ["Amulet of S'amoht", "Rune Gloves", "Rune Shield", "Wraith Ring"])
    showMessage(e,
        ["Having found the Amulet, you decide it would be in your best interests to let the dead",
	 "lie and return the heirloom to Tairenaugh"])
    CataFlag2 = 1
    setTag(e, "CataFlag2", CataFlag2)

def lostCataFight(e):
    showMesasge(e,
        ["With your last gasp of breath, you hear the grating voice speak - Now they'll be one of us"])

def defeatedCataFight(e):
    global CataFlag2
    showMessage(e,
        ["Your retreat was successful, but you know you must retrieve the amulet somehow"])
    CataFlag2 = 2
    setTag(e, "CataFlag2", CataFlag2)
    
