﻿INJECT:je_meiji_restoration_proclaim_imperial_restoration = {
	ai_chance = {
		value = 1
		if = {
			limit = {
				any_political_movement = {
					is_political_movement_type = movement_meiji_restorationist
					political_movement_radicalism > define:NPolitics|RADICALISM_PROTESTING_THRESHOLD
				}
			}
			add = 5
		}
		else_if = {
			limit = {
				any_political_movement = {
					is_political_movement_type = movement_meiji_restorationist
					political_movement_radicalism > define:NPolitics|RADICALISM_MILITANT_THRESHOLD
				}
			}
			add = 25
		}
		add = { # -15 to 5
			value = government_legitimacy
			subtract = 75
			divide = 5
		}
		if = {
			limit = {
				has_variable = kogi_yoron
				ruler ?= {
					OR = {
						has_ideology = ideology:ideology_modernizer_leader
						has_ideology = ideology:ideology_mitogaku
					}
				}
			}
			add = 10
		}
		if = {
			limit = {
				has_variable = kobu_gattai
				NOT = {
					has_variable = japan_completed_imperial_marriage
				}
			}
			# KAI: This route leads to passing Closed Borders to calm the Sonno Joi movement
			# Don't hit the panic button too early
			add = -100
		}
	}
}

INJECT:je_meiji_restoration_decide_shogunate_strategy = {
	ai_chance = {
		value = -5
		if = {
			limit = {
				any_political_movement = {
					is_political_movement_type = movement_meiji_restorationist
				}
			}
			every_political_movement = {
				limit = {
					is_political_movement_type = movement_meiji_restorationist
				}
				add = {
					value = this.political_movement_radicalism
					# KAI: Radicalism goes from 0 to 1
					# Vanilla dividing it by 5 is most certainly a mistake
					divide = 0.05
				}
			}
		}
		if = {
			limit = {
				ruler ?= {
					OR = {
						has_ideology = ideology:ideology_modernizer_leader
						has_ideology = ideology:ideology_mitogaku
					}
				}
			}
			add = 25
		}
		else_if = {
			limit = {
				ruler ?= {
					NOT = {
						has_ideology = ideology:ideology_traditionalist
					}
				}
			}
			add = 10
		}
		# KAI: Failing The Imperial Marriage JE automatically sets the reform strategy to Taikunate
		# There is no need to change strategy afterwards, since Kobu Gattai would be impossible
		if = {
			limit = {
				has_variable = je_meiji_restoration_imperial_marriage_var
			}
			add = -1000
		}
	}
}
