#Script for Mage's redruM tavern

from eventAPI import *
from APIUtils import *
from SDLKeys import SDLK_y, SDLK_n, SDLK_p, SDLK_ESCAPE, SDLK_g, SDLK_b, SDLK_s, SDLK_r, SDLK_a

DKRumor1 = 0

def fireEvent(e):
    showPicture(e, "Tavern")
    choice = optionInput(e, ["An old man stands behind the bar filled with bottles of strange looking liquids. Welcome to the redruM tavern!,  People round here just call me Mage. Might I offer you a drink?.", "", "(P)urchase Drinks"], ["(ESCAPE) to Exit"], [SDLK_p, SDLK_ESCAPE])
    if (choice == SDLK_p):
        purchasedrinks(e)
    elif (choice == SDLK_ESCAPE):
        return 0
    else:
        mainmenu(e)


def mainmenu(e):
    showPicture(e, "Tavern")
    choice = optionInput(e, ["An old man stands behind the bar filled with bottles of strange looking liquids. Welcome to the redruM tavern!,  People round here just call me Mage. Might I offer you a drink?.", "", "(P)urchase Drinks"], ["(ESCAPE) to Exit"], [SDLK_p, SDLK_ESCAPE])
    if (choice == SDLK_p):
        purchasedrinks(e)
    elif (choice == SDLK_ESCAPE):
        return 0
    else:
        mainmenu(e)

def purchasedrinks(e):
    choice = optionInput(e, ["What shall I get you?", "", "(G)reen liquid", "(B)lue milk", "(S)piderfighter", "(r)edrum", "(A)ila"], ["(ESCAPE) to Cancel"], [SDLK_g, SDLK_b, SDLK_s, SDLK_r, SDLK_a, SDLK_ESCAPE])
    if (choice == SDLK_g):
        greenl(e)
    elif (choice == SDLK_b):
        bluel(e)
    elif (choice == SDLK_s):
        spiderfighter(e)
    elif (choice == SDLK_r):
        redrum(e)
    elif (choice == SDLK_a):
        aila(e)
    else: 
        mainmenu(e)

def greenl(e):
    if (optionInput(e, ["This homebrew will cost you 40 gold.  Will ya pay?"], ["(Y)es, (N)o"], [SDLK_y, SDLK_n]) == SDLK_n):
        showMessage(e, ["My friend, Come back when you want to purchase a drink."])
        mainmenu(e) 
    else:
        greenl2(e)

def greenl2(e):
    if (modifyGold(e, 0, -40)):
        showMessage(e, ["The green liquid leaves behind a bitter taste on your tongue, but yet somehow it is refreshing."])
        x, c = 0, getPartyCount(e)
        while (x < c):
            modifySP(e, x, 40)
            x += 1
        mainmenu(e)    
   
           

    
def bluel(e):
    if (optionInput(e, ["Blue milk costs 80 gold.  Will ya pay?"], ["(Y)es, (N)o"], [SDLK_y, SDLK_n]) == SDLK_n):
        showMessage(e, ["If you don't wanna pay for your drinks, don't bother ordering anything."])
        mainmenu(e)   
    else:
        bluel2(e)

def bluel2(e):
    if (modifyGold(e, 0, -80)):
        showMessage(e, ["The thick blue drink, goes down smooth and cleanses your mind."])
        x, c = 0, getPartyCount(e)
        while (x < c):
            modifySP(e, x, 80)
            x += 1
        mainmenu(e)

         

def spiderfighter(e):
    if (optionInput(e, ["This classic atari drink mixes spiders with fruit and costs 160 gold.  Will ya pay?"], ["(Y)es, (N)o"], [SDLK_y, SDLK_n]) == SDLK_n):
        showMessage(e, ["If your gonna sit at this bar, then you'd best be willing to pay!"])
        mainmenu(e)  
    else:
        spiderfighter2(e)

def spiderfighter2(e):
    if (modifyGold(e, 0, -160)):
        showMessage(e, ["This drink sure has some rapidfire energy. woohoo! kick arse!!"])
        x, c = 0, getPartyCount(e)
        while (x < c):
            modifySP(e, x, 160)
            x += 1
        mainmenu(e)    

 
def redrum(e):
    if (optionInput(e, ["Gosling's redruM will cost you 500 gold.  Will ya pay?"], ["(Y)es, (N)o"], [SDLK_y, SDLK_n]) == SDLK_n):
        showMessage(e, ["We don't run tabs here at the redruM tavern! Come back when your ready to pay for your drinks you filthy swine!"])
        mainmenu(e) 
    else:
        redrum2(e)

def redrum2(e):
    if (modifyGold(e, 0, -500)):
        showMessage(e, ["You down the shot of rum. You feel ENERGIZED!"])
        x, c = 0, getPartyCount(e)
        while (x < c):
            modifySP(e, x, 500)
            x += 1
        mainmenu(e)    
         

def aila(e):
    if (optionInput(e, ["A fine drink such as the Aila can only be obtained here, Mage smirks.  It costs $2000 GP's. Will ya pay?"], ["(Y)es, (N)o"], [SDLK_y, SDLK_n]) == SDLK_n):
        showMessage(e, ["Come back when your ready to pay for the Aila. It is well worth the price!"])
        mainmenu(e)    
    else:
        aila2(e)

def aila2(e):
    if (modifyGold(e, 0, -2000)):
        showMessage(e, ["It tastes like hell, but you feel TOTALLY ENERGIZED!"])
        x, c = 0, getPartyCount(e)
        while (x < c):
            modifySP(e, x, 2000)
            x += 1
        mainmenu(e)       
