﻿found_the_hanseatic_league_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/gdp_republic_trade_ships.dds"
	}
	decision_group_type = major
	sort_order = 100

	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 60
		kingdom = 30
		empire = 30
		hegemony = 30
	}

	desc = found_the_hanseatic_league_decision_desc
	selection_tooltip = found_the_hanseatic_league_decision_tooltip
	confirm_text = found_the_hanseatic_league_decision_confirm

	is_shown = {
		government_has_flag = government_is_republic
		capital_province ?= { geographical_region = hanseatic_trade_region }
		NOT = {
			confederation ?= { has_variable = is_hanseatic_league }
		}
		has_gdp_dlc_trigger = yes
	}

	is_valid_showing_failures_only = {
		is_at_war = no
		gdp_is_trade_league_head_trigger = yes
		custom_tooltip = {
			text = found_the_hanseatic_league_cohesion_tt
			confederation ?= {
				cohesion >= 70
			}
		}
		custom_tooltip = {
			text = found_the_hanseatic_league_members_tt
			confederation ?= {
				any_confederation_member = { count >= 4 }
			}
		}
	}

	cost = {
		gold = massive_gold_value
		prestige = {
			value = massive_prestige_value
			if = {
				limit = { is_ai = yes }
				value = 250
			}
		}
	}

	effect = {
		save_scope_as = hanse_founder

		if = {
			limit = { exists = confederation }

			confederation = {
				leading_title ?= { save_scope_as = hanse_lead_town }
				set_variable = is_hanseatic_league
				set_coa = k_hansa

				if = {
					limit = {
						NOT = {
							any_confederation = {
								has_variable = hanseatic_baltic_identity
							}
						}
					}
					set_variable = hanseatic_baltic_identity
					set_confederation_name = HANSEATIC_LEAGUE_NAME
				}
				else = {
					set_confederation_name = GENERIC_HANSE_NAME
				}
			}

			hanseatic_elevate_all_members_effect = { LEAGUE = root.confederation }

			add_prestige = major_prestige_gain

			add_achievement_global_variable_effect = {
				VARIABLE = ep5_14_league_of_ledgers_achievement_unlocked
				VALUE = yes
			}

			hanseatic_ask_personal_monopoly_holders_effect = { LEAGUE = root.confederation }

			every_player = {
				limit = {
					is_member_of_confederation = root.confederation
				}
				send_interface_message = {
					type = event_generic_good_text
					title = found_the_hanseatic_league_message_title
					desc = found_the_hanseatic_league_message_desc
					left_icon = root
				}
			}
		}
	}

	ai_potential = {
		is_ai = yes
		is_ruler = yes
		capital_province ?= { geographical_region = hanseatic_core_commune_region }
		gdp_is_trade_league_head_trigger = yes
	}

	ai_will_do = {
		base = 100
	}
}
