Page MenuHomeWildfire Games

petra: Remove redundant 'PETRA' variable indirection
ClosedPublic

Authored by Krinkle on Jul 20 2019, 9:59 PM.

Details

Reviewers
elexis
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Owners Package(Owns No Changed Paths)
Restricted Owners Package(Owns No Changed Paths)
Commits
rP22803: Remove PETRA Module and Augmentation pattern from rP14441, refs #2322, and in…
Trac Tickets
#5524
#2322
Summary
Redundant re-assignments

The redefining of this variable in each file was flagged by the use-before-define ESLint rule via Coala/ESLintBear, and has been for a long time.

These assignments never worked as intended. However, the Petra code still worked because these assignments aren't actually needed.

Previously, the structure for each file was like so:

var PETRA = function(m){
 m.something = ;
 
 return m;
}(PETRA);

The var declaration here is silently ignored as we cannot create PETRA. It already exists as a global variable by this point. And that's good, because if it didn't exist yet, the m.something assignment wouldn't work because you can't assign a property to undefined. Removing this redundant bit, leaves us with the following:

PETRA = function(m){
 m.something = ;
 
 return m;
}(PETRA);

This creates an unnamed function, then immediately invokes it with the current object reference stored at PETRA, the function then augments that object, returns the same reference, and stores the same reference, in the same var. This is also a no-op.

Remove the assignment as well, and leave only the file-level function wrapper which avoids leaking variables to the global scope. This is known as the "IIFE" pattern. Same as before basically, but without the odd variable indirection which isn't normally part of this pattern, and wasn't helping us with anything.

(function(m){
 m.something = ;
 
}(PETRA));

Ref #5524.

Redundant closures and aliasing

On suggestion by @elexis, I've also gone ahead and removed the closure and the variable alias, thus leaving us with just the part that matters. No boilerplate of any kind:

PETA.something = ;
Test Plan

Result from Coala no longer includes any use-before-define error. The remaining (pre-existing) errors for this file are trivial and auto-fixed by D1993 instead.

Edit elexis:
svn blame on the lines that introduced the pattern, find rP14865, find rP14441, find #2322, find the irclogs from december 2013, find

2013-12-14-QuakeNet-#0ad-dev.log:11:23 < Yves`> the code will have to be wrapped in some kind of module pattern to avoid naming conflicts between different AI scripts: http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
01:30 < Philip`> Yves`: (It would perhaps be nice if we could use the ES6 module system to import/export things instead of requiring a "m." prefix thing, but I guess we need to wait for SpiderMonkey to implement that first, and need to upgrade to that SpiderMonkey :-) )

refute the argument for the augmentation pattern, use this information to prove that there is no conceptual regression introduced.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
master
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 9089
Build 14893: Vulcan BuildJenkins
Build 14892: arc lint + arc unit

Event Timeline

Krinkle created this revision.Jul 20 2019, 9:59 PM
Owners added a subscriber: Restricted Owners Package.Jul 20 2019, 9:59 PM
Krinkle edited the summary of this revision. (Show Details)Jul 20 2019, 9:59 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/155/display/redirect

This has been split out of D2103 as being the only semantic change (due to fixing a quality issue rather than a style issue). This way D2103, can focus solely on auto-fixed style changes.

Krinkle edited the summary of this revision. (Show Details)Jul 20 2019, 10:04 PM
Krinkle edited the summary of this revision. (Show Details)
Krinkle updated this revision to Diff 9142.Jul 27 2019, 5:15 PM

(Rebased. Hopefully Jenkins is working again properly now.)

Krinkle edited the summary of this revision. (Show Details)Jul 27 2019, 5:18 PM
Krinkle edited the summary of this revision. (Show Details)Jul 27 2019, 5:21 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/mapModule.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/mapModule.js
| 193| 193| 		}
| 194| 194| 	}
| 195| 195| 
| 196|    |-//	map.dumpIm("border.png", 5);
|    | 196|+	//	map.dumpIm("border.png", 5);
| 197| 197| 	return map;
| 198| 198| };
| 199| 199| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js
| 195| 195| 		medium.sort((r1, r2) => r1.dist - r2.dist);
| 196| 196| 		faraway.sort((r1, r2) => r1.dist - r2.dist);
| 197| 197| 
| 198|    |-/*		let debug = false;
|    | 198|+		/*		let debug = false;
| 199| 199| 		if (debug)
| 200| 200| 		{
| 201| 201| 			faraway.forEach(function(res){
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
| 424| 424| 	let candidate = { "gain": 0 };
| 425| 425| 	let potential = { "gain": 0 };
| 426| 426| 	let bestIndex = { "gain": 0 };
| 427|    |-	let bestLand  = { "gain": 0 };
|    | 427|+	let bestLand = { "gain": 0 };
| 428| 428| 
| 429| 429| 	let mapSize = gameState.sharedScript.mapSize;
| 430| 430| 	let traderTemplatesGains = gameState.getTraderTemplatesGains();
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
| 169| 169| 			plan.removeUnit(gameState, ent);
| 170| 170| 	}
| 171| 171| 
| 172|    |-/*
|    | 172|+	/*
| 173| 173| 	// TODO be sure that all units in the transport need the cancelation
| 174| 174| 	if (!ent.position())	// this unit must still be in a transport plan ... try to cancel it
| 175| 175| 	{
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/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 (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/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.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/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| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 744| 744|  * if wantedSea is given, this tile should be inside this sea
| 745| 745|  */
| 746| 746| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 747|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 747|+	        [-1.0, 0.0], [-0.87, -0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 748| 748| 
| 749| 749| m.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 750| 750| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 744| 744|  * if wantedSea is given, this tile should be inside this sea
| 745| 745|  */
| 746| 746| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 747|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 747|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50, -0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 748| 748| 
| 749| 749| m.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 750| 750| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 744| 744|  * if wantedSea is given, this tile should be inside this sea
| 745| 745|  */
| 746| 746| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 747|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 747|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0, -1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 748| 748| 
| 749| 749| m.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 750| 750| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 744| 744|  * if wantedSea is given, this tile should be inside this sea
| 745| 745|  */
| 746| 746| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 747|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 747|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50, -0.87], [ 0.87,-0.50]];
| 748| 748| 
| 749| 749| m.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 750| 750| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 744| 744|  * if wantedSea is given, this tile should be inside this sea
| 745| 745|  */
| 746| 746| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 747|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 747|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87, -0.50]];
| 748| 748| 
| 749| 749| m.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 750| 750| {
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/transportPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/transportPlan.js
| 240| 240| 		ent.setMetadata(PlayerID, "endPos", undefined);
| 241| 241| 		ent.setMetadata(PlayerID, "onBoard", undefined);
| 242| 242| 		ent.setMetadata(PlayerID, "transport", undefined);
| 243|    |-		// TODO if the index of the endPos of the entity is !=, 
|    | 243|+		// TODO if the index of the endPos of the entity is !=,
| 244| 244| 		// require again another transport (we could need land-sea-land-sea-land)
| 245| 245| 	}
| 246| 246| 
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 139| 139| 	{
| 140| 140| 		priority = 90;
| 141| 141| 		// basically we want a mix of citizen soldiers so our barracks have a purpose, and champion units.
| 142|    |-		this.unitStat.RangedInfantry    = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
|    | 142|+		this.unitStat.RangedInfantry = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
| 143| 143| 			"interests": [["strength", 3]] };
| 144| 144| 		this.unitStat.MeleeInfantry     = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
| 145| 145| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 141| 141| 		// basically we want a mix of citizen soldiers so our barracks have a purpose, and champion units.
| 142| 142| 		this.unitStat.RangedInfantry    = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
| 143| 143| 			"interests": [["strength", 3]] };
| 144|    |-		this.unitStat.MeleeInfantry     = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
|    | 144|+		this.unitStat.MeleeInfantry = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
| 145| 145| 			"interests": [["strength", 3]] };
| 146| 146| 		this.unitStat.ChampRangedInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Ranged", "Champion"],
| 147| 147| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 145| 145| 			"interests": [["strength", 3]] };
| 146| 146| 		this.unitStat.ChampRangedInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Ranged", "Champion"],
| 147| 147| 			"interests": [["strength", 3]] };
| 148|    |-		this.unitStat.ChampMeleeInfantry  = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
|    | 148|+		this.unitStat.ChampMeleeInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
| 149| 149| 			"interests": [["strength", 3]] };
| 150| 150| 		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 151| 151| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 147| 147| 			"interests": [["strength", 3]] };
| 148| 148| 		this.unitStat.ChampMeleeInfantry  = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
| 149| 149| 			"interests": [["strength", 3]] };
| 150|    |-		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
|    | 150|+		this.unitStat.RangedCavalry = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 151| 151| 			"interests": [["strength", 2]] };
| 152| 152| 		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 153| 153| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 149| 149| 			"interests": [["strength", 3]] };
| 150| 150| 		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 151| 151| 			"interests": [["strength", 2]] };
| 152|    |-		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
|    | 152|+		this.unitStat.MeleeCavalry = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 153| 153| 			"interests": [["strength", 2]] };
| 154| 154| 		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 155| 155| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 151| 151| 			"interests": [["strength", 2]] };
| 152| 152| 		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 153| 153| 			"interests": [["strength", 2]] };
| 154|    |-		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
|    | 154|+		this.unitStat.ChampRangedCavalry = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 155| 155| 			"interests": [["strength", 3]] };
| 156| 156| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 157| 157| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 153| 153| 			"interests": [["strength", 2]] };
| 154| 154| 		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 155| 155| 			"interests": [["strength", 3]] };
| 156|    |-		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
|    | 156|+		this.unitStat.ChampMeleeCavalry = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 157| 157| 			"interests": [["strength", 2]] };
| 158| 158| 		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
| 159| 159| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 155| 155| 			"interests": [["strength", 3]] };
| 156| 156| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 157| 157| 			"interests": [["strength", 2]] };
| 158|    |-		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
|    | 158|+		this.unitStat.Hero = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
| 159| 159| 			"interests": [["strength", 2]] };
| 160| 160| 		this.neededShips = 5;
| 161| 161| 	}
|    | [NORMAL] ESLintBear (key-spacing):
|    | Extra space before value for key 'targetSize'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 155| 155| 			"interests": [["strength", 3]] };
| 156| 156| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 157| 157| 			"interests": [["strength", 2]] };
| 158|    |-		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
|    | 158|+		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize": 1, "batchSize": 1, "classes": ["Hero"],
| 159| 159| 			"interests": [["strength", 2]] };
| 160| 160| 		this.neededShips = 5;
| 161| 161| 	}
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 164| 164| 		priority = 70;
| 165| 165| 		this.unitStat.RangedInfantry = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Ranged"],
| 166| 166| 			"interests": [["canGather", 1], ["strength", 1.6], ["costsResource", 0.3, "stone"], ["costsResource", 0.3, "metal"]] };
| 167|    |-		this.unitStat.MeleeInfantry  = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Melee"],
|    | 167|+		this.unitStat.MeleeInfantry = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Melee"],
| 168| 168| 			"interests": [["canGather", 1], ["strength", 1.6], ["costsResource", 0.3, "stone"], ["costsResource", 0.3, "metal"]] };
| 169| 169| 		this.unitStat.Cavalry = { "priority": 1, "minSize": 2, "targetSize": 6, "batchSize": 2, "classes": ["Cavalry", "CitizenSoldier"],
| 170| 170| 			"interests": [["strength", 1]] };
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1143|1143| 
|1144|1144| 	if (blocker && blocker.hasClass("StoneWall"))
|1145|1145| 	{
|1146|    |-/*		if (this.hasSiegeUnits())
|    |1146|+		/*		if (this.hasSiegeUnits())
|1147|1147| 		{ */
|1148|1148| 			this.isBlocked = true;
|1149|1149| 			return blocker;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1145|1145| 	{
|1146|1146| /*		if (this.hasSiegeUnits())
|1147|1147| 		{ */
|1148|    |-			this.isBlocked = true;
|    |1148|+		this.isBlocked = true;
|1149|1149| 			return blocker;
|1150|1150| /*		}
|1151|1151| 		return undefined; */
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1146|1146| /*		if (this.hasSiegeUnits())
|1147|1147| 		{ */
|1148|1148| 			this.isBlocked = true;
|1149|    |-			return blocker;
|    |1149|+		return blocker;
|1150|1150| /*		}
|1151|1151| 		return undefined; */
|1152|1152| 	}
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1147|1147| 		{ */
|1148|1148| 			this.isBlocked = true;
|1149|1149| 			return blocker;
|1150|    |-/*		}
|    |1150|+		/*		}
|1151|1151| 		return undefined; */
|1152|1152| 	}
|1153|1153| 	else if (blocker)
|    | [NORMAL] ESLintBear (operator-assignment):
|    | Assignment can be replaced with operator assignment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1541|1541| 				range = 30 + ent.attackRange("Ranged").max;
|1542|1542| 			else if (ent.hasClass("Cavalry"))
|1543|1543| 				range += 30;
|1544|    |-			range = range * range;
|    |1544|+			range *= range;
|1545|1545| 			let entAccess = m.getLandAccess(gameState, ent);
|1546|1546| 			// Checking for gates if we're a siege unit.
|1547|1547| 			if (siegeUnit)
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/config.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/config.js
|  54|  54| 		"armyMergeSize": 1400	// squared.
|  55|  55| 	};
|  56|  56| 
|  57|    |-	// Additional buildings that the AI does not yet know when to build 
|    |  57|+	// Additional buildings that the AI does not yet know when to build
|  58|  58| 	// and that it will try to build on phase 3 when enough resources.
|  59|  59| 	this.buildings =
|  60|  60| 	{
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/248/display/redirect

Krinkle edited the test plan for this revision. (Show Details)Aug 4 2019, 1:19 AM
Krinkle updated this revision to Diff 9518.Aug 25 2019, 11:56 PM
Krinkle retitled this revision from petra: Remove redundant 'PETRA' re-assignments to petra: Remove redundant 'PETRA' variable indirection.
Krinkle edited the summary of this revision. (Show Details)
Krinkle added a subscriber: elexis.

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
| 420| 420| 	let candidate = { "gain": 0 };
| 421| 421| 	let potential = { "gain": 0 };
| 422| 422| 	let bestIndex = { "gain": 0 };
| 423|    |-	let bestLand  = { "gain": 0 };
|    | 423|+	let bestLand = { "gain": 0 };
| 424| 424| 
| 425| 425| 	let mapSize = gameState.sharedScript.mapSize;
| 426| 426| 	let traderTemplatesGains = gameState.getTraderTemplatesGains();
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 136| 136| 	{
| 137| 137| 		priority = 90;
| 138| 138| 		// basically we want a mix of citizen soldiers so our barracks have a purpose, and champion units.
| 139|    |-		this.unitStat.RangedInfantry    = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
|    | 139|+		this.unitStat.RangedInfantry = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
| 140| 140| 			"interests": [["strength", 3]] };
| 141| 141| 		this.unitStat.MeleeInfantry     = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
| 142| 142| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 138| 138| 		// basically we want a mix of citizen soldiers so our barracks have a purpose, and champion units.
| 139| 139| 		this.unitStat.RangedInfantry    = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
| 140| 140| 			"interests": [["strength", 3]] };
| 141|    |-		this.unitStat.MeleeInfantry     = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
|    | 141|+		this.unitStat.MeleeInfantry = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
| 142| 142| 			"interests": [["strength", 3]] };
| 143| 143| 		this.unitStat.ChampRangedInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Ranged", "Champion"],
| 144| 144| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 142| 142| 			"interests": [["strength", 3]] };
| 143| 143| 		this.unitStat.ChampRangedInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Ranged", "Champion"],
| 144| 144| 			"interests": [["strength", 3]] };
| 145|    |-		this.unitStat.ChampMeleeInfantry  = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
|    | 145|+		this.unitStat.ChampMeleeInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
| 146| 146| 			"interests": [["strength", 3]] };
| 147| 147| 		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 148| 148| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 144| 144| 			"interests": [["strength", 3]] };
| 145| 145| 		this.unitStat.ChampMeleeInfantry  = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
| 146| 146| 			"interests": [["strength", 3]] };
| 147|    |-		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
|    | 147|+		this.unitStat.RangedCavalry = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 148| 148| 			"interests": [["strength", 2]] };
| 149| 149| 		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 150| 150| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 146| 146| 			"interests": [["strength", 3]] };
| 147| 147| 		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 148| 148| 			"interests": [["strength", 2]] };
| 149|    |-		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
|    | 149|+		this.unitStat.MeleeCavalry = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 150| 150| 			"interests": [["strength", 2]] };
| 151| 151| 		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 152| 152| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 148| 148| 			"interests": [["strength", 2]] };
| 149| 149| 		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 150| 150| 			"interests": [["strength", 2]] };
| 151|    |-		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
|    | 151|+		this.unitStat.ChampRangedCavalry = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 152| 152| 			"interests": [["strength", 3]] };
| 153| 153| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 150| 150| 			"interests": [["strength", 2]] };
| 151| 151| 		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 152| 152| 			"interests": [["strength", 3]] };
| 153|    |-		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
|    | 153|+		this.unitStat.ChampMeleeCavalry = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
| 155| 155| 		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
| 156| 156| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 152| 152| 			"interests": [["strength", 3]] };
| 153| 153| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
| 155|    |-		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
|    | 155|+		this.unitStat.Hero = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
| 156| 156| 			"interests": [["strength", 2]] };
| 157| 157| 		this.neededShips = 5;
| 158| 158| 	}
|    | [NORMAL] ESLintBear (key-spacing):
|    | Extra space before value for key 'targetSize'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 152| 152| 			"interests": [["strength", 3]] };
| 153| 153| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
| 155|    |-		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
|    | 155|+		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize": 1, "batchSize": 1, "classes": ["Hero"],
| 156| 156| 			"interests": [["strength", 2]] };
| 157| 157| 		this.neededShips = 5;
| 158| 158| 	}
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 161| 161| 		priority = 70;
| 162| 162| 		this.unitStat.RangedInfantry = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Ranged"],
| 163| 163| 			"interests": [["canGather", 1], ["strength", 1.6], ["costsResource", 0.3, "stone"], ["costsResource", 0.3, "metal"]] };
| 164|    |-		this.unitStat.MeleeInfantry  = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Melee"],
|    | 164|+		this.unitStat.MeleeInfantry = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Melee"],
| 165| 165| 			"interests": [["canGather", 1], ["strength", 1.6], ["costsResource", 0.3, "stone"], ["costsResource", 0.3, "metal"]] };
| 166| 166| 		this.unitStat.Cavalry = { "priority": 1, "minSize": 2, "targetSize": 6, "batchSize": 2, "classes": ["Cavalry", "CitizenSoldier"],
| 167| 167| 			"interests": [["strength", 1]] };
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1140|1140| 
|1141|1141| 	if (blocker && blocker.hasClass("StoneWall"))
|1142|1142| 	{
|1143|    |-/*		if (this.hasSiegeUnits())
|    |1143|+		/*		if (this.hasSiegeUnits())
|1144|1144| 		{ */
|1145|1145| 			this.isBlocked = true;
|1146|1146| 			return blocker;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1142|1142| 	{
|1143|1143| /*		if (this.hasSiegeUnits())
|1144|1144| 		{ */
|1145|    |-			this.isBlocked = true;
|    |1145|+		this.isBlocked = true;
|1146|1146| 			return blocker;
|1147|1147| /*		}
|1148|1148| 		return undefined; */
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1143|1143| /*		if (this.hasSiegeUnits())
|1144|1144| 		{ */
|1145|1145| 			this.isBlocked = true;
|1146|    |-			return blocker;
|    |1146|+		return blocker;
|1147|1147| /*		}
|1148|1148| 		return undefined; */
|1149|1149| 	}
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1144|1144| 		{ */
|1145|1145| 			this.isBlocked = true;
|1146|1146| 			return blocker;
|1147|    |-/*		}
|    |1147|+		/*		}
|1148|1148| 		return undefined; */
|1149|1149| 	}
|1150|1150| 	else if (blocker)
|    | [NORMAL] ESLintBear (operator-assignment):
|    | Assignment can be replaced with operator assignment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1538|1538| 				range = 30 + ent.attackRange("Ranged").max;
|1539|1539| 			else if (ent.hasClass("Cavalry"))
|1540|1540| 				range += 30;
|1541|    |-			range = range * range;
|    |1541|+			range *= range;
|1542|1542| 			let entAccess = PETRA.getLandAccess(gameState, ent);
|1543|1543| 			// Checking for gates if we're a siege unit.
|1544|1544| 			if (siegeUnit)
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/mapModule.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/mapModule.js
| 190| 190| 		}
| 191| 191| 	}
| 192| 192| 
| 193|    |-//	map.dumpIm("border.png", 5);
|    | 193|+	//	map.dumpIm("border.png", 5);
| 194| 194| 	return map;
| 195| 195| };
| 196| 196| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
| 167| 167| 			plan.removeUnit(gameState, ent);
| 168| 168| 	}
| 169| 169| 
| 170|    |-/*
|    | 170|+	/*
| 171| 171| 	// TODO be sure that all units in the transport need the cancelation
| 172| 172| 	if (!ent.position())	// this unit must still be in a transport plan ... try to cancel it
| 173| 173| 	{
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/transportPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/transportPlan.js
| 237| 237| 		ent.setMetadata(PlayerID, "endPos", undefined);
| 238| 238| 		ent.setMetadata(PlayerID, "onBoard", undefined);
| 239| 239| 		ent.setMetadata(PlayerID, "transport", undefined);
| 240|    |-		// TODO if the index of the endPos of the entity is !=, 
|    | 240|+		// TODO if the index of the endPos of the entity is !=,
| 241| 241| 		// require again another transport (we could need land-sea-land-sea-land)
| 242| 242| 	}
| 243| 243| 
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1088|1088| 				val += gameState.sharedScript.ccResourceMaps[res].map[j];
|1089|1089| 		val *= norm;
|1090|1090| 
|1091|    |-		// If oversea, be just above threshold to be accepted if nothing else 
|    |1091|+		// If oversea, be just above threshold to be accepted if nothing else
|1092|1092| 		if (oversea)
|1093|1093| 			val = Math.max(val, cut + 0.1);
|1094|1094| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2679|2679| 			this.phasing = 0;
|2680|2680| 	}
|2681|2681| 
|2682|    |-/*	if (this.Config.debug > 1)
|    |2682|+	/*	if (this.Config.debug > 1)
|2683|2683| 	{
|2684|2684| 		gameState.getOwnUnits().forEach (function (ent) {
|2685|2685| 			if (!ent.position())
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2754|2754| 		this.currentBase %= this.baseManagers.length;
|2755|2755| 		activeBase = this.baseManagers[this.currentBase++].update(gameState, queues, events);
|2756|2756| 		--nbBases;
|2757|    |-// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|    |2757|+		// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|2758|2758| 	}
|2759|2759| 	while (!activeBase && nbBases != 0);
|2760|2760| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js
| 192| 192| 		medium.sort((r1, r2) => r1.dist - r2.dist);
| 193| 193| 		faraway.sort((r1, r2) => r1.dist - r2.dist);
| 194| 194| 
| 195|    |-/*		let debug = false;
|    | 195|+		/*		let debug = false;
| 196| 196| 		if (debug)
| 197| 197| 		{
| 198| 198| 			faraway.forEach(function(res){
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/config.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/config.js
|  51|  51| 		"armyMergeSize": 1400	// squared.
|  52|  52| 	};
|  53|  53| 
|  54|    |-	// Additional buildings that the AI does not yet know when to build 
|    |  54|+	// Additional buildings that the AI does not yet know when to build
|  55|  55| 	// and that it will try to build on phase 3 when enough resources.
|  56|  56| 	this.buildings =
|  57|  57| 	{
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87, -0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50, -0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0, -1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50, -0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87, -0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/498/display/redirect

Krinkle updated this revision to Diff 9533.Aug 29 2019, 2:53 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/config.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/config.js
|  51|  51| 		"armyMergeSize": 1400	// squared.
|  52|  52| 	};
|  53|  53| 
|  54|    |-	// Additional buildings that the AI does not yet know when to build 
|    |  54|+	// Additional buildings that the AI does not yet know when to build
|  55|  55| 	// and that it will try to build on phase 3 when enough resources.
|  56|  56| 	this.buildings =
|  57|  57| 	{
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 136| 136| 	{
| 137| 137| 		priority = 90;
| 138| 138| 		// basically we want a mix of citizen soldiers so our barracks have a purpose, and champion units.
| 139|    |-		this.unitStat.RangedInfantry    = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
|    | 139|+		this.unitStat.RangedInfantry = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
| 140| 140| 			"interests": [["strength", 3]] };
| 141| 141| 		this.unitStat.MeleeInfantry     = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
| 142| 142| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 138| 138| 		// basically we want a mix of citizen soldiers so our barracks have a purpose, and champion units.
| 139| 139| 		this.unitStat.RangedInfantry    = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Ranged", "CitizenSoldier"],
| 140| 140| 			"interests": [["strength", 3]] };
| 141|    |-		this.unitStat.MeleeInfantry     = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
|    | 141|+		this.unitStat.MeleeInfantry = { "priority": 0.7, "minSize": 5, "targetSize": 20, "batchSize": 5, "classes": ["Infantry", "Melee", "CitizenSoldier"],
| 142| 142| 			"interests": [["strength", 3]] };
| 143| 143| 		this.unitStat.ChampRangedInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Ranged", "Champion"],
| 144| 144| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 142| 142| 			"interests": [["strength", 3]] };
| 143| 143| 		this.unitStat.ChampRangedInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Ranged", "Champion"],
| 144| 144| 			"interests": [["strength", 3]] };
| 145|    |-		this.unitStat.ChampMeleeInfantry  = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
|    | 145|+		this.unitStat.ChampMeleeInfantry = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
| 146| 146| 			"interests": [["strength", 3]] };
| 147| 147| 		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 148| 148| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 144| 144| 			"interests": [["strength", 3]] };
| 145| 145| 		this.unitStat.ChampMeleeInfantry  = { "priority": 1, "minSize": 3, "targetSize": 18, "batchSize": 3, "classes": ["Infantry", "Melee", "Champion"],
| 146| 146| 			"interests": [["strength", 3]] };
| 147|    |-		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
|    | 147|+		this.unitStat.RangedCavalry = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 148| 148| 			"interests": [["strength", 2]] };
| 149| 149| 		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 150| 150| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 146| 146| 			"interests": [["strength", 3]] };
| 147| 147| 		this.unitStat.RangedCavalry     = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Ranged", "CitizenSoldier"],
| 148| 148| 			"interests": [["strength", 2]] };
| 149|    |-		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
|    | 149|+		this.unitStat.MeleeCavalry = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 150| 150| 			"interests": [["strength", 2]] };
| 151| 151| 		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 152| 152| 			"interests": [["strength", 3]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 148| 148| 			"interests": [["strength", 2]] };
| 149| 149| 		this.unitStat.MeleeCavalry      = { "priority": 0.7, "minSize": 4, "targetSize": 20, "batchSize": 4, "classes": ["Cavalry", "Melee", "CitizenSoldier"],
| 150| 150| 			"interests": [["strength", 2]] };
| 151|    |-		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
|    | 151|+		this.unitStat.ChampRangedCavalry = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 152| 152| 			"interests": [["strength", 3]] };
| 153| 153| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 150| 150| 			"interests": [["strength", 2]] };
| 151| 151| 		this.unitStat.ChampRangedCavalry  = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Ranged", "Champion"],
| 152| 152| 			"interests": [["strength", 3]] };
| 153|    |-		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
|    | 153|+		this.unitStat.ChampMeleeCavalry = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
| 155| 155| 		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
| 156| 156| 			"interests": [["strength", 2]] };
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 152| 152| 			"interests": [["strength", 3]] };
| 153| 153| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
| 155|    |-		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
|    | 155|+		this.unitStat.Hero = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
| 156| 156| 			"interests": [["strength", 2]] };
| 157| 157| 		this.neededShips = 5;
| 158| 158| 	}
|    | [NORMAL] ESLintBear (key-spacing):
|    | Extra space before value for key 'targetSize'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 152| 152| 			"interests": [["strength", 3]] };
| 153| 153| 		this.unitStat.ChampMeleeCavalry   = { "priority": 1, "minSize": 3, "targetSize": 15, "batchSize": 3, "classes": ["Cavalry", "Melee", "Champion"],
| 154| 154| 			"interests": [["strength", 2]] };
| 155|    |-		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize":  1, "batchSize": 1, "classes": ["Hero"],
|    | 155|+		this.unitStat.Hero                = { "priority": 1, "minSize": 0, "targetSize": 1, "batchSize": 1, "classes": ["Hero"],
| 156| 156| 			"interests": [["strength", 2]] };
| 157| 157| 		this.neededShips = 5;
| 158| 158| 	}
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
| 161| 161| 		priority = 70;
| 162| 162| 		this.unitStat.RangedInfantry = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Ranged"],
| 163| 163| 			"interests": [["canGather", 1], ["strength", 1.6], ["costsResource", 0.3, "stone"], ["costsResource", 0.3, "metal"]] };
| 164|    |-		this.unitStat.MeleeInfantry  = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Melee"],
|    | 164|+		this.unitStat.MeleeInfantry = { "priority": 1, "minSize": 6, "targetSize": 16, "batchSize": 3, "classes": ["Infantry", "Melee"],
| 165| 165| 			"interests": [["canGather", 1], ["strength", 1.6], ["costsResource", 0.3, "stone"], ["costsResource", 0.3, "metal"]] };
| 166| 166| 		this.unitStat.Cavalry = { "priority": 1, "minSize": 2, "targetSize": 6, "batchSize": 2, "classes": ["Cavalry", "CitizenSoldier"],
| 167| 167| 			"interests": [["strength", 1]] };
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1140|1140| 
|1141|1141| 	if (blocker && blocker.hasClass("StoneWall"))
|1142|1142| 	{
|1143|    |-/*		if (this.hasSiegeUnits())
|    |1143|+		/*		if (this.hasSiegeUnits())
|1144|1144| 		{ */
|1145|1145| 			this.isBlocked = true;
|1146|1146| 			return blocker;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1142|1142| 	{
|1143|1143| /*		if (this.hasSiegeUnits())
|1144|1144| 		{ */
|1145|    |-			this.isBlocked = true;
|    |1145|+		this.isBlocked = true;
|1146|1146| 			return blocker;
|1147|1147| /*		}
|1148|1148| 		return undefined; */
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1143|1143| /*		if (this.hasSiegeUnits())
|1144|1144| 		{ */
|1145|1145| 			this.isBlocked = true;
|1146|    |-			return blocker;
|    |1146|+		return blocker;
|1147|1147| /*		}
|1148|1148| 		return undefined; */
|1149|1149| 	}
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1144|1144| 		{ */
|1145|1145| 			this.isBlocked = true;
|1146|1146| 			return blocker;
|1147|    |-/*		}
|    |1147|+		/*		}
|1148|1148| 		return undefined; */
|1149|1149| 	}
|1150|1150| 	else if (blocker)
|    | [NORMAL] ESLintBear (operator-assignment):
|    | Assignment can be replaced with operator assignment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/attackPlan.js
|1538|1538| 				range = 30 + ent.attackRange("Ranged").max;
|1539|1539| 			else if (ent.hasClass("Cavalry"))
|1540|1540| 				range += 30;
|1541|    |-			range = range * range;
|    |1541|+			range *= range;
|1542|1542| 			let entAccess = PETRA.getLandAccess(gameState, ent);
|1543|1543| 			// Checking for gates if we're a siege unit.
|1544|1544| 			if (siegeUnit)
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js
| 192| 192| 		medium.sort((r1, r2) => r1.dist - r2.dist);
| 193| 193| 		faraway.sort((r1, r2) => r1.dist - r2.dist);
| 194| 194| 
| 195|    |-/*		let debug = false;
|    | 195|+		/*		let debug = false;
| 196| 196| 		if (debug)
| 197| 197| 		{
| 198| 198| 			faraway.forEach(function(res){
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/defenseArmy.js
| 167| 167| 			plan.removeUnit(gameState, ent);
| 168| 168| 	}
| 169| 169| 
| 170|    |-/*
|    | 170|+	/*
| 171| 171| 	// TODO be sure that all units in the transport need the cancelation
| 172| 172| 	if (!ent.position())	// this unit must still be in a transport plan ... try to cancel it
| 173| 173| 	{
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '='.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/tradeManager.js
| 420| 420| 	let candidate = { "gain": 0 };
| 421| 421| 	let potential = { "gain": 0 };
| 422| 422| 	let bestIndex = { "gain": 0 };
| 423|    |-	let bestLand  = { "gain": 0 };
|    | 423|+	let bestLand = { "gain": 0 };
| 424| 424| 
| 425| 425| 	let mapSize = gameState.sharedScript.mapSize;
| 426| 426| 	let traderTemplatesGains = gameState.getTraderTemplatesGains();
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87, -0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50, -0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0, -1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50, -0.87], [ 0.87,-0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
| 741| 741|  * if wantedSea is given, this tile should be inside this sea
| 742| 742|  */
| 743| 743| const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50],
| 744|    |-	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]];
|    | 744|+	        [-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87, -0.50]];
| 745| 745| 
| 746| 746| PETRA.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea)
| 747| 747| {
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/mapModule.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/mapModule.js
| 190| 190| 		}
| 191| 191| 	}
| 192| 192| 
| 193|    |-//	map.dumpIm("border.png", 5);
|    | 193|+	//	map.dumpIm("border.png", 5);
| 194| 194| 	return map;
| 195| 195| };
| 196| 196| 
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|1088|1088| 				val += gameState.sharedScript.ccResourceMaps[res].map[j];
|1089|1089| 		val *= norm;
|1090|1090| 
|1091|    |-		// If oversea, be just above threshold to be accepted if nothing else 
|    |1091|+		// If oversea, be just above threshold to be accepted if nothing else
|1092|1092| 		if (oversea)
|1093|1093| 			val = Math.max(val, cut + 0.1);
|1094|1094| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2679|2679| 			this.phasing = 0;
|2680|2680| 	}
|2681|2681| 
|2682|    |-/*	if (this.Config.debug > 1)
|    |2682|+	/*	if (this.Config.debug > 1)
|2683|2683| 	{
|2684|2684| 		gameState.getOwnUnits().forEach (function (ent) {
|2685|2685| 			if (!ent.position())
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/headquarters.js
|2754|2754| 		this.currentBase %= this.baseManagers.length;
|2755|2755| 		activeBase = this.baseManagers[this.currentBase++].update(gameState, queues, events);
|2756|2756| 		--nbBases;
|2757|    |-// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|    |2757|+		// TODO what to do with this.reassignTerritories(this.baseManagers[this.currentBase]);
|2758|2758| 	}
|2759|2759| 	while (!activeBase && nbBases != 0);
|2760|2760| 
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/transportPlan.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/ai/petra/transportPlan.js
| 237| 237| 		ent.setMetadata(PlayerID, "endPos", undefined);
| 238| 238| 		ent.setMetadata(PlayerID, "onBoard", undefined);
| 239| 239| 		ent.setMetadata(PlayerID, "transport", undefined);
| 240|    |-		// TODO if the index of the endPos of the entity is !=, 
|    | 240|+		// TODO if the index of the endPos of the entity is !=,
| 241| 241| 		// require again another transport (we could need land-sea-land-sea-land)
| 242| 242| 	}
| 243| 243| 
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/511/display/redirect

elexis updated the Trac tickets for this revision.Aug 29 2019, 5:46 PM
elexis edited the test plan for this revision. (Show Details)Aug 29 2019, 5:59 PM
elexis edited the test plan for this revision. (Show Details)
elexis accepted this revision.EditedAug 29 2019, 6:26 PM

Analysis sounds sane from reading it.

It looks like _petrabot.js is the instance defining PETRA first.

I.e. all of this depending on filename order / loading order.

If this is already dependent on it, perhaps we can remove the anonymous function altogether and can extend PetraBot.prototype directly instead of a local m?

Better would be not having to rely on other files at all and just define self-sufficient prototypes, i.e. NavalManager not being part of the Petra object. Something similar to the simulation component layout.

I'm ok with performing this individual step independently if you only want to address the ESLint warning. It reduces some characters that would have to be removed as well if there will be more refactoring.


One obvious review question is wheather this approach makes it harder to create a new AI type that inherits PETRA via prototype chain.

Looking at how this is horse is settled:

var PETRA = {};
 PETRA.PetraBot = function PetraBot(settings)
PETRA.PetraBot.prototype = new API3.BaseAI();
PETRA.PetraBot.prototype.CustomInit = function(gameState)
this.attackManager = new PETRA.AttackManager(this.Config);
PETRA.AttackManager.prototype.setRushes

So PETRA is a JS object where each property is a JS class specified using prototype syntax.

(I hope to stick as close as possible to JS terminology https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain )

The patch only removes a local variable, so it in fact does not add any regression with regards to external / independent files that want to inherit or otherwise use parts or all of PETRA.

The only thing that this patch doesn't allow anymore is variables that are in this specific scope. But there are none of them, nor should there be.
Having small confined scopes makes it more fail safe (I guess that was said for the titanic too I suppose).

So I only see benefits from this diff, if it is correct.

Then the next question is whether the patch is correct. To establish that I searched for all m. ocurrences in thedatabase, read every line of the patch with satisfaction and let AI bots play a match against each other, on two 1v1 matches, one of them naval.
Also performed loading a savegame, everything fine. Also ran non-visual replay of an MP match with 2 bots to test the hash with against without the patch and they match.
AI had some bugs, but thats different from this patch.

I noticed that the AI/common-api folder has the same issue!? Maybe not the same ESLint issue, but I suppose it would be preferable to have it consistent. (API3 instead of m).
Wondering whether that should be API3 and not just API then.

Perhaps one side effect that could be laid out to be disadvantageous is that using PETRA instead of m everywhere makes it harder to rename the AI to Peter or something.
At least all the lines changed in this patch would be renamed, which are a bit more than would have to be renamed before this patch.
Then again Im not sure if we want to perform such a step, especially since nothing changed code-wise.
Renaming would be a branding question, and a new brand would require new features.
So I suppose that's better to be done when someone follows that path.

Init Order
Init order should also be considered for regressions.
We see _petrabot.js is used to ensure that this file is processed first, PETRA defined first before it is extended.
refs D1756 for a patch to ensure that this is actually ensured independent of platform.
Clearly the long term objective is to write the code in such a way that it doesnt depend on the order in which the files are loaded.
At least without considering mods, since mods often want to extend a prototype, and for that to happen it must exist already.
So there need to be hooks, like a defined init function and a hook for mods to perform code, perhaps even in an order they define.
Until then, the patch is not adding any regression in that regard.

Looking at the pattern originally complained about by ESLint and removed in the patch

var PETRA = function(m){
 m.something = …;
 …
 return m;
}(PETRA);

It seems this was made to avoid the init order from taking place, but doesn't work, since it already relies on the predefined PETRA object and can't work without it.

So if the idea has been to make the code function without the PETRA object, then yes, the entire file should be wrapped in a function, but the function should have been called in one central place defining that.
.........

........

Archeology department found the following:

Petra uses this pattern since introduction in rP14865.
The pattern was copied from Aegis, which introduced the pattern in rP14441.
The problem that rP14441 solved was

11:21 < Yves`> there's one ScriptInterface with an own global object for each AI players

and was done for the SpiderMonkey 24 upgrade (#1886).
That there is only one global object now is still met after removing the pattern.

The pattern was a conscious choice by Yves. The patch was discussed on December 2013 with wraitii, Philip and leper.
It seems only Philip really checked whether the pattern is okay, since I couldn't find any concept feedback on the pattern used by the others:

2013-12-14-QuakeNet-#0ad-dev.log:11:23 < Yves`> the code will have to be wrapped in some kind of module pattern to avoid naming conflicts between different AI scripts: http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html

01:30 < Philip`> Yves`: (It would perhaps be nice if we could use the ES6 module system to import/export things instead of requiring a "m." prefix thing, but I guess we need to wait for SpiderMonkey to implement that first, and need to upgrade to that SpiderMonkey :-) )

If we look at the quoted link, we can see the advantages of the so called Augmentation pattern.
It's to have variables private to that function and to refer to function input arguments rather than globals.
But those advantages were never used, while triggering the ESLint warning (var use before definition).

See also IRC discussions between Krinkle and me today and (those must have been on the days where this revision proposal was updated), for example http://irclogs.wildfiregames.com/2019-08/2019-08-25-QuakeNet-%230ad-dev.log

So Philip was the only one who in one sentence seems to have questioned the pattern at the review stage, I don't know if it was discussed later in IRC.

I mentioned on IRC that I'd prefer this pattern here because we use it in the simulation with great success. The scope should not exist because there should not be variables within that scope. If there is need for intermediary data, it should be in a different file, or there should be a helper function or the init function should process it. But it shouldn't be mixed. There is less code complexity if there is only one global and prototype scope, rather than global+prototype+closure scope.

So all in all, I am forced to accept the patch:
Q.E.D. and thanks Krinkle!

The same pattern still seems to apply to the API3, but I am happy to have that performed after saving this progress.

binaries/data/mods/public/simulation/ai/petra/_petrabot.js
5

Shouldn't this be PETRA.PetraBot = function (settings)?
It's a bit misleading if changing the name won't change the function call.

(I wonder if PetraBot could receive a name more distinct from PETRA, but I don't find an obvious better one.)

Edit: Update: You updated the patch after I mentioned this on IRC. We came to the conclusion it's necessary to keep this name for the Map in API3, but here it is not necessary, thus misleading for the reader (as he may think its necessary to name it like that).
Its also the only two occurrences in the codebase. So away with this one.

30

(Deserialization needs to be fixed over here.)

This revision is now accepted and ready to land.Aug 29 2019, 6:26 PM