namespace = Plus

# reserved: Plus.700 to Plus.729

#######################################
# JEWISH EVENTS
#######################################

# Jewish community grows
character_event = {
	id = Plus.700 # formerly 1000182984
	desc = EVTDESC_Plus_700
	picture = GFX_evt_market

	is_triggered_only = yes # on_decade_pulse, random_events

	only_rulers = yes
	war = no

	trigger = {
		any_demesne_province = {
			owned_by = PREV

			any_province_holding = {
				has_building = ct_jewish_community_1
			}

			trigger_if = {
				limit = { any_province_holding = { has_building = ct_jewish_community_3 } }
				ROOT = { ai = yes }
			}

			NOT = { has_province_modifier = brm_revolt }

			trigger_if = {
				limit = { has_dlc = "Reapers" }

				OR = {
					has_province_modifier = prosperity_modifier_1
					has_province_modifier = prosperity_modifier_2
					has_province_modifier = prosperity_modifier_3
				}
			}
			trigger_else = {
				OR = {
					has_province_modifier = province_prosperity_1
					has_province_modifier = province_prosperity_2
				}
			}
		}

		OR = {
			is_playable = yes

			NOT = {
				liege = {
					has_character_flag = pogrom
					has_character_modifier = expelled_jews_timer
				}
			}
		}

		NOR = {
			has_character_flag = pogrom
			has_character_modifier = expelled_jews_timer
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.5

			trigger_if = {
				limit = { is_playable = yes }
				trait = zealous
			}
			trigger_else = {
				liege = { trait = zealous }
			}
		}

		mult_modifier = {
			factor = 0.67

			trigger_if = {
				limit = { is_playable = yes }
				trait = cruel
			}
			trigger_else = {
				liege = { trait = cruel }
			}
		}

		mult_modifier = {
			factor = 0.67

			trigger_if = {
				limit = { is_playable = yes }
				trait = arbitrary
			}
			trigger_else = {
				liege = { trait = arbitrary }
			}
		}

		mult_modifier = {
			factor = 1.33

			trigger_if = {
				limit = { is_playable = yes }
				trait = just
			}
			trigger_else = {
				liege = { trait = just }
			}
		}

		mult_modifier = {
			factor = 1.33

			trigger_if = {
				limit = { is_playable = yes }
				trait = charitable
			}
			trigger_else = {
				liege = { trait = charitable }
			}
		}

		mult_modifier = {
			factor = 0.67

			any_demesne_province = {
				owned_by = PREV

				any_province_holding = {
					has_building = ct_jewish_community_2
				}
			}
		}

		mult_modifier = {
			factor = 0.67

			any_demesne_province = {
				owned_by = PREV

				any_province_holding = {
					has_building = ct_jewish_community_3
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			any_demesne_province = {
				owned_by = PREV

				trigger_if = {
					limit = { has_dlc = "Reapers" }

					OR = {
						has_province_modifier = prosperity_modifier_2
						has_province_modifier = prosperity_modifier_3
					}
				}
				trigger_else = {
					has_province_modifier = province_prosperity_2
				}

				any_province_holding = {
					has_building = ct_jewish_community_1
				}
			}
		}
	}

	option = {
		name = EXCELLENT

		random_demesne_title = {
			show_scope_change = no

			limit = {
				real_tier = baron
				has_building = ct_jewish_community_1

				trigger_if = {
					limit = { has_building = ct_jewish_community_3 }
					ROOT = { ai = yes }
				}

				location = {
					NOT = { has_province_modifier = brm_revolt }

					OR = {
						has_province_modifier = province_prosperity_1
						has_province_modifier = province_prosperity_2
						has_dlc = "Reapers"
					}
				}
			}

			if = {
				limit = { has_building = ct_jewish_community_3 }

				hidden_effect = {
					change_variable = {
						which = global_jewish_refugees
						value = 1
					}
				}
			}
			else_if = {
				limit = { has_building = ct_jewish_community_2 }

				add_building = ct_jewish_community_3

				hidden_effect = {
					ROOT = {
						if = {
							limit = {
								real_tier = BARON
								demesne_size < 2
							}

							liege = {
								letter_event = {
									id = Plus.702
									days = 3
								}
							}
						}
					}
				}
			}
			else_if = {
				limit = { has_building = ct_jewish_community_1 }

				add_building = ct_jewish_community_2

				hidden_effect = {
					ROOT = {
						if = {
							limit = {
								real_tier = BARON
								demesne_size < 2
							}

							liege = {
								letter_event = {
									id = Plus.701
									days = 3
								}
							}
						}
					}
				}
			}
		}
	}
}

# Liege informed that jewish community has grown
letter_event = {
	id = Plus.701
	desc = EVTDESC_Plus_701

	is_triggered_only = yes

	ai = no

	option = {
		name = EXCELLENT

		tooltip = {
			FROM = {
				show_scope_change = no

				capital_holding = {
					show_scope_change = no

					add_building = ct_jewish_community_2
				}
			}
		}
	}
}

# Liege informed that jewish community has grown
letter_event = {
	id = Plus.702
	desc = EVTDESC_Plus_701

	is_triggered_only = yes

	ai = no

	option = {
		name = EXCELLENT

		tooltip = {
			FROM = {
				show_scope_change = no

				capital_holding = {
					show_scope_change = no

					add_building = ct_jewish_community_3
				}
			}
		}
	}
}

# Jewish courtier
character_event = {
	id = Plus.703 #formerly 1000182987
	picture = GFX_evt_emissary
	desc = EVTDESC_Plus_703

	is_triggered_only = yes

	only_rulers = yes
	war = no

	trigger = {
		any_demesne_province = {
			owned_by = PREV

			any_province_holding = {
				has_building = ct_jewish_community_1
			}
		}

		NAND = {
			real_tier = BARON

			liege = {
				has_character_flag = pogrom
				has_character_modifier = expelled_jews_timer
			}
		}

		NOR = {
			has_character_flag = pogrom
			has_character_modifier = expelled_jews_timer
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.5

			trigger_if = {
				limit = { is_playable = yes }
				trait = zealous
			}
			trigger_else = {
				liege = { trait = zealous }
			}
		}

		mult_modifier = {
			factor = 0.67

			trigger_if = {
				limit = { is_playable = yes }
				trait = cruel
			}
			trigger_else = {
				liege = { trait = cruel }
			}
		}

		mult_modifier = {
			factor = 0.67

			trigger_if = {
				limit = { is_playable = yes }
				trait = arbitrary
			}
			trigger_else = {
				liege = { trait = arbitrary }
			}
		}

		mult_modifier = {
			factor = 1.33

			trigger_if = {
				limit = { is_playable = yes }
				trait = just
			}
			trigger_else = {
				liege = { trait = just }
			}
		}

		mult_modifier = {
			factor = 1.33

			trigger_if = {
				limit = { is_playable = yes }
				trait = charitable
			}
			trigger_else = {
				liege = { trait = charitable }
			}
		}

		mult_modifier = {
			factor = 1.5

			any_demesne_province = {
				owned_by = PREV

				any_province_holding = {
					has_building = ct_jewish_community_2
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			any_demesne_province = {
				owned_by = PREV

				any_province_holding = {
					has_building = ct_jewish_community_3
				}
			}
		}
	}

	option = {
		name = OK

		# TODO: Change to check for regions instead of culture?
		if = {
			limit = {
				OR = {
					culture = levantine_arabic
					culture = bedouin_arabic
					culture = egyptian_arabic
					culture_group = altaic
					culture_group = iranian
					culture_group = east_african
				}
			}

			create_character = {
				random_traits = yes
				dynasty = random
				religion = jewish
				culture = mizrahim
				female = no
			}

			new_character = {
				set_character_flag = jewish_advisor

				random = {
					chance = 50

					create_character = {
						random_traits = yes
						dynasty = random
						religion = jewish
						culture = mizrahim
						female = yes
					}

					new_character = {
						set_character_flag = jewish_advisor
						add_spouse = PREV
					}
				}
			}
		}
		else_if = {
			limit = {
				OR = {
					culture = andalusian_arabic
					culture = maghreb_arabic
					culture = sicilian_arabic
					culture_group = west_african
					culture_group = central_african
				}
			}

			create_character = {
				random_traits = yes
				dynasty = random
				religion = jewish
				culture = sephardi
				female = no
			}

			new_character = {
				set_character_flag = jewish_advisor

				random = {
					chance = 50
					create_character = {
						random_traits = yes
						dynasty = random
						religion = jewish
						culture = sephardi
						female = yes
					}
					new_character = {
						set_character_flag = jewish_advisor
						add_spouse = PREV
					}
				}
			}
		}
		else = {
			create_character = {
				random_traits = yes
				dynasty = random
				religion = jewish
				culture = ashkenazi
				female = no
			}

			new_character = {
				set_character_flag = jewish_advisor

				random = {
					chance = 50

					create_character = {
						random_traits = yes
						dynasty = random
						religion = jewish
						culture = ashkenazi
						female = yes
					}

					new_character = {
						set_character_flag = jewish_advisor
						add_spouse = PREV
					}
				}
			}
		}

		hidden_effect = {
			if = {
				limit = { real_tier = BARON }

				liege = {
					ROOT = {
						any_courtier = {
							limit = { has_character_flag = jewish_advisor }
							clr_character_flag = jewish_advisor
							banish = PREVPREV
						}
					}
				}
			}

			any_courtier = {
				limit = { has_character_flag = jewish_advisor }
				clr_character_flag = jewish_advisor
			}
		}
	}
}

# Jewish refugees wish to settle in your holding
character_event = {
	id = Plus.704 # formerly 1000182988
	desc = EVTDESC_Plus_704
	picture = GFX_evt_emissary

	is_triggered_only = yes

	only_playable = yes
	war = no

	trigger = {
		OR = {
			religion_group = christian
			religion_group = muslim
			religion_group = pagan_group
		}

		check_variable = {
			which = global_jewish_refugees
			value >= 0
		}

		OR = {
			any_demesne_province = {
				owned_by = PREV

				any_province_holding = {
					has_building = ct_wall_1
					NOT = { has_building = ct_jewish_community_3 }
				}
			}

			any_vassal = {
				real_tier = BARON
				is_patrician = no

				any_demesne_province = {
					owned_by = PREV

					any_province_holding = {
						has_building = ct_wall_1
						NOT = { has_building = ct_jewish_community_3 }
					}
				}
			}
		}

		NOR = {
			any_liege = {
				has_character_flag = pogrom
				has_character_modifier = expelled_jews_timer
			}

			has_character_flag = jews_not_welcome
			has_character_flag = pogrom
			has_character_modifier = expelled_jews_timer
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.5
			liege = { trait = zealous }
		}

		mult_modifier = {
			factor = 0.67
			liege = { trait = cruel }
		}

		mult_modifier = {
			factor = 0.67
			liege = { trait = arbitrary }
		}

		mult_modifier = {
			factor = 1.33
			liege = { trait = just }
		}

		mult_modifier = {
			factor = 1.33
			liege = { trait = charitable }
		}

		mult_modifier = {
			factor = 1.33
			religion_group = muslim
		}

		mult_modifier = {
			factor = 0.67
			religion_group = pagan_group
		}

		mult_modifier = {
			factor = 0.5

			OR = {
				religion = orthodox
				religion = chalcedonian
			}
		}

		mult_modifier = {
			factor = 0.1

			OR = {
				culture_group = north_germanic
				culture_group = celtic
				culture_group = finno_ugric
				culture_group = west_african
				culture_group = central_african
			}
		}

		mult_modifier = {
			factor = 0.2

			OR = {
				culture_group = byzantine
				culture_group = baltic
				culture_group = south_slavic
				culture_group = east_african
			}
		}

		mult_modifier = {
			factor = 0.5

			OR = {
				culture_group = west_germanic
				culture_group = altaic
				culture_group = east_slavic
				culture_group = magyar
			}
		}

		mult_modifier = {
			factor = 0.33
			real_tier = COUNT
		}

		mult_modifier = {
			factor = 0.5
			real_tier = DUKE
		}

		mult_modifier = {
			factor = 1.33
			real_tier = EMPEROR
		}

		mult_modifier = {
			factor = 1.5

			OR = {
				any_demesne_province = {
					owned_by = PREV

					any_province_holding = {
						has_building = ct_jewish_community_1
					}
				}

				any_vassal = {
					real_tier = BARON
					is_patrician = no

					any_demesne_province = {
						owned_by = PREV

						any_province_holding = {
							has_building = ct_jewish_community_1
						}
					}
				}
			}
		}
	}

	immediate = {
		change_variable = {
			which = global_jewish_refugees
			value = -1
		}
	}

	option = {
		name = EVTOPTA_Plus_704 # They are welcome

		if = {
			limit = { trait = zealous }
			remove_trait = zealous
		}

		if = {
			limit = {
				any_demesne_title = {
					real_tier = BARON
					has_building = ct_wall_1
					NOT = { has_building = ct_jewish_community_3 }
				}
			}

			random_demesne_title = {
				show_scope_change = no

				limit = {
					real_tier = BARON
					has_building = ct_wall_1
					NOT = { has_building = ct_jewish_community_3 }
				}

				if = {
					limit = { has_building = ct_jewish_community_2 }
					add_building = ct_jewish_community_3
				}
				else_if = {
					limit = { has_building = ct_jewish_community_1 }
					add_building = ct_jewish_community_2
				}
				else = {
					add_building = ct_jewish_community_1
				}
			}
		}
		else = {
			random_vassal = {
				show_scope_change = no

				limit = {
					real_tier = BARON
					is_patrician = no

					any_demesne_title = {
						real_tier = BARON
						has_building = ct_wall_1
						NOT = { has_building = ct_jewish_community_3 }
					}
				}

				random_demesne_title = {
					show_scope_change = no

					limit = {
						real_tier = BARON
						has_building = ct_wall_1
						NOT = { has_building = ct_jewish_community_3 }
					}

					if = {
						limit = { has_building = ct_jewish_community_2 }
						add_building = ct_jewish_community_3
					}
					else_if = {
						limit = { has_building = ct_jewish_community_1 }
						add_building = ct_jewish_community_2
					}
					else = {
						add_building = ct_jewish_community_1
					}
				}
			}
		}

		any_vassal = {
			show_scope_change = no

			limit = {
				is_republic = no

				NOR = {
					trait = charitable
					trait = just
					trait = kind
				}
			}

			if = {
				limit = { trait = zealous }

				opinion = {
					name = opinion_settled_jews
					who = ROOT
					years = 10
					multiplier = 2
				}
			}
			else = {
				opinion = {
					name = opinion_settled_jews
					who = ROOT
					years = 10
				}
			}
		}


		pf_tradition_minus2_effect = yes
		pf_prosperity_plus2_effect = yes

		ai_chance = {
			factor = 75

			mult_modifier = {
				factor = 0.66
				religion_group = christian
			}

			mult_modifier = {
				factor = 0.1
				trait = zealous
			}

			mult_modifier = {
				factor = 0.5
				trait = cruel
			}

			mult_modifier = {
				factor = 1.5
				trait = kind
			}

			mult_modifier = {
				factor = 2.0
				trait = charitable
			}
		}
	}

	option = {
		name = EVTOPTB_Plus_704 # Tell them to move on

		prestige = 10
		set_character_flag = jews_not_welcome

		hidden_effect = {
			random = {
				chance = 75

				change_variable = {
					which = global_jewish_refugees
					value = 1
				}
			}
		}

		pf_tradition_plus2_effect = yes

		ai_chance = { factor = 25 }
	}
}

# Vassal informed that liege wants jews expelled
character_event = {
	id = Plus.705 # formerly 1000182989
	desc = EVTDESC_Plus_705
	picture = GFX_evt_burning_house

	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_705 # Bow to his demands

		any_title_under = {
			show_scope_change = no

			limit = {
				real_tier = BARON
				has_building = ct_jewish_community_1
			}

			if = {
				limit = { has_building = ct_jewish_community_3 }

				remove_building = ct_jewish_community_3

				hidden_effect = {
					remove_building = ct_jewish_community_2
					remove_building = ct_jewish_community_1
					change_variable = { which = global_jewish_refugees value = 6 }
				}

				FROM = {
					show_scope_change = no

					piety = -30
					wealth = 150
				}
			}
			else_if = {
				limit = { has_building = ct_jewish_community_2 }

				remove_building = ct_jewish_community_2

				hidden_effect = {
					remove_building = ct_jewish_community_1
					change_variable = { which = global_jewish_refugees value = 4 }
				}

				FROM = {
					show_scope_change = no

					piety = -20
					wealth = 100
				}
			}
			else = {
				remove_building = ct_jewish_community_1

				hidden_effect = {
					change_variable = { which = global_jewish_refugees value = 2 }
				}

				FROM = {
					show_scope_change = no

					piety = -10
					wealth = 50
				}
			}
		}

		# TODO: Find nearby provinces with Jewish Communities and send them there as well as to Jewish realms
		any_realm_character = {
			show_scope_change = no
			limit = { religion_group = jewish }
			banish = yes
		}

		ai_chance = { factor = 100 }
	}

	option = {
		name = EVTOPTB_Plus_705 # Never!

		reverse_war = {
			target = FROM
			casus_belli = overthrow_ruler
		}

		ai_chance = { factor = 0 }
	}
}

# The Fast Begins
# Events similar to Ramadan but the feast happens before the fast, instead of after
# and Yom Kippur only lasts 25h, however for sanity reasons the events will be spread
# over a similar period as Ramadan and generally structured like Ramadan
character_event = {
	id = Plus.706
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_706
	picture = GFX_evt_bishop
	border =  GFX_event_normal_frame_religion

	is_triggered_only = yes

	only_playable = yes
	has_character_flag = planning_yom_kippur
	min_age = 16
	prisoner = no
	only_capable = yes
	war = no

	trigger = {
		# Yom Kippur happens typically in September or October however preperations must happen before
		month >= 8
		month < 10
		is_inaccessible_trigger = no
	}

	fail_trigger_effect = {
		# Try again later
		if = {
			limit = {
				has_character_flag = planning_yom_kippur
				is_playable = yes
			}

			repeat_event = {
				id = Plus.706
				months = 1
			}
		}
	}

	option = {
		name = EVTOPTA706

		clr_character_flag = planning_yom_kippur
		set_character_flag = yom_kippur

		add_character_modifier = {
			name = observed_yom_kippur
			days = 1900
		}

		hidden_effect = {
			add_character_modifier = {
				name = do_not_disturb
				days = 36
				hidden = yes
			}

			character_event = { id = Plus.728 days = 3 }				# Preparation Tombola
			character_event = { id = Plus.709 days = 19 }				# Gift for Wife
			character_event = { id = Plus.708 days = 21 }				# Feast Begins
			character_event = { id = Plus.729 days = 27 }				# Feast Tombola
			character_event = { id = Plus.707 days = 35 }				# Yom Kippur is over
		}
	}
}

# Preparation Tombola
character_event = {
	id = Plus.728

	is_triggered_only = yes
	hide_window = yes

	only_playable = yes
	has_character_flag = yom_kippur
	only_capable = yes
	prisoner = no

	immediate = {
		random_list = {
			10 = {
				trigger = {
					num_of_prisoners >= 1
					NOT = { has_character_flag = yom_kippur_prisoners }
				}

				character_event = { id = Plus.710 } # Release Prisoners
			}

			10 = {
				trigger = {
					scaled_wealth >= 0.20
					NOT = { has_character_flag = yom_kippur_charity }
				}

				character_event = { id = Plus.711 } # Alms to the Poor
			}

			10 = {
				trigger = {
					NOT = { has_character_flag = yom_kippur_prayers }
				}

				character_event = { id = Plus.712 } # Prayers
			}

			 4 = {
				trigger = {
					NOR = {
						trait = gluttonous
						trait = temperate
					}
				}

				character_event = { id = Plus.713 } # Gain Temperate
			}

			 4 = {
				trigger = {
					NOR = {
						trait = greedy
						trait = charitable
					}
				}

				character_event = { id = Plus.714 } # Gain Charitable
			}
		}

		repeat_event = {
			id = Plus.728 # Next event
			days = 7
		}
	}
}

# Yom Kippur Ends
character_event = {
	id = Plus.707
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_707
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	trigger = { has_character_flag = yom_kippur }

	option = {
		name = EVTOPTA88522 # Until Next Year

		pf_tradition_plus1_effect = yes
		remove_do_not_disturb_effect = yes
		clr_character_flag = yom_kippur
		clr_character_flag = yom_kippur_prisoners
		clr_character_flag = yom_kippur_charity
		clr_character_flag = yom_kippur_prayers
		clr_character_flag = yom_kippur_gluttonous
		clr_character_flag = yom_kippur_lustful_hedonist
		clr_character_flag = yom_kippur_greedy
		clr_character_flag = yom_kippur_cynical
	}
}

# Hold Feast
character_event = {
	id = Plus.708
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_708
	picture = GFX_evt_feast
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	has_character_flag = yom_kippur

	trigger = {
		num_of_vassals >= 1
		scaled_wealth >= 0.3
	}

	option = {
		name = EVTOPTA706

		scaled_wealth = -0.3

		any_vassal = {
			show_scope_change = no

			limit = {
				prisoner = no
				war = no
				has_regent = no
				is_inaccessible_trigger = no
			}

			letter_event = {
				id = Plus.719
				tooltip = EVTTOOLTIP72011
			}
		}

		character_event = {
			id = Plus.717
			days = 3
			tooltip = EVTTOOLTIP_PLUS_717
		}
	}

	option = {
		name = EVTOPTB88510
	}
}

# Gift for Wife
character_event = {
	id = Plus.709
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_709
	picture = GFX_evt_marriage
	border = GFX_event_normal_frame_religion

	has_character_flag = yom_kippur
	only_men = yes
	is_married = yes

	is_triggered_only = yes

	trigger = {
		NOT = {
			any_spouse = { is_main_spouse = no }
		}
	}

	option = {
		name = EVTOPTA88515

		scaled_wealth = -0.25

		reverse_opinion = {
			name = opinion_happy
			who = spouse
			years = 1
		}
	}

	option = {
		name = EVTOPTB88515

		reverse_opinion = {
			name = spouse_ignores_me
			who = spouse
			years = 1
		}
	}
}

# Release prisoners
character_event = {
	id = Plus.710
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC88501
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	only_playable = yes
	has_character_flag = yom_kippur
	min_age = 16
	prisoner = no
	only_capable = yes

	trigger = {
		num_of_prisoners >= 1
		NOT = { has_character_flag = yom_kippur_prisoners }
	}

	option = {
		name = EVTOPTA88501

		set_character_flag = yom_kippur_prisoners

		any_courtier = {
			show_scope_change = no
			limit = { prisoner = yes }
			imprison = no
		}

		piety = 5
	}

	option = {
		name = EVTOPTB88501

		set_character_flag = yom_kippur_prisoners
		piety = -5
	}
}

# Charity for the People
character_event = {
	id = Plus.711
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_711
	picture = GFX_evt_market
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	only_playable = yes
	has_character_flag = yom_kippur
	min_age = 16
	prisoner = no
	only_capable = yes

	trigger = {
		scaled_wealth >= 0.20
		NOT = { has_character_flag = yom_kippur_charity }
	}

	option = {
		name = EVTOPTA88502

		scaled_wealth = -0.20
		set_character_flag = yom_kippur_charity
		piety = 5
	}

	option = {
		name = EVTOPTB88502

		set_character_flag = yom_kippur_charity
		piety = -5
	}
}

# Prayers
character_event = {
	id = Plus.712
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_712
	picture = GFX_evt_monk
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	only_playable = yes
	has_character_flag = yom_kippur
	min_age = 16
	prisoner = no
	only_capable = yes

	trigger = {
		NOT = { has_character_flag = yom_kippur_prayers }
	}

	option = {
		name = EVTOPTA712

		set_character_flag = yom_kippur_prayers
		piety = 5
	}

	option = {
		name = EVTOPTB88503

		set_character_flag = yom_kippur_prayers
		piety = -5
	}
}

# Gain Temperate
character_event = {
	id = Plus.713
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_713
	picture = GFX_evt_monk
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	only_playable = yes
	has_character_flag = yom_kippur
	min_age = 16
	prisoner = no
	only_capable = yes

	trigger = {
		NOR = {
			trait = gluttonous
			trait = temperate
		}
	}

	option = {
		name = EVTOPTA88506

		add_trait = temperate
		piety = 5
	}
}

# Gain Charitable
character_event = {
	id = Plus.714
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_714
	picture = GFX_evt_monk
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	only_rulers = yes
	has_character_flag = yom_kippur
	min_age = 16
	prisoner = no
	only_capable = yes

	trigger = {
		NOR = {
			trait = greedy
			trait = charitable
		}
	}

	option = {
		name = EVTOPTA88507

		add_trait = charitable
		piety = 5
	}
}

# War interrupts Fast
character_event = {
	id = Plus.727

	is_triggered_only = yes # on_war_started
	hide_window = yes

	trigger = {
		OR = {
			ROOT = { has_character_flag = yom_kippur }
			FROM = { has_character_flag = yom_kippur }
		}
	}

	immediate = {
		ROOT = { character_event = { id = Plus.715 } }
		FROM = { character_event = { id = Plus.715 } }
	}
}

character_event = {
	id = Plus.715
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC88508
	picture = GFX_evt_moors
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	has_character_flag = yom_kippur

	option = {
		name = EVTOPTA88508

		character_event = {
			id = Plus.707
			days = 1
		}
	}
}

# Vassal Refuses Invitation
letter_event = {
	id = Plus.716
	desc = EVTDESC_Plus_716

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA88512
	}
}

# Host is told about Feast
character_event = {
	id = Plus.717
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_717
	picture = GFX_evt_feast

	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_4153

		any_vassal = {
			show_scope_change = no

			limit = { has_character_flag = attending_yom_kippur_feast }

			opinion = {
				name = opinion_impressed
				who = ROOT
				years = 1
			}
		}
	}
}

# Vassal is told about Feast
character_event = {
	id = Plus.718
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_718
	picture = GFX_evt_feast

	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_4153

		clr_character_flag = attending_yom_kippur_feast
	}
}

# Vassal Invited
letter_event = {
	id = Plus.719
	desc = EVTDESC_Plus_719

	is_triggered_only = yes

	trigger = { is_inaccessible_trigger = no }

	option = {
		name = EVTOPTA88511 # I am honored to accept

		character_event = {
			id = Plus.718
			days = 4
			tooltip = EVTTOOLTIP_PLUS_718
		}

		add_character_modifier = {
			name = do_not_disturb
			days = 5
			hidden = yes
		}

		set_character_flag = attending_yom_kippur_feast
		end_inaccessibility_effect = yes

		ai_chance = {
			factor = 1

			mult_modifier  = {
				factor = 0.1
				ai = yes
				is_inaccessible_trigger = yes
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = FROM
					value >= -40
				}
			}

			mult_modifier  = {
				factor = 2

				opinion = {
					who = FROM
					value >= -20
				}
			}
		}
	}

	option = {
		name = EVTOPTB88511 # No I have other plans

		FROM = {
			show_scope_change = no

			letter_event = {
				id = Plus.716 # Invited Rejected
				days = 1
				tooltip = EVTTOOLTIP88512
			}

			opinion = {
				name = opinion_disappointed
				who = ROOT
				years = 1
			}
		}

		ai_chance = {
			factor = 1

			trigger = {
				trigger_if = {
					limit = {
						opinion = {
							who = FROM
							value >= 0
						}

						is_inaccessible_trigger = yes
					}
				}
			}

			mult_modifier  = {
				factor = 2

				opinion = {
					who = FROM
					value < -60
				}
			}

			mult_modifier  = {
				factor = 2

				opinion = {
					who = FROM
					value < -80
				}
			}
		}
	}
}

# Feast Tombola
character_event = {
	id = Plus.729

	is_triggered_only = yes
	hide_window = yes

	only_playable = yes
	has_character_flag = yom_kippur
	only_capable = yes
	prisoner = no

	immediate = {
		random_list = {
			10 = {
				trigger = {
					trait = gluttonous
					NOT = { has_character_flag = yom_kippur_gluttonous }
				}

				character_event = { id = Plus.720 } # Gluttonous sin
			}

			10 = {
				trigger = {
					OR = {
						trait = lustful
						trait = hedonist
					}
				}

				character_event = { id = Plus.721 } # Lustful/Hedonist sin
			}

			10 = {
				trigger = {
					trait = drunkard
				}

				character_event = { id = Plus.722 } # Drunkard sin
			}

			 4 = {
				trigger = {
					trait = greedy
					NOT = { trait = just }
				}

				character_event = { id = Plus.723 } # Greedy sin
			}

			 4 = {
				trigger = {
					trait = cynical
				}

				character_event = { id = Plus.724 } # Cynical sin
			}
		}
	}
}

# Gluttonous Sin
character_event = {
	id = Plus.720
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC88517
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA88517

		piety = -5
	}
}

# Lustful/Hedonist Sin
character_event = {
	id = Plus.721
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC88518
	picture = GFX_evt_jugglers
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA88518

		piety = -5
	}
}

# Drunkard Sin
character_event = {
	id = Plus.722
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_722
	picture = GFX_evt_drunk
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA88519

		piety = -5
	}
}

# Greedy Sin
character_event = {
	id = Plus.723
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_723
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA88520

		piety = -5
		wealth = 5
	}
}

# Cynical Sin
character_event = {
	id = Plus.724
	title = YOM_KIPPUR_TITLE
	desc = EVTDESC_Plus_724
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA88521

		piety = -5
	}
}

# Province holder informed that jewish community has turned into a minority
character_event = {
	id = Plus.725
	desc = EVTDESC_Plus_725
	picture = GFX_evt_bishop

	is_triggered_only = yes
	hide_from = yes

	option = {
		name = EVTOPTAPlus_725 # Leave them be

		ai_chance = {
			factor = 25

			mult_modifier = {
				factor = 3
				trait = slothful
			}

			mult_modifier = {
				factor = 0.5
				trait = zealous
			}
		}

		piety = -10

		FROM = { # Origin Province
			show_scope_change = no

			random_province_holding = {
				show_scope_change = no

				limit = { holding_type = city }

				random_list = {
					50 = { add_building = ct_jewish_community_1 }
					25 = { add_building = ct_jewish_community_2 }
					15 = { add_building = ct_jewish_community_3 }

					10 = {  # The Jews find a new home
						custom_tooltip = {
							text = ctt_the_jews_leave

							random_list = {
								55 = { change_variable = { which = global_jewish_refugees value = 1 } }
								30 = { change_variable = { which = global_jewish_refugees value = 2 } }
								15 = { change_variable = { which = global_jewish_refugees value = 3 } }
							}
						}
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTBPlus_725 # Ease their concerns

		trigger = {
			OR = {
				trait = sympathy_judaism
				trait = kind
				trait = charitable
			}
		}

		FROM = { # Origin Province
			show_scope_change = no

			random_province_holding = {
				show_scope_change = no

				limit = { holding_type = city }

				random_list = {
					55 = { add_building = ct_jewish_community_1 }
					30 = { add_building = ct_jewish_community_2 }
					15 = { add_building = ct_jewish_community_3 }
				}
			}
		}

		ai_chance = { factor = 50 }
	}

	option = {
		name = EVTOPTCPlus_725 # Threaten the rest out

		custom_tooltip = {
			text = ctt_the_jews_leave

			random_list = {
				55 = { change_variable = { which = global_jewish_refugees value = 1 } }
				30 = { change_variable = { which = global_jewish_refugees value = 2 } }
				15 = { change_variable = { which = global_jewish_refugees value = 3 } }
			}
		}

		piety = 10

		ai_chance = {
			factor = 25

			mult_modifier = {
				factor = 3
				trait = zealous
			}
		}
	}
}

province_event = {
	id = Plus.726 # Bounce

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		FROM = { religion_group = jewish_group } # FROM = Old Religion
		NOT = { religion_group = jewish_group } # Make sure it didn't just convert to a heresy but entirely out of the Jewish group
	}

	immediate = {
		if = { # Make sure there actually is a city to place a community into
			limit = { has_city = yes }
			owner = { character_event = { id = Plus.725 } }
		}
		else = { # There's no city for them to go to, so they just leave
			random_list = {
				55 = { change_variable = { which = global_jewish_refugees value = 1 } }
				30 = { change_variable = { which = global_jewish_refugees value = 2 } }
				15 = { change_variable = { which = global_jewish_refugees value = 3 } }
			}
		}
	}
}