Page MenuHomeWildfire Games

Rename class Stables to Stable following introduction in rP22280
ClosedPublic

Authored by Silier on May 14 2019, 9:43 AM.

Details

Summary

Patch rP22280 used by mistake class "Stable" instead "Stables", since form "Stable" seems to be the valid one based on changes of generic names in D1790 , this is going to rename class "Stables" to "Stable".

Add ElephantStables -> ElephantStable class rename

(This do not have intentions to fix every form of word stables in the code or in filenames. Only mentioned class.)

Test Plan

Check that there is no class Stables and ElephantStables in the code.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 7704
Build 12554: Vulcan BuildJenkins
Build 12553: arc lint + arc unit

Event Timeline

Silier created this revision.May 14 2019, 9:43 AM
Owners added a subscriber: Restricted Owners Package.May 14 2019, 9:43 AM

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/1402/display/redirect

Silier updated this revision to Diff 8023.May 14 2019, 10:09 AM

maps and techs

Owners added a subscriber: Restricted Owners Package.May 14 2019, 10:09 AM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (space-before-function-paren):
|    | Unexpected space before function parentheses.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Identity.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Identity.js
|  97|  97| 	this.visibleClassesList = GetVisibleIdentityClasses(this.template);
|  98|  98| };
|  99|  99| 
| 100|    |-Identity.prototype.Deserialize = function ()
|    | 100|+Identity.prototype.Deserialize = function()
| 101| 101| {
| 102| 102| 	this.Init();
| 103| 103| };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '9'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
| 120| 120| var jebelBarkal_firstAttackTime = (difficulty, isNomad) =>
| 121| 121| 	jebelBarkal_attackInterval(0, difficulty) +
| 122| 122| 	2 * Math.max(0, 3 - difficulty) +
| 123|    |-	(isNomad ?  9 - difficulty : 0);
|    | 123|+	(isNomad ? 9 - difficulty : 0);
| 124| 124| 
| 125| 125| /**
| 126| 126|  * Account for varying mapsizes and number of players when spawning attackers.

binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
| 639| {
|    | [NORMAL] ESLintBear (no-lone-blocks):
|    | Block is redundant.
|    | [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/1403/display/redirect

Nescio added a subscriber: Nescio.May 14 2019, 10:22 AM

For consistency, could you also rename the "ElephantStables" class to "ElephantStable"?

binaries/data/mods/public/simulation/components/Identity.js
65

And add the "Range" class here.

Silier updated this revision to Diff 8025.May 14 2019, 10:39 AM
Silier edited the summary of this revision. (Show Details)
Silier edited the test plan for this revision. (Show Details)

add ElephantStables

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (space-before-function-paren):
|    | Unexpected space before function parentheses.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Identity.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Identity.js
|  97|  97| 	this.visibleClassesList = GetVisibleIdentityClasses(this.template);
|  98|  98| };
|  99|  99| 
| 100|    |-Identity.prototype.Deserialize = function ()
|    | 100|+Identity.prototype.Deserialize = function()
| 101| 101| {
| 102| 102| 	this.Init();
| 103| 103| };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '9'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
| 120| 120| var jebelBarkal_firstAttackTime = (difficulty, isNomad) =>
| 121| 121| 	jebelBarkal_attackInterval(0, difficulty) +
| 122| 122| 	2 * Math.max(0, 3 - difficulty) +
| 123|    |-	(isNomad ?  9 - difficulty : 0);
|    | 123|+	(isNomad ? 9 - difficulty : 0);
| 124| 124| 
| 125| 125| /**
| 126| 126|  * Account for varying mapsizes and number of players when spawning attackers.

binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
| 639| {
|    | [NORMAL] ESLintBear (no-lone-blocks):
|    | Block is redundant.
|    | [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/1405/display/redirect

Nescio accepted this revision.EditedMay 14 2019, 11:00 AM

Thank you, it looks good, I did a grep in the maps and simulation folders.

This revision is now accepted and ready to land.May 14 2019, 11:00 AM
Stan added a subscriber: Stan.May 26 2019, 10:16 PM

Might need a rebase after rP22306

Silier planned changes to this revision.EditedMay 30 2019, 8:04 PM

need rebase because rP22320

This revision is now accepted and ready to land.May 31 2019, 6:49 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (space-before-function-paren):
|    | Unexpected space before function parentheses.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Identity.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Identity.js
|  97|  97| 	this.visibleClassesList = GetVisibleIdentityClasses(this.template);
|  98|  98| };
|  99|  99| 
| 100|    |-Identity.prototype.Deserialize = function ()
|    | 100|+Identity.prototype.Deserialize = function()
| 101| 101| {
| 102| 102| 	this.Init();
| 103| 103| };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '9'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
| 120| 120| var jebelBarkal_firstAttackTime = (difficulty, isNomad) =>
| 121| 121| 	jebelBarkal_attackInterval(0, difficulty) +
| 122| 122| 	2 * Math.max(0, 3 - difficulty) +
| 123|    |-	(isNomad ?  9 - difficulty : 0);
|    | 123|+	(isNomad ? 9 - difficulty : 0);
| 124| 124| 
| 125| 125| /**
| 126| 126|  * Account for varying mapsizes and number of players when spawning attackers.

binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
| 639| {
|    | [NORMAL] ESLintBear (no-lone-blocks):
|    | Block is redundant.
|    | [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
|2004|2004| 		nAdvanced += gameState.countEntitiesAndQueuedByType(advanced, true);
|2005|2005| 
|2006|2006| 	if (!nAdvanced || nAdvanced < this.bAdvanced.length && this.getAccountedPopulation(gameState) > 110)
|2007|    |-	{
|    |2007|+	
|2008|2008| 		for (let advanced of this.bAdvanced)
|2009|2009| 		{
|2010|2010| 			if (gameState.countEntitiesAndQueuedByType(advanced, true) > 0 || !this.canBuild(gameState, advanced))
|2019|2019| 				queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, advanced));
|2020|2020| 			return;
|2021|2021| 		}
|2022|    |-	}
|    |2022|+	
|2023|2023| };
|2024|2024| 
|2025|2025| /**
|    | [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
|2107|2107| 	// in which case we prefer melee units
|2108|2108| 	let numGarrisoned = this.garrisonManager.numberOfGarrisonedUnits(nearestAnchor);
|2109|2109| 	if (nearestAnchor._entity.trainingQueue)
|2110|    |-	{
|    |2110|+	
|2111|2111| 		for (let item of nearestAnchor._entity.trainingQueue)
|2112|2112| 		{
|2113|2113| 			if (item.metadata && item.metadata.garrisonType)
|2115|2115| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2116|2116| 				nearestAnchor.stopProduction(item.id);
|2117|2117| 		}
|2118|    |-	}
|    |2118|+	
|2119|2119| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2120|2120| 	                   nearestAnchor.hitpoints() > nearestAnchor.garrisonEjectHealth() * nearestAnchor.maxHitpoints();
|2121|2121| 	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
|2109|2109| 	if (nearestAnchor._entity.trainingQueue)
|2110|2110| 	{
|2111|2111| 		for (let item of nearestAnchor._entity.trainingQueue)
|2112|    |-		{
|    |2112|+		
|2113|2113| 			if (item.metadata && item.metadata.garrisonType)
|2114|2114| 				numGarrisoned += item.count;
|2115|2115| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2116|2116| 				nearestAnchor.stopProduction(item.id);
|2117|    |-		}
|    |2117|+		
|2118|2118| 	}
|2119|2119| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2120|2120| 	                   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
|2149|2149| 	let cost = new API3.Resources(templateFound[1].cost());
|2150|2150| 	queueManager.setAccounts(gameState, cost, "emergency");
|2151|2151| 	if (!queueManager.canAfford("emergency", cost))
|2152|    |-	{
|    |2152|+	
|2153|2153| 		for (let q in queueManager.queues)
|2154|2154| 		{
|2155|2155| 			if (q == "emergency")
|2158|2158| 			if (queueManager.canAfford("emergency", cost))
|2159|2159| 				break;
|2160|2160| 		}
|2161|    |-	}
|    |2161|+	
|2162|2162| 	let metadata = { "role": "worker", "base": nearestAnchor.getMetadata(PlayerID, "base"), "plan": -1, "trainer": nearestAnchor.id() };
|2163|2163| 	if (autogarrison)
|2164|2164| 		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
|2439|2439| m.HQ.prototype.assignGatherers = function()
|2440|2440| {
|2441|2441| 	for (let base of this.baseManagers)
|2442|    |-	{
|    |2442|+	
|2443|2443| 		for (let worker of base.workers.values())
|2444|2444| 		{
|2445|2445| 			if (worker.unitAIState().split(".")[1] != "RETURNRESOURCE")
|2449|2449| 				continue;
|2450|2450| 			this.AddTCGatherer(orders[1].target);
|2451|2451| 		}
|2452|    |-	}
|    |2452|+	
|2453|2453| };
|2454|2454| 
|2455|2455| 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
|2621|2621| 	{
|2622|2622| 		let pop = gameState.getPopulation();
|2623|2623| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2624|    |-		{
|    |2624|+		
|2625|2625| 			for (let item of ent.trainingQueue())
|2626|2626| 			{
|2627|2627| 				if (!item.unitTemplate)
|2630|2630| 				if (unitPop)
|2631|2631| 					pop += item.count * unitPop;
|2632|2632| 			}
|2633|    |-		}
|    |2633|+		
|2634|2634| 		this.turnCache.accountedPopulation = pop;
|2635|2635| 	}
|2636|2636| 	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
|2645|2645| 	{
|2646|2646| 		let workers = gameState.getOwnEntitiesByRole("worker", true).length;
|2647|2647| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2648|    |-		{
|    |2648|+		
|2649|2649| 			for (let item of ent.trainingQueue())
|2650|2650| 			{
|2651|2651| 				if (!item.metadata || !item.metadata.role || item.metadata.role != "worker")
|2652|2652| 					continue;
|2653|2653| 				workers += item.count;
|2654|2654| 			}
|2655|    |-		}
|    |2655|+		
|2656|2656| 		this.turnCache.accountedWorkers = workers;
|2657|2657| 	}
|2658|2658| 	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
|2683|2683| 			this.phasing = 0;
|2684|2684| 	}
|2685|2685| 
|2686|    |-/*	if (this.Config.debug > 1)
|    |2686|+	/*	if (this.Config.debug > 1)
|2687|2687| 	{
|2688|2688| 		gameState.getOwnUnits().forEach (function (ent) {
|2689|2689| 			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
|2758|2758| 		this.currentBase %= this.baseManagers.length;
|2759|2759| 		activeBase = this.baseManagers[this.currentBase++].update(gameState, queues, events);
|2760|2760| 		--nbBases;
|2761|    |-// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|    |2761|+		// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|2762|2762| 	}
|2763|2763| 	while (!activeBase && nbBases != 0);
|2764|2764| 

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/1565/display/redirect

bb accepted this revision.May 31 2019, 10:45 PM

No more instances of Stables left in the public mod

fixing JB while committing

binaries/data/mods/public/maps/random/jebel_barkal_triggers.js
82

This stable instance can be removed now, since stables no longer have the barracks class

166

same

This revision was automatically updated to reflect the committed changes.