﻿namespace = gr_agot_debug

# ================================================
# GRAND REMEMBRANCE - AGOT SUBMOD DEBUG EVENTS
#
# Fire from console: event gr_agot_debug.1  (etc.)
# Cleanup between tests: event gr_agot_debug.99
#
# Each event sets gr_agot_ variables directly on ROOT
# then fires gr_obituary.10.
#
# TESTS:
#   gr_agot_debug.1   Targaryen Dragonrider (dragon + Valyrian + named wars)
#   gr_agot_debug.2   Night's Watch Ranger  (NW lifestyle + First Men + Old Gods)
#   gr_agot_debug.3   Kingsguard Knight     (sworn service + Andal + Seven + named wars)
#   gr_agot_debug.4   Archmaester Priority  (maester else_if chain + maester chronicler)
#   gr_agot_debug.5   Ironborn Captain      (Ironborn heritage + Drowned faith + pirate/ranging wars)
#   gr_agot_debug.6   Hostile Chronicle     (negative opinion + greyscale + crippled + kinslayer)
#   gr_agot_debug.7   War Pile              (8 different war variables, no trait content)
#   gr_agot_debug.8   Essos Exile           (Dothraki heritage + R'hllor faith + spider + slavery war)
#   gr_agot_debug.9   New Content           (half_blind, shivers, authoritative, inquisitive, LP->feudal govt)
#   gr_agot_debug.99  Cleanup               (removes all gr_agot_ and debug base vars from ROOT)
# ================================================


# ================================================
# TEST 1: TARGARYEN DRAGONRIDER
# Tests: dragonrider, dragon kingdom war won_att,
#        Blackfyre survived_def, Valyrian heritage,
#        Valyrian faith, dragon_dreams, authoritative
# Opinion: positive (50)
# Seed: 0 (first text variant)
# Console: event gr_agot_debug.1
# ================================================
gr_agot_debug.1 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_1
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes

		# --- Iron Throne opening (7 kingdoms) ---
		set_variable = { name = gr_agot_iron_throne value = yes }
		set_variable = { name = gr_agot_sub_kingdom_count value = 7 }
		# Iron Throne is hegemony tier in AGOT (above empire) - override the base gr_tier = 4
		set_variable = { name = gr_tier value = 5 }

		# --- Dragon traits ---
		set_variable = { name = gr_agot_dragonrider value = yes }
		# dragon_dreams as bonus mystical trait
		set_variable = { name = gr_agot_dragon_dreams value = yes }

		# --- Personality ---
		set_variable = { name = gr_agot_authoritative value = yes }

		# --- Heritage and faith (Valyrian) ---
		set_variable = { name = gr_agot_heritage value = flag:valyrian_cult }
		set_variable = { name = gr_agot_faith value = flag:valyrian_faith }

		# --- Wars ---
		# Won a dragon kingdom conquest as attacker
		set_variable = { name = gr_agot_war_dragon value = flag:won_att }
		set_variable = { name = gr_agot_war_dragon_tier value = flag:kingdom }
		# Survived the Blackfyre rebellion as defender (lost the war)
		set_variable = { name = gr_agot_war_blackfyre value = flag:survived_def }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 2: NIGHT'S WATCH RANGER
# Tests: night_watch + ranger lifestyle, greensight,
#        First Men heritage, Old Gods faith,
#        NW ranging won_att, wall reclaim won_att
# Opinion: positive (50)
# Seed: 40 (second/third text variants)
# Console: event gr_agot_debug.2
# ================================================
gr_agot_debug.2 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_2
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		set_variable = { name = gr_random_seed value = 40 }

		# --- Night's Watch with ranger lifestyle ---
		set_variable = { name = gr_agot_nightswatch value = yes }
		set_variable = { name = gr_agot_nw_lifestyle value = flag:ranger }

		# --- Mystical ---
		set_variable = { name = gr_agot_greensight value = yes }

		# --- Heritage and faith ---
		set_variable = { name = gr_agot_heritage value = flag:first_men }
		set_variable = { name = gr_agot_faith value = flag:old_gods }

		# --- Wars ---
		set_variable = { name = gr_agot_war_ranging value = flag:won_att }
		set_variable = { name = gr_agot_war_wall_reclaim value = flag:won_att }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 3: KINGSGUARD KNIGHT
# Tests: kingsguard, knight, Andal heritage,
#        Seven faith, Reyne rebellion won_att,
#        Duskendale won_def, inquisitive personality
# Opinion: positive (50)
# Seed: 60
# Console: event gr_agot_debug.3
# ================================================
gr_agot_debug.3 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_3
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		set_variable = { name = gr_random_seed value = 60 }

		# --- Sworn service + knighthood ---
		set_variable = { name = gr_agot_kingsguard value = yes }
		set_variable = { name = gr_agot_knight value = yes }

		# --- Personality ---
		set_variable = { name = gr_agot_inquisitive value = yes }

		# --- Heritage and faith ---
		set_variable = { name = gr_agot_heritage value = flag:andal }
		set_variable = { name = gr_agot_faith value = flag:seven }

		# --- Wars ---
		set_variable = { name = gr_agot_war_reyne value = flag:won_att }
		set_variable = { name = gr_agot_war_duskendale value = flag:won_def }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 4: ARCHMAESTER PRIORITY + MAESTER CHRONICLER
# Tests: maester else_if priority (archmaester wins),
#        maester chronicler_type override,
#        high_septon religious role,
#        Andal + Seven, Ninepenny Kings won_att
# IMPORTANT: The chronicler_type is forced to flag:maester
#            here by directly setting the variable so the
#            maester narrative voice triggers in the obituary.
# Opinion: neutral (0)
# Seed: 20
# Console: event gr_agot_debug.4
# ================================================
gr_agot_debug.4 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_4
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		set_variable = { name = gr_opinion value = 0 }
		set_variable = { name = gr_random_seed value = 20 }

		# --- Force maester chronicler voice ---
		# Normally set in gr_obituary.10 immediate if var:gr_chronicler has_trait maester.
		# In debug we set it directly to skip the trait check.
		set_variable = { name = gr_chronicler_type value = flag:maester }

		# --- Maester tier: archmaester should win (tests else_if priority) ---
		# Set flag:maester first, then archmaester; archmaester should override.
		# Since gr_obituary.10's detection uses else_if, only one flag is ever set per run.
		# This debug test sets archmaester directly to confirm the maester path renders.
		set_variable = { name = gr_agot_maester value = flag:archmaester }

		# --- Religious role: high_septon ---
		set_variable = { name = gr_agot_religious_role value = flag:high_septon }

		# --- Heritage and faith ---
		set_variable = { name = gr_agot_heritage value = flag:andal }
		set_variable = { name = gr_agot_faith value = flag:seven }

		# --- Wars ---
		set_variable = { name = gr_agot_war_ninepenny value = flag:won_att }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 5: IRONBORN CAPTAIN
# Tests: Ironborn heritage, Drowned faith,
#        greensight + dragon_dreams (both mystical),
#        drowned_man religious role,
#        pirate war won_att, Daemon Stepstones won_att,
#        broke_vows social trait
# Opinion: positive (50)
# Seed: 80
# Console: event gr_agot_debug.5
# ================================================
gr_agot_debug.5 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_5
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		set_variable = { name = gr_random_seed value = 80 }

		# --- Mystical (both, to test they stack) ---
		set_variable = { name = gr_agot_greensight value = yes }
		set_variable = { name = gr_agot_dragon_dreams value = yes }

		# --- Religious role ---
		set_variable = { name = gr_agot_religious_role value = flag:drowned_man }

		# --- Social ---
		set_variable = { name = gr_agot_broke_vows value = yes }

		# --- Heritage and faith ---
		set_variable = { name = gr_agot_heritage value = flag:ironborn }
		set_variable = { name = gr_agot_faith value = flag:drowned }

		# --- Wars ---
		set_variable = { name = gr_agot_war_pirate value = flag:won_att }
		set_variable = { name = gr_agot_war_daemon value = flag:won_att }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 6: HOSTILE CHRONICLE
# Tests: negative opinion (-50), negative text variants,
#        greyscale + crippled + burned conditions,
#        kinslayer_accidental + rude social/personality,
#        Blackfyre lost_att (attacker lost),
#        First Men heritage, Old Gods faith
# Opinion: negative (-50)
# Seed: 0
# Console: event gr_agot_debug.6
# ================================================
gr_agot_debug.6 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_6
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		set_variable = { name = gr_opinion value = -50 }
		set_variable = { name = gr_score_tier value = flag:notable }

		# --- Physical conditions ---
		set_variable = { name = gr_agot_greyscale value = yes }
		set_variable = { name = gr_agot_crippled value = yes }
		set_variable = { name = gr_agot_burned value = yes }

		# --- Social/personality ---
		set_variable = { name = gr_agot_kinslayer_accidental value = yes }
		set_variable = { name = gr_agot_rude value = yes }

		# --- Heritage and faith ---
		set_variable = { name = gr_agot_heritage value = flag:first_men }
		set_variable = { name = gr_agot_faith value = flag:old_gods }

		# --- Wars ---
		# Lost the Blackfyre as attacker
		set_variable = { name = gr_agot_war_blackfyre value = flag:lost_att }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 7: WAR PILE
# Tests: 8 different war variables simultaneously,
#        no trait content (verify war section stands alone)
# Opinion: positive (50)
# Seed: 40
# Console: event gr_agot_debug.7
# ================================================
gr_agot_debug.7 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_7
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		set_variable = { name = gr_random_seed value = 40 }

		# --- Heritage and faith (minimal, Andal/Seven) ---
		set_variable = { name = gr_agot_heritage value = flag:andal }
		set_variable = { name = gr_agot_faith value = flag:seven }

		# --- 8 war variables with mixed outcomes ---
		set_variable = { name = gr_agot_war_reyne value = flag:won_att }
		set_variable = { name = gr_agot_war_ninepenny value = flag:won_def }
		set_variable = { name = gr_agot_war_faegon value = flag:survived_def }
		set_variable = { name = gr_agot_war_rebellion value = flag:won_att }
		set_variable = { name = gr_agot_war_succession value = flag:lost_att }
		set_variable = { name = gr_agot_war_independence value = flag:won_def }
		set_variable = { name = gr_agot_war_eradicate value = flag:won_att }
		set_variable = { name = gr_agot_war_slavery value = flag:won_att }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 8: ESSOS EXILE
# Tests: Grasslands/Dothraki heritage, R'hllor faith,
#        red_priest religious role, spider + paramour
#        + fire_obsessed social traits,
#        Faegon invasion won_att, slavery war won_att,
#        one_handed condition
# Opinion: neutral (10)
# Seed: 60
# Console: event gr_agot_debug.8
# ================================================
gr_agot_debug.8 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_8
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		set_variable = { name = gr_opinion value = 10 }
		set_variable = { name = gr_random_seed value = 60 }

		# --- Social/personality traits ---
		set_variable = { name = gr_agot_spider value = yes }
		set_variable = { name = gr_agot_paramour value = yes }
		set_variable = { name = gr_agot_fire_obsessed value = yes }

		# --- Physical condition ---
		set_variable = { name = gr_agot_one_handed value = yes }

		# --- Religious role ---
		set_variable = { name = gr_agot_religious_role value = flag:red_priest }

		# --- Heritage and faith ---
		set_variable = { name = gr_agot_heritage value = flag:grasslands }
		set_variable = { name = gr_agot_faith value = flag:rhllor }

		# --- Wars ---
		set_variable = { name = gr_agot_war_faegon value = flag:won_att }
		set_variable = { name = gr_agot_war_slavery value = flag:won_att }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 9: NEW CONDITIONS + PERSONALITY + GOVT
# Covers: half_blind, the_mark, shivers, scurvy,
#         authoritative, rude, inquisitive, uncouth,
#         LP->feudal govt transition, knightings (memory-based, can't fake)
# Console: event gr_agot_debug.9
# ================================================
gr_agot_debug.9 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_9
	hidden = yes

	immediate = {
		gr_agot_debug_base_setup = yes
		# Conditions
		set_variable = { name = gr_agot_half_blind value = yes }
		set_variable = { name = gr_agot_shivers value = yes }
		# Personality traits
		set_variable = { name = gr_agot_authoritative value = yes }
		set_variable = { name = gr_agot_inquisitive value = yes }
		# Govt: LP lost status (lp_feudal -> feudal)
		set_variable = { name = gr_agot_govt_old value = flag:lp_feudal }
		set_variable = { name = gr_agot_govt_new value = flag:feudal }
		set_variable = { name = gr_memory_govt_change value = yes }
		# Faith/Heritage for section completeness
		set_variable = { name = gr_agot_faith value = flag:seven }
		set_variable = { name = gr_agot_heritage value = flag:andal }

		trigger_event = { id = gr_obituary.10 days = 1 }
	}
}


# ================================================
# TEST 99: CLEANUP
# Removes all gr_agot_ debug vars from ROOT.
# Run this between tests to avoid variable bleed.
# Console: event gr_agot_debug.99
# ================================================
gr_agot_debug.99 = {
	type = character_event
	title = gr_agot_debug_title
	desc = gr_agot_debug_desc_99
	hidden = yes

	immediate = {
		gr_agot_debug_cleanup = yes
	}
}
