#This is a sample monster encounter.
#It prints some stuff, does some combat,
#prints some more stuff, and we're done.
# NOTE: Add special args for exitX,exitY,exitRot from evt!
# THIS EVENT IS FOR HOUSE AT (25,32) in Rennibister
#Only active if never active before.
from eventAPI import getTag, setTag, setExit, showPicture, optionInput, combat, modifyGold, modifyHP, modifySP, modifyBP, tickGame, getPartyCount
from APIUtils import showMessage, splitXP
from SDLKeys import SDLK_f, SDLK_SPACE
import strangersHouse

def fireEvent(e):
    lFlagU = getTag(e, "lFlagU")
    if (lFlagU != 0):
        strangersHouse.fireEvent(e)
        setExit(e, None, 25, 31, 180)
        return
    showPicture(e, "Yeodaugh")
    if (optionInput(e,
        ["Welcome to my home.",
         "You must defeat some of my friends if you wish to speak with me."],
        ["(F)ight the creatures", "(SPACE) to Exit"], [SDLK_f, SDLK_SPACE]) == SDLK_SPACE):
        return
    combatRet = combat(e, [("Orc Chieftain", 1, 1, 40), ("Orc", 2, 1, 30)])
    if (combatRet == 1):
        showPicture(e, "Yeodaugh")
        showMessage(e,
            ["\"You have done well!",
             "Nothing to tell you have I, but help you I will.",
             "Health for you, and energy, and gold, and experience have I.",
             "Now, on with your journey you go!\""])
        setTag(e, "lFlagU", lFlagU | 0x1)
        splitXP(e, 50000)
        x, c = 0, getPartyCount(e)
        while (x < c):
            modifyGold(e, 5000)
            modifyHP(e, 200)
            modifySP(e, 200)
            modifyBP(e, 5)
            x += 1
        tickGame(e, 60)
    elif (combatRet == 2):
        showPicture(e, "Yeodaugh")
        showMessage(e,
            ["\"Cowards you are!  Help you I will not!",
             "Return you will when stones you grow!\""])
    elif (combatRet == 3):
        showPicture(e, "Yeodaugh")
        showMessage(e,
            ["\"You have all died!",
             "Bad for you!",
             "Return to Go you will!",
             "Collect 200 gold you will not!\""])
