﻿# Dominion of Communion — Breast Profile values (2.5.8)

# Display-only conversion. Canonical variables remain tenths of an inch.
domcom_underbust_display_value = {
    value = 0
    if = {
        limit = { has_variable = domcom_underbust_tenths }
        if = { limit = { has_global_variable = domcom_metric_units } add = { value = var:domcom_underbust_tenths multiply = 0.508 round = yes divide = 2 } }
        else = { add = { value = var:domcom_underbust_tenths divide = 10 } }
    }
}
domcom_bust_display_value = {
    value = 0
    if = {
        limit = { has_variable = domcom_bust_tenths }
        if = { limit = { has_global_variable = domcom_metric_units } add = { value = var:domcom_bust_tenths multiply = 0.508 round = yes divide = 2 } }
        else = { add = { value = var:domcom_bust_tenths divide = 10 } }
    }
}
domcom_breast_fullness_display_value = {
    value = 0
    if = {
        limit = { has_variable = domcom_breast_fullness_tenths }
        if = { limit = { has_global_variable = domcom_metric_units } add = { value = var:domcom_breast_fullness_tenths multiply = 0.508 round = yes divide = 2 } }
        else = { add = { value = var:domcom_breast_fullness_tenths divide = 10 } }
    }
}
domcom_pref_underbust_display_value = {
    value = 0
    if = {
        limit = { has_variable = domcom_pref_underbust_tenths }
        if = { limit = { has_global_variable = domcom_metric_units } add = { value = var:domcom_pref_underbust_tenths multiply = 0.508 round = yes divide = 2 } }
        else = { add = { value = var:domcom_pref_underbust_tenths divide = 10 } }
    }
}
domcom_pref_breast_fullness_display_value = {
    value = 0
    if = {
        limit = { has_variable = domcom_pref_breast_fullness_tenths }
        if = { limit = { has_global_variable = domcom_metric_units } add = { value = var:domcom_pref_breast_fullness_tenths multiply = 0.508 round = yes divide = 2 } }
        else = { add = { value = var:domcom_pref_breast_fullness_tenths divide = 10 } }
    }
}

# Attraction distance: fullness is the primary preference, frame/underbust is secondary.
domcom_breast_pref_fullness_delta_value = {
    value = var:domcom_pref_breast_fullness_tenths
    subtract = scope:domcom_compatibility_target.var:domcom_breast_fullness_tenths
}
domcom_breast_pref_fullness_distance_value = {
    value = domcom_breast_pref_fullness_delta_value
    if = { limit = { domcom_breast_pref_fullness_delta_value < 0 } multiply = -1 }
}
domcom_breast_pref_frame_delta_value = {
    value = var:domcom_pref_underbust_tenths
    subtract = scope:domcom_compatibility_target.var:domcom_underbust_tenths
}
domcom_breast_pref_frame_distance_value = {
    value = domcom_breast_pref_frame_delta_value
    if = { limit = { domcom_breast_pref_frame_delta_value < 0 } multiply = -1 }
}
domcom_breast_pref_weighted_distance_value = {
    value = 0
    add = { value = domcom_breast_pref_fullness_distance_value multiply = 0.75 }
    add = { value = domcom_breast_pref_frame_distance_value multiply = 0.25 }
}
domcom_breast_preference_match_value = {
    value = 0
    if = {
        limit = {
            has_variable = domcom_pref_breast_fullness_tenths
            has_variable = domcom_pref_underbust_tenths
            scope:domcom_compatibility_target = {
                is_female = yes age >= 18
                has_variable = domcom_breast_fullness_tenths
                has_variable = domcom_underbust_tenths
            }
        }
        if = { limit = { domcom_breast_pref_weighted_distance_value <= 3 } add = 12 }
        else_if = { limit = { domcom_breast_pref_weighted_distance_value <= 8 } add = 8 }
        else_if = { limit = { domcom_breast_pref_weighted_distance_value <= 15 } add = 4 }
        else_if = { limit = { domcom_breast_pref_weighted_distance_value <= 25 } add = 0 }
        else_if = { limit = { domcom_breast_pref_weighted_distance_value <= 40 } add = -4 }
        else = { add = -8 }
    }
}

# Registry sorting helpers.
domcom_sort_breast_fullness_value = {
    value = 0
    if = { limit = { has_variable = domcom_breast_fullness_tenths } add = var:domcom_breast_fullness_tenths }
    if = { limit = { has_variable = domcom_sort_seed } add = { value = var:domcom_sort_seed divide = 100000 } }
}
domcom_sort_bust_value = {
    value = 0
    if = { limit = { has_variable = domcom_bust_tenths } add = var:domcom_bust_tenths }
    if = { limit = { has_variable = domcom_sort_seed } add = { value = var:domcom_sort_seed divide = 100000 } }
}
domcom_sort_underbust_value = {
    value = 0
    if = { limit = { has_variable = domcom_underbust_tenths } add = var:domcom_underbust_tenths }
    if = { limit = { has_variable = domcom_sort_seed } add = { value = var:domcom_sort_seed divide = 100000 } }
}
domcom_sort_pref_breast_fullness_value = {
    value = 0
    if = { limit = { has_variable = domcom_pref_breast_fullness_tenths } add = var:domcom_pref_breast_fullness_tenths }
    if = { limit = { has_variable = domcom_sort_seed } add = { value = var:domcom_sort_seed divide = 100000 } }
}
domcom_sort_pref_breast_frame_value = {
    value = 0
    if = { limit = { has_variable = domcom_pref_underbust_tenths } add = var:domcom_pref_underbust_tenths }
    if = { limit = { has_variable = domcom_sort_seed } add = { value = var:domcom_sort_seed divide = 100000 } }
}
domcom_sort_pref_breast_both_value = {
    value = 0
    if = { limit = { has_variable = domcom_pref_breast_fullness_tenths } add = { value = var:domcom_pref_breast_fullness_tenths multiply = 0.75 } }
    if = { limit = { has_variable = domcom_pref_underbust_tenths } add = { value = var:domcom_pref_underbust_tenths multiply = 0.25 } }
    if = { limit = { has_variable = domcom_sort_seed } add = { value = var:domcom_sort_seed divide = 100000 } }
}


# Breast Mastery UI/sort helpers.
domcom_breast_mastery_xp_value = {
    value = 0
    if = { limit = { exists = root has_variable = domcom_breast_mastery_xp } add = var:domcom_breast_mastery_xp }
    min = 0
    max = 64
}

domcom_sort_breast_mastery_value = {
    value = 0
    if = { limit = { has_variable = domcom_breast_mastery_xp } add = var:domcom_breast_mastery_xp }
    if = { limit = { has_variable = domcom_sort_seed } add = { value = var:domcom_sort_seed divide = 100000 } }
}
