# Comprehensive Sandbox Control - confirmation events for disruptive actions
add_namespace = csc_confirmation

# csc_confirmation.1 - State Action Confirmation
country_event = {
	id = csc_confirmation.1
	title = csc_confirmation.1.t
	desc = csc_confirmation.1.d
	picture = GFX_report_event_generic_sign_treaty

	is_triggered_only = yes

	option = {
		name = csc_confirmation_confirm
		# State Transfer
		if = {
			limit = {
				has_country_flag = csc_pending_action_transfer_owner
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_transfer_owner = yes
			}
		}
		# Control Transfer
		if = {
			limit = {
				has_country_flag = csc_pending_action_transfer_controller
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_transfer_controller = yes
			}
		}
		# Add Core
		if = {
			limit = {
				has_country_flag = csc_pending_action_add_core
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_add_core = yes
			}
		}
		# Remove Core
		if = {
			limit = {
				has_country_flag = csc_pending_action_remove_core
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_remove_core = yes
			}
		}
		# Add Claim
		if = {
			limit = {
				has_country_flag = csc_pending_action_add_claim
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_add_claim = yes
			}
		}
		# Remove Claim
		if = {
			limit = {
				has_country_flag = csc_pending_action_remove_claim
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_remove_claim = yes
			}
		}
		# Move Capital
		if = {
			limit = {
				has_country_flag = csc_pending_action_move_capital
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_move_capital = yes
			}
		}
		# Add Build Slots
		if = {
			limit = {
				has_country_flag = csc_pending_action_build_slots
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_build_slots = yes
			}
		}
		# Repair Buildings
		if = {
			limit = {
				has_country_flag = csc_pending_action_repair_buildings
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_repair_buildings = yes
			}
		}
		# Give Resource Rights
		if = {
			limit = {
				has_country_flag = csc_pending_action_give_resource_rights
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_give_resource_rights = yes
			}
		}
		# Remove Resource Rights
		if = {
			limit = {
				has_country_flag = csc_pending_action_remove_resource_rights
			}
			event_target:csc_pending_target_state = {
				csc_effect_state_remove_resource_rights = yes
			}
		}

		# Clear pending flags
		clr_country_flag = csc_pending_action_transfer_owner
		clr_country_flag = csc_pending_action_transfer_controller
		clr_country_flag = csc_pending_action_add_core
		clr_country_flag = csc_pending_action_remove_core
		clr_country_flag = csc_pending_action_add_claim
		clr_country_flag = csc_pending_action_remove_claim
		clr_country_flag = csc_pending_action_move_capital
		clr_country_flag = csc_pending_action_build_slots
		clr_country_flag = csc_pending_action_repair_buildings
		clr_country_flag = csc_pending_action_give_resource_rights
		clr_country_flag = csc_pending_action_remove_resource_rights
		clr_country_flag = csc_confirmation_pending
	}

	option = {
		name = csc_confirmation_cancel
		# Clear pending flags
		clr_country_flag = csc_pending_action_transfer_owner
		clr_country_flag = csc_pending_action_transfer_controller
		clr_country_flag = csc_pending_action_add_core
		clr_country_flag = csc_pending_action_remove_core
		clr_country_flag = csc_pending_action_add_claim
		clr_country_flag = csc_pending_action_remove_claim
		clr_country_flag = csc_pending_action_move_capital
		clr_country_flag = csc_pending_action_build_slots
		clr_country_flag = csc_pending_action_repair_buildings
		clr_country_flag = csc_pending_action_give_resource_rights
		clr_country_flag = csc_pending_action_remove_resource_rights
		clr_country_flag = csc_confirmation_pending
	}
}

# csc_confirmation.3 - Bulk Marked-State Transfer Confirmation
country_event = {
	id = csc_confirmation.3
	title = csc_confirmation.3.t
	desc = csc_confirmation.3.d
	picture = GFX_report_event_generic_sign_treaty

	is_triggered_only = yes

	option = {
		name = csc_confirmation_confirm
		csc_effect_state_transfer_marked = yes
		clr_country_flag = csc_confirmation_pending
	}

	option = {
		name = csc_confirmation_cancel
		clr_country_flag = csc_confirmation_pending
	}
}

# csc_confirmation.2 - Country Action Confirmation
country_event = {
	id = csc_confirmation.2
	title = csc_confirmation.2.t
	desc = csc_confirmation.2.d
	picture = GFX_report_event_generic_sign_treaty

	is_triggered_only = yes

	option = {
		name = csc_confirmation_confirm
		# Check if co-op consent is required for the target country
		if = {
			limit = {
				event_target:csc_pending_target_country = {
					csc_consent_required = yes
				}
			}
			# Cooperative Consent Mode - send request to target country
			save_global_event_target_as = csc_pending_actor_country
			event_target:csc_pending_target_country = {
				country_event = { id = csc_consent.1 }
			}
			set_country_flag = csc_consent_request_pending
			clr_country_flag = csc_confirmation_pending
		}
		else = {
			# Direct execution
			# Annex Target
			if = {
				limit = {
					has_country_flag = csc_pending_action_annex
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_annex = yes
				}
			}
			# Puppet Target
			if = {
				limit = {
					has_country_flag = csc_pending_action_puppet
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_puppet = yes
				}
			}
			# Release Subject
			if = {
				limit = {
					has_country_flag = csc_pending_action_release_subject
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_release_subject = yes
				}
			}
			# Grant Independence
			if = {
				limit = {
					has_country_flag = csc_pending_action_grant_independence
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_grant_independence = yes
				}
			}
			# Set Autonomy
			if = {
				limit = {
					has_country_flag = csc_pending_action_set_autonomy
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_set_autonomy = yes
				}
			}
			# White Peace
			if = {
				limit = {
					has_country_flag = csc_pending_action_white_peace
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_white_peace = yes
				}
			}
			# Faction Invite
			if = {
				limit = {
					has_country_flag = csc_pending_action_faction_invite
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_faction_invite = yes
				}
			}
			# Faction Remove
			if = {
				limit = {
					has_country_flag = csc_pending_action_faction_remove
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_faction_remove = yes
				}
			}
			# Leave Faction
			if = {
				limit = {
					has_country_flag = csc_pending_action_leave_faction
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_leave_faction = yes
				}
			}
			# Create Faction
			if = {
				limit = {
					has_country_flag = csc_pending_action_create_faction
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_create_faction = yes
				}
			}
			# Dismantle Faction
			if = {
				limit = {
					has_country_flag = csc_pending_action_dismantle_faction
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_dismantle_faction = yes
				}
			}
			# Set Faction Leader
			if = {
				limit = {
					has_country_flag = csc_pending_action_set_faction_leader
				}
				event_target:csc_pending_target_country = {
					csc_effect_country_set_faction_leader = yes
				}
			}

			# Clear pending flags
			clr_country_flag = csc_pending_action_annex
			clr_country_flag = csc_pending_action_puppet
			clr_country_flag = csc_pending_action_release_subject
			clr_country_flag = csc_pending_action_grant_independence
			clr_country_flag = csc_pending_action_set_autonomy
			clr_country_flag = csc_pending_action_white_peace
			clr_country_flag = csc_pending_action_faction_invite
			clr_country_flag = csc_pending_action_faction_remove
			clr_country_flag = csc_pending_action_leave_faction
			clr_country_flag = csc_pending_action_create_faction
			clr_country_flag = csc_pending_action_dismantle_faction
			clr_country_flag = csc_pending_action_set_faction_leader
			clr_country_flag = csc_confirmation_pending
		}
	}

	option = {
		name = csc_confirmation_cancel
		# Clear pending flags
		clr_country_flag = csc_pending_action_annex
		clr_country_flag = csc_pending_action_puppet
		clr_country_flag = csc_pending_action_release_subject
		clr_country_flag = csc_pending_action_grant_independence
		clr_country_flag = csc_pending_action_set_autonomy
		clr_country_flag = csc_pending_action_white_peace
		clr_country_flag = csc_pending_action_faction_invite
		clr_country_flag = csc_pending_action_faction_remove
		clr_country_flag = csc_pending_action_leave_faction
		clr_country_flag = csc_pending_action_create_faction
		clr_country_flag = csc_pending_action_dismantle_faction
		clr_country_flag = csc_pending_action_set_faction_leader
		clr_country_flag = csc_confirmation_pending
	}
}
