const dryRun = false;

/**
 * If enabled, prints the number of units to the command line output.
 */
const debugLog = false;
var disabledTemplates = (civ) => [
	// Economic structures
	"structures/" + civ + "_corral",
	"structures/" + civ + "_farmstead",
	"structures/" + civ + "_field",
	"structures/" + civ + "_storehouse",
	"structures/" + civ + "_rotarymill",
	"structures/" + civ + "_market",
	"units/" + civ + "_support_female_citizen",
	"units/" + civ + "_support_female_citizen_house",
	"units/maur_support_elephant",

	// Expansions


	// Walls
	"structures/" + civ + "_wallset_stone",
	"structures/rome_wallset_siege",


	// Shoreline
	"structures/" + civ + "_dock",
	"structures/brit_crannog",
	"structures/cart_super_dock",
	"structures/ptol_lighthouse"
];
Trigger.prototype.SetDisableTemplates = function()
{
	for (let i = 1; i < TriggerHelper.GetNumberOfPlayers(); ++i)
	{
		let cmpPlayer = QueryPlayerIDInterface(i);
		cmpPlayer.SetDisabledTemplates(disabledTemplates(cmpPlayer.GetCiv()));
	}
};
Trigger.prototype.SpawnCCPlayer = function(playerNr)
{
	let ii=playerNr;
	let z=0;
	for (let gaiaCC of this.civicCentersplayers[playerNr-1])
	{

	    TriggerHelper.HasDealtWithTech(ii, "unlock_shared_los");
		TriggerHelper.HasDealtWithTech(ii, "map_totalwar_tech");
		TriggerHelper.HasDealtWithTech(ii, "health_regen_units");
		TriggerHelper.HasDealtWithTech(ii, "attack_soldiers_will");

		z++;
		let ents = TriggerHelper.SpawnUnits(gaiaCC, "units/builder_man",3, playerNr);


	}

	
};

Trigger.prototype.InitSurvival = function()
{
    this.SetDisableTemplates();
	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 });

};

