#Dwarf plot events
from eventAPI import getTag, setTag, playSpecAudio, showPicture, optionInput, giveItems, callEvent
from APIUtils import showMessage, poseYesNo

DwarfPlt1 = 0

def fireEvent(e):
    showPicture(e, "Almara")
    DwarfPlt = getTag(e, "DwarfPlt1")
    if(DwarfPlt == 0):
        meetDwarf(e)
    if(DwarfPlt == 1):
        backAgainEh(e)
    if(DwarfPlt == 2):
        getToDragon(e)
    if(DwarfPlt == 3):
        sendToTemple(e)
    if(DwarfPlt == 4):
        getToTemple(e)
    if(DwarfPlt == 5):
        reward(e)
    if(DwarfPlt == 6):
        thanks(e)
    return 0

def meetDwarf(e):
    showMessage(e,
        ["\"Well well well. It HAS been a long time since one of your kind came here sun-dweller.",
	 "I am Almara, and I speak for my people.",
	 "I'll venture a guess and say you're here to inquire about our blood-right, the Elonian Pipes.",
	 "You may have noticed the entrance to our temple, and how it was blocked off to you?  This is the magic of the pipes.",
	 "They can deny entrance as well as grant it.  If you've heard our story, you'll know we can't simply hand them over ",
	 "to the first sun-dweller who asks! Our people have been tormented for many years, and even now our lost brothers scream",
	 " to us from our temple below."])
    if(poseYesNo(e,
	["Do you think YOU are capable of freeing us from so many years of suffering?"])):
        dragonIntro(e)
    else:
        goAwayThen(e)

def goAwayThen(e):
    showMessage(e,
        ["Heh, just like every other sun-dweller, a bit of a challenge and you back down, you should be going now."])
    setTag(e, "DwarfPlt1", 1)

def backAgainEh(e):
    showMessage(e,
        ["Oh, figure out you need us more than we need you eh?"])
    if(poseYesNo(e,
        ["What say you then, will you help us?"])):
        dragonIntro(e)

def dragonIntro(e):
    showMessage(e,
        ["Before we can trust you to enter our temple, we need proof that you are willing to help our people.",
         "Here's part of the story you may have not heard: These are not the ONLY caves we dwarves called our own.",
         "Not too far from here, there is another cave entrance, this too used to be a part of our mighty kingdom.",
         "During the dark times, with the loss of our Clerics, we were forced out by unimaginable beasts of evil and cunning.",
         "They envied our gems and ore, and laid claim to our home as their lair. We lost several heirlooms in the ",
         "hurried evacuation of our homes, but one item we left behind has left a hole in our history. The Axe of DwarfHome."])
    setTag(e, "DwarfPlt1", 2)
    getToDragon(e)

def getToDragon(e):
    showMessage(e,
        ["Take yourselves to our ancestral cave, which lies to the North and East of here, and deliver to us our lost ",
         "Axe of DwarfHome. Complete this feat, and our trust will lie with you."])

def sendToTemple(e):
    showMessage(e,
        ["Amazing. Perhaps there is something to you sun-dwellers after all. I regret to say that we cannot ",
	 "give the Elonian Pipes to you until we are sure the temple can be made safe again.",
	 "The many years of torture drove our Stone Clerics beyond madness, to the point that they would kill ",
	 "their own kinspeople.  There are stories, from the time when they were first interred there ",
	 "that speak of a jet black bird, who communes with the spirits. This bird is said to be linked somehow to ",
	 "a magical lantern, crafted by one of the clerics, and bringing the curse of our gods upon us.",
	 "find this Beacon, and bring it forth from the temple, the beacon AND the pipes will become yours once you complete",
	 "This feat."])
    setTag(e, "DwarfPlt1", 4)
    getToTemple(e)

def getToTemple(e):
    showMessage(e,
        ["Even now, the piper is being informed to weaken the enchantment enough to let you pass into the temple.",
	 "Go forth, and prove yourself our benefactor, our hope lies with you!"])

def reward(e):
    showMessage(e,
        ["We are forever in your debt.  With the removal of that vile device from our holy temple, the powers over our comrades",
	 "will surely weaken soon.  Perhaps we can even begin to rehabilitate the lost souls.  It will of course take time",
	 "but I am confident that without your help, we would not even have that ray of hope.  Please, take the Elonian Pipes ",
	 " and the Raven Beacon with you on your travels. Perhaps it can help you in your quest."])
    giveItems(e, ["Elonian Pipes"])
    setTag(e, "DwarfPlt1", 6)

def thanks(e):
    showMessage(e,
        ["Many thanks to you adventurers! You will always be remembered as Dwarf-friends from now on"])

    
