﻿je_warlord_china = {
	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	group = je_group_historical_content

	immediate = {
		random_law = {
			limit = { type = law_type:law_monarchy }
			save_scope_as = monarchy_scope
		}
	}

	complete = {
		custom_tooltip = {
			text = won_boxer_tt
			has_variable = won_boxer_rebellion
		}
		custom_tooltip = {
			text = china_recognized_tt
			has_variable = china_warlord_explosion_recognized
		}
		custom_tooltip = {
			text = china_abolished_monarchy_tt
			has_variable = china_warlord_abolished_monarchy
		}
	}

	fail = {
		custom_tooltip = {
			text = je_china_failure_tt
			var:china_warlord_explosion <= 0
		}
	}

	on_fail = {
		trigger_event = { id = warlord_china_events.100 }
	}

	on_complete = {
		trigger_event = { id = warlord_china_events.200 }
	}

	current_value = {
		value = var:china_warlord_explosion
	}

	goal_add_value = {
		add = 5
	}
	
	progressbar = yes

	on_weekly_pulse = {
		effect = {
			if = {
				limit = {
					NOT = { has_variable = china_warlord_explosion_subject }
					is_subject = yes
				}
				chi_remove_1_fragile_unity = yes
				set_variable = china_warlord_explosion_subject
			}
			if = {
				limit = {
					NOT = { has_variable = china_warlord_explosion_loans }
					taking_loans = yes
				}
				chi_remove_1_fragile_unity = yes
				set_variable = china_warlord_explosion_loans
			}
			if = {
				limit = {
					NOT = { has_variable = china_warlord_explosion_recognized }
					country_rank != rank_value:unrecognized_power
					country_rank != rank_value:unrecognized_major_power
					country_rank != rank_value:unrecognized_regional_power
				}
				set_variable = china_warlord_explosion_recognized
				chi_add_1_fragile_unity = yes
			}
			if = {
				limit = {
					NOT = { has_variable = china_abolished_monarchy }
					NOT = { has_law = law_type:law_monarchy }
				}
				set_variable = china_abolished_monarchy
				chi_remove_1_fragile_unity = yes
				if = {
					limit = {
						NOT = { has_variable = china_han_empire }
					}
					trigger_event = { id = boxer_rebellion_events.4 days = 0 popup = yes }
				}
			}
		}
	}

	weight = 10000
	should_be_pinned_by_default = yes
}
