﻿
on_game_start_after_lobby = {
	on_actions = {
    	gptm_set_domiciles
    }
}

gptm_set_domiciles = {
	effect = {
		every_ruler = {
			limit = {
				has_game_rule = GPT_domiciles_enabled
				exists = dynasty
				is_landed = yes
				highest_held_title_tier >= 2
				is_house_head = yes
				OR = {
					government_has_flag = government_is_feudal
					government_has_flag = government_is_free_city
				}
				exists = domicile
			}
			domicile ?= { gptm_feudal_domicile_set_up_effect = yes }
		}
		every_ruler = {
			limit = {
				has_game_rule = GPT_domiciles_enabled
				exists = dynasty
				is_landed = yes
				highest_held_title_tier >= 2
				is_house_head = yes
				government_has_flag = government_is_clan
				exists = domicile
			}
			domicile ?= { gptm_clan_domicile_set_up_effect = yes }
		}
		every_ruler = {
			limit = {
				has_game_rule = GPT_domiciles_enabled
				exists = dynasty
				is_landed = yes
				highest_held_title_tier >= 2
				is_house_head = yes
				OR = {
					government_has_flag = government_is_tribal
					government_has_flag = government_is_pirate
				}
				exists = domicile
			}
			domicile ?= { gptm_tribal_camp_set_up_effect = yes }
		}
	}
}

quarterly_playable_pulse = {
	on_actions = {
		delay = { days = 3 }
    	gptm_add_domicile_feudal
    }
	on_actions = {
		delay = { days = 6 }
    	gptm_add_domicile_clan
    }
	on_actions = {
		delay = { days = 9 }
    	gptm_add_domicile_tribal
    }
	on_actions = {
		delay = { days = 12 }
    	gptm_add_domicile_lp
    }
	on_actions = {
		delay = { days = 15 }
    	gptm_add_domicile_freecity
    }
	on_actions = {
		delay = { days = 18 }
    	gptm_add_domicile_pirate
    }
}

gptm_add_domicile_lp = {
	trigger = {
		has_game_rule = GPT_domiciles_enabled
		exists = dynasty
		is_landed = yes
		highest_held_title_tier >= 2
		is_house_head = yes
		has_government = lp_feudal_government
		NOT = { exists = domicile }
	}
	effect = {
		change_government = clan_government
		change_government = lp_feudal_government
		domicile ?= { gptm_feudal_domicile_set_up_effect = yes }
	}
}

gptm_add_domicile_freecity = {
	trigger = {
		has_game_rule = GPT_domiciles_enabled
		exists = dynasty
		is_landed = yes
		highest_held_title_tier >= 2
		is_house_head = yes
		has_government = free_city_government
		NOT = { exists = domicile }
	}
	effect = {
		change_government = feudal_government
		change_government = free_city_government
		domicile ?= { gptm_feudal_domicile_set_up_effect = yes }
	}
}

gptm_add_domicile_feudal = {
	trigger = {
		has_game_rule = GPT_domiciles_enabled
		exists = dynasty
		is_landed = yes
		highest_held_title_tier >= 2
		is_house_head = yes
		has_government = feudal_government
		NOT = { exists = domicile }
	}
	effect = {
		change_government = clan_government
		change_government = feudal_government
		domicile ?= { gptm_feudal_domicile_set_up_effect = yes }
	}
}

gptm_add_domicile_clan = {
	trigger = {
		has_game_rule = GPT_domiciles_enabled
		exists = dynasty
		is_landed = yes
		highest_held_title_tier >= 2
		is_house_head = yes
		has_government = clan_government
		NOT = { exists = domicile }
	}
	effect = {
		change_government = feudal_government
		change_government = clan_government
		domicile ?= { gptm_clan_domicile_set_up_effect = yes }
	}
}

gptm_add_domicile_tribal = {
	trigger = {
		has_game_rule = GPT_domiciles_enabled
		exists = dynasty
		is_landed = yes
		highest_held_title_tier >= 2
		is_house_head = yes
		has_government = tribal_government
		NOT = { exists = domicile }
	}
	effect = {
		change_government = clan_government
		change_government = tribal_government
		domicile ?= { gptm_tribal_camp_set_up_effect = yes }
	}
}

gptm_add_domicile_pirate = {
	trigger = {
		has_game_rule = GPT_domiciles_enabled
		exists = dynasty
		is_landed = yes
		highest_held_title_tier >= 2
		is_house_head = yes
		has_government = pirate_government
		NOT = { exists = domicile }
	}
	effect = {
		change_government = clan_government
		change_government = pirate_government
		domicile ?= { gptm_tribal_camp_set_up_effect = yes }
	}
}