
label summon_luna:

    $ active_girl = "luna"
    $ last_character = "luna"

    $ luna_busy = True

    call update_luna
    call update_lun_tier

    $ renpy.checkpoint(hard=True)

    call play_music("luna")
    call play_sound("door")
    call lun_chibi("stand","mid","base")
    with d3

    lun "[lun_genie_name]..." ("base", "base", "base", "mid", xpos="base", ypos="base")

    if spectrespecs_E3 and not spectrespecs_E4:
        jump spectrespecs_E4

    label luna_requests:

    # Reset
    call reset_menu_position
    lun "" (xpos="base",ypos="base")

    menu:

        # Talk
        "-Talk-" (icon="interface/icons/small/talk.webp"):
            if lun_mood > 0:
                lun "I have nothing to say to you sir..."
                jump luna_requests

            call luna_chitchat
            jump luna_talk

        # Personal Favors
        "-Sexual Favours-" (icon="interface/icons/small/condom.webp") if luna_favors:
            jump luna_favor_menu

        "-Sexual Favours-" (style="disabled") if not luna_favors:
            call nar(">You haven't unlocked this feature yet.")
            jump luna_requests

        # Wardrobe
        "-Wardrobe-" (icon="interface/icons/small/wardrobe.webp") if luna_wardrobe_unlocked:
            hide astoria_main with d1
            call wardrobe
            jump luna_requests

        "-Wardrobe-" (style="disabled") if not luna_wardrobe_unlocked:
            call nar(">You haven't unlocked this feature yet.")
            jump luna_requests

        "-Give Item-" (icon="interface/icons/small/gift.webp"):
            $ TBA_message()
            jump luna_requests

            # hide luna_main with d1
            # call gift_menu
            # jump luna_requests

        # Dismiss
        "-Dismiss her-":
            stop music fadeout 3.0

            if game.daytime:
                if lun_mood >= 3:
                    lun "Good day..."
                else:
                    lun "Sure thing, [lun_genie_name]. I will head to class."
            else:
                if lun_mood >= 3:
                    lun "Good night..."
                else:
                    lun "Sure thing, good night [lun_genie_name]."

            jump end_luna_event

label update_lun_tier:
    if lun_tier == 1 and lun_whoring >= 3:
        if not ll_pf_talk.is_event_complete(1, 3):
            return

        $ lun_level_up = 1
    elif lun_tier == 2 and lun_whoring >= 6:
        if not ll_pf_inspect.is_event_complete(2, 3):
            return
        $ lun_level_up = 2
    elif lun_tier == 3 and lun_whoring >= 9:
        # T4 NOT AVAILABLE
        return

        if not ll_pf_masturbate.is_event_complete(3, 3):
            return

        $ lun_level_up = 3
    elif lun_tier == 4 and lun_whoring >= 13:
        # T5 NOT AVAILABLE
        return

        # Requirement: Tier 4 - Blow me T4 E3
        $ lun_level_up = 4
    return

label luna_level_up(tier=None):

    call bld
    if tier == 1:
        gen "(I think it's about time to give her a proper inspection...)" ("base", xpos="far_left", ypos="head")
    elif tier == 2:
        gen "(Let's see if she's ready for some self-care...)" ("base", xpos="far_left", ypos="head")
    elif tier == 3:
        gen "(I wonder if she'll be able to get the spurts out with her mouth...)" ("base", xpos="far_left", ypos="head")
    elif tier == 4:
        gen "(Getting the spurts out of two people at the same time...)" ("base", xpos="far_left", ypos="head")
        gen "(Now that's going to require some careful timing!)" ("grin", xpos="far_left", ypos="head")

    $ lun_tier = tier+1
    $ lun_level_up = None
    $ lun_mood = 0

    pause.5
    call nar(">Luna has reached {i}favour tier{/i} "+str(lun_tier)+"!")

    call update_lun_tier

    return

# Luna Favor Menu
label luna_favor_menu:
    call update_luna_favors

    menu:
        "-Level Up-" (icon="interface/icons/small/levelup.webp") if lun_level_up != None:
                call luna_level_up(tier=lun_level_up)
                jump luna_favor_menu

        "-Personal Favours-" (icon="interface/icons/small/heart_red.webp"):
            call tutorial("hearts")

            label .personal:
            python:
                menu_choices = []
                for i in ll_favor_list:
                    if i in []: # Not in the game yet.
                        menu_choices.append(gui.menu_item("-Not available-", "na", style="disabled"))
                    elif i.start_tier > lun_tier:
                        menu_choices.append(gui.menu_item("-Not Ready-", "vague", style="disabled"))
                    else:
                        menu_choices.append(i.get_menu_item())

                menu_choices.append(("-Never mind-", "nvm"))
                result = renpy.display_menu(menu_choices)

            if result == "nvm":
                jump luna_favor_menu
            elif result == "vague":
                call favor_not_ready
                jump .personal
            elif result == "na":
                call not_available
                jump .personal
            else:
                $ renpy.jump(result)

        "-Public Requests-" (icon="interface/icons/small/star_yellow.webp", style="disabled"):
            call not_available
            jump luna_favor_menu

        "-Never mind-":
            jump luna_requests

label update_luna_favors:
    python:
        for i in ll_favor_list:
            i.tier = lun_tier
    return

label luna_talk:
    # General.
    menu:
        "-Ask her to cheer for Ravenclaw-" if cho_quid.gryffindor_failed and not cho_quid.E11_complete:
            jump cho_quid_E11

        "-Address me only as-" if spectrespecs_E4:
            menu:
                "-Sir-":
                    $ lun_genie_name = "Sir"
                "-Dumbledore-":
                    $ lun_genie_name = "Dumbledore"
                "-Professor-":
                    $ lun_genie_name = "Professor"
                "-Partner-":
                    $ lun_genie_name = "Partner"
                "-Master-" if lun_tier >= 2:
                    $ lun_genie_name = "Master"
                "-Daddy-" if lun_tier >= 2:
                    $ lun_genie_name = "Daddy"
                "-Custom Input-" if lun_tier >= 3:
                    $ lun_genie_name = renpy.input("(Please enter the name.)", lun_genie_name, ALLOWED_CHARACTERS, length=14).strip() or "Professor"
                "-Never mind-":
                    jump luna_talk

            jump genie_luna_change

        "-From now on I will refer to you as-" if spectrespecs_E4:
            menu:
                "-Miss Lovegood-":
                    $ luna_name = "Miss Lovegood"
                "-Luna-":
                    $ luna_name = "Luna"
                "-Loony-":
                    $ luna_name = "Loony"
                "-Girl-":
                    $ luna_name = "Girl"
                "-Partner-":
                    $ luna_name = "Partner"
                "-Bimbo-" if lun_tier >= 2:
                    $ luna_name = "Bimbo"
                "-Minx-" if lun_tier >= 3:
                    $ luna_name = "Minx"
                "-Cumslut-" if lun_tier >= 5:
                    $ luna_name = "Cumslut"
                "-Custom Input-" if lun_tier >= 3:
                    $ luna_name = renpy.input("(Please enter the name.)", luna_name, ALLOWED_CHARACTERS, length=14).strip() or "Miss Lovegood"
                "-Never mind-":
                    jump luna_talk

            jump luna_name

        "-Never mind-":
            jump luna_requests

label genie_luna_change:
    # NickName responses
    if lun_genie_name == "Sir":
        lun "Certainly, [lun_genie_name]." ("base", "base", "base", "mid")
    elif lun_genie_name == "Dumbledore":
        lun "You want me to call you by your last name?" ("annoyed", "narrow", "base", "mid")
        gen "Is that going to be a problem?" ("base", xpos="far_left", ypos="head")
        lun "Of course not [lun_genie_name]..." ("angry", "base", "base", "mid")
        lun "[lun_genie_name]..." ("angry", "base", "base", "downL")
        lun "Don't think I've ever heard anyone call you just [lun_genie_name] before..." ("grin", "base", "base", "mid")
    elif lun_genie_name == "Professor":
        lun "Yes, [lun_genie_name]." ("base", "base", "base", "mid")
    elif lun_genie_name == "Partner":
        lun "[lun_genie_name]?" ("soft", "base", "raised", "mid")
        gen "Yes, we're working together now so it's only appropriate." ("base", xpos="far_left", ypos="head")
        lun "Oh... Of course [lun_genie_name]." ("grin", "base", "base", "mid")
    elif lun_genie_name == "Master":
        lun "[lun_genie_name]?" ("soft", "narrow", "base", "mid")
        lun "What are you a [lun_genie_name] of exactly?" ("angry", "base", "base", "mid")
        if lun_tier >= 3:
            gen "A master baiter!" ("grin", xpos="far_left", ypos="head")
            lun "Oh, right!" ("smile", "base", "base", "mid")
            lun "Thank you for allowing me to be your pupil, [lun_genie_name]." ("base", "base", "base", "mid")
        else:
            gen "*Err*...{w=0.4} Of the arts?" ("base", xpos="far_left", ypos="head")
            lun "What arts?" ("angry", "narrow", "base", "mid")
            gen "Avoiding confrontation." ("base", xpos="far_left", ypos="head")
            lun "*Huh*?" ("mad", "base", "base", "mid")
            gen "..." ("base", xpos="far_left", ypos="head")
            lun "..." ("annoyed", "base", "base", "mid")
            gen "..." ("base", xpos="far_left", ypos="head")
            lun "Sir?" ("soft", "narrow", "base", "mid")
            gen "..." ("base", xpos="far_left", ypos="head")
            lun "[lun_genie_name]?" ("open", "base", "base", "mid")
            gen "That's me." ("base", xpos="far_left", ypos="head")
            lun "Okay, I'll call you [lun_genie_name] from now on." ("soft", "base", "base", "mid")
            gen "(Another confrontation expertly avoided...)" ("base", xpos="far_left", ypos="head")
    elif lun_genie_name == "Daddy":
        lun "[lun_genie_name]?" ("open", "narrow", "base", "mid")
        gen "Yes..." ("base", xpos="far_left", ypos="head")
        lun "But wont that be confusing?" ("annoyed", "narrow", "base", "mid")
        gen "Would it?" ("base", xpos="far_left", ypos="head")
        lun "Yes, that's usually what I call my father..." ("open", "base", "base", "R")
        gen "I'm your daddy now..." ("base", xpos="far_left", ypos="head")
        lun "*Huh*?" ("angry", "base", "base", "mid")
        gen "Call me daddy you naughty girl!" ("angry", xpos="far_left", ypos="head")
        lun "Oh...{w=0.3} Yes, I'm sorry [lun_genie_name]!" ("angry", "happyCl", "base", "mid")
    else: #custom/fallback
        lun "Okay, I'll call you [lun_genie_name] from now on..." ("base", "base", "base", "mid")
    jump luna_talk

label luna_name:
    # NickName responses
    if luna_name == "Miss Lovegood":
        lun "Of course, [lun_genie_name]." ("base", "wink", "base", "mid")
    elif luna_name == "Luna":
        lun "But that's my first name!" ("angry", "base", "base", "mid")
        gen "So?" ("base", xpos="far_left", ypos="head")
        lun "Isn't it against the law?" ("mad", "narrow", "base", "mid")
        gen "... Is what against the law?" ("base", xpos="far_left", ypos="head")
        lun "Teachers and students calling each other by their first name. I read an article about it in the quibbler." ("angry", "narrow", "raised", "mid")
        gen "*Err*... No they recently made it legal." ("base", xpos="far_left", ypos="head")
        lun "Oh, How progressive!" ("soft", "base", "base", "stare")
        lun "Then of course, you can call me that!" ("smile", "base", "base", "mid")
    elif luna_name == "Loony":
        lun "Do you really need to call me that, [lun_genie_name]?" ("upset", "base", "base", "mid")
        lun "Other students call me that to make fun of me." ("upset", "base", "base", "R")
        gen "I like it." ("grin", xpos="far_left", ypos="head")
        lun "Alright then..." ("annoyed", "base", "base", "mid")
    elif luna_name == "Girl":
        lun "Just [luna_name]?" ("soft", "base", "raised", "mid")
        gen "Yep." ("base", xpos="far_left", ypos="head")
        lun "Alright, I suppose I am a girl after all." ("grin", "narrow", "base", "mid")
    elif luna_name == "Partner":
        lun "[luna_name]?" ("soft", "base", "base", "mid")
        gen "Yes, we're partners in venture are we not?" ("base", xpos="far_left", ypos="head")
        lun "Oh right!" ("angry", "base", "base", "mid")
        lun "Of course, you can call me that!" ("grin", "base", "base", "mid")
    elif luna_name == "Bimbo":
        lun "A what?" ("soft", "base", "base", "mid")
        gen "A Bimbo..." ("base", xpos="far_left", ypos="head")
        lun "Oh... Okay..." ("base", "base", "base", "mid")
        gen "(...{w} Maybe she doesn't know what that means...)" ("base", xpos="far_left", ypos="head")
    elif luna_name == "Minx":
        lun "A mink?" ("soft", "base", "base", "mid")
        gen "No, a--" ("base", xpos="far_left", ypos="head")
        lun "I love minks!" ("smile", "wide", "base", "mid")
        gen "...{w=0.3} Great." ("base", xpos="far_left", ypos="head")
    elif luna_name == "Cumslut":
        lun "Well I do love helping you cum..." ("grin", "narrow", "base", "downL")
        lun "Sure, you can call me that." ("grin", "base", "base", "mid")
    else: #Custom/fallback
        lun "That's not too bad... Sure you can call me that." ("base", "base", "base", "mid")

    jump luna_talk
