Page MenuHomeWildfire Games

centre → center
ClosedPublic

Authored by Nescio on Mar 24 2019, 3:33 PM.

Details

Summary

This patch corrects the few text strings that have centre instead of center.

Test Plan

Ought to be unproblematic

Diff Detail

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

Event Timeline

Nescio created this revision.Mar 24 2019, 3:33 PM
Owners added a subscriber: Restricted Owners Package.Mar 24 2019, 3:33 PM
Vulcan added a subscriber: Vulcan.Mar 24 2019, 3:35 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/common-api/gamestate.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/common-api/gamestate.js
| 610| 610| 	else if (template.resourceSupplyType() !== undefined)	// animal resources
| 611| 611| 		count += this.countEntitiesByType("resource|" + type, true);
| 612| 612| 	else
| 613|    |-	{
|    | 613|+	
| 614| 614| 		// Count entities in building production queues
| 615| 615| 		// TODO: maybe this fails for corrals.
| 616| 616| 		this.getOwnTrainingFacilities().forEach(function(ent) {
| 618| 618| 				if (item.unitTemplate == type)
| 619| 619| 					count += item.count;
| 620| 620| 		});
| 621|    |-	}
|    | 621|+	
| 622| 622| 
| 623| 623| 	return count;
| 624| 624| };
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/common-api/gamestate.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/common-api/gamestate.js
| 770| 770| 				ret.push([techs[1]._templateName, techs[1]]);
| 771| 771| 		}
| 772| 772| 		else if (this.canResearch(tech))
| 773|    |-		{
|    | 773|+		
| 774| 774| 			// Phases are treated separately
| 775| 775| 			if (this.phases.every(phase => template._templateName != phase.name))
| 776| 776| 				ret.push([tech, template]);
| 777|    |-		}
|    | 777|+		
| 778| 778| 	}
| 779| 779| 	return ret;
| 780| 780| };

binaries/data/mods/public/simulation/ai/common-api/gamestate.js
| 269| »   »   switch·(entity.check)
|    | [NORMAL] ESLintBear (default-case):
|    | Expected a default case.

binaries/data/mods/public/simulation/ai/common-api/gamestate.js
| 286| »   »   »   switch·(type)
|    | [NORMAL] ESLintBear (default-case):
|    | Expected a default case.
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-in'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|  52|  52| 		}
|  53|  53| 	}
|  54|  54| 	for (let enemy in attackingArmies)
|  55|    |-	{
|    |  55|+	
|  56|  56| 		for (let ally in attackingArmies[enemy])
|  57|  57| 		{
|  58|  58| 			if (this.attackedAllies[ally] === undefined)
|  59|  59| 				this.attackedAllies[ally] = 0;
|  60|  60| 			this.attackedAllies[ally] += 1;
|  61|  61| 		}
|  62|    |-	}
|    |  62|+	
|  63|  63| 	this.checkEnemyArmies(gameState);
|  64|  64| 	this.checkEnemyUnits(gameState);
|  65|  65| 	this.assignDefenders(gameState);
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|  70|  70| m.DefenseManager.prototype.makeIntoArmy = function(gameState, entityID, type = "default")
|  71|  71| {
|  72|  72| 	if (type == "default")
|  73|    |-	{
|    |  73|+	
|  74|  74| 		// Try to add it to an existing army.
|  75|  75| 		for (let army of this.armies)
|  76|  76| 			if (army.getType() == type && army.addFoe(gameState, entityID))
|  77|  77| 				return;	// over
|  78|    |-	}
|    |  78|+	
|  79|  79| 
|  80|  80| 	// Create a new army for it.
|  81|  81| 	let army = new m.DefenseArmy(gameState, [entityID], type);
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
| 179| 179| 		if (territoryOwner != PlayerID && this.attackedAllies[territoryOwner] &&
| 180| 180| 		                                  this.attackedAllies[territoryOwner] > 1 &&
| 181| 181| 		                                  this.GetCooperationLevel(territoryOwner) > 0.7)
| 182|    |-		{
|    | 182|+		
| 183| 183| 			for (let building of gameState.getAllyStructures(territoryOwner).values())
| 184| 184| 			{
| 185| 185| 				if (building.foundationProgress() == 0 ||
| 188| 188| 				if (!this.territoryMap.isBlinking(building.position()))
| 189| 189| 					return true;
| 190| 190| 			}
| 191|    |-		}
|    | 191|+		
| 192| 192| 
| 193| 193| 		// Update the number of enemies attacking this ally
| 194| 194| 		let enemy = entity.owner();
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
| 211| 211| 	if (i == PlayerID)
| 212| 212| 	{
| 213| 213| 		if (!this.armies.length)
| 214|    |-		{
|    | 214|+		
| 215| 215| 			// check if we can recover capture points from any of our notdecaying structures
| 216| 216| 			for (let ent of gameState.getOwnStructures().values())
| 217| 217| 			{
| 229| 229| 				this.makeIntoArmy(gameState, ent.id(), "capturing");
| 230| 230| 				break;
| 231| 231| 			}
| 232|    |-		}
|    | 232|+		
| 233| 233| 		return;
| 234| 234| 	}
| 235| 235| 	else if (!gameState.isPlayerEnemy(i))
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
| 328| 328| 		if (!gameState.isPlayerEnemy(owner))
| 329| 329| 		{
| 330| 330| 			if (gameState.isPlayerMutualAlly(owner))
| 331|    |-			{
|    | 331|+			
| 332| 332| 				// update the number of enemies attacking this ally
| 333| 333| 				for (let id of army.foeEntities)
| 334| 334| 				{
| 343| 343| 					this.attackingArmies[enemy][owner] += 1;
| 344| 344| 					break;
| 345| 345| 				}
| 346|    |-			}
|    | 346|+			
| 347| 347| 			continue;
| 348| 348| 		}
| 349| 349| 		else if (owner != 0)   // enemy army back in its territory
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
| 530| 530| 		army.checkEvents(gameState, events);
| 531| 531| 
| 532| 532| 	for (let evt of events.OwnershipChanged)   // capture events
| 533|    |-	{
|    | 533|+	
| 534| 534| 		if (gameState.isPlayerMutualAlly(evt.from) && evt.to > 0)
| 535| 535| 		{
| 536| 536| 			let ent = gameState.getEntityById(evt.entity);
| 537| 537| 			if (ent && ent.hasClass("CivCentre")) // one of our cc has been captured
| 538| 538| 				gameState.ai.HQ.attackManager.switchDefenseToAttack(gameState, ent, { "range": 150 });
| 539| 539| 		}
| 540|    |-	}
|    | 540|+	
| 541| 541| 
| 542| 542| 	let allAttacked = {};
| 543| 543| 	for (let evt of events.Attacked)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
| 552| 552| 		let attacker = gameState.getEntityById(evt.attacker);
| 553| 553| 		if (attacker && gameState.isEntityOwn(attacker) && gameState.isEntityEnemy(target) && !attacker.hasClass("Ship") &&
| 554| 554| 		   (!target.hasClass("Structure") || target.attackRange("Ranged")))
| 555|    |-		{
|    | 555|+		
| 556| 556| 			// If enemies are in range of one of our defensive structures, garrison it for arrow multiplier
| 557| 557| 			// (enemy non-defensive structure are not considered to stay in sync with garrisonManager)
| 558| 558| 			if (attacker.position() && attacker.isGarrisonHolder() && attacker.getArrowMultiplier() &&
| 559| 559| 			    (target.owner() != 0 || !target.hasClass("Unit") ||
| 560| 560| 			     target.unitAIState() && target.unitAIState().split(".")[1] == "COMBAT"))
| 561| 561| 				this.garrisonUnitsInside(gameState, attacker, { "attacker": target });
| 562|    |-		}
|    | 562|+		
| 563| 563| 
| 564| 564| 		if (!gameState.isEntityOwn(target))
| 565| 565| 			continue;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/ai/petra/defenseManager.js
| 756| 756| 	let typeGarrison = data.type || "protection";
| 757| 757| 	let allowMelee = gameState.ai.HQ.garrisonManager.allowMelee(target);
| 758| 758| 	if (allowMelee === undefined)
| 759|    |-	{
|    | 759|+	
| 760| 760| 		// Should be kept in sync with garrisonManager to avoid garrisoning-ungarrisoning some units
| 761| 761| 		if (data.attacker)
| 762| 762| 			allowMelee = data.attacker.hasClass("Structure") ? data.attacker.attackRange("Ranged") : !m.isSiegeUnit(data.attacker);
| 763| 763| 		else
| 764| 764| 			allowMelee = true;
| 765|    |-	}
|    | 765|+	
| 766| 766| 	let units = gameState.getOwnUnits().filter(ent => {
| 767| 767| 		if (!ent.position())
| 768| 768| 			return false;
|    | [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
|2006|2006| 		nAdvanced += gameState.countEntitiesAndQueuedByType(advanced, true);
|2007|2007| 
|2008|2008| 	if (!nAdvanced || nAdvanced < this.bAdvanced.length && this.getAccountedPopulation(gameState) > 110)
|2009|    |-	{
|    |2009|+	
|2010|2010| 		for (let advanced of this.bAdvanced)
|2011|2011| 		{
|2012|2012| 			if (gameState.countEntitiesAndQueuedByType(advanced, true) > 0 || !this.canBuild(gameState, advanced))
|2021|2021| 				queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, advanced));
|2022|2022| 			return;
|2023|2023| 		}
|2024|    |-	}
|    |2024|+	
|2025|2025| };
|2026|2026| 
|2027|2027| /**
|    | [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
|2109|2109| 	// in which case we prefer melee units
|2110|2110| 	let numGarrisoned = this.garrisonManager.numberOfGarrisonedUnits(nearestAnchor);
|2111|2111| 	if (nearestAnchor._entity.trainingQueue)
|2112|    |-	{
|    |2112|+	
|2113|2113| 		for (let item of nearestAnchor._entity.trainingQueue)
|2114|2114| 		{
|2115|2115| 			if (item.metadata && item.metadata.garrisonType)
|2117|2117| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2118|2118| 				nearestAnchor.stopProduction(item.id);
|2119|2119| 		}
|2120|    |-	}
|    |2120|+	
|2121|2121| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2122|2122| 	                   nearestAnchor.hitpoints() > nearestAnchor.garrisonEjectHealth() * nearestAnchor.maxHitpoints();
|2123|2123| 	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
|2111|2111| 	if (nearestAnchor._entity.trainingQueue)
|2112|2112| 	{
|2113|2113| 		for (let item of nearestAnchor._entity.trainingQueue)
|2114|    |-		{
|    |2114|+		
|2115|2115| 			if (item.metadata && item.metadata.garrisonType)
|2116|2116| 				numGarrisoned += item.count;
|2117|2117| 			else if (!item.progress && (!item.metadata || !item.metadata.trainer))
|2118|2118| 				nearestAnchor.stopProduction(item.id);
|2119|    |-		}
|    |2119|+		
|2120|2120| 	}
|2121|2121| 	let autogarrison = numGarrisoned < nearestAnchor.garrisonMax() &&
|2122|2122| 	                   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
|2151|2151| 	let cost = new API3.Resources(templateFound[1].cost());
|2152|2152| 	queueManager.setAccounts(gameState, cost, "emergency");
|2153|2153| 	if (!queueManager.canAfford("emergency", cost))
|2154|    |-	{
|    |2154|+	
|2155|2155| 		for (let q in queueManager.queues)
|2156|2156| 		{
|2157|2157| 			if (q == "emergency")
|2160|2160| 			if (queueManager.canAfford("emergency", cost))
|2161|2161| 				break;
|2162|2162| 		}
|2163|    |-	}
|    |2163|+	
|2164|2164| 	let metadata = { "role": "worker", "base": nearestAnchor.getMetadata(PlayerID, "base"), "plan": -1, "trainer": nearestAnchor.id() };
|2165|2165| 	if (autogarrison)
|2166|2166| 		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
|2441|2441| m.HQ.prototype.assignGatherers = function()
|2442|2442| {
|2443|2443| 	for (let base of this.baseManagers)
|2444|    |-	{
|    |2444|+	
|2445|2445| 		for (let worker of base.workers.values())
|2446|2446| 		{
|2447|2447| 			if (worker.unitAIState().split(".")[1] != "RETURNRESOURCE")
|2451|2451| 				continue;
|2452|2452| 			this.AddTCGatherer(orders[1].target);
|2453|2453| 		}
|2454|    |-	}
|    |2454|+	
|2455|2455| };
|2456|2456| 
|2457|2457| 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
|2623|2623| 	{
|2624|2624| 		let pop = gameState.getPopulation();
|2625|2625| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2626|    |-		{
|    |2626|+		
|2627|2627| 			for (let item of ent.trainingQueue())
|2628|2628| 			{
|2629|2629| 				if (!item.unitTemplate)
|2632|2632| 				if (unitPop)
|2633|2633| 					pop += item.count * unitPop;
|2634|2634| 			}
|2635|    |-		}
|    |2635|+		
|2636|2636| 		this.turnCache.accountedPopulation = pop;
|2637|2637| 	}
|2638|2638| 	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
|2647|2647| 	{
|2648|2648| 		let workers = gameState.getOwnEntitiesByRole("worker", true).length;
|2649|2649| 		for (let ent of gameState.getOwnTrainingFacilities().values())
|2650|    |-		{
|    |2650|+		
|2651|2651| 			for (let item of ent.trainingQueue())
|2652|2652| 			{
|2653|2653| 				if (!item.metadata || !item.metadata.role || item.metadata.role != "worker")
|2654|2654| 					continue;
|2655|2655| 				workers += item.count;
|2656|2656| 			}
|2657|    |-		}
|    |2657|+		
|2658|2658| 		this.turnCache.accountedWorkers = workers;
|2659|2659| 	}
|2660|2660| 	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
|2685|2685| 			this.phasing = 0;
|2686|2686| 	}
|2687|2687| 
|2688|    |-/*	if (this.Config.debug > 1)
|    |2688|+	/*	if (this.Config.debug > 1)
|2689|2689| 	{
|2690|2690| 		gameState.getOwnUnits().forEach (function (ent) {
|2691|2691| 			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
|2760|2760| 		this.currentBase %= this.baseManagers.length;
|2761|2761| 		activeBase = this.baseManagers[this.currentBase++].update(gameState, queues, events);
|2762|2762| 		--nbBases;
|2763|    |-// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|    |2763|+		// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|2764|2764| 	}
|2765|2765| 	while (!activeBase && nbBases != 0);
|2766|2766| 

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

Gallaecio accepted this revision.Mar 31 2019, 1:26 PM
This revision is now accepted and ready to land.Mar 31 2019, 1:26 PM

This revision is now accepted and ready to land.

Feel free to implement this (and other patches); I can't commit myself.

This revision was automatically updated to reflect the committed changes.