
# TODO: Replace values according to Luna's expressions list
define lun_face = {
    "mouth": {
        "neutral":      ["base","open"],
        "happy":        ["base","grin"],
        "naughty":      ["soft","base"],
        "horny":        ["horny","base"],
        "annoyed":      ["upset","annoyed"],
        "disgusted":    ["disgust","upset"],
        "angry":        ["clench","mad","upset"]
    },

    "eyes": {
        "neutral":      ["base"],
        "happy":        ["happyCl"],
        "naughty":      ["narrow"],
        "horny":        ["narrow"],
        "annoyed":      ["narrow","base"],
        "disgusted":    ["base"],
        "angry":        ["base"]
    },

    "eyebrows": {
        "neutral":      ["base"],
        "happy":        ["base","raised"],
        "naughty":      ["base","raised"],
        "horny":        ["base","raised"],
        "annoyed":      ["annoyed"],
        "disgusted":    ["raised","worried"],
        "angry":        ["angry"]
    },

    "pupils": {
        "neutral":      ["mid"],
        "happy":        ["mid"],
        "naughty":      ["mid","up","downR"],
        "horny":        ["mid","stare","down"],
        "annoyed":      ["mid","downR","R"],
        "disgusted":    ["mid","down"],
        "angry":        ["mid"]
    }
}

label end_luna_event:

    call lun_chibi("hide")
    hide luna_main
    with d3
    pause.5

    call update_luna

    $ active_girl = None
    $ luna_busy = True
    $ luna.wear("all")

    $ renpy.stop_predict(luna.get_image())
    $ renpy.stop_predict("characters/luna/face/*.webp")

    call music_block
    jump main_room_menu

label update_luna:
    # Chibi Update
    $ luna_chibi.update()
    $ luna_chibi.position(flip=False)
    $ luna.xzoom = 1
    hide screen luna_cloth_pile

    return

define character.luna_say = Character("luna_name", show_icon="luna", dynamic=True)

init python:
    def lun(what, mouth=False, eyes=False, eyebrows=False, pupils=False, cheeks=None, tears=None,
        emote=None, face=None, xpos=None, ypos=None, pos=None, flip=None, trans=None, animation=False, **kwargs):

        redraw = False
        tag = luna.tag
        layer = luna.layer
        #showing = renpy.showing(name=tag, layer=layer)

        if xpos != None or ypos != None:
            xpos = luna.pos[0] if xpos == None else sprite_pos.get("x").get(xpos, xpos)
            ypos = luna.pos[1] if ypos == None else sprite_pos.get("y").get(ypos, ypos)
            luna.pos = (xpos, ypos)
            redraw = True

        head_only = luna.pos[1] == sprite_pos.get("y").get("head")

        if any((mouth, eyes, eyebrows, pupils, cheeks, tears)):
            luna.set_face(mouth=mouth, eyes=eyes, eyebrows=eyebrows, pupils=pupils, cheeks=cheeks, tears=tears)
            redraw = True

        luna.set_emote(emote)

        if animation != False:
            luna.animation = animation
            redraw = True

        if flip != None:
            luna.xzoom = -1 if flip else 1
            redraw = True

        if redraw:
            luna.show()

            if not renpy.in_rollback():
                if trans:
                    renpy.with_statement(trans)
                else:
                    renpy.with_statement(d2)

        if what:
            character.luna_say(what, **kwargs)

        if head_only:
            luna.hide()
