#Wolf Plot event, combat with cellar boss to clear and get the key to catacombs
from eventAPI import getTag, setTag, giveItems, optionInput, combat
from APIUtils import isclearall, showMessage, showPicture

WolfFlag = 0

def fireEvent(e):
    global WolfFlag
    WolfFlag = getTag(e, "WolfFlag")
    if (WolfFlag == 1):
        return 1
    elif (WolfFlag == 2):
        showMessage(e,
            ["You hear a great rumbling growl and know your foe is upon you."])
    else:
        showMessage(e,
            ["You come across a large cage with an odd-looking beast in it, as you approach to examine it you ",
             "hear a horrendous snarl come from behind you, as you turn, you see a horrid sight - ",
             "a werewolf."], optionInput)
        showPicture(e, "wolfman")
        showMessage(e, 
            ["\"Welcome to my lair, foolish mortals. If you seek to free the Wolfdeer, you ",
             "must first defeat me...and my friends!\""], optionInput)
    fightThem(e)
    setTag(e, "WolfFlag", WolfFlag)
    return 0


def fightThem(e):
    combatRet = combat(e, [("Werewolf", 1, 0, 30), ("Warrior Wolf", 15, 0, 10), ("Wolf", 12, 2, 20)])
    if (combatRet == 1):
        wonWolfFight(e)
    elif (combatRet == 3):
        lostWolfFight(e)
    else:
        defeatedWolfFight(e)

def wonWolfFight(e):
    global WolfFlag
    showMessage(e, ["With the horrid creature now dispatched, you approach the apparently wounded animal in the cage "])
    showMessage(e, ["The creature rises and begins to speak!"])
    showPicture(e, "Wolf_Deer")
    showMessage(e, 
        ["My thanks for thy aid, brave fellows. This horrific beast had kept me captive longer than I ",
         "would have thought possible.  For thy efforts on my behalf, I do ",
         "grant thee these trinkets, in hopes that your minds may stay lively in the face of any danger. "])
    giveItems(e, ["Arcanist's Mark", "Elementalist's Mark"])
    WolfFlag = 1
    setTag(e, "WolfFlag", WolfFlag)

def lostWolfFight(e):
    showMesasge(e,
        ["With your last gasp of breath, you see your enemies smiling as they know your end is near."])

def defeatedWolfFight(e):
    global WolfFlag
    showMessage(e,
        ["The horrifying howls of the WolfMan continue to blast your ears as you retreat."])
    WolfFlag = 2
    setTag(e, "WolfFlag", WolfFlag)
    
