Index: 0ad/binaries/data/mods/public/simulation/ai/aegis/naval-manager.js
===================================================================
--- 0ad/binaries/data/mods/public/simulation/ai/aegis/naval-manager.js	(revision 14206)
+++ 0ad/binaries/data/mods/public/simulation/ai/aegis/naval-manager.js	(working copy)
@@ -22,10 +22,12 @@
 	this.seaShips = [];
 	this.seaTpShips = [];
 	this.seaWarships = [];
+	this.fishingShips = [];
 
 	// wanted NB per zone.
 	this.wantedTpShips = [];
 	this.wantedWarships = [];
+	this.wantedFishShips = [];
 	
 	this.transportPlans = [];
 	this.askedPlans = [];
@@ -42,10 +44,12 @@
 	// note: those two can overlap (some transport ships are warships too and vice-versa).
 	this.tpShips = this.ships.filter(Filters.byCanGarrison());
 	this.warships = this.ships.filter(Filters.byClass("Warship"));
+	this.fishingShips = this.ships.filter(Filters.byClass("FishingBoat"));
 
 	this.ships.registerUpdates();
 	this.tpShips.registerUpdates();
 	this.warships.registerUpdates();
+	this.fishingShips.registerUpdates();
 	
 	for (var i = 0; i < gameState.ai.accessibility.regionSize.length; ++i)
 	{
@@ -55,8 +59,10 @@
 			this.seaShips.push(new EntityCollection(gameState.sharedScript));
 			this.seaTpShips.push(new EntityCollection(gameState.sharedScript));
 			this.seaWarships.push(new EntityCollection(gameState.sharedScript));
+			this.fishingShips.push(new EntityCollection(gameState.sharedScript));
 			this.wantedTpShips.push(0);
 			this.wantedWarships.push(0);
+			this.wantedFishShips.push(0);
 		} else {
 			var collec = this.ships.filter(Filters.byStaticMetadata(PlayerID, "sea", i));
 			collec.registerUpdates();
@@ -67,6 +73,8 @@
 			var collec = this.warships.filter(Filters.byStaticMetadata(PlayerID, "sea", i));
 			collec.registerUpdates();
 			this.seaWarships.push(collec);
+			collec = this.warships.filter(Filters.byStaticMetadata(PlayerID, "sea", i));
+			collec.registerUpdates();
 			
 			this.wantedTpShips.push(1);
 			this.wantedWarships.push(1);
@@ -181,18 +189,96 @@
 NavalManager.prototype.maintainFleet = function(gameState, queues, events) {
 	// check if we have enough transport ships.
 	// check per region.
+	
+	// check if we can build the Ptolemaic Champion Juggernaut.
+	var superShipAllowed = gameState.getTemplate(gameState.applyCiv("units/ptol_champion_juggernaut")).available(gameState);
+	
+	// check if we can build more than one.
+	var hasSuperShipHero = ((gameState.getOwnEntities().filter(Filters.byType("units/ptol_hero_ptolemy_IV"))).length() === 1) ? true : false;
+	
+	// check how many we already have.
+	var totalSuperShips = (gameState.getOwnEntities().filter(Filters.byType("units/ptol_champion_juggernaut"))).length();
 	for (var i = 0; i < this.seaShips.length; ++i)
 	{
 		var tpNb = gameState.countOwnQueuedEntitiesWithMetadata("sea", i);
-		if (this.accessibleSeas.indexOf(i) !== -1 && this.seaTpShips[i].length < this.wantedTpShips[i]
-			&& tpNb + queues.ships.length() === 0 && gameState.getTemplate(gameState.applyCiv("units/{civ}_ship_bireme")).available(gameState))
+		var warNb = gameState.countOwnQueuedEntitiesWithMetadata("sea", (0 - i));
+		if (this.accessibleSeas.indexOf(i) !== -1)
 		{
-			// TODO: check our dock can build the wanted ship types, for Carthage.
-			queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_bireme", { "sea" : i }, 1, 0, -1, 1 ));
-		}
+			if (gameState.getTemplate(gameState.applyCiv("units/iber_ship_fire")).available(gameState)) // Check our naval options.
+			{
+				if (this.seaWarships[i].length < this.wantedWarships[i] && warNb + queues.ships.length() === 0)
+				{
+					queues.ships.addItem(new TrainingPlan(gameState, "units/iber_ship_fire", { "sea" : (0 - i) }, 1, 0, -1, 1));
+				}
+				if (this.seaTpShips[i].length < this.wantedTpShips[i] && tpNb + queues.ships.length() === 0)
+				{
+					 queues.ships.addItem(new TrainingPlan(gameState, "units/iber_ship_merchant", { "sea" : i }, 1, 0, -1, 1));
+				}
+			}
+			else
+			{
+				if (gameState.getTemplate(gameState.applyCiv("units/{civ}_ship_quinquereme")).available(gameState)) // Check if we command Rome, Carthage, Ptolemies, or Seleucids.
+				{
+					if (this.seaWarships[i].length < this.wantedWarships[i] && warNb + queues.ships.length() === 0)
+					{
+						if (i % 5 === 0) // be sparing in production of big ships, so as to conserve resources and population space.
+						{
+							queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_quinquereme", { "sea" : (0 - i) }, 1, 0, -1, 1));
+						}
+						else
+						{
+							if (i % 7 === 0 && superShipAllowed && (totalSuperShips === 0 || (totalSuperShips < 5 && hasSuperShipHero)))
+							{
+								queues.ships.addItem(new TrainingPlan(gameState, "units/ptol_champion_juggernaut", { "sea" : (0 - i) }, 1, 0, -1, 1));
+							}
+							else
+							{
+								queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_trireme", { "sea" : (0 - i) }, 1, 0, -1, 1));
+							}
+						}
+					}
+					if (this.seaTpShips[i].length < this.wantedTpShips[i] && tpNb + queues.ships.length() === 0)
+					{
+						queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_bireme", { "sea" : i }, 1, 0, -1, 1));
+					}
+				}
+				else
+				{
+					if (this.seaWarships[i].length < this.wantedWarships[i] && warNb + queues.ships.length() === 0)
+					{
+						  queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_trireme", { "sea" : (0 - i) }, 1, 0, -1, 1));
+					}
+					if (this.seaTpShips[i].length < this.wantedTpShips && tpNb + queues.ships.length() === 0)
+					{
+						if (gameState.getTemplate(gameState.applyCiv("units/{civ}_ship_bireme")).available(gameState))
+						{
+							queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_bireme", { "sea" : i }, 1, 0, -1, 1));
+						}
+						else
+						{
+							if (i % 3 === 0)
+							{
+								queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_trireme", { "sea" : i }, 1, 0. -1, 1));
+							}
+							else
+							{
+								queues.ships.addItem(new TrainingPlan(gameState, "units/{civ}_ship_merchant", { "sea" : i }, 1, 0, -1, 1));
+							}
+						}
+			
+					}
+				}
+			}
+		}			
 	}
 };
 
+NavalManager.prototype.findFish = function(gameState, resource) {
+};
+
+NavalManager.prototype.orderFishing = function(gameState, queues) {
+};
+
 // bumps up the number of ships we want if we need more.
 NavalManager.prototype.checkLevels = function(gameState, queues) {
 	if (queues.ships.length() !== 0)
