package data.missions.hadd_scrapperMission7;

import com.fs.starfarer.api.combat.BattleObjectiveAPI;
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.ATTACK, false, 10);
		api.initFleet(FleetSide.ENEMY, "ISS", FleetGoal.ATTACK, true, 10);

		// Set a blurb for each fleet
		api.setFleetTagline(FleetSide.PLAYER, "Scrapper fleet");
		api.setFleetTagline(FleetSide.ENEMY, "Corvus Alliance");
		
		// These show up as items in the bulleted list under 
		// "Tactical Objectives" on the mission detail screen
		api.addBriefingItem("Defeat all enemies.");
		api.addBriefingItem("The ISS Scrapper must survive.");
		api.addBriefingItem("The ISS Mettle Elite Striker is expendable.");
		
		// Set up the player's fleet
		api.addToFleet(FleetSide.PLAYER, "hadd_elitestriker_Elite", FleetMemberType.SHIP, "ISS Mettle", false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_battleborn_Balanced", FleetMemberType.SHIP, "ISS Scrapper", true, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_terra_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_terra_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_beast_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_beast_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_menace_PD", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_menace_Balanced", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_bite_Close", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_vice_Assault", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_juggernaut_Support", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN);
		api.addToFleet(FleetSide.PLAYER, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_platypus_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_bat_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_bat_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_raptor_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		api.addToFleet(FleetSide.PLAYER, "hadd_raptor_wing", FleetMemberType.FIGHTER_WING, false, CrewXPLevel.ELITE);
		
		// Mark a ship as essential, if you want
		api.defeatOnShipLoss("ISS Scrapper");
		
		// Set up the enemy fleet
		api.addToFleet(FleetSide.ENEMY, "paragon_Elite", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "astral_Elite", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "onslaught_Elite", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "conquest_Elite", FleetMemberType.SHIP, false, CrewXPLevel.VETERAN).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "apogee_Balanced", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "atlas_Standard", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "aurora_Balanced", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "brawler_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "buffalo_Standard", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "buffalo2_FS", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "condor_FS", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "condor_Strike", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "conquest_Elite", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "dominator_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "dominator_Support", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "dram_Light", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "eagle_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "eagle_Balanced", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "enforcer_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "enforcer_Balanced", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "enforcer_CS", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "falcon_Attack", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "falcon_CS", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "hammerhead_Elite", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "hound_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "hound_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "hound_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "lasher_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "lasher_Assault", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "lasher_PD", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "lasher_Strike", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "medusa_PD", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "medusa_PD", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "medusa_CS", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "odyssey_Balanced", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "tempest_Attack", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "tempest_Attack", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "tempest_Attack", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "tempest_Attack", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "vigilance_Standard", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "vigilance_Standard", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "wolf_Strike", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "wolf_PD", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");
		api.addToFleet(FleetSide.ENEMY, "wolf_PD", FleetMemberType.SHIP, false).getCaptain().setPersonality("suicidal");

		
		
		// Set up the map.
		float width = 30000f;
		float height = 30000f;
		api.initMap((float)-width/2f, (float)width/2f, (float)-height/2f, (float)height/2f);
		
		float minX = -width/2;
		float minY = -height/2;
		
		// All the addXXX methods take a pair of coordinates followed by data for
		// whatever object is being added.
		
		// Add three big nebula clouds
		api.addNebula(minX + width * 0.5f, minY + height * 0.5f, 2000);
		api.addNebula(minX + width * 0.25f, minY + height * 0.6f, 1000);
		api.addNebula(minX + width * 0.75f, minY + height * 0.4f, 1000);
		
		// And a few random ones to spice up the playing field.
		// A similar approach can be used to randomize everything
		// else, including fleet composition.
		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() * 400f; 
			api.addNebula(x, y, radius);
		}
		
		// Add objectives. These can be captured by each side
		// and provide stat bonuses and extra command points to
		// bring in reinforcements.
		// Reinforcements only matter for large fleets - in this
		// case, assuming a 100 command point battle size,
		// both fleets will be able to deploy fully right away.
		api.addObjective(minX + width * 0.5f, minY + height * 0.1f, "comm_relay", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.5f, minY + height * 0.9f, "comm_relay", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.4f, minY + height * 0.6f, "sensor_array", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.6f, minY + height * 0.6f, "comm_relay", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.4f, minY + height * 0.4f, "sensor_array", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.6f, minY + height * 0.4f, "comm_relay", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.33f, minY + height * 0.25f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.45f, minY + height * 0.33f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.67f, minY + height * 0.25f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.55f, minY + height * 0.33f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.33f, minY + height * 0.75f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.45f, minY + height * 0.67f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.67f, minY + height * 0.75f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);
		api.addObjective(minX + width * 0.55f, minY + height * 0.67f, "nav_buoy", BattleObjectiveAPI.Importance.NORMAL);

		api.addAsteroidField(-(minY + height), minY + height, -45, 2000f,
								20f, 70f, 100);
	}

}






