﻿# 2.6.21 — dense procurement + visible workforce service economy.
# Ownership is still never moved AI-to-AI by a background list traversal. AI rulers obtain
# new stock through CSR's native foreign-slave event and enslave prisoners through CSR's
# native interaction. Procurement cadence is rank-scaled and protected by per-ruler cooldowns.

monthly_playable_pulse = {
    on_actions = {
        delay = { days = { 1 28 } }
        domcom_csr_living_market_monthly
    }
}

# Monthly work is limited to existing slave owners: service income/contracts and the 90-day workforce
# organizer. AI procurement was separated below because its candidate-availability trigger contains a
# wide any_ruler search and did not need to be evaluated twelve times per year.
domcom_csr_living_market_monthly = {
    trigger = { is_alive = yes carnx_is_slave_owner_trigger = yes }
    effect = {
        if = {
            limit = { is_ai = yes NOT = { has_character_flag = domcom_csr_workforce_organize_recent } }
            domcom_csr_assign_best_slave_roles_core_effect = yes
            add_character_flag = { flag = domcom_csr_workforce_organize_recent days = 90 }
        }
        domcom_csr_process_slave_services_effect = yes
    }
}

# Procurement is a growth/stocking system, not a monthly accounting system. A quarterly stagger keeps
# AI households replenishing while cutting its global seller/template availability search by ~75%.
quarterly_playable_pulse = {
    on_actions = {
        delay = { days = { 1 80 } }
        domcom_csr_living_market_procurement_quarterly
    }
}

domcom_csr_living_market_procurement_quarterly = {
    trigger = { domcom_csr_can_run_household_procurement_trigger = yes }
    effect = { domcom_csr_safe_household_procurement_effect = yes }
}

# Legacy yearly workforce hook retained as a no-op for old queued references. AI workforce organization
# already runs behind a 90-day owner cooldown in the monthly market pulse, so the yearly duplicate only
# repeated the same slave-role traversal.
yearly_playable_pulse = {
    on_actions = { domcom_csr_living_market_yearly }
}

domcom_csr_living_market_yearly = {
    trigger = { always = no }
}
