﻿# 2.6.20 — safe AI household procurement target.
# This never transfers an existing slave relation directly. It only decides whether a ruler
# is below the household size at which Living Market should ask CSR's own foreign-slave event
# to offer candidates. War no longer blocks procurement; a ruler who is still below target can
# continue receiving opportunities while campaigning.

domcom_csr_needs_household_procurement_trigger = {
    OR = {
        AND = {
            highest_held_title_tier >= tier_empire
            NOT = { any_relation = { type = slave count >= 10 } }
        }
        AND = {
            highest_held_title_tier = tier_kingdom
            NOT = { any_relation = { type = slave count >= 8 } }
        }
        AND = {
            highest_held_title_tier = tier_duchy
            NOT = { any_relation = { type = slave count >= 4 } }
        }
    }
}

domcom_csr_can_run_household_procurement_trigger = {
    is_ai = yes
    is_alive = yes
    NOT = { has_game_rule = carn_slavery_content_disabled }
    is_landed_or_landless_administrative = yes
    highest_held_title_tier >= tier_duchy
    carnx_can_be_slave_owner_trigger = yes
    exists = capital_province
    NOT = { carnx_is_slavery_always_crime_trigger = yes }
    NOT = { carnx_is_slavery_always_forbidden_trigger = { ACTION = flag:buy } }
    NOT = { has_variable = carnx_1000_refused_recently }
    NOT = { has_character_flag = domcom_csr_household_procurement_recent }
    short_term_gold > minor_gold_value
    domcom_csr_needs_household_procurement_trigger = yes
}
