Page MenuHomeWildfire Games

Correct detected number of Barracks by Petra when building training facilities
ClosedPublic

Authored by Silier on May 2 2019, 1:44 PM.

Details

Summary

Class Barracks has been removed from Ranged training building, but Petra is still lowering number of detected barracks by number of detected ranged barracks, what makes the count of barracks (melee) incorrect.

Test Plan

:)

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Silier created this revision.May 2 2019, 1:44 PM
Owners added a subscriber: Restricted Owners Package.May 2 2019, 1:44 PM
Vulcan added a comment.May 2 2019, 1:45 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 209| 209| 	}
| 210| 210| 
| 211| 211| 	for (let evt of events.Destroy)
| 212|    |-	{
|    | 212|+	
| 213| 213| 		// Let's check we haven't lost an important building here.
| 214| 214| 		if (evt && !evt.SuccessfulFoundation && evt.entityObj && evt.metadata && evt.metadata[PlayerID] &&
| 215| 215| 			evt.metadata[PlayerID].base)
| 226| 226| 			if (evt.metadata[PlayerID].baseAnchor && evt.metadata[PlayerID].baseAnchor === true)
| 227| 227| 				base.anchorLost(gameState, ent);
| 228| 228| 		}
| 229|    |-	}
|    | 229|+	
| 230| 230| 
| 231| 231| 	for (let evt of events.EntityRenamed)
| 232| 232| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 255| 255| 			// Let's get a few units from other bases there to build this.
| 256| 256| 			let builders = this.bulkPickWorkers(gameState, newbase, 10);
| 257| 257| 			if (builders !== false)
| 258|    |-			{
|    | 258|+			
| 259| 259| 				builders.forEach(worker => {
| 260| 260| 					worker.setMetadata(PlayerID, "base", newbase.ID);
| 261| 261| 					worker.setMetadata(PlayerID, "subrole", "builder");
| 262| 262| 					worker.setMetadata(PlayerID, "target-foundation", ent.id());
| 263| 263| 				});
| 264|    |-			}
|    | 264|+			
| 265| 265| 		}
| 266| 266| 		else if (ent.getMetadata(PlayerID, "base") == -2)	// anchorless base around a dock
| 267| 267| 		{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 269| 269| 			// Let's get a few units from other bases there to build this.
| 270| 270| 			let builders = this.bulkPickWorkers(gameState, newbase, 4);
| 271| 271| 			if (builders != false)
| 272|    |-			{
|    | 272|+			
| 273| 273| 				builders.forEach(worker => {
| 274| 274| 					worker.setMetadata(PlayerID, "base", newbase.ID);
| 275| 275| 					worker.setMetadata(PlayerID, "subrole", "builder");
| 276| 276| 					worker.setMetadata(PlayerID, "target-foundation", ent.id());
| 277| 277| 				});
| 278|    |-			}
|    | 278|+			
| 279| 279| 		}
| 280| 280| 	}
| 281| 281| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 395| 395| 	}
| 396| 396| 
| 397| 397| 	for (let evt of events.TrainingFinished)
| 398|    |-	{
|    | 398|+	
| 399| 399| 		for (let entId of evt.entities)
| 400| 400| 		{
| 401| 401| 			let ent = gameState.getEntityById(entId);
| 463| 463| 					ent.moveToRange(goal[0], goal[1]);
| 464| 464| 			}
| 465| 465| 		}
| 466|    |-	}
|    | 466|+	
| 467| 467| 
| 468| 468| 	for (let evt of events.TerritoryDecayChanged)
| 469| 469| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 411| 411| 					this.garrisonManager.registerHolder(gameState, holder);
| 412| 412| 			}
| 413| 413| 			else if (ent.getMetadata(PlayerID, "garrisonType"))
| 414|    |-			{
|    | 414|+			
| 415| 415| 				// we were supposed to be autogarrisoned, but this has failed (may-be full)
| 416| 416| 				ent.setMetadata(PlayerID, "garrisonType", undefined);
| 417|    |-			}
|    | 417|+			
| 418| 418| 
| 419| 419| 			// Check if this unit is no more needed in its attack plan
| 420| 420| 			// (happen when the training ends after the attack is started or aborted)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 482| 482| 	}
| 483| 483| 
| 484| 484| 	if (addBase)
| 485|    |-	{
|    | 485|+	
| 486| 486| 		if (!this.firstBaseConfig)
| 487| 487| 		{
| 488| 488| 			// This is our first base, let us configure our starting resources
| 495| 495| 			this.saveSpace = undefined;
| 496| 496| 			this.maxFields = false;
| 497| 497| 		}
| 498|    |-	}
|    | 498|+	
| 499| 499| 
| 500| 500| 	// Then deals with decaying structures: destroy them if being lost to enemy (except in easier difficulties)
| 501| 501| 	if (this.Config.difficulty < 2)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 484| 484| 	if (addBase)
| 485| 485| 	{
| 486| 486| 		if (!this.firstBaseConfig)
| 487|    |-		{
|    | 487|+		
| 488| 488| 			// This is our first base, let us configure our starting resources
| 489| 489| 			this.configFirstBase(gameState);
| 490|    |-		}
|    | 490|+		
| 491| 491| 		else
| 492| 492| 		{
| 493| 493| 			// Let us hope this new base will fix our possible resource shortage
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 773| 773| 		let aValue = 0.1;
| 774| 774| 		let bValue = 0.1;
| 775| 775| 		for (let param of parameters)
| 776|    |-		{
|    | 776|+		
| 777| 777| 			if (param[0] == "strength")
| 778| 778| 			{
| 779| 779| 				aValue += m.getMaxStrength(a[1]) * param[1];
| 807| 807| 			}
| 808| 808| 			else
| 809| 809| 				API3.warn(" trainMoreUnits avec non prevu " + uneval(param));
| 810|    |-		}
|    | 810|+		
| 811| 811| 		return -aValue/aCost + bValue/bCost;
| 812| 812| 	});
| 813| 813| 	return units[0][0];
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1051|1051| 				continue;
|1052|1052| 
|1053|1053| 			if (minDist > maxAccessDisfavored)     // Disfavor if quite far from any allied cc
|1054|    |-			{
|    |1054|+			
|1055|1055| 				if (!accessible)
|1056|1056| 				{
|1057|1057| 					if (minDist > maxNoAccessDisfavored)
|1061|1061| 				}
|1062|1062| 				else
|1063|1063| 					norm *= 0.5;
|1064|    |-			}
|    |1064|+			
|1065|1065| 
|1066|1066| 			// Not near any of our dropsite, except for oversea docks
|1067|1067| 			oversea = !accessible && dpList.some(dp => m.getLandAccess(gameState, dp.ent) == index);
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1053|1053| 			if (minDist > maxAccessDisfavored)     // Disfavor if quite far from any allied cc
|1054|1054| 			{
|1055|1055| 				if (!accessible)
|1056|    |-				{
|    |1056|+				
|1057|1057| 					if (minDist > maxNoAccessDisfavored)
|1058|1058| 						norm *= 0.5;
|1059|1059| 					else
|1060|1060| 						norm *= 0.8;
|1061|    |-				}
|    |1061|+				
|1062|1062| 				else
|1063|1063| 					norm *= 0.5;
|1064|1064| 			}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1066|1066| 			// Not near any of our dropsite, except for oversea docks
|1067|1067| 			oversea = !accessible && dpList.some(dp => m.getLandAccess(gameState, dp.ent) == index);
|1068|1068| 			if (!oversea)
|1069|    |-			{
|    |1069|+			
|1070|1070| 				for (let dp of dpList)
|1071|1071| 				{
|1072|1072| 					let dist = API3.SquareVectorDistance(dp.pos, pos);
|1078|1078| 					else if (dist < 6400)
|1079|1079| 						norm *= 0.5;
|1080|1080| 				}
|1081|    |-			}
|    |1081|+			
|1082|1082| 			if (norm == 0)
|1083|1083| 				continue;
|1084|1084| 		}
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1092|1092| 				val += gameState.sharedScript.ccResourceMaps[res].map[j];
|1093|1093| 		val *= norm;
|1094|1094| 
|1095|    |-		// If oversea, be just above threshold to be accepted if nothing else 
|    |1095|+		// If oversea, be just above threshold to be accepted if nothing else
|1096|1096| 		if (oversea)
|1097|1097| 			val = Math.max(val, cut + 0.1);
|1098|1098| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1378|1378| 	// do not keep it if gain is too small, except if this is our first BarterMarket
|1379|1379| 	let idx;
|1380|1380| 	if (expectedGain < this.tradeManager.minimalGain)
|1381|    |-	{
|    |1381|+	
|1382|1382| 		if (template.hasClass("BarterMarket") &&
|1383|1383| 		    !gameState.getOwnEntitiesByClass("BarterMarket", true).hasEntities())
|1384|1384| 			idx = -1;	// needed by queueplanBuilding manager to keep that market
|1385|1385| 		else
|1386|1386| 			return false;
|1387|    |-	}
|    |1387|+	
|1388|1388| 	else
|1389|1389| 		idx = this.basesMap.map[bestJdx];
|1390|1390| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1565|1565| 			let cost = queues.economicBuilding.plans[0].getCost();
|1566|1566| 			queueManager.setAccounts(gameState, cost, "economicBuilding");
|1567|1567| 			if (!queueManager.canAfford("economicBuilding", cost))
|1568|    |-			{
|    |1568|+			
|1569|1569| 				for (let q in queueManager.queues)
|1570|1570| 				{
|1571|1571| 					if (q == "economicBuilding")
|1574|1574| 					if (queueManager.canAfford("economicBuilding", cost))
|1575|1575| 						break;
|1576|1576| 				}
|1577|    |-			}
|    |1577|+			
|1578|1578| 		}
|1579|1579| 		return;
|1580|1580| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-in'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1624|1624| 		let highLevel = 0;
|1625|1625| 		let lowLevel = 0;
|1626|1626| 		for (let res in cost)
|1627|    |-		{
|    |1627|+		
|1628|1628| 			if (resources[res] && resources[res] > 0.7 * cost[res])
|1629|1629| 				++highLevel;
|1630|1630| 			else if (!resources[res] || resources[res] < 0.3 * cost[res])
|1631|1631| 				++lowLevel;
|1632|    |-		}
|    |1632|+		
|1633|1633| 		if (highLevel == 0 || lowLevel > 1)
|1634|1634| 			return;
|1635|1635| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1750|1750| 	let freeSlots = gameState.getPopulationLimit() + HouseNb*popBonus - this.getAccountedPopulation(gameState);
|1751|1751| 	let priority;
|1752|1752| 	if (freeSlots < 5)
|1753|    |-	{
|    |1753|+	
|1754|1754| 		if (this.buildManager.isUnbuildable(gameState, house))
|1755|1755| 		{
|1756|1756| 			if (this.Config.debug > 1)
|1759|1759| 		}
|1760|1760| 		else
|1761|1761| 			priority = 2*this.Config.priorities.house;
|1762|    |-	}
|    |1762|+	
|1763|1763| 	else
|1764|1764| 		priority = this.Config.priorities.house;
|1765|1765| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1841|1841| 		return;
|1842|1842| 
|1843|1843| 	if (!this.saveResources && (this.currentPhase > 2 || gameState.isResearching(gameState.getPhaseName(3))))
|1844|    |-	{
|    |1844|+	
|1845|1845| 		// try to build fortresses
|1846|1846| 		if (this.canBuild(gameState, "structures/{civ}_fortress"))
|1847|1847| 		{
|1860|1860| 				return;
|1861|1861| 			}
|1862|1862| 		}
|1863|    |-	}
|    |1863|+	
|1864|1864| 
|1865|1865| 	if (this.Config.Military.numSentryTowers && this.currentPhase < 2 && this.canBuild(gameState, "structures/{civ}_sentry_tower"))
|1866|1866| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2005|2005| 		nAdvanced += gameState.countEntitiesAndQueuedByType(advanced, true);
|2006|2006| 
|2007|2007| 	if (!nAdvanced || nAdvanced < this.bAdvanced.length && this.getAccountedPopulation(gameState) > 110)
|2008|    |-	{
|    |2008|+	
|2009|2009| 		for (let advanced of this.bAdvanced)
|2010|2010| 		{
|2011|2011| 			if (gameState.countEntitiesAndQueuedByType(advanced, true) > 0 || !this.canBuild(gameState, advanced))
|2020|2020| 				queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, advanced));
|2021|2021| 			return;
|2022|2022| 		}
|2023|    |-	}
|    |2023|+	
|2024|2024| };
|2025|2025| 
|2026|2026| /**
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2108|2108| 	// in which case we prefer melee units
|2109|2109| 	let numGarrisoned = this.garrisonManager.numberOfGarrisonedUnits(nearestAnchor);
|2110|2110| 	if (nearestAnchor._entity.trainingQueue)
|2111|    |-	{
|    |2111|+	
|2112|2112| 		for (let item of nearestAnchor._entity.trainingQueue)
|2113|2113| 		{
|2114|2114| 			if (item.metadata && item.metadata.garrisonType)
|2116|2116| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2117|2117| 				nearestAnchor.stopProduction(item.id);
|2118|2118| 		}
|2119|    |-	}
|    |2119|+	
|2120|2120| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2121|2121| 	                   nearestAnchor.hitpoints() > nearestAnchor.garrisonEjectHealth() * nearestAnchor.maxHitpoints();
|2122|2122| 	let rangedWanted = randBool() && autogarrison;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2110|2110| 	if (nearestAnchor._entity.trainingQueue)
|2111|2111| 	{
|2112|2112| 		for (let item of nearestAnchor._entity.trainingQueue)
|2113|    |-		{
|    |2113|+		
|2114|2114| 			if (item.metadata && item.metadata.garrisonType)
|2115|2115| 				numGarrisoned += item.count;
|2116|2116| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2117|2117| 				nearestAnchor.stopProduction(item.id);
|2118|    |-		}
|    |2118|+		
|2119|2119| 	}
|2120|2120| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2121|2121| 	                   nearestAnchor.hitpoints() > nearestAnchor.garrisonEjectHealth() * nearestAnchor.maxHitpoints();
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2150|2150| 	let cost = new API3.Resources(templateFound[1].cost());
|2151|2151| 	queueManager.setAccounts(gameState, cost, "emergency");
|2152|2152| 	if (!queueManager.canAfford("emergency", cost))
|2153|    |-	{
|    |2153|+	
|2154|2154| 		for (let q in queueManager.queues)
|2155|2155| 		{
|2156|2156| 			if (q == "emergency")
|2159|2159| 			if (queueManager.canAfford("emergency", cost))
|2160|2160| 				break;
|2161|2161| 		}
|2162|    |-	}
|    |2162|+	
|2163|2163| 	let metadata = { "role": "worker", "base": nearestAnchor.getMetadata(PlayerID, "base"), "plan": -1, "trainer": nearestAnchor.id() };
|2164|2164| 	if (autogarrison)
|2165|2165| 		metadata.garrisonType = "protection";
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2440|2440| m.HQ.prototype.assignGatherers = function()
|2441|2441| {
|2442|2442| 	for (let base of this.baseManagers)
|2443|    |-	{
|    |2443|+	
|2444|2444| 		for (let worker of base.workers.values())
|2445|2445| 		{
|2446|2446| 			if (worker.unitAIState().split(".")[1] != "RETURNRESOURCE")
|2450|2450| 				continue;
|2451|2451| 			this.AddTCGatherer(orders[1].target);
|2452|2452| 		}
|2453|    |-	}
|    |2453|+	
|2454|2454| };
|2455|2455| 
|2456|2456| m.HQ.prototype.isDangerousLocation = function(gameState, pos, radius)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2622|2622| 	{
|2623|2623| 		let pop = gameState.getPopulation();
|2624|2624| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2625|    |-		{
|    |2625|+		
|2626|2626| 			for (let item of ent.trainingQueue())
|2627|2627| 			{
|2628|2628| 				if (!item.unitTemplate)
|2631|2631| 				if (unitPop)
|2632|2632| 					pop += item.count * unitPop;
|2633|2633| 			}
|2634|    |-		}
|    |2634|+		
|2635|2635| 		this.turnCache.accountedPopulation = pop;
|2636|2636| 	}
|2637|2637| 	return this.turnCache.accountedPopulation;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2646|2646| 	{
|2647|2647| 		let workers = gameState.getOwnEntitiesByRole("worker", true).length;
|2648|2648| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2649|    |-		{
|    |2649|+		
|2650|2650| 			for (let item of ent.trainingQueue())
|2651|2651| 			{
|2652|2652| 				if (!item.metadata || !item.metadata.role || item.metadata.role != "worker")
|2653|2653| 					continue;
|2654|2654| 				workers += item.count;
|2655|2655| 			}
|2656|    |-		}
|    |2656|+		
|2657|2657| 		this.turnCache.accountedWorkers = workers;
|2658|2658| 	}
|2659|2659| 	return this.turnCache.accountedWorkers;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2684|2684| 			this.phasing = 0;
|2685|2685| 	}
|2686|2686| 
|2687|    |-/*	if (this.Config.debug > 1)
|    |2687|+	/*	if (this.Config.debug > 1)
|2688|2688| 	{
|2689|2689| 		gameState.getOwnUnits().forEach (function (ent) {
|2690|2690| 			if (!ent.position())
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2759|2759| 		this.currentBase %= this.baseManagers.length;
|2760|2760| 		activeBase = this.baseManagers[this.currentBase++].update(gameState, queues, events);
|2761|2761| 		--nbBases;
|2762|    |-// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|    |2762|+		// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|2763|2763| 	}
|2764|2764| 	while (!activeBase && nbBases != 0);
|2765|2765| 

binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 524| »   »   »   let·ratioMax·=·0.70·+·randFloat(0.,·0.1);
|    | [NORMAL] JSHintBear:
|    | A trailing decimal point can be confused with a dot: '0.'.

binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 529| »   »   »   »   ratioMax·=·0.85·+·randFloat(0.,·0.1);
|    | [NORMAL] JSHintBear:
|    | A trailing decimal point can be confused with a dot: '0.'.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1319/display/redirect

bb added a subscriber: bb.May 2 2019, 1:51 PM

Thanks for noticing this, didn't we also rename the archery class in the commit?

Nescio added a subscriber: Nescio.EditedMay 2 2019, 2:00 PM

Yes, the Archery class has been replaced with a Range class (rP22190)

Silier updated this revision to Diff 7899.EditedMay 2 2019, 2:26 PM

update class for Ranged barracks. Funny, it did not break because range barrack detection was broken. :)

Vulcan added a comment.May 2 2019, 2:28 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 209| 209| 	}
| 210| 210| 
| 211| 211| 	for (let evt of events.Destroy)
| 212|    |-	{
|    | 212|+	
| 213| 213| 		// Let's check we haven't lost an important building here.
| 214| 214| 		if (evt && !evt.SuccessfulFoundation && evt.entityObj && evt.metadata && evt.metadata[PlayerID] &&
| 215| 215| 			evt.metadata[PlayerID].base)
| 226| 226| 			if (evt.metadata[PlayerID].baseAnchor && evt.metadata[PlayerID].baseAnchor === true)
| 227| 227| 				base.anchorLost(gameState, ent);
| 228| 228| 		}
| 229|    |-	}
|    | 229|+	
| 230| 230| 
| 231| 231| 	for (let evt of events.EntityRenamed)
| 232| 232| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 255| 255| 			// Let's get a few units from other bases there to build this.
| 256| 256| 			let builders = this.bulkPickWorkers(gameState, newbase, 10);
| 257| 257| 			if (builders !== false)
| 258|    |-			{
|    | 258|+			
| 259| 259| 				builders.forEach(worker => {
| 260| 260| 					worker.setMetadata(PlayerID, "base", newbase.ID);
| 261| 261| 					worker.setMetadata(PlayerID, "subrole", "builder");
| 262| 262| 					worker.setMetadata(PlayerID, "target-foundation", ent.id());
| 263| 263| 				});
| 264|    |-			}
|    | 264|+			
| 265| 265| 		}
| 266| 266| 		else if (ent.getMetadata(PlayerID, "base") == -2)	// anchorless base around a dock
| 267| 267| 		{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 269| 269| 			// Let's get a few units from other bases there to build this.
| 270| 270| 			let builders = this.bulkPickWorkers(gameState, newbase, 4);
| 271| 271| 			if (builders != false)
| 272|    |-			{
|    | 272|+			
| 273| 273| 				builders.forEach(worker => {
| 274| 274| 					worker.setMetadata(PlayerID, "base", newbase.ID);
| 275| 275| 					worker.setMetadata(PlayerID, "subrole", "builder");
| 276| 276| 					worker.setMetadata(PlayerID, "target-foundation", ent.id());
| 277| 277| 				});
| 278|    |-			}
|    | 278|+			
| 279| 279| 		}
| 280| 280| 	}
| 281| 281| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 395| 395| 	}
| 396| 396| 
| 397| 397| 	for (let evt of events.TrainingFinished)
| 398|    |-	{
|    | 398|+	
| 399| 399| 		for (let entId of evt.entities)
| 400| 400| 		{
| 401| 401| 			let ent = gameState.getEntityById(entId);
| 463| 463| 					ent.moveToRange(goal[0], goal[1]);
| 464| 464| 			}
| 465| 465| 		}
| 466|    |-	}
|    | 466|+	
| 467| 467| 
| 468| 468| 	for (let evt of events.TerritoryDecayChanged)
| 469| 469| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 411| 411| 					this.garrisonManager.registerHolder(gameState, holder);
| 412| 412| 			}
| 413| 413| 			else if (ent.getMetadata(PlayerID, "garrisonType"))
| 414|    |-			{
|    | 414|+			
| 415| 415| 				// we were supposed to be autogarrisoned, but this has failed (may-be full)
| 416| 416| 				ent.setMetadata(PlayerID, "garrisonType", undefined);
| 417|    |-			}
|    | 417|+			
| 418| 418| 
| 419| 419| 			// Check if this unit is no more needed in its attack plan
| 420| 420| 			// (happen when the training ends after the attack is started or aborted)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 482| 482| 	}
| 483| 483| 
| 484| 484| 	if (addBase)
| 485|    |-	{
|    | 485|+	
| 486| 486| 		if (!this.firstBaseConfig)
| 487| 487| 		{
| 488| 488| 			// This is our first base, let us configure our starting resources
| 495| 495| 			this.saveSpace = undefined;
| 496| 496| 			this.maxFields = false;
| 497| 497| 		}
| 498|    |-	}
|    | 498|+	
| 499| 499| 
| 500| 500| 	// Then deals with decaying structures: destroy them if being lost to enemy (except in easier difficulties)
| 501| 501| 	if (this.Config.difficulty < 2)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 484| 484| 	if (addBase)
| 485| 485| 	{
| 486| 486| 		if (!this.firstBaseConfig)
| 487|    |-		{
|    | 487|+		
| 488| 488| 			// This is our first base, let us configure our starting resources
| 489| 489| 			this.configFirstBase(gameState);
| 490|    |-		}
|    | 490|+		
| 491| 491| 		else
| 492| 492| 		{
| 493| 493| 			// Let us hope this new base will fix our possible resource shortage
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 773| 773| 		let aValue = 0.1;
| 774| 774| 		let bValue = 0.1;
| 775| 775| 		for (let param of parameters)
| 776|    |-		{
|    | 776|+		
| 777| 777| 			if (param[0] == "strength")
| 778| 778| 			{
| 779| 779| 				aValue += m.getMaxStrength(a[1]) * param[1];
| 807| 807| 			}
| 808| 808| 			else
| 809| 809| 				API3.warn(" trainMoreUnits avec non prevu " + uneval(param));
| 810|    |-		}
|    | 810|+		
| 811| 811| 		return -aValue/aCost + bValue/bCost;
| 812| 812| 	});
| 813| 813| 	return units[0][0];
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1051|1051| 				continue;
|1052|1052| 
|1053|1053| 			if (minDist > maxAccessDisfavored)     // Disfavor if quite far from any allied cc
|1054|    |-			{
|    |1054|+			
|1055|1055| 				if (!accessible)
|1056|1056| 				{
|1057|1057| 					if (minDist > maxNoAccessDisfavored)
|1061|1061| 				}
|1062|1062| 				else
|1063|1063| 					norm *= 0.5;
|1064|    |-			}
|    |1064|+			
|1065|1065| 
|1066|1066| 			// Not near any of our dropsite, except for oversea docks
|1067|1067| 			oversea = !accessible && dpList.some(dp => m.getLandAccess(gameState, dp.ent) == index);
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1053|1053| 			if (minDist > maxAccessDisfavored)     // Disfavor if quite far from any allied cc
|1054|1054| 			{
|1055|1055| 				if (!accessible)
|1056|    |-				{
|    |1056|+				
|1057|1057| 					if (minDist > maxNoAccessDisfavored)
|1058|1058| 						norm *= 0.5;
|1059|1059| 					else
|1060|1060| 						norm *= 0.8;
|1061|    |-				}
|    |1061|+				
|1062|1062| 				else
|1063|1063| 					norm *= 0.5;
|1064|1064| 			}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1066|1066| 			// Not near any of our dropsite, except for oversea docks
|1067|1067| 			oversea = !accessible && dpList.some(dp => m.getLandAccess(gameState, dp.ent) == index);
|1068|1068| 			if (!oversea)
|1069|    |-			{
|    |1069|+			
|1070|1070| 				for (let dp of dpList)
|1071|1071| 				{
|1072|1072| 					let dist = API3.SquareVectorDistance(dp.pos, pos);
|1078|1078| 					else if (dist < 6400)
|1079|1079| 						norm *= 0.5;
|1080|1080| 				}
|1081|    |-			}
|    |1081|+			
|1082|1082| 			if (norm == 0)
|1083|1083| 				continue;
|1084|1084| 		}
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1092|1092| 				val += gameState.sharedScript.ccResourceMaps[res].map[j];
|1093|1093| 		val *= norm;
|1094|1094| 
|1095|    |-		// If oversea, be just above threshold to be accepted if nothing else 
|    |1095|+		// If oversea, be just above threshold to be accepted if nothing else
|1096|1096| 		if (oversea)
|1097|1097| 			val = Math.max(val, cut + 0.1);
|1098|1098| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1378|1378| 	// do not keep it if gain is too small, except if this is our first BarterMarket
|1379|1379| 	let idx;
|1380|1380| 	if (expectedGain < this.tradeManager.minimalGain)
|1381|    |-	{
|    |1381|+	
|1382|1382| 		if (template.hasClass("BarterMarket") &&
|1383|1383| 		    !gameState.getOwnEntitiesByClass("BarterMarket", true).hasEntities())
|1384|1384| 			idx = -1;	// needed by queueplanBuilding manager to keep that market
|1385|1385| 		else
|1386|1386| 			return false;
|1387|    |-	}
|    |1387|+	
|1388|1388| 	else
|1389|1389| 		idx = this.basesMap.map[bestJdx];
|1390|1390| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1565|1565| 			let cost = queues.economicBuilding.plans[0].getCost();
|1566|1566| 			queueManager.setAccounts(gameState, cost, "economicBuilding");
|1567|1567| 			if (!queueManager.canAfford("economicBuilding", cost))
|1568|    |-			{
|    |1568|+			
|1569|1569| 				for (let q in queueManager.queues)
|1570|1570| 				{
|1571|1571| 					if (q == "economicBuilding")
|1574|1574| 					if (queueManager.canAfford("economicBuilding", cost))
|1575|1575| 						break;
|1576|1576| 				}
|1577|    |-			}
|    |1577|+			
|1578|1578| 		}
|1579|1579| 		return;
|1580|1580| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-in'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1624|1624| 		let highLevel = 0;
|1625|1625| 		let lowLevel = 0;
|1626|1626| 		for (let res in cost)
|1627|    |-		{
|    |1627|+		
|1628|1628| 			if (resources[res] && resources[res] > 0.7 * cost[res])
|1629|1629| 				++highLevel;
|1630|1630| 			else if (!resources[res] || resources[res] < 0.3 * cost[res])
|1631|1631| 				++lowLevel;
|1632|    |-		}
|    |1632|+		
|1633|1633| 		if (highLevel == 0 || lowLevel > 1)
|1634|1634| 			return;
|1635|1635| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1750|1750| 	let freeSlots = gameState.getPopulationLimit() + HouseNb*popBonus - this.getAccountedPopulation(gameState);
|1751|1751| 	let priority;
|1752|1752| 	if (freeSlots < 5)
|1753|    |-	{
|    |1753|+	
|1754|1754| 		if (this.buildManager.isUnbuildable(gameState, house))
|1755|1755| 		{
|1756|1756| 			if (this.Config.debug > 1)
|1759|1759| 		}
|1760|1760| 		else
|1761|1761| 			priority = 2*this.Config.priorities.house;
|1762|    |-	}
|    |1762|+	
|1763|1763| 	else
|1764|1764| 		priority = this.Config.priorities.house;
|1765|1765| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1841|1841| 		return;
|1842|1842| 
|1843|1843| 	if (!this.saveResources && (this.currentPhase > 2 || gameState.isResearching(gameState.getPhaseName(3))))
|1844|    |-	{
|    |1844|+	
|1845|1845| 		// try to build fortresses
|1846|1846| 		if (this.canBuild(gameState, "structures/{civ}_fortress"))
|1847|1847| 		{
|1860|1860| 				return;
|1861|1861| 			}
|1862|1862| 		}
|1863|    |-	}
|    |1863|+	
|1864|1864| 
|1865|1865| 	if (this.Config.Military.numSentryTowers && this.currentPhase < 2 && this.canBuild(gameState, "structures/{civ}_sentry_tower"))
|1866|1866| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2005|2005| 		nAdvanced += gameState.countEntitiesAndQueuedByType(advanced, true);
|2006|2006| 
|2007|2007| 	if (!nAdvanced || nAdvanced < this.bAdvanced.length && this.getAccountedPopulation(gameState) > 110)
|2008|    |-	{
|    |2008|+	
|2009|2009| 		for (let advanced of this.bAdvanced)
|2010|2010| 		{
|2011|2011| 			if (gameState.countEntitiesAndQueuedByType(advanced, true) > 0 || !this.canBuild(gameState, advanced))
|2020|2020| 				queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, advanced));
|2021|2021| 			return;
|2022|2022| 		}
|2023|    |-	}
|    |2023|+	
|2024|2024| };
|2025|2025| 
|2026|2026| /**
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2108|2108| 	// in which case we prefer melee units
|2109|2109| 	let numGarrisoned = this.garrisonManager.numberOfGarrisonedUnits(nearestAnchor);
|2110|2110| 	if (nearestAnchor._entity.trainingQueue)
|2111|    |-	{
|    |2111|+	
|2112|2112| 		for (let item of nearestAnchor._entity.trainingQueue)
|2113|2113| 		{
|2114|2114| 			if (item.metadata && item.metadata.garrisonType)
|2116|2116| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2117|2117| 				nearestAnchor.stopProduction(item.id);
|2118|2118| 		}
|2119|    |-	}
|    |2119|+	
|2120|2120| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2121|2121| 	                   nearestAnchor.hitpoints() > nearestAnchor.garrisonEjectHealth() * nearestAnchor.maxHitpoints();
|2122|2122| 	let rangedWanted = randBool() && autogarrison;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2110|2110| 	if (nearestAnchor._entity.trainingQueue)
|2111|2111| 	{
|2112|2112| 		for (let item of nearestAnchor._entity.trainingQueue)
|2113|    |-		{
|    |2113|+		
|2114|2114| 			if (item.metadata && item.metadata.garrisonType)
|2115|2115| 				numGarrisoned += item.count;
|2116|2116| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2117|2117| 				nearestAnchor.stopProduction(item.id);
|2118|    |-		}
|    |2118|+		
|2119|2119| 	}
|2120|2120| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2121|2121| 	                   nearestAnchor.hitpoints() > nearestAnchor.garrisonEjectHealth() * nearestAnchor.maxHitpoints();
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2150|2150| 	let cost = new API3.Resources(templateFound[1].cost());
|2151|2151| 	queueManager.setAccounts(gameState, cost, "emergency");
|2152|2152| 	if (!queueManager.canAfford("emergency", cost))
|2153|    |-	{
|    |2153|+	
|2154|2154| 		for (let q in queueManager.queues)
|2155|2155| 		{
|2156|2156| 			if (q == "emergency")
|2159|2159| 			if (queueManager.canAfford("emergency", cost))
|2160|2160| 				break;
|2161|2161| 		}
|2162|    |-	}
|    |2162|+	
|2163|2163| 	let metadata = { "role": "worker", "base": nearestAnchor.getMetadata(PlayerID, "base"), "plan": -1, "trainer": nearestAnchor.id() };
|2164|2164| 	if (autogarrison)
|2165|2165| 		metadata.garrisonType = "protection";
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2440|2440| m.HQ.prototype.assignGatherers = function()
|2441|2441| {
|2442|2442| 	for (let base of this.baseManagers)
|2443|    |-	{
|    |2443|+	
|2444|2444| 		for (let worker of base.workers.values())
|2445|2445| 		{
|2446|2446| 			if (worker.unitAIState().split(".")[1] != "RETURNRESOURCE")
|2450|2450| 				continue;
|2451|2451| 			this.AddTCGatherer(orders[1].target);
|2452|2452| 		}
|2453|    |-	}
|    |2453|+	
|2454|2454| };
|2455|2455| 
|2456|2456| m.HQ.prototype.isDangerousLocation = function(gameState, pos, radius)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2622|2622| 	{
|2623|2623| 		let pop = gameState.getPopulation();
|2624|2624| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2625|    |-		{
|    |2625|+		
|2626|2626| 			for (let item of ent.trainingQueue())
|2627|2627| 			{
|2628|2628| 				if (!item.unitTemplate)
|2631|2631| 				if (unitPop)
|2632|2632| 					pop += item.count * unitPop;
|2633|2633| 			}
|2634|    |-		}
|    |2634|+		
|2635|2635| 		this.turnCache.accountedPopulation = pop;
|2636|2636| 	}
|2637|2637| 	return this.turnCache.accountedPopulation;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2646|2646| 	{
|2647|2647| 		let workers = gameState.getOwnEntitiesByRole("worker", true).length;
|2648|2648| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2649|    |-		{
|    |2649|+		
|2650|2650| 			for (let item of ent.trainingQueue())
|2651|2651| 			{
|2652|2652| 				if (!item.metadata || !item.metadata.role || item.metadata.role != "worker")
|2653|2653| 					continue;
|2654|2654| 				workers += item.count;
|2655|2655| 			}
|2656|    |-		}
|    |2656|+		
|2657|2657| 		this.turnCache.accountedWorkers = workers;
|2658|2658| 	}
|2659|2659| 	return this.turnCache.accountedWorkers;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2684|2684| 			this.phasing = 0;
|2685|2685| 	}
|2686|2686| 
|2687|    |-/*	if (this.Config.debug > 1)
|    |2687|+	/*	if (this.Config.debug > 1)
|2688|2688| 	{
|2689|2689| 		gameState.getOwnUnits().forEach (function (ent) {
|2690|2690| 			if (!ent.position())
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2759|2759| 		this.currentBase %= this.baseManagers.length;
|2760|2760| 		activeBase = this.baseManagers[this.currentBase++].update(gameState, queues, events);
|2761|2761| 		--nbBases;
|2762|    |-// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|    |2762|+		// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|2763|2763| 	}
|2764|2764| 	while (!activeBase && nbBases != 0);
|2765|2765| 

binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 524| »   »   »   let·ratioMax·=·0.70·+·randFloat(0.,·0.1);
|    | [NORMAL] JSHintBear:
|    | A trailing decimal point can be confused with a dot: '0.'.

binaries/data/mods/public/simulation/ai/petra/headquarters.js
| 529| »   »   »   »   ratioMax·=·0.85·+·randFloat(0.,·0.1);
|    | [NORMAL] JSHintBear:
|    | A trailing decimal point can be confused with a dot: '0.'.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1320/display/redirect

Stan added a subscriber: temple.May 3 2019, 7:56 AM
This comment was removed by Stan.
Silier removed a reviewer: Stan.May 3 2019, 10:03 AM
Silier added inline comments.May 6 2019, 4:41 PM
binaries/data/mods/public/simulation/ai/petra/headquarters.js
1927 ↗(On Diff #7899)

@Nescio we have pers_stables and *_stable, + *_elephant_stables. Are you up to task to unify this (stable/stables) ? I would do myself but dont know which one is correct. (then this can be simplier)

Nescio added inline comments.May 6 2019, 6:08 PM
binaries/data/mods/public/simulation/ai/petra/headquarters.js
1927 ↗(On Diff #7899)

It ought to be “stable” (singular, without s).
Correcting it properly also involves renaming about two dozen art files and some sounds, and updating all files that invoke those.
Feel free to propose a patch.

Silier added inline comments.May 6 2019, 6:11 PM
binaries/data/mods/public/simulation/ai/petra/headquarters.js
1927 ↗(On Diff #7899)

I am speaking just about structure template names not every single one use in whole project :)

Nescio added inline comments.May 6 2019, 6:15 PM
binaries/data/mods/public/simulation/ai/petra/headquarters.js
1927 ↗(On Diff #7899)

Simply correcting Mauryans into Mauryas (D1342) required moving numerous art and other files, though.

Silier added a comment.May 6 2019, 7:39 PM

@bb could you please find some time to review and possibly commit this when you will be around? thank you

bb accepted this revision.May 13 2019, 8:41 PM

No other cases of "archery" in code

This revision is now accepted and ready to land.May 13 2019, 8:41 PM
This revision was automatically updated to reflect the committed changes.