const dryRun = false;

/**
 * If enabled, prints the number of units to the command line output.
 */
const debugLog = false;

Trigger.prototype.SpawnCCPlayer = function(playerNr)
{
	let ii=playerNr;
	let z=0;
	for (let gaiaCC of this.civicCentersplayers[playerNr-1])
	{

	    TriggerHelper.HasDealtWithTech(ii, "phase_town_generic");
		TriggerHelper.HasDealtWithTech(ii, "phase_city_generic");
		TriggerHelper.HasDealtWithTech(ii, "armor_infantry_01");
		TriggerHelper.HasDealtWithTech(ii, "armor_infantry_02");
		TriggerHelper.HasDealtWithTech(ii, "armor_cav_01");
		TriggerHelper.HasDealtWithTech(ii, "armor_cav_02");
		TriggerHelper.HasDealtWithTech(ii, "health_regen_units");
		TriggerHelper.HasDealtWithTech(ii, "attack_soldiers_will");
		TriggerHelper.HasDealtWithTech(ii, "armor_hero_01");

		z++;
		let ents = TriggerHelper.SpawnUnits(gaiaCC, "units/superman",1, playerNr);
		TriggerHelper.SpawnUnits(gaiaCC, "units/hero_of_the_battlefield_archer",1, playerNr);
		TriggerHelper.SpawnUnits(gaiaCC, "units/hero_of_the_battlefield_cav",1, playerNr);
		TriggerHelper.SpawnUnits(gaiaCC, "units/hero_of_the_battlefield",1, playerNr);
		TriggerHelper.SpawnUnits(gaiaCC, "units/hero_of_the_battlefield_ele",1, playerNr);
		TriggerHelper.SpawnUnits(gaiaCC, "units/merc_thorakites",1, playerNr);
		TriggerHelper.SpawnUnits(gaiaCC, "units/merc_thureophoros",1, playerNr);

		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pro_cavalry_champion_swordsman",8, playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pro_cavalry_champion_spearman",8, playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pro_infantry_champion_armbrust",8, playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pro_infantry_champion_swordsman",8, playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pro_infantry_champion_spearman",8, playerNr);

		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pro_infantry_champion_archer",8, playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pro_cavalry_champion_archer",8, playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/maur_infantry_spearman_e",12,playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/sele_mechanical_siege_tower",1,playerNr);
		TriggerHelper.SpawnUnits(gaiaCC, "units/ptol_mechanical_siege_lithobolos_unpacked",1,playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/maur_champion_elephant",1, playerNr);

		ents = TriggerHelper.SpawnUnits(gaiaCC, "units/maur_cavalry_swordsman_e",8, playerNr);

	}

	
};

Trigger.prototype.InitSurvival = function()
{
	let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetActivePlayers().length;
	this.civicCentersplayers = [];
		
	for (var ii =1; ii < (numPlayers+1); ii++)
	{
		this.civicCentersplayers.push(new Set(TriggerHelper.GetPlayerEntitiesByClass(ii, "CivCentre")));
		
	}
	for (var iii =1; iii < (numPlayers+1); iii++)
		this.SpawnCCPlayer(iii);
	
	
};
Trigger.prototype.OnInitGame = function()
{
	let a=0;
};
{	
	let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
	cmpTrigger.RegisterTrigger("OnInitGame", "InitSurvival", { "enabled": true });

};

