﻿councillor_chancellor_level_up_chance_effects = {
	if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor 
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_marshal
				has_trait = lifestyle_spymaster
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 1
			scope:councillor_liege = {
				scope:councillor = {
					councillor_chancellor_lifestyle_set_up_effects = yes
				}
			}
		}
	}
	else_if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_marshal
				has_trait = lifestyle_spymaster
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 10
			if = {
				limit = {
					has_trait_xp = {
						trait = lifestyle_chancellor
						value < 100
					}
				}
				scope:councillor_liege = {
					scope:councillor = {
						councillor_chancellor_lifestyle_rank_up_effects = yes
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			is_alive = yes
		}
		random = {
			chance = 30
			scope:councillor = {
				councillor_lifestyle_rank_down_effects = yes
			}
		}
	}
}

councillor_chancellor_lifestyle_set_up_effects = {
	add_trait = lifestyle_chancellor
}

councillor_chancellor_lifestyle_rank_up_effects = {
	add_trait_xp = {
		trait = lifestyle_chancellor
		value = {
			integer_range = {
				min = 3
				max = 7
			}
		}
	}	
}

councillor_chaplain_level_up_chance_effects = {
	if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor 
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_marshal
				has_trait = lifestyle_spymaster
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 1
			scope:councillor_liege = {
				scope:councillor = {
					councillor_chaplain_lifestyle_set_up_effects = yes
				}
			}
		}
	}
	else_if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor
				has_trait = lifestyle_marshal
				has_trait = lifestyle_spymaster
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 10
			if = {
				limit = {
					has_trait_xp = {
						trait = lifestyle_chaplain
						value < 100
					}
				}
				scope:councillor_liege = {
					scope:councillor = {
						councillor_chaplain_lifestyle_rank_up_effects = yes
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			is_alive = yes
		}
		random = {
			chance = 30
			scope:councillor = {
				councillor_lifestyle_rank_down_effects = yes
			}
		}
	}
}

councillor_chaplain_lifestyle_set_up_effects = {
	add_trait = lifestyle_chaplain
}

councillor_chaplain_lifestyle_rank_up_effects = {
	add_trait_xp = {
		trait = lifestyle_chaplain
		value = {
			integer_range = {
				min = 3
				max = 7
			}
		}
	}		
}

councillor_marshal_level_up_chance_effects = {
	if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor 
				has_trait = lifestyle_marshal
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_spymaster
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 1
			scope:councillor_liege = {
				scope:councillor = {
					councillor_marshal_lifestyle_set_up_effects = yes
				}
			}
		}
	}
	else_if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_spymaster
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 10
			if = {
				limit = {
					has_trait_xp = {
						trait = lifestyle_marshal
						value < 100
					}
				}
				scope:councillor_liege = {
					scope:councillor = {
						councillor_marshal_lifestyle_rank_up_effects = yes
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			is_alive = yes
		}
		random = {
			chance = 30
			scope:councillor = {
				councillor_lifestyle_rank_down_effects = yes
			}
		}
	}
}

councillor_marshal_lifestyle_set_up_effects = {
	add_trait = lifestyle_marshal
}

councillor_marshal_lifestyle_rank_up_effects = {
	add_trait_xp = {
		trait = lifestyle_marshal
		value = {
			integer_range = {
				min = 3
				max = 7
			}
		}
	}
}

councillor_spymaster_level_up_chance_effects = {
	if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor 
				has_trait = lifestyle_marshal
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_spymaster
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 1
			scope:councillor_liege = {
				scope:councillor = {
					councillor_spymaster_lifestyle_set_up_effects = yes
				}
			}
		}
	}
	else_if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_marshal
				has_trait = lifestyle_steward
			}
			is_alive = yes
		}
		random = {
			chance = 10
			if = {
				limit = {
					has_trait_xp = {
						trait = lifestyle_spymaster
						value < 100
					}
				}
				scope:councillor_liege = {
					scope:councillor = {
						councillor_spymaster_lifestyle_rank_up_effects = yes
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			is_alive = yes
		}
		random = {
			chance = 30
			scope:councillor = {
				councillor_lifestyle_rank_down_effects = yes
			}
		}
	}
}

councillor_spymaster_lifestyle_set_up_effects = {
	add_trait = lifestyle_spymaster
}

councillor_spymaster_lifestyle_rank_up_effects = {
	add_trait_xp = {
		trait = lifestyle_spymaster
		value = {
			integer_range = {
				min = 3
				max = 7
			}
		}		
	}
}

councillor_steward_level_up_chance_effects = {
	if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor 
				has_trait = lifestyle_marshal
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_steward
				has_trait = lifestyle_spymaster
			}
			is_alive = yes
		}
		random = {
			chance = 1
			scope:councillor_liege = {
				scope:councillor = {
					councillor_steward_lifestyle_set_up_effects = yes
				}
			}
		}
	}
	else_if = {
		limit = {
			NOT = {
				has_trait = lifestyle_chancellor
				has_trait = lifestyle_chaplain
				has_trait = lifestyle_marshal
				has_trait = lifestyle_spymaster
			}
			is_alive = yes
		}
		random = {
			chance = 10
			if = {
				limit = {
					has_trait_xp = {
						trait = lifestyle_steward
						value < 100
					}
				}
				scope:councillor_liege = {
					scope:councillor = {
						councillor_steward_lifestyle_rank_up_effects = yes
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			is_alive = yes
		}
		random = {
			chance = 30
			scope:councillor = {
				councillor_lifestyle_rank_down_effects = yes
			}
		}
	}
}

councillor_steward_lifestyle_set_up_effects = {
	add_trait = lifestyle_steward
}

councillor_steward_lifestyle_rank_up_effects = {
	add_trait_xp = {
		trait = lifestyle_steward
		value = {
			integer_range = {
				min = 3
				max = 7
			}
		}
	}
}

councillor_lifestyle_rank_down_effects = {
	if = {
		limit = {
			has_trait = lifestyle_chancellor
		}
		if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_chancellor
					value <= 5
				}
			}
			remove_trait = lifestyle_chancellor
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_chancellor
				value = -5
			}
		}
	}
	else_if = {
		limit = {
			has_trait = lifestyle_chaplain
		}
		if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_chaplain
					value <= 5
				}
			}
			
			remove_trait = lifestyle_chaplain
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_chaplain
				value = -5
			}
		}
	}
	else_if = {
		limit = {
			has_trait = lifestyle_marshal
		}
		if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_marshal
					value <= 5
				}
			}
			remove_trait = lifestyle_marshal
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_marshal
				value = -5
			}
		}
	}
	else_if = {
		limit = {
			has_trait = lifestyle_spymaster
		}
		if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_spymaster
					value <= 5
				}
			}
			remove_trait = lifestyle_spymaster
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_spymaster
				value = -5
			}
		}
	}
	else_if = {
		limit = {
			has_trait = lifestyle_steward
		}
		if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_steward
					value <= 5
				}
			}
			remove_trait = lifestyle_steward
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_steward
				value = -5
			}
		}
	}
}