﻿bdp_ai_vs_ai_live_battle_phase = {
	type = commander

	# Dragon events go first. Riders stay out; everyone else can still duel.
	is_valid = {
		bdp_ai_vs_ai_phase_ready_trigger = yes
	}

	# Keep checking until one valid duel locks the battle.
	chance = {
		base = 1000000
	}

	effect = {
		clear_saved_scope = bdp_ai_vs_ai_phase_producer
		save_scope_value_as = { name = bdp_ai_vs_ai_phase_producer value = flag:bdp_commander_phase }
		bdp_ai_vs_ai_resolve_live_phase_effect = yes
		clear_saved_scope = bdp_ai_vs_ai_phase_producer
	}
}

# Knight fallback gives long or dragon-heavy battles another chance.
bdp_ai_vs_ai_live_battle_knight_phase = {
	type = knight

	is_valid = {
		bdp_ai_vs_ai_knight_phase_ready_trigger = yes
	}

	chance = {
		base = 1000000
	}

	effect = {
		clear_saved_scope = bdp_ai_vs_ai_phase_producer
		save_scope_value_as = { name = bdp_ai_vs_ai_phase_producer value = flag:bdp_knight_phase }
		bdp_ai_vs_ai_resolve_live_phase_effect = yes
		clear_saved_scope = bdp_ai_vs_ai_phase_producer
	}
}
