init python:
    import math

    renpy.music.register_channel("music2", "music", loop=True, tight=False)
    renpy.music.register_channel("sound2", "sound", loop=False, tight=False)
    renpy.music.register_channel("talk", "voice", loop=False, tight=False)

    def character_callback(event, interact=True, **kwargs):
        if not interact:
            return
        
        global previous_sayer
        global current_sayer
        if event == "end":
            previous_sayer = current_sayer

    def say_arguments_callback(who, interact=True, color="#fff"):
        global current_sayer
        current_sayer = who
        
        return (), { "interact" : interact, "what_color" : color }

    config.say_arguments_callback = say_arguments_callback
    config.character_callback = character_callback

    class Shaker(object):
        anchors = {
            'top' : 0.0,
            'center' : 0.5,
            'bottom' : 1.0,
            'left' : 0.0,
            'right' : 1.0,
            }
        
        def __init__(self, start, child, dist):
            if start is None:
                start = child.get_placement()
            
            self.start = [ self.anchors.get(i, i) for i in start ]  
            self.dist = dist    
            self.child = child
        
        def __call__(self, t, sizes):
            
            
            def fti(x, r):
                if x is None:
                    x = 0
                if isinstance(x, float):
                    return int(x * r)
                else:
                    return x
            
            xpos, ypos, xanchor, yanchor = [ fti(a, b) for a, b in zip(self.start, sizes) ]
            
            xpos = xpos - xanchor
            ypos = ypos - yanchor
            
            nx = xpos
            ny = ypos - abs((1.0-t) * self.dist)
            
            return (int(nx), int(ny), 0, 0)

    def _Shake(start, time, child=None, dist=100.0, **properties):
        
        move = Shaker(start, child, dist=dist)
        motion = renpy.display.layout.Motion(
            move,
            time,
            child,
            add_sizes=True,
            **properties)
        
        return motion

    Shake = renpy.curry(_Shake)

    def music_queue_empty_callback():
        global music_queue
        
        if music_queue != None:
            renpy.music.set_volume(music_queue[1], delay=music_queue[2])
            renpy.music.queue(music_queue[0], fadein=music_queue[2], loop=True, tight=True)
            music_queue = None

    renpy.music.set_queue_empty_callback(music_queue_empty_callback)

define LocDissolve = Dissolve(0.55)





define mom_bathroom_action = 0
define mom_dinner_cloth = "normal"
default mom_dining_cloth_index = 0
default sis_dining_cloth_index = 0
define said_you_love_nami = False
define drink_water_times = 0
define time_skip_prevent = None


define mom_location = ""
define sister_location = ""
define sada_location = ""
define taka_location = ""
define nami_location = ""
define okemia_location = ""
define kimiko_location = ""
define hitomu_namie_location = ""

define sister_location_locked = 0
define mom_location_locked = 0
define show_return_home_button = False


define is_nami_work_day = False
define is_sister_school_day = False
define sister_going_to_bathroom = False

define week_day = [
    "{b}Sunday{/b}",
    "{b}Monday{/b}",
    "{b}Tuesday{/b}",
    "{b}Wednesday{/b}",
    "{b}Thursday{/b}",
    "{b}Friday{/b}",
    "{b}Saturday{/b}"
]

define daytime = {
    'morning'               : "Early Morning",
    'late'                  : "Late Morning",
    'afternoon'             : "Afternoon",
    'evening'               : "Evening",
    'night'                 : "Night",
    'midnight'              : "Late Night"
}

define location = {
    'living_room'           : "{b}Living room{/b}",
    'my_room'               : "{b}My room{/b}",
    'mom_room'              : "{b}Airi's room{/b}",
    'sada_room'             : "{b}Sada's room{/b}",
    'sister_room'           : "{b}Momoko's room{/b}",
    'bath_room'             : "{b}Bathroom{/b}",
    'dinner_room'           : "{b}Dining room{/b}",
    'kitchen'               : "{b}Kitchen{/b}",
    'house_front'           : "{b}House front{/b}",
    'house_side'            : "{b}House side{/b}",
    'red_place'             : "{b}Red Place{/b}",
    'yamiyo_prison'         : "{b}Yamiyo's Prison{/b}",
    'outside_mine'          : "{b}Coal Mine{/b}",
    'outside_prison'        : "{b}Castle Prison{/b}",
    'outside_market'        : "{b}Day Market{/b}",
    'outside_castle_front'  : "{b}Castle Front{/b}",
    'outside_castle'        : "{b}Castle{/b}",
    'outside_store'         : "{b}Local Store{/b}",
    'outside_bar'           : "{b}Tavern{/b}",
    'outside_clinic'        : "{b}Saito Clinic{/b}",
    'outside_school'        : "{b}Saint Saito's School{/b}",
    'outside_park'          : "{b}West Park{/b}",
    'outside_lake'          : "{b}Wisdom Lake{/b}",
    'outside_onsen'         : "{b}Saito's Onsen{/b}",
    'outside_old_temple'    : "{b}Old Temple{/b}",
    'outside_graveyard'     : "{b}Graveyard{/b}",
    'outside_art_shop'      : "{b}Art Shop{/b}",
    'outside_secret_swing'  : "{b}Secret Swing{/b}",

    
    'kimiko_room'           : "{b}[kimiko]'s room{/b}",

    
    'taka_home'             : "{b}Taka's Home{/b}",
    'okemia_mojo'           : "{b}Okemia's Dojo{/b}",
    'nami_home'             : "{b}Nami's Home{/b}",
    'yasuko_home'           : "{b}Yasuko's Home{/b}",
}

define info_screen = True
define click_point = False

default read_book = []
default daily_values = []
default character_affections = {}


default my_inventory = []
default living_room_inventory = []
default bathroom_inventory = ['towel']
default my_bedroom_inventory = []
default airi_room_inventory = []
default momoko_room_inventory = []
default kitchen_inventory = []
default dinning_room_inventory = []
default taka_basement_inventory = []
default red_place_inventory = []
default yamiyo_prison_inventory = []
default nami_home_inventory = []
default okemia_dojo_inventory = []
default yasuko_office_inventory = []


default inventory_callbacks = {}


define my_location = location['outside_prison']
define my_name = "Jack"
define my_clean = False
define is_drunk = False
define drunk_at_bar_count = 0
define alcohol_takein_amount = 0
define fishing_failed_count = 0
define my_fishing_percent = 50
define my_money = 0
define my_knowledge = 0
define my_strength = 0
define my_bravery = 0
define my_magicskill = 0
define my_mana = 0
define mana_capacity = 0
define max_mana = 100
define can_read_book = True
define can_exercies = True
define learned_about_magic = False
define come_from_somewhere_else = False


define day_random = 0
define day_time_index = 0
define day_of_week = week_day[1]
define day_time = daytime['morning']
define day_count = 1
define is_weekend = False
define greeting = "Good afternoon"


define location_outside_clinic = False
define location_taka_home = False
define location_nami_home = False
define location_okemia_mojo = False
define location_town_school = False
define location_wisdom_lake = False
define location_yasuko_home = False





default key_values = {}
default actived_events = None
default activated_events = set()
default temp_booleans = set()

define living_room_event = None
define music_queue = None

label check_if_replaying():
    if _in_replay:
        $ renpy.end_replay()

    return

label active_event(event_name, mark_day=False):
    $ activated_events.add(event_name)
    if mark_day:
        call mark_event_day (event_name + "_day")
    call update_magic_notes ()
    return

label deactive_event(event_name):
    if event_name in activated_events:
        $ activated_events.remove(event_name)
        call update_magic_notes ()

    return

label set_key_value(_key, _value):
    $ key_values[_key] = _value
    return

label remove_key_value(_key):
    if _key in key_values:
        $ key_values.pop(_key)
    return

label mark_event_day(event_day_name):
    $ key_values[event_day_name] = day_count
    return

label remove_mark_day(event_day_name):
    if event_day_name in key_values:
        $ key_values.pop(event_day_name)
    return


label check(temp_name, temp_bool=True):
    if temp_bool:
        $ temp_booleans.add(temp_name)
    elif check(temp_name):
        $ temp_booleans.remove(temp_name)
    return

label uncheck(temp_name):
    if check(temp_name):
        $ temp_booleans.remove(temp_name)
    return





label set_time(t):
    if time_skip_prevent != None:
        with vpunch
        $ narrator(time_skip_prevent)
        return

    $ day_time = t
    call update_daytime_index ()
    call update_schedule ()

    return

label set_daily(val):
    $ daily_values.append(val)
    return

label update_daytime_index:
    if day_time == daytime['morning']:
        $ day_time_index = 0
    elif day_time == daytime['late']:
        $ day_time_index = 1
    elif day_time == daytime['afternoon']:
        $ day_time_index = 2
    elif day_time == daytime['evening']:
        $ day_time_index = 3
    elif day_time == daytime['night']:
        $ day_time_index = 4
    else:
        $ day_time_index = 5

    return

label increase_time:
    if day_time == daytime['morning']:
        call set_time (daytime['late']) from _call_set_time_54
    elif day_time == daytime['late']:
        call set_time (daytime['afternoon']) from _call_set_time_58
    elif day_time == daytime['afternoon']:
        call set_time (daytime['evening']) from _call_set_time_66
    elif day_time == daytime['evening']:
        call set_time (daytime['night']) from _call_set_time_68
    elif day_time == daytime['night']:
        call set_time (daytime['midnight']) from _call_set_time_79
    else:
        call set_time (daytime['midnight']) from _call_set_time_80
    return

label increase_day:
    $ day_count          += 1
    $ day_of_week        = week_day[day_count % 7]
    $ is_weekend         = day_of_week == week_day[0] or day_of_week == week_day[6]

    call day_events_check () from _call_day_events_check
    call set_time (daytime['morning']) from _call_set_time_15
    return

label add_money(amount):
    call play_sound ('cashier', 0.5) from _call_play_sound_741

    $ add_amount = amount
    $ my_money += add_amount
    $ renpy.notify("{b}Earned{/b} [add_amount] coins.")
    return



label open_my_inventory():
    $ renpy.call_in_new_context('show_inventory', "player", "inventory_bg", "My Inventory")
    call on_inventory_closed ("player")
    return

label open_box_inventory(_inventory_id, _inv_title=None):
    if _inv_title == None:
        $ _inv_title = _inventory_id

    $ renpy.call_in_new_context('show_inventory', _inventory_id, "inventory_bg2", _inv_title)
    call on_inventory_closed (_inventory_id)
    call update_magic_notes ()
    return

label pick_item(item_id, from_inv_id, to_inv_id):
    if get_inventory(to_inv_id) == None:
        "There's no where to put it."
    else:

        $ remove_item(item_id, from_inv_id)
        $ add_item(item_id, to_inv_id)
        $ renpy.notify("Transferred " + ITEMS[item_id].name)

        call play_sound ('cloth1')
    return

label add_inventory_callback(_inventory_id, label_name):
    $ inventory_callbacks[_inventory_id] = label_name
    return

label on_inventory_closed(_inventory_id):
    if my_location in inventory_callbacks:
        $ renpy.call(inventory_callbacks[my_location], _inventory_id == my_location)
    return



transform scenefade_in:
    zoom 1.05 align (0.5, 0.75)
    linear 0.9 zoom 1.0 align (0.5, 0.5)

transform cumming:
    align (0.5, 0.5) additive 0.4
    linear 0.5 zoom 1.1 alpha 0

label cumming_fx(image_name, who=None, what=None):
    $ renpy.show(image_name, layer="screens", at_list=[cumming])
    $ renpy.scene()
    $ renpy.show(image_name)
    with vpunch

    if who:
        $ renpy.say(who, what)
    else:
        pause 0.25
    $ renpy.hide(image_name, layer="screens")

    return



define random_number = 0
label random_number(min=0, max=1):
    $ random_number = renpy.random.randint(min, max)
    return



label should_corrupt_her_more_thinking:
    if my_magicskill == 0:
        "I shouldn't do that just yet."
    else:
        "I should corrupt her more before doing that."

    return


init python:
    config.window_show_transition = dissolve
    config.window_hide_transition = dissolve

    def delta_day(value_key, auto_set_value=True):
        global day_count
        
        if auto_set_value:
            return day_count - get_key_value(value_key, day_count)
        
        else:
            delta_d = get_key_value(value_key)
            if delta_d is not None:
                return day_count - delta_d
            else:
                return 0



    def can_use_magic(mana_cost):
        global my_mana
        return my_mana >= mana_cost or _in_replay

    def is_day_time():
        global day_time_index
        return day_time_index >= 1 and day_time_index <= 3

    def is_event_active(event_name):
        if event_name == None:
            return True
        
        global activated_events
        return event_name in activated_events

    def are_event_active(event_names):
        for event_name in event_names:
            if not is_event_active(event_name):
                return False
        
        return True

    def after_replay():
        if persistent.replay_add_item != None:
            renpy.call('after_replay', from_current=True)

    config.after_replay_callback = after_replay


    def get_affection(char_name):
        global character_affections
        char_name = str(char_name)
        if char_name in character_affections:
            return character_affections[char_name]
        return 0

    def add_item(item_id, inventory_id, amount=1):
        _inventory = get_inventory(inventory_id)
        if _inventory != None:
            for _ in range(amount):
                _inventory.append(item_id)

    def remove_item(item_id, inventory_id):
        _inventory = get_inventory(inventory_id)
        if _inventory != None and item_id in _inventory:
            _inventory.remove(item_id)

    def get_location_inventory():
        return get_inventory(my_location)

    def get_inventory(inventory_id):
        global location
        if inventory_id == "player":
            global my_inventory
            return my_inventory
        elif inventory_id == location['living_room']:
            global living_room_inventory
            return living_room_inventory
        elif inventory_id == location['bath_room']:
            global bathroom_inventory
            return bathroom_inventory
        elif inventory_id == location['my_room']:
            global my_bedroom_inventory
            return my_bedroom_inventory
        elif inventory_id == location['sister_room']:
            global momoko_room_inventory
            return momoko_room_inventory
        elif inventory_id == location['mom_room']:
            global airi_room_inventory
            return airi_room_inventory
        elif inventory_id == location['kitchen']:
            global kitchen_inventory
            return kitchen_inventory
        elif inventory_id == location['dinner_room']:
            global dinning_room_inventory
            return dinning_room_inventory
        elif inventory_id == location['taka_home']:
            global taka_basement_inventory
            return taka_basement_inventory
        elif inventory_id == location['red_place']:
            global red_place_inventory
            return red_place_inventory
        elif inventory_id == location['yamiyo_prison']:
            global yamiyo_prison_inventory
            return yamiyo_prison_inventory
        elif inventory_id == location['nami_home']:
            global nami_home_inventory
            return nami_home_inventory
        elif inventory_id == location['okemia_mojo']:
            global okemia_dojo_inventory
            return okemia_dojo_inventory
        elif inventory_id == location['outside_mine']:
            global yasuko_office_inventory
            return yasuko_office_inventory
        
        return None

    def has_enough_money(cost):
        global my_money
        return my_money >= cost

    def use_money(amount):
        if _in_replay:
            return True
        
        global my_money
        
        if my_money >= amount:
            my_money -= amount
            renpy.notify("{b}Spent{/b} {color=#ffd230}" + str(amount) + " coins.{/color}")
            renpy.music.play('sfx/cashier.mp3', 'sound')
            
            return True
        else:
            renpy.notify("Not enough coins.")
        
        return False

    def get_key_value(_key, _default = None):
        global key_values
        
        if _key in key_values:
            return key_values[_key]
        else:
            if _default:
                key_values[_key] = _default
            
            return _default

    def is_morning():
        global daytime
        global day_time
        return day_time == daytime['morning']

    def is_late():
        global daytime
        global day_time
        return day_time == daytime['late']

    def is_afternoon():
        global daytime
        global day_time
        return day_time == daytime['afternoon']

    def is_evening():
        global daytime
        global day_time
        return day_time == daytime['evening']

    def is_night():
        global daytime
        global day_time
        return day_time == daytime['night']

    def is_midnight():
        global daytime
        global day_time
        return day_time == daytime['midnight']

    def time_range(min, max):
        global day_time_index
        return day_time_index >= min and day_time_index <= max

    def is_done(_status, _var=True):
        global status
        
        if _var:
            return _status == status['done']
        else:
            return get_key_value(_status) == status['done']

    def is_progress(_status, _var=True):
        global status
        
        if _var:
            return _status == status['progress']
        else:
            return get_key_value(_status) == status['progress']

    def is_none(_status, _var=True):
        global status
        
        if _var:
            return _status == None or _status == status['none']
        else:
            return get_key_value(_status) == None or get_key_value(_status) == status['none']

    def randomInt(min=0, max=100):
        return renpy.random.randint(min, max)

    def randomArr(arr=[]):
        return renpy.random.choice(arr)

    def has_location_event(location_key):
        global event_map
        
        for _event in event_map:
            if location_key == _event[0] and time_range(_event[1], _event[2]):
                return len(_event) < 4 or eval(_event[3])
        
        return False

    def has_location_corruption(location_name):
        if my_magicskill == 0:
            return False
        
        
        if (day_time_index == 0 or day_time_index == 4) and mom_location == location_name:
            return True
        elif (day_time_index == 2 or (day_time_index == 4 and sister_going_to_bathroom)) and sister_location == location_name:
            return True
        
        
        elif (day_time_index == 2) and mom_location == location_name == location['outside_castle_front']:
            return True
        elif time_range(0, 3) and location_name == location['outside_mine']:
            return True
        elif time_range(1, 4) and location_name == nami_location:
            return True
        elif time_range(2, 3) and location_name == okemia_location:
            return True
        elif day_time_index == 0 and is_event_active('meet_emica_rw') and location_name == location['outside_park']:
            return True
        
        return False

    def is_in_home(_location):
        global location
        
        return (_location == location['living_room']
            or _location == location['my_room']
            or _location == location['mom_room']
            or _location == location['sada_room']
            or _location == location['sister_room']
            or _location == location['bath_room']
            or _location == location['house_side']
            or _location == location['kitchen']
            or _location == location['red_place']
            or _location == location['dinner_room'])

    def gset_event_active(_event):
        global activated_events
        if is_event_active(_event):
            return True
        else:
            activated_events.add(_event)
            update_magic_notes_py()
            
            return False

    def update_magic_notes_py():
        available_magic_notes.clear()
        
        for todo_condition in what_todo_contidions:
            if eval(todo_condition[0]):
                available_magic_notes.append(todo_condition)
        
        
        if len(available_magic_notes) > 0:
            available_magic_notes.sort(
                key=lambda todo: (len(todo) <= 2 and -1) or (len(todo) > 2 and not time_range(todo[2][1], todo[2][2])))
        
        update_event_map()
        return

    def update_event_map():
        global event_map
        global available_magic_notes
        event_map.clear()
        
        for whattodo in available_magic_notes:
            if len(whattodo) > 2:
                event_map.append(whattodo[2])
        
        return

    def day_parts():
        global day_time_index
        if day_time_index <= 1:
            return "Morning"
        elif day_time_index <= 3:
            return "Afternoon"
        
        return "Night"

    def get_daily(val):
        global daily_values
        return val in daily_values

    def gset_daily(val):
        global daily_values
        if not get_daily(val):
            daily_values.append(val)
            return False
        return True

    def check(temp_name):
        global temp_booleans
        return temp_name in temp_booleans

    def check_and_remove(temp_name):
        global temp_booleans
        if temp_name in temp_booleans:
            temp_booleans.remove(temp_name)
            return True

    def remove_daily(val):
        global daily_values
        if val in daily_values:
            daily_values.remove(val)
        return

    def wait_event(completed_events, wait_event):
        if not isinstance(completed_events, list):
            return not is_event_active(wait_event) and is_event_active(completed_events)
        else:
            if not is_event_active(wait_event):
                all_completed = True
                for e in completed_events:
                    if not is_event_active(e):
                        all_completed = False
                        break
                
                if all_completed:
                    return True
        
        return False

    def has_book_to_read():
        global my_inventory
        global my_bedroom_inventory
        global ITEMS
        global read_book
        
        book_count = 0
        for item_id in my_inventory + my_bedroom_inventory:
            if item_id in ITEMS and "studybook" in ITEMS[item_id].type:
                book_count += 1
        
        if book_count != len(read_book):
            return True
        
        return False

    def get_bol_index(char_name):
        for i in range(0, len(bol_characters)):
            
            if bol_characters[i][0] == char_name:
                return i

    def get_bol_unlocked(char_name):
        global bol_characters
        
        for bol_char in bol_characters:
            if bol_char[0] == char_name:
                return eval(bol_char[3])

    def merge_dicts(dict1, dict2):
        dict3 = dict1.copy()
        dict3.update(dict2)
        return dict3

label set_volume(vol, fade_time=3, channel='music'):
    $ renpy.music.set_volume(vol, fade_time, channel=channel)
    return

label play_music(music_name, volume=0.4, fadein=3, is_loop=True):
    if renpy.music.get_playing() != "musics/" + music_name + ".mp3":
        $ renpy.music.stop(fadeout=1)
        $ renpy.music.queue("musics/" + music_name + ".mp3", fadein=fadein, clear_queue=True, loop=is_loop)
        $ renpy.music.set_volume(volume, 1)
    else:
        $ renpy.music.set_volume(volume, fadein)

    return

label play_music2(music_name, volume=0.4, fadein=3):
    play music2 "musics/" + music_name + ".mp3" fadein fadein
    $ renpy.music.set_volume(volume, 0, 'music2')
    return

label play_queue(music_name, volume=0.4, fadein=3):
    $ renpy.music.queue("musics/" + music_name + ".mp3", fadein=fadein)
    return

label play_romance_music(force=""):
    $ renpy.music.stop(fadeout=1)
    $ renpy.music.set_volume(0.4, 3)

    if force == "":
        $ renpy.music.queue(renpy.random.choice(["musics/Arms_of_Heaven.mp3", "musics/Touching_Moment.mp3", "musics/Heavenly.mp3", "musics/Beneath_the_Moonlight.mp3", "musics/The_Beauty_of_Love.mp3"]), fadein=3, clear_queue=True)
    else:
        $ renpy.music.queue(force, fadein=3, clear_queue=True)

    return

label play_music_queue(song1, song2):
    $ renpy.music.stop(fadeout=1)
    $ renpy.music.set_volume(0.5, 3)

    $ renpy.music.play(song1, fadein=2)
    $ renpy.music.queue(song2, fadein=2)
    return

label stop_and_play(song, vol=0.5, fade_time=3):
    $ renpy.music.stop(channel='music', fadeout=fade_time)
    $ music_queue = (song, vol, fade_time)
    return

label play_main_music(fade_time=3):
    if renpy.music.get_playing() != "musics/English_Country_Garden.mp3":
        call stop_and_play ("musics/English_Country_Garden.mp3", 0.4, fade_time) from _call_stop_and_play_104
    else:
        call set_volume (0.4, 6) from _call_set_volume_257
    return

label queue_main_music:
    call play_queue ("English_Country_Garden", 0.4, 3)
    return

label play_night_ambient(fade_time=3):
    if renpy.music.get_playing() != "sfx/night_ambience.mp3":
        call stop_and_play ("sfx/night_ambience.mp3", 0.5, fade_time)
    else:
        call set_volume (0.5, 5)
    return

label play_happy_music:
    $ renpy.music.set_volume(0.4, 6)
    if renpy.music.get_playing() != "musics/happy.mp3":
        $ renpy.music.stop(fadeout=1)
        $ renpy.music.queue("musics/happy.mp3", loop=True, fadein=6, clear_queue=True)
    return

label play_sexy_music:
    if renpy.music.get_playing() != "musics/sexy.mp3":
        $ renpy.music.stop(fadeout=0)
        $ renpy.music.set_volume(0.185)
        $ renpy.music.queue("musics/sexy.mp3", loop=True, fadein=0)
    else:
        call set_volume (0.185, 6)
    return

label play_sexy_music_post:
    if renpy.music.get_playing() != "musics/sexy.mp3":
        $ renpy.music.stop(fadeout=0)
        $ renpy.music.set_volume(0.111)
        $ renpy.music.queue("musics/sexy.mp3", loop=True, fadein=0)
    else:
        call set_volume (0.111, 6)
    return

label play_after_sex_music:
    call play_music ('after_sex_relaxing', 0.4, 0)
    return

label play_drama_music:
    if renpy.music.get_playing() != "musics/Poison_Apple.mp3":
        $ renpy.music.stop(fadeout=2)
        $ renpy.music.set_volume(0.175)
        $ renpy.music.queue("musics/Poison_Apple.mp3", loop=True, fadein=3, clear_queue=True)
    return

label play_mystery_music:
    if renpy.music.get_playing() != "musics/Window_Demons.mp3":
        $ renpy.music.stop(fadeout=2)
        $ renpy.music.set_volume(0.25)
        $ renpy.music.queue("musics/Window_Demons.mp3", loop=True, fadein=3, clear_queue=True)
    return

label play_sad_music:
    if renpy.music.get_playing() != "musics/Spirit_of_the_Dead.mp3":
        $ renpy.music.stop(fadeout=2)
        $ renpy.music.set_volume(0.3)
        $ renpy.music.queue("musics/Spirit_of_the_Dead.mp3", loop=True, fadein=3, clear_queue=True)
    return

label play_sneaky_music:
    if renpy.music.get_playing() != "musics/sneaky_snooper.mp3":
        call stop_and_play ("musics/sneaky_snooper.mp3", 0.3, 4) from _call_stop_and_play_114
    else:
        call set_volume (0.3, 4) from _call_set_volume_258
    return

label play_sound(sound_name, vol=0.75):
    $ renpy.music.set_volume(vol, 0, 'sound')
    play sound "sfx/" + sound_name + ".mp3" volume 1
    return

label play_sound2(sound_name, vol=0.75):
    $ renpy.music.set_volume(vol, 0, 'sound2')
    play sound2 "sfx/" + sound_name + ".mp3" volume 1
    return

label sound_drink:
    play sound "sfx/drinking.mp3"
    return

label sound_gulp:
    call random_number (1, 3) from _call_random_number_2
    play sound "sfx/gulp" + str(random_number) + ".mp3"
    return

label sound_slurp:
    play sound "sfx/slurping-02.mp3"
    return

label sound_bong:
    play sound "sfx/cartoon-sounds-bang-01.mp3"
    return

label door_is_locked:
    call play_sound ('door_stuck', 0.6)
    with sshake
    "The door is locked."

    return

label play_sex_sound(sound_name, vol=0.5, fadein=2, loop=True):
    $ renpy.music.play("sfx/sex/" + sound_name + ".mp3", "sound", loop=loop, fadein=fadein, relative_volume=1)
    $ renpy.music.set_volume(vol, 0, "sound")
    return

label stop_sex_sound(fade_out=2):
    stop sound fadeout fade_out
    return

label cpoint(wait_delay=0):
    call gap (wait_delay) from _call_gap_2490
    $ click_point = True
    pause
    $ click_point = False
    pause 0.01
    return

label hide_window(fast=False):
    if (fast):
        window hide Dissolve(0.15)
    else:
        window hide dissolve

    window auto
    return

label gap(gap_delay=0.25, hard_pause=False):
    call hide_window (eval("gap_delay == 0"))
    if (gap_delay > 0):
        $ renpy.pause(gap_delay, hard=hard_pause)

    return

label black_screen(wait_time=1, fade_time=0.75):
    scene black with Fade(fade_time, 0, 0)
    $ renpy.pause(wait_time, hard=True)

    return

label end_scene(event_name=None, show_info_screen=True, fast_fade=False):
    $ info_screen = show_info_screen

    if fast_fade:
        scene black with fade
    else:
        call black_screen (1.5)

    call check_if_replaying ()
    if event_name != None:
        call active_event (event_name)

    return

label scene_fadein():
    $ info_screen = False
    scene black with fade
    $ renpy.pause(0.75)

    return

label corruption_pay_off(_character):
    show screen notify_icon(str(_character) + " corruption pay off", "heart_icon")
    return

label notify_unlocked_new_lover(_character):
    if _in_replay:
        return
    show screen notify_icon("Book of Lover +" + str(_character), "heart_icon")
    return

label notify_corruption(percentage=0, corrupt_char=""):
    $ notify_text = "+" + str(percentage) + "% " + str(corrupt_char) + " Corruption"
    call corruption_effect (None)
    show screen notify_icon(notify_text, "magic_icon")

    return

screen corruption_magic_fx:
    timer 2 action Hide('corruption_magic_fx')

    frame:
        align (0.5, 0.5)
        xfill True
        yfill True
        background None





        add "red_magic" align (0.5, 0.5):
            at transform:
                alpha 0.0
                parallel:
                    linear 1 alpha 1
                    linear 1 alpha 0
                parallel:
                    linear 3 rotate 8 zoom 1.2

        add Frame(Solid("#e00d0d"), xsize=config.screen_width, ysize=config.screen_height):
            at transform:
                alpha 0
                pause 1
                ease 0.4 alpha 1
                pause 0.3
                ease 1 alpha 0 additive 1

        add "magic_immerge" align (0.5, 0.5):
            at transform:
                zoom 3.0 alpha 0 additive 1
                parallel:
                    linear 0.25 alpha 1
                    linear 1.5 alpha 0
                parallel:
                    linear 1.75 zoom 2
        at transform:
            zoom 1.01
            on hide:
                linear 0.6 alpha 0
screen mesmerizing_fx:
    timer 0.3 action Hide('mesmerizing_fx')
    frame:
        align (0.5, 0.5)
        xfill True
        yfill True
        background None



        add Frame(Solid("#e00d0d"), xsize=config.screen_width, ysize=config.screen_height):
            at transform:
                alpha 0
                ease 0.3 alpha 1
                parallel:
                    ease 0.1 additive 1
                parallel:
                    pause 0.1
                    ease 1 alpha 0
        at transform:
            zoom 1.01
            on hide:
                linear 0.6 alpha 0
label notify_group_corruption(percentage=0):
    $ notify_text = "Group corruption: +" + str(percentage) + "% each"
    show screen notify_icon(notify_text, "magic_icon")
    return
label notify_affection(char_name_str):
    $ notify_text = char_name_str + " likes you more"
    show screen notify_icon(notify_text, "heart_icon")
    return
screen affection_notify():
    timer 1.0 action Return()
    frame:
        background Solid("#ff114d44")
        xalign 0.5
        yalign 0.5
        at transform:
            alpha 0.0 additive 1
            linear 0.5 alpha 1
            on hide:
                linear 0.75 alpha 0

    add "heartbeat":
        align (0.5, 0.515)
        at transform:
            alpha 0.0 zoom 0.25 additive 1
            parallel:
                linear 1.0 zoom 3.25
            parallel:
                linear 0.25 alpha 0.75
                linear 0.75 alpha 0.0

    add "she_likes_you":
        align (0.5, 0.5)
        at transform:
            alpha 0 zoom 0.7 additive 1
            parallel:
                linear 1.0 zoom 0.85 additive 0
            parallel:
                linear 0.4 alpha 1.0

            on hide:
                linear 1.0 alpha 0 zoom 1.0

label increase_affection(char_name):
    $ char_name = str(char_name)

    call play_sound ('heartbeat')
    call screen affection_notify

    if char_name in character_affections:
        $ character_affections[char_name] += 1
    else:
        $ character_affections[char_name] = 1

    return

label use_magic(mana=50):
    $ spend_mana     = mana
    $ my_mana       -= mana
    return

label first_scene_visit(scene_name, wait_delay=1.5):
    if not gset_event_active(scene_name):
        $ info_screen = False
        call black_screen (wait_delay, 0.55)

    return

label magic_effect():
    $ info_screen = False
    call play_sound ('corruption_magic', 1)
    show screen corruption_magic_fx
    $ renpy.pause(1.5, hard=True)
    return

label mesmerize_effect():
    $ info_screen = False
    call play_sound ('mesmerize_fx', 1)
    show screen mesmerizing_fx
    $ renpy.pause(0.3, hard=True)
    return

label end_of_version():
    call black_screen (1.5)
    scene end_of_version with Fade(0.1, 0.1, 1)
    pause

    menu:
        "Alright":
            pass

    call black_screen (2, 1)
    return

transform left:
    xalign 0.39 xanchor 0.5

transform right:
    xalign 0.61 xanchor 0.5

transform magic_effect_cover_appear:
    on show:
        alpha 0
        xalign 0.5
        yalign 0.5
        additive 1
        pause 4
        ease 0.5 alpha 1.0 additive 0
    on hide:

        ease 0.3 alpha 1.0 additive 0

transform magic_effect_appear:
    on show:
        alpha 0
        additive 1
        rotate -8
        zoom 1.4
        xalign 0.5
        yalign 0.5

        parallel:
            pause 1.5
            linear 1 alpha 1
            pause 0.5
            linear 1.0 alpha 0.0
        parallel:
            linear 4 rotate 8 zoom 1.2
    on hide:
        linear 0.3 alpha 0.0

define sshake = Shake((0, 0, 0, 0), 0.15, dist=15)

label increase_mana(increase_amount, notify=True):
    if my_magicskill == 0:
        return

    $ add_mana_amount = increase_amount

    if my_mana + add_mana_amount <= max_mana + mana_capacity:
        $ my_mana += add_mana_amount

        if notify:
            $ renpy.notify("Mana increased by [add_mana_amount]%")
    else:
        $ my_mana = max_mana + mana_capacity

        if notify:
            $ renpy.notify("Your Mana is now full")

    return

label increase_strength(increase_amount):
    $ add_strength_amount = increase_amount

    if my_strength + add_strength_amount <= 10:
        $ my_strength += add_strength_amount
    else:
        $ my_strength = 10

    $ mana_capacity = math.ceil(my_strength * 10)
    $ renpy.notify("My strength has increased!")
    return


label splashscreen:
    scene black
    with Pause(0.5, hard=True)

    image splash = "images/SplashScreen.jpg"
    scene splash with dissolve
    $ renpy.pause(4, hard=True)

    scene black with dissolve
    with Pause(0.5, hard=True)
    $ renpy.pause(0.5, hard=True)

    return

label mm_red_witch_video:

    play music "musics/red-bgm.mp3" noloop

    image mainmenu1_video = Movie(channel="movie", play="movies/mm_1.mp4")
    scene black with fade
    scene mainmenu1_video with Fade(0.2, 0.0, 0.2, color="#ff1414"):
        zoom 1.4 align (0.5, 0.5)
        linear 0.3 zoom 1

    return

label mm_dark_fairy_video:

    image mainmenu2_video = Movie(channel="movie", play="movies/mm_2.mp4")
    scene black with fade

    play music "musics/dark-bgm.mp3" noloop

    scene mainmenu2_video with Fade(0.2, 0.0, 0.2, color="#cc0066"):
        zoom 1.4 align (0.5, 0.5)
        linear 0.3 zoom 1

    return

label mm_df_queen_video:

    image video_mm_df_queen = Movie(channel="movie", play="movies/mm_df_queen.mp4")

    scene black with fade
    play music "musics/mm_df_queen.mp3" noloop
    scene video_mm_df_queen with Fade(0.2, 0.1, 0.2, color="#ff26be"):
        zoom 1.4 align (0.5, 0.5)
        linear 0.4 zoom 1

    return

label mm_red_witch_new_video:

    image video_mm_red_witch = Movie(channel="movie", play="movies/mm_red_witch.mp4")
    play music "musics/red-bgm.mp3" noloop

    scene black with fade
    scene video_mm_red_witch with Fade(0.2, 0.1, 0.2, color="#ff2626"):
        zoom 1.4 align (0.5, 0.5)
        linear 0.4 zoom 1

    return

label mm_red_witch_video2:

    image video_mm_red_witch2 = Movie(channel="movie", play="movies/mm_red_witch2.mp4")

    scene black with fade
    play music "musics/mm_rw2_lust_for_love.mp3" noloop
    scene video_mm_red_witch2 with Fade(0.2, 0.1, 0.65, color="#ff2626"):
        zoom 1.3 align (0.5, 0.5)
        linear 1 zoom 1

    return

label mm_airi_momoko_video:

    image video_mm_airi_momoko = Movie(channel="movie", play="movies/mm_airi_momoko.mp4")

    scene black with fade

    play music "musics/mm_airi_momoko.mp3" noloop
    $ renpy.music.set_volume(0.4, 0, channel="music")

    scene video_mm_airi_momoko with Fade(0.1, 0.1, 0.3, color="#ffa826"):
        zoom 1.3 align (0.5, 0.5)
        linear 0.3 zoom 1

    return

label before_main_menu:
    if persistent.mm_video_index == None:
        $ persistent.mm_video_index = 0
    else:

        $ persistent.mm_video_index += 1
        if persistent.mm_video_index > 3:
            $ persistent.mm_video_index = 0

    $ renpy.music.set_volume(0.5, 0, channel="music")

    if not persistent.mm_red_witch2:

        $ persistent.mm_red_witch2 = True
        $ persistent.mm_video_index = 3

    if persistent.use_old_mm_video:
        if persistent.old_mm_video == 0:
            $ persistent.old_mm_video = 1
        else:
            $ persistent.old_mm_video = 0

        if persistent.old_mm_video == 0:
            call mm_dark_fairy_video ()
        else:

            call mm_red_witch_video ()
    else:

        if persistent.mm_video_index == 1:
            call mm_red_witch_new_video ()

        elif persistent.mm_video_index == 2:
            call mm_airi_momoko_video ()

        elif persistent.mm_video_index == 3:
            call mm_red_witch_video2 ()
        else:

            call mm_df_queen_video ()

    return


label after_load:

    if actived_events != None:
        $ actived_events = None
        $ renpy.call_in_new_context("a_new_beginning")


    $ config.window_show_transition = Dissolve(0.15)
    $ config.window_hide_transition = Dissolve(0.15)
    $ dissolve = Dissolve(0.3)
    $ learned_about_magic = (total_consumed_amount - ruriko_consumed) > 0
    $ renpy.music.set_volume(0.85, 0, "talk")

    if not is_event_active('event_dark_prison_torturing'):
        $ yamiyo = Character("{b}Dark Fairy{/b}")
    else:
        $ yamiyo = Character("{b}Yamiyo{/b}")

    if rel_mom.name == "{b}Mom{/b}":
        $ persistent.mom_call = "{b}Mom{/b}"

    if _mom.name == "{b}Mom{/b}":
        $ persistent.mom_call = "{b}Mom{/b}"

    show screen timeofday_screen
    show screen ui_button


    call calculate_total_consumed ()
    call prepare_inventory_items ()
    call check_for_exclusive_items ()
    call update_magic_notes ()
    call version_rework_events ()

    if not config.developer:
        $ renpy.block_rollback()

    return

label version_rework_events:

    # Saves created by V.0.22.0 must not run the old-save migration.
    if _version == config.version:
        $ activated_events.add('rework_0.22.0')
        return

    if not gset_event_active('rework_0.22.0'):
        call progress.start ('event_meet_with_dark_fairly')
        call progress.start ('quest_visit_okemia_mojo')
        call progress.start ('quest_visit_taka_at_home')
        call progress.start ('bath_with_momoko')
        call progress.cancel ('mind_training_with_okemia')
        call deactive_event ('event_okemia_first_meet_extends')
        call deactive_event ('first_okemia_mind_connect')
        call deactive_event ('reports_to_queen')
        call deactive_event ('bath_with_momoko')
        call deactive_event ('quest_visit_okemia_mojo')
        call deactive_event ('event_meet_okemia_mom')
        call deactive_event ('event_first_airi_go_to_bath_approach')
        call deactive_event ('event_df_queen_visit_kana')
        call deactive_event ('event_okemia_trained_with_luna')
        call deactive_event ('event_thanks_okemia_luna_for_training')

    return

label after_replay:
    if persistent.replay_add_item != None:
        call add_my_item (persistent.replay_add_item)
        pause 1.0

    $ persistent.replay_add_item = None
    return


label start:
    # Mark new V.0.22.0 games as already migrated.
    $ activated_events.add('rework_0.22.0')

    $ renpy.music.set_volume(0.50, 0, "music")
    $ renpy.music.set_volume(0.85, 0, "talk")

    stop music fadeout 10

    $ info_screen = False
    $ persistent._clear()


    show black with dissolve
    show text "{size=40}" + "{b}Disclaimer{/b}\n(18+ Adult Content)\n\nThis game is for adults only! If you are under 18 years old, please do not play this game.\nThe following program may contain strong language, as well as violent and sexual content. All characters involved in the forementioned activities are over 18 years old.\n\n{b}Play this game at your own risk!{/b}" + "{/size}" at truecenter with dissolve
    $ renpy.pause(5, hard=True)
    "(Tap to continue)"

    scene black with Dissolve(0.5)
    hide text


    call prepare_inventory_items ()
    $ renpy.pause(1.0)

    $ my_name = "Jack"
    $ persistent.my_name = my_name
    $ menu_message = "{b}Skip your name input? (Use " + my_name + "){/b}"
    menu:
        "Yes":
            call reset_menu_message ()
            jump intro
        "No":
            call reset_menu_message ()

    call user_name_input_prompt ()
    jump intro

label user_name_input_prompt:

    $ my_name = renpy.input("What is your name?", default=my_name, length=10)
    $ my_name = my_name.strip()
    if not my_name:
        $ my_name= "Jack"

    $ persistent.my_name = my_name
    "My name's [me]."
    call gap () from _call_gap_10748

    return


label show_center_text(txt, t=1):
    $ info_screen = False
    $ click_point = False

    show black with dissolve
    show text "{size=44}" + txt + "{/size}" at truecenter with dissolve
    $ renpy.pause(t, hard=True)
    hide text with dissolve

    $ info_screen = True
    return



define leaving_call_action = ""
define before_leaving_events = []

label home_room_menu(show_back_button=False, leaving_call_action=""):
    $ map_screen_close_button = show_back_button
    $ renpy.call_in_new_context("show_goto_map_home")

    call jumping_to_place ()
    return

label show_outside_place_menu(show_back_button=True, leaving_call_action=""):
    call check_time_skip_leaving ()
    if _return:
        return

    $ map_screen_close_button = show_back_button
    $ renpy.call_in_new_context("show_goto_map_outside")

    call jumping_to_place ()
    return

label check_time_skip_leaving():
    if time_skip_prevent != None:
        with vpunch
        $ narrator(time_skip_prevent)
        return True
    return False

label jumping_to_my_room():
    scene black
    call DoLeavingEvents ()
    with LocDissolve

    jump scene_my_room

label jumping_to_place():
    if going_to_location_label != "":
        if leaving_call_action != "":
            $ renpy.call(leaving_call_action)
        call before_jump_to_other_scene ()
        call DoLeavingEvents ()

        $ renpy.jump(going_to_location_label)
    return

label before_jump_to_other_scene():
    if my_location == location['my_room']:
        call leave_my_room_events ()

    if is_in_home(my_location) and going_to_location_label == "scene_go_outside":
        call scene_entering_fx_house_front ()

    $ come_from_somewhere_else = not is_in_home(my_location)
    return

label DoLeavingEvents():
    python:
        for eventName in before_leaving_events:
            renpy.call(eventName)
    $ before_leaving_events = []

    return

label AddLeavingEvent(call_event_name):
    $ before_leaving_events.append(call_event_name)
    return

label scene_go_outside:
    call play_sound ('door_open')

    scene black with dissolve
    jump scene_house_front

label show_leaving_menu(show_back_button=True, wait_time=0):
    call gap (wait_time)
    menu:
        "Leave":
            call home_room_menu (show_back_button)
    return

label a_new_beginning:
    call play_music ('welcome_new_beginning', 0.5, 0)
    scene a_new_beginning with Fade(0.5, 0.5, 1.0)
    pause

    menu:
        "{b}Main Menu{/b}":
            $ renpy.full_restart()
# Decompiled by unrpyc: https://github.com/CensoredUsername/unrpyc
