init -1 python:
    def ending_image():
        #0b0000, DCBA, flash the bits with |=, check with &
        endings = 0b0000
        _e = 0b1
        for i in range(1, 5):
            fn = "e"+str(i)+"of4"
            endings |= (_e * renpy.seen_image(fn))
            _e = _e << 0b1
        persistent.old_endings = persistent.endings
        persistent.endings = endings

label storyline:
    call chapter_1
    call chapter_2
    call chapter_3
    call chapter_4
    call chapter_5
    call chapter_6
    call chapter_7
    call chapter_8
    call chapter_9
    call chapter_10
    call chapter_11
    call get_ending
    if _return == 4:
        call chapter_11D
        call chapter_12D
        call chapter_12_5D
        call chapter_13D
        call chapter_14D
    elif _return == 3:
        $ tradwife = True
        call chapter_11C
        call chapter_12C
        call chapter_12_5C
        call chapter_13C
        call chapter_14C
    elif _return == 2:
        call chapter_11B
        call chapter_12B
        # no chapter_13 here since the scene is different enough to the other routes for everything to go into 13C
        call chapter_13B
        call chapter_14B
    else:
        call chapter_11A
        call chapter_12A
        call chapter_12_5D
        call chapter_13A
        call chapter_14A
        $ ending_image()
        $ renpy.quit()
    $ ending_image()
    call .ending
    return

image b_credits = Composite(
    (1920, 11000),
    (0, 0), "credits",
    (0, 10410), "b_sketch")

image c_credits = Composite(
    (1920, 11000),
    (0, 0), "credits",
    (0, 10410), "c_sketch")

image d_credits = Composite(
    (1920, 11000),
    (0, 0), "credits",
    (0, 10410), "d_sketch")

label .ending:
    call get_ending
    if _return == 4:
        show d_credits at Pan((0, -500),(0, 9850), 65) with fade
    elif _return == 3:
        play music "audio/OST/Dino Destiny Reader.ogg"
        show c_credits at Pan((0, -500),(0, 9850), 65) with fade
    else:
        play music "audio/OST/Dino Destiny Reader.ogg"
        show b_credits at Pan((0, -500),(0, 9850), 65) with fade
    pause
    stop music fadeout 5
    scene black with Dissolve(3)
    pause 2
    if tradwife:
       scene c10 with Dissolve(1.5)
       pause 20
       scene black with Dissolve(2)
       pause 1
    elif anonscore >= 4 and fangscore >= 4:
       scene ending_d_cg with Dissolve(1.5)
       pause 20
       scene black with Dissolve(2)
       pause 1
    return