const dryRun = false;

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

var Dic={0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J"};
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",8, 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_javel",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",18,playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/sele_mechanical_siege_tower",1,playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/pers_mechanical_siege_ram",1,playerNr);
		ents=TriggerHelper.SpawnUnits(gaiaCC, "units/maur_champion_elephant",3, playerNr);
		
		
		ents = TriggerHelper.SpawnUnits(gaiaCC, "units/ptol_cavalry_spearman_merc_e",12, playerNr);
		ents = TriggerHelper.SpawnUnits(gaiaCC, "units/maur_cavalry_swordsman_e",12, 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 });

};

