#include "PvPBeta.h"

PvPBeta::PvPBeta( Overseer* ov )
{
	overseer = ov;
	id = HIGHLEVEL_STRAT_PVP_BETA;
}

void PvPBeta::setUpBranches() { 


	/*
			Before doing anything, configure the Synapse system to maintain certain unit ratios. This can be changed in the future
			but it's best to first give it some initial idea of what we want.

			Remember we also need to send the command to turn Synapse on later, typically after our opener is done.

	*/

	Synapse* synapseCore = overseer->getUnitManager()->getSynapse();
	synapseCore->registerNewRatio(new UnitRatio(UnitTypes::Protoss_Dragoon, UnitTypes::Protoss_Zealot, 3, 1, overseer, 0)); // 0
	synapseCore->registerNewRatio(new UnitRatio(UnitTypes::None, UnitTypes::Protoss_Dark_Templar, 0, 6, overseer, 0)); // 3
	synapseCore->registerNewRatio(new UnitRatio(UnitTypes::Protoss_Dragoon, UnitTypes::Protoss_Reaver, 5, 2, overseer, 0)); // 1
	//synapseCore->registerNewRatio(new UnitRatio(UnitTypes::Protoss_Arbiter, UnitTypes::Protoss_Dragoon, 1, 10, overseer, 0)); // 2
	synapseCore->registerNewRatio(new UnitRatio(UnitTypes::None, UnitTypes::Protoss_Observer, 0, 5, overseer, 0)); // 3
	synapseCore->registerNewRatio(new UnitRatio(UnitTypes::Protoss_Nexus, UnitTypes::Protoss_Gateway, 1, 2, overseer, 6)); // 4
	synapseCore->registerNewRatio(new UnitRatio(UnitTypes::Protoss_Reaver, UnitTypes::Protoss_Shuttle, 3, 1, overseer, 3)); // 5
	synapseCore->registerNewRatio(new UnitRatio(UnitTypes::Protoss_Dragoon, UnitTypes::Protoss_High_Templar, 5, 1, overseer, 0)); // 6
	synapseCore->setCentralManagement(0, true);
	overseer->getUnitManager()->setPreferredDTStrat(PROTOSS_ROAMING_DARK_TEMPLAR);
	/*
			Finish synapse configuration
	*/

	BuildOrderTemplate* rootOpener = new BuildOrderTemplate(overseer);

	rootOpener->setTargetMineralWorkers(19);
	rootOpener->setTargetGasWorkers(3);
	rootOpener->setTargetParent(overseer->getUnitManager()->getFriendlyMainBase());
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Gateway);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Gateway);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Zealot, RALLY_NONE);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Zealot, RALLY_NONE);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Zealot, RALLY_NONE);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Zealot, RALLY_NONE);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Zealot, RALLY_NONE);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Zealot, RALLY_NONE);

	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Cybernetics_Core);	
	rootOpener->addToOpeningSequence(new ScoutTask(overseer));
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Assimilator);	
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Forge);	
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Photon_Cannon);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Photon_Cannon);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Photon_Cannon);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Photon_Cannon);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Citadel_of_Adun);	

	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Templar_Archives);	
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Gateway);
	BuildOrderTemplate* expansionBuildOrder = new BuildOrderTemplate(overseer);
	expansionBuildOrder->setTargetMineralWorkers(18);
	expansionBuildOrder->setTargetGasWorkers(3);

	expansionBuildOrder->addToOpeningSequence(UnitTypes::Protoss_Pylon);
	expansionBuildOrder->addToOpeningSequence(UnitTypes::Protoss_Photon_Cannon);
	expansionBuildOrder->addToOpeningSequence(UnitTypes::Protoss_Photon_Cannon);	
	expansionBuildOrder->addToOpeningSequence(UnitTypes::Protoss_Photon_Cannon);
	expansionBuildOrder->addToOpeningSequence(UnitTypes::Protoss_Assimilator);
	expansionBuildOrder->setTargetParent(overseer->getUnitManager()->getFriendlyMainBase());
	rootOpener->addToOpeningSequenceWithGuardStrength(UnitTypes::Protoss_Nexus, 0, expansionBuildOrder);

	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Dark_Templar, RALLY_NATURAL);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Dark_Templar, RALLY_NATURAL);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Dark_Templar, RALLY_NATURAL);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Dark_Templar, RALLY_NATURAL);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Dark_Templar, RALLY_NATURAL);
	rootOpener->addToOpeningSequenceWithRally(UnitTypes::Protoss_Dark_Templar, RALLY_NATURAL);

	rootOpener->addToOpeningSequence(new InternalStateChangeTask(overseer, ACTIVATE_SYNAPSE));
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Robotics_Facility);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Observatory);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Robotics_Support_Bay);
	rootOpener->addToOpeningSequence(UnitTypes::Protoss_Forge);	
	rootOpener->addToOpeningSequence(TechTypes::Psionic_Storm);	
	rootOpener->addToOpeningSequence(UpgradeTypes::Singularity_Charge);	
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Ground_Weapons);
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Ground_Armor);
	

	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Ground_Armor);
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Ground_Weapons);
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Ground_Armor);
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Ground_Weapons);
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Plasma_Shields);
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Plasma_Shields);
	rootOpener->addToOpeningSequence(UpgradeTypes::Protoss_Plasma_Shields);




	buildOrder.push_back(rootOpener);
}

void PvPBeta::loadOpener()
{
	BaseModel* startBase = overseer->getUnitManager()->getFriendlyMainBase();
	startBase->setBuildOrderTemplate(buildOrder.at(0));
}

void PvPBeta::monitorBuildOrder()
{
	// consistency checking code?
}


