package data.missions.hadd_triScrapperMission2;

import com.fs.starfarer.api.campaign.CargoAPI.CrewXPLevel;
import com.fs.starfarer.api.fleet.FleetGoal;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.mission.FleetSide;
import com.fs.starfarer.api.mission.MissionDefinitionAPI;
import com.fs.starfarer.api.mission.MissionDefinitionPlugin;

public class MissionDefinition implements MissionDefinitionPlugin {

	public void defineMission(MissionDefinitionAPI api) {

		// Set up the fleets
		api.initFleet(FleetSide.PLAYER, "ISS", FleetGoal.ESCAPE, false, 15);
		api.initFleet(FleetSide.ENEMY, "ISS", FleetGoal.ATTACK, true, 15);

		// Set a blurb for each fleet
		api.setFleetTagline(FleetSide.PLAYER, "Tri-Tachyon fleet");
		api.setFleetTagline(FleetSide.ENEMY, "Scrapper fleet");
		
		// These show up as items in the bulleted list under 
		// "Tactical Objectives" on the mission detail screen
		api.addBriefingItem("ISS Radiance must survive.");
		api.addBriefingItem("The battle will end upon defeating the ISS Scrapper");
		api.addBriefingItem("At least 25% of the Tri-Tachyon forces must escape");
		api.addBriefingItem("Ships ordered to retreat will escape along the top edge of the map");
		
		// Set up the player's fleet
		
		api.addToFleet(FleetSide.PLAYER, "paragon_Elite", FleetMemberType.SHIP, "ISS Radiance", true, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "odyssey_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "odyssey_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "aurora_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "aurora_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "aurora_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "medusa_CS", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "medusa_PD", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "wolf_Assault", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "wolf_Assault", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "wolf_Assault", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "wolf_Assault", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "wolf_Assault", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "tempest_Attack", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "tempest_Attack", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "tempest_Attack", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.PLAYER, "wasp_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "wasp_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "wasp_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		
		// Mark player flagship as essential
		api.defeatOnShipLoss("ISS Radiance");
		
		// Set up the enemy fleet
		api.addToFleet(FleetSide.ENEMY, "hadd_battleborn_Balanced", FleetMemberType.SHIP, "ISS Scrapper", false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.ENEMY, "hadd_terra_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.ENEMY, "hadd_terra_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.ENEMY, "hadd_striker_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_striker_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_striker_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_striker_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_striker_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_striker_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_beast_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_beast_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_beast_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_beast_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_menace_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_menace_PD", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_menace_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_menace_PD", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_bite_Close", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_bite_Close", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_bite_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_manta_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_manta_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_manta_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_vice_Assault", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_vice_Balanced", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_refuge_PD", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_refuge_PD", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_refuge_PD", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_refuge_PD", FleetMemberType.SHIP, false);
		api.addToFleet(FleetSide.ENEMY, "hadd_sparrow_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_sparrow_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_sparrow_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_sparrow_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_raptor_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_raptor_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_raptor_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_bat_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_bat_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.ENEMY, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.VETERAN);
		
		
		//Opposing team essential ship.
		api.defeatOnShipLoss("ISS Scrapper");
		
		// Set up the map.
		float width = 18000f;
		float height = 32000f;
		api.initMap((float)-width/2f, (float)width/2f, (float)-height/2f, (float)height/2f);
		
		float minX = -width/2;
		float minY = -height/2;
		
		for (int i = 0; i < 10; i++) {
			float x = (float) Math.random() * width - width/2;
			float y = (float) Math.random() * height - height/2;
			float radius = 100f + (float) Math.random() * 900f; 
			api.addNebula(x, y, radius);
		}
		
		api.addNebula(minX + width * 0.8f, minY + height * 0.4f, 2000);
		api.addNebula(minX + width * 0.8f, minY + height * 0.5f, 2000);
		api.addNebula(minX + width * 0.8f, minY + height * 0.6f, 2000);
		
		api.addObjective(minX + width * 0.25f, minY + height * 0.2f, "nav_buoy");
		api.addObjective(minX + width * 0.33f, minY + height * 0.1f, "nav_buoy");
		api.addObjective(minX + width * 0.45f, minY + height * 0.05f, "comm_relay");
		api.addObjective(minX + width * 0.75f, minY + height * 0.2f, "nav_buoy");
		api.addObjective(minX + width * 0.67f, minY + height * 0.1f, "nav_buoy");
		api.addObjective(minX + width * 0.55f, minY + height * 0.05f, "comm_relay");
		api.addObjective(minX + width * 0.45f, minY + height * 0.7f, "comm_relay");
		api.addObjective(minX + width * 0.55f, minY + height * 0.7f, "comm_relay");
		api.addObjective(minX + width * 0.45f, minY + height * 0.8f, "comm_relay");
		api.addObjective(minX + width * 0.55f, minY + height * 0.8f, "comm_relay");
		api.addObjective(minX + width * 0.45f, minY + height * 0.9f, "comm_relay");
		api.addObjective(minX + width * 0.55f, minY + height * 0.9f, "comm_relay");
	}

}






