Page MenuHomeWildfire Games

Add a time multiplier for AI levels
ClosedPublic

Authored by mimo on Mar 2 2018, 7:55 PM.

Details

Summary

The AI currently uses the gather and trade rate to define the difficulty levels. But as we have regularly complaints from new players that the easiest difficulty levels are too hard, we can slow it down even more by also using a time multiplier which increases the building and training time for the AI entities.

Test Plan

Agree or not with the changes.

Diff Detail

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

Event Timeline

mimo created this revision.Mar 2 2018, 7:55 PM
elexis added a subscriber: elexis.Mar 2 2018, 8:10 PM

easiest difficulty levels are too hard

I always wonder if that has specific reasons, like not having swordsmen to destroy siege engines or enough units to kill those tanky war elephants.

Init looks ok, doesnt look like it could break serialization, concept seems ok.
Ok for me if previous features are left intact.

binaries/data/mods/public/simulation/components/Pack.js
102 ↗(On Diff #5997)

-\n

binaries/data/mods/public/simulation/components/Player.js
235 ↗(On Diff #5997)

The more agnostic the Player component remains of other components existence, the better.
So it would be nice to nuke the gatherrate multiplier as well. But since we have it already, could be done elsewhere.
On the other hand, having things configurable independently is also a feature and you use it for the trade multiplier, so ok.
(If those are becoming too many, we could think about moving that to a separate component, but sounds unlikely)

247 ↗(On Diff #5997)

(/**\n IMO)

binaries/data/mods/public/simulation/components/ProductionQueue.js
351 ↗(On Diff #5997)

-1 space

binaries/data/mods/public/simulation/components/ResourceGatherer.js
253 ↗(On Diff #5997)

Does this still allow instant-gathering when someone typed the cheat?

binaries/data/mods/public/simulation/helpers/InitGame.js
46 ↗(On Diff #5997)

timeMultiplier or timeFactor?, otherwise one might think it's a duration

48 ↗(On Diff #5997)

(Reminds me that P101 should be done some day)

mimo added a comment.Mar 2 2018, 8:33 PM
In D1350#55316, @elexis wrote:

easiest difficulty levels are too hard

I always wonder if that has specific reasons, like not having swordsmen to destroy siege engines or enough units to kill those tanky war elephants.

Yes the rams or war elephants are certainly a challenge for beginners, but most comments i've seen on the forum are people who already at phase 1 or 2 are attacked by an outnumbering AI. So increasing its training time should already help.

Init looks ok, doesnt look like it could break serialization, concept seems ok.
Ok for me if previous features are left intact.

binaries/data/mods/public/simulation/components/Player.js
235 ↗(On Diff #5997)

Not sure to understand what you mean. Here Player.js is not aware of any other component specificity. It only defines the timeMultiplier which can have input either from cheat or from AI, both set by a Player.Setter.

GatherRateMultiplier and TradeRateMultiplier could be merged has both have currently the same values for the AI, but as these are two fondamentally different way of getting resources, we may want different values in the future, so does not hurt to keep separate.

binaries/data/mods/public/simulation/components/ResourceGatherer.js
253 ↗(On Diff #5997)

yep the rate is multiplied (not modified by the patch) by GetGatherRateMultiplier which is now defined in Player.js as this.gatherRateMultiplier/this.cheatTimeMultiplier while it was only this.gatherRateMultiplier before

binaries/data/mods/public/simulation/helpers/InitGame.js
46 ↗(On Diff #5997)

yes, we multiply the duration, so looks ok to me

elexis added a comment.Mar 2 2018, 8:44 PM

I don't have time to test it correctly now (and I don't want to pretend having it tested well when I can't).
Not reall conident enough for an acceptance, but having it committed would be ok for me and I think for anyone else using, reading or extending that code too.

binaries/data/mods/public/simulation/components/Player.js
235 ↗(On Diff #5997)

(Yes, it was about those 2.)

Vulcan added a subscriber: Vulcan.Mar 2 2018, 11:17 PM

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

Linter detected issues:
Executing section Default...
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-in'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|  52|  52| {
|  53|  53| 	let ret = [];
|  54|  54| 	for (let type in this.carrying)
|  55|    |-	{
|    |  55|+	
|  56|  56| 		ret.push({
|  57|  57| 			"type": type,
|  58|  58| 			"amount": this.carrying[type],
|  59|  59| 			"max": +this.GetCapacity(type)
|  60|  60| 		});
|  61|    |-	}
|    |  61|+	
|  62|  62| 	return ret;
|  63|  63| };
|  64|  64| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|  69|  69| ResourceGatherer.prototype.GiveResources = function(resources)
|  70|  70| {
|  71|  71| 	for (let resource of resources)
|  72|    |-	{
|    |  72|+	
|  73|  73| 		this.carrying[resource.type] = +(resource.amount);
|  74|    |-	}
|    |  74|+	
|  75|  75| 
|  76|  76| 	Engine.PostMessage(this.entity, MT_ResourceCarryingChanged, { "to": this.GetCarryingStatus() });
|  77|  77| };
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|  98|  98| {
|  99|  99| 	if (this.lastCarriedType && this.lastCarriedType.generic in this.carrying)
| 100| 100| 		return this.lastCarriedType;
| 101|    |-	else
| 102|    |-		return undefined;
|    | 101|+	return undefined;
| 103| 102| };
| 104| 103| 
| 105| 104| // Since this code is very performancecritical and applying technologies quite slow, cache it.
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
| 179| 179| 
| 180| 180| 	let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 181| 181| 	if (cmpTrigger && cmpPlayer)
| 182|    |-		cmpTrigger.CallEvent("TreasureCollected", {"player": cmpPlayer.GetPlayerID(), "type": type.specific, "amount": status.amount });
|    | 182|+		cmpTrigger.CallEvent("TreasureCollected", { "player": cmpPlayer.GetPlayerID(), "type": type.specific, "amount": status.amount });
| 183| 183| 
| 184| 184| 	return true;
| 185| 185| };
|    | [NORMAL] ESLintBear (key-spacing):
|    | Extra space before value for key 'goods'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Player.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Player.js
|  90|  90| 		this.resourceCount[res] = 300;
|  91|  91| 		this.resourceNames[res] = Resources.GetResource(res).name;
|  92|  92| 		this.tradingGoods.push({
|  93|    |-			"goods":  res,
|    |  93|+			"goods": res,
|  94|  94| 			"proba": 5 * (quotient + (+i < remainder ? 1 : 0))
|  95|  95| 		});
|  96|  96| 	}

binaries/data/mods/public/simulation/components/Player.js
| 376| »   for·(var·type·in·amounts)
|    | [NORMAL] JSHintBear:
|    | 'type' is already defined.
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'while' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 191| 191| 	{
| 192| 192| 		var tech = techList[i];
| 193| 193| 		while (this.IsTechnologyResearchedOrInProgress(tech))
| 194|    |-		{
|    | 194|+		
| 195| 195| 			tech = superseded[tech];
| 196|    |-		}
|    | 196|+		
| 197| 197| 
| 198| 198| 		techList[i] = tech;
| 199| 199| 	}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 212| 212| 
| 213| 213| 		let template = TechnologyTemplates.Get(tech);
| 214| 214| 		if (template.top)
| 215|    |-			ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom};
|    | 215|+			ret[i] = { "pair": true, "top": template.top, "bottom": template.bottom};
| 216| 216| 		else
| 217| 217| 			ret[i] = tech;
| 218| 218| 	}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 212| 212| 
| 213| 213| 		let template = TechnologyTemplates.Get(tech);
| 214| 214| 		if (template.top)
| 215|    |-			ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom};
|    | 215|+			ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom };
| 216| 216| 		else
| 217| 217| 			ret[i] = tech;
| 218| 218| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 237| 237| 
| 238| 238| 	let template = TechnologyTemplates.Get(tech);
| 239| 239| 	if (template.top)
| 240|    |-	{
|    | 240|+	
| 241| 241| 		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top)
| 242| 242| 			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243|    |-	}
|    | 243|+	
| 244| 244| 	else
| 245| 245| 	{
| 246| 246| 		return (cmpTechnologyManager.IsTechnologyResearched(tech) || cmpTechnologyManager.IsInProgress(tech));
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '||' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 238| 238| 	let template = TechnologyTemplates.Get(tech);
| 239| 239| 	if (template.top)
| 240| 240| 	{
| 241|    |-		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top)
| 242|    |-			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
|    | 241|+		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top) ||
|    | 242|+			cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243| 243| 	}
| 244| 244| 	else
| 245| 245| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 242| 242| 			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243| 243| 	}
| 244| 244| 	else
| 245|    |-	{
|    | 245|+	
| 246| 246| 		return (cmpTechnologyManager.IsTechnologyResearched(tech) || cmpTechnologyManager.IsInProgress(tech));
| 247|    |-	}
|    | 247|+	
| 248| 248| };
| 249| 249| 
| 250| 250| /*
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 241| 241| 		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top)
| 242| 242| 			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243| 243| 	}
| 244|    |-	else
| 245|    |-	{
|    | 244|+	
| 246| 245| 		return (cmpTechnologyManager.IsTechnologyResearched(tech) || cmpTechnologyManager.IsInProgress(tech));
| 247|    |-	}
|    | 246|+	
| 248| 247| };
| 249| 248| 
| 250| 249| /*
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '+'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 300| 300| 				totalCosts[res] = Math.floor(count * costs[res]);
| 301| 301| 			}
| 302| 302| 
| 303|    |-			var population = ApplyValueModificationsToTemplate("Cost/Population",  +template.Cost.Population, cmpPlayer.GetPlayerID(), template);
|    | 303|+			var population = ApplyValueModificationsToTemplate("Cost/Population", +template.Cost.Population, cmpPlayer.GetPlayerID(), template);
| 304| 304| 
| 305| 305| 			// TrySubtractResources should report error to player (they ran out of resources)
| 306| 306| 			if (!cmpPlayer.TrySubtractResources(totalCosts))
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 329| 329| 
| 330| 330| 			// Call the related trigger event
| 331| 331| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 332|    |-			cmpTrigger.CallEvent("TrainingQueued", {"playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity});
|    | 332|+			cmpTrigger.CallEvent("TrainingQueued", { "playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity});
| 333| 333| 		}
| 334| 334| 		else if (type == "technology")
| 335| 335| 		{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 329| 329| 
| 330| 330| 			// Call the related trigger event
| 331| 331| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 332|    |-			cmpTrigger.CallEvent("TrainingQueued", {"playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity});
|    | 332|+			cmpTrigger.CallEvent("TrainingQueued", {"playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity });
| 333| 333| 		}
| 334| 334| 		else if (type == "technology")
| 335| 335| 		{
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'techCostMultiplier'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 348| 348| 
| 349| 349| 			let template = TechnologyTemplates.Get(templateName);
| 350| 350| 			let techCostMultiplier = this.GetTechCostMultiplier();
| 351|    |-			let time =  techCostMultiplier.time * template.researchTime * cmpPlayer.GetTimeMultiplier();
|    | 351|+			let time = techCostMultiplier.time * template.researchTime * cmpPlayer.GetTimeMultiplier();
| 352| 352| 
| 353| 353| 			let cost = {};
| 354| 354| 			for (let res in template.cost)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 378| 378| 
| 379| 379| 			// Call the related trigger event
| 380| 380| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 381|    |-			cmpTrigger.CallEvent("ResearchQueued", {"playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity});
|    | 381|+			cmpTrigger.CallEvent("ResearchQueued", { "playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity});
| 382| 382| 		}
| 383| 383| 		else
| 384| 384| 		{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 378| 378| 
| 379| 379| 			// Call the related trigger event
| 380| 380| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 381|    |-			cmpTrigger.CallEvent("ResearchQueued", {"playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity});
|    | 381|+			cmpTrigger.CallEvent("ResearchQueued", {"playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity });
| 382| 382| 		}
| 383| 383| 		else
| 384| 384| 		{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 397| 397| 	}
| 398| 398| 	else
| 399| 399| 	{
| 400|    |-		var notification = {"players": [cmpPlayer.GetPlayerID()], "message": markForTranslation("The production queue is full."), "translateMessage": true };
|    | 400|+		var notification = { "players": [cmpPlayer.GetPlayerID()], "message": markForTranslation("The production queue is full."), "translateMessage": true };
| 401| 401| 		var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
| 402| 402| 		cmpGUIInterface.PushNotification(notification);
| 403| 403| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 411| 411| {
| 412| 412| 	// Destroy any cached entities (those which didn't spawn for some reason)
| 413| 413| 	for (var i = 0; i < this.entityCache.length; ++i)
| 414|    |-	{
|    | 414|+	
| 415| 415| 		Engine.DestroyEntity(this.entityCache[i]);
| 416|    |-	}
|    | 416|+	
| 417| 417| 	this.entityCache = [];
| 418| 418| 
| 419| 419| 	for (var i = 0; i < this.queue.length; ++i)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 479| 479| {
| 480| 480| 	var out = [];
| 481| 481| 	for (var item of this.queue)
| 482|    |-	{
|    | 482|+	
| 483| 483| 		out.push({
| 484| 484| 			"id": item.id,
| 485| 485| 			"unitTemplate": item.unitTemplate,
| 490| 490| 			"timeRemaining": item.timeRemaining,
| 491| 491| 			"metadata": item.metadata,
| 492| 492| 		});
| 493|    |-	}
|    | 493|+	
| 494| 494| 	return out;
| 495| 495| };
| 496| 496| 
|    | [NORMAL] ESLintBear (space-in-parens):
|    | There should be no spaces inside this paren.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 486| 486| 			"technologyTemplate": item.technologyTemplate,
| 487| 487| 			"count": item.count,
| 488| 488| 			"neededSlots": item.neededSlots,
| 489|    |-			"progress": 1 - ( item.timeRemaining / (item.timeTotal || 1) ),
|    | 489|+			"progress": 1 - (item.timeRemaining / (item.timeTotal || 1) ),
| 490| 490| 			"timeRemaining": item.timeRemaining,
| 491| 491| 			"metadata": item.metadata,
| 492| 492| 		});
|    | [NORMAL] ESLintBear (space-in-parens):
|    | There should be no spaces inside this paren.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 486| 486| 			"technologyTemplate": item.technologyTemplate,
| 487| 487| 			"count": item.count,
| 488| 488| 			"neededSlots": item.neededSlots,
| 489|    |-			"progress": 1 - ( item.timeRemaining / (item.timeTotal || 1) ),
|    | 489|+			"progress": 1 - ( item.timeRemaining / (item.timeTotal || 1)),
| 490| 490| 			"timeRemaining": item.timeRemaining,
| 491| 491| 			"metadata": item.metadata,
| 492| 492| 		});
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 572| 572| 	var spawnedEnts = [];
| 573| 573| 
| 574| 574| 	if (this.entityCache.length == 0)
| 575|    |-	{
|    | 575|+	
| 576| 576| 		// We need entities to test spawning, but we don't want to waste resources,
| 577| 577| 		//	so only create them once and use as needed
| 578| 578| 		for (var i = 0; i < count; ++i)
| 591| 591| 				cmpPlayerEntityLimits.ChangeCount(unitCategory,-1);
| 592| 592| 			}
| 593| 593| 		}
| 594|    |-	}
|    | 594|+	
| 595| 595| 
| 596| 596| 	let cmpAutoGarrison;
| 597| 597| 	if (cmpRallyPoint)
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 588| 588| 			{
| 589| 589| 				var unitCategory = cmpTrainingRestrictions.GetCategory();
| 590| 590| 				var cmpPlayerEntityLimits = QueryOwnerInterface(this.entity, IID_EntityLimits);
| 591|    |-				cmpPlayerEntityLimits.ChangeCount(unitCategory,-1);
|    | 591|+				cmpPlayerEntityLimits.ChangeCount(unitCategory, -1);
| 592| 592| 			}
| 593| 593| 		}
| 594| 594| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 651| 651| 	}
| 652| 652| 
| 653| 653| 	if (spawnedEnts.length > 0 && !cmpAutoGarrison)
| 654|    |-	{
|    | 654|+	
| 655| 655| 		// If a rally point is set, walk towards it (in formation) using a suitable command based on where the
| 656| 656| 		// rally point is placed.
| 657| 657| 		if (cmpRallyPoint)
| 664| 664| 					ProcessCommand(cmpOwnership.GetOwner(), com);
| 665| 665| 			}
| 666| 666| 		}
| 667|    |-	}
|    | 667|+	
| 668| 668| 
| 669| 669| 	if (createdEnts.length > 0)
| 670| 670| 		Engine.PostMessage(this.entity, MT_TrainingFinished, {
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '+'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 701| 701| 			{
| 702| 702| 				// If something change population cost
| 703| 703| 				var template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate(item.unitTemplate);
| 704|    |-				item.population = ApplyValueModificationsToTemplate("Cost/Population",  +template.Cost.Population, item.player, template);
|    | 704|+				item.population = ApplyValueModificationsToTemplate("Cost/Population", +template.Cost.Population, item.player, template);
| 705| 705| 
| 706| 706| 				// Batch's training hasn't started yet.
| 707| 707| 				// Try to reserve the necessary population slots
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 729| 729| 
| 730| 730| 			item.productionStarted = true;
| 731| 731| 			if (item.unitTemplate)
| 732|    |-				Engine.PostMessage(this.entity, MT_TrainingStarted, {"entity": this.entity});
|    | 732|+				Engine.PostMessage(this.entity, MT_TrainingStarted, { "entity": this.entity});
| 733| 733| 		}
| 734| 734| 
| 735| 735| 		// If we won't finish the batch now, just update its timer
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 729| 729| 
| 730| 730| 			item.productionStarted = true;
| 731| 731| 			if (item.unitTemplate)
| 732|    |-				Engine.PostMessage(this.entity, MT_TrainingStarted, {"entity": this.entity});
|    | 732|+				Engine.PostMessage(this.entity, MT_TrainingStarted, {"entity": this.entity });
| 733| 733| 		}
| 734| 734| 
| 735| 735| 		// If we won't finish the batch now, just update its timer

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 349| »   »   »   let·template·=·TechnologyTemplates.Get(templateName);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'template' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 351| »   »   »   let·time·=··techCostMultiplier.time·*·template.researchTime·*·cmpPlayer.GetTimeMultiplier();
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'time' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 604| »   for·(let·i·=·0;·i·<·count;·++i)
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 606| »   »   let·ent·=·this.entityCache[0];
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 788| »   »   »   let·template·=·TechnologyTemplates.Get(item.technologyTemplate);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'template' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 190| »   for·(var·i·in·techList)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 192| »   »   var·tech·=·techList[i];
|    | [NORMAL] JSHintBear:
|    | 'tech' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 204| »   for·(var·i·=·0;·i·<·techList.length;·i++)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 206| »   »   var·tech·=·techList[i];
|    | [NORMAL] JSHintBear:
|    | 'tech' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 242| »   »   »   ||·cmpTechnologyManager.IsTechnologyResearched(template.bottom)·||·cmpTechnologyManager.IsInProgress(template.bottom));
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 380| »   »   »   var·cmpTrigger·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_Trigger);
|    | [NORMAL] JSHintBear:
|    | 'cmpTrigger' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 419| »   for·(var·i·=·0;·i·<·this.queue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 774| »   »   »   »   »   var·cmpPlayer·=·QueryOwnerInterface(this.entity);
|    | [NORMAL] JSHintBear:
|    | 'cmpPlayer' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 785| »   »   »   var·cmpTechnologyManager·=·QueryOwnerInterface(this.entity,·IID_TechnologyManager);
|    | [NORMAL] JSHintBear:
|    | 'cmpTechnologyManager' is already defined.

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

mimo updated this revision to Diff 6011.Mar 3 2018, 12:18 AM

update fixing tests

Vulcan added a comment.Mar 3 2018, 2:20 AM

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

Linter detected issues:
Executing section Default...
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-in'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|  52|  52| {
|  53|  53| 	let ret = [];
|  54|  54| 	for (let type in this.carrying)
|  55|    |-	{
|    |  55|+	
|  56|  56| 		ret.push({
|  57|  57| 			"type": type,
|  58|  58| 			"amount": this.carrying[type],
|  59|  59| 			"max": +this.GetCapacity(type)
|  60|  60| 		});
|  61|    |-	}
|    |  61|+	
|  62|  62| 	return ret;
|  63|  63| };
|  64|  64| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|  69|  69| ResourceGatherer.prototype.GiveResources = function(resources)
|  70|  70| {
|  71|  71| 	for (let resource of resources)
|  72|    |-	{
|    |  72|+	
|  73|  73| 		this.carrying[resource.type] = +(resource.amount);
|  74|    |-	}
|    |  74|+	
|  75|  75| 
|  76|  76| 	Engine.PostMessage(this.entity, MT_ResourceCarryingChanged, { "to": this.GetCarryingStatus() });
|  77|  77| };
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|  98|  98| {
|  99|  99| 	if (this.lastCarriedType && this.lastCarriedType.generic in this.carrying)
| 100| 100| 		return this.lastCarriedType;
| 101|    |-	else
| 102|    |-		return undefined;
|    | 101|+	return undefined;
| 103| 102| };
| 104| 103| 
| 105| 104| // Since this code is very performancecritical and applying technologies quite slow, cache it.
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ResourceGatherer.js
| 179| 179| 
| 180| 180| 	let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 181| 181| 	if (cmpTrigger && cmpPlayer)
| 182|    |-		cmpTrigger.CallEvent("TreasureCollected", {"player": cmpPlayer.GetPlayerID(), "type": type.specific, "amount": status.amount });
|    | 182|+		cmpTrigger.CallEvent("TreasureCollected", { "player": cmpPlayer.GetPlayerID(), "type": type.specific, "amount": status.amount });
| 183| 183| 
| 184| 184| 	return true;
| 185| 185| };
|    | [NORMAL] ESLintBear (key-spacing):
|    | Extra space before value for key 'goods'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Player.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Player.js
|  90|  90| 		this.resourceCount[res] = 300;
|  91|  91| 		this.resourceNames[res] = Resources.GetResource(res).name;
|  92|  92| 		this.tradingGoods.push({
|  93|    |-			"goods":  res,
|    |  93|+			"goods": res,
|  94|  94| 			"proba": 5 * (quotient + (+i < remainder ? 1 : 0))
|  95|  95| 		});
|  96|  96| 	}

binaries/data/mods/public/simulation/components/Player.js
| 377| »   for·(var·type·in·amounts)
|    | [NORMAL] JSHintBear:
|    | 'type' is already defined.
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'while' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 191| 191| 	{
| 192| 192| 		var tech = techList[i];
| 193| 193| 		while (this.IsTechnologyResearchedOrInProgress(tech))
| 194|    |-		{
|    | 194|+		
| 195| 195| 			tech = superseded[tech];
| 196|    |-		}
|    | 196|+		
| 197| 197| 
| 198| 198| 		techList[i] = tech;
| 199| 199| 	}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 212| 212| 
| 213| 213| 		let template = TechnologyTemplates.Get(tech);
| 214| 214| 		if (template.top)
| 215|    |-			ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom};
|    | 215|+			ret[i] = { "pair": true, "top": template.top, "bottom": template.bottom};
| 216| 216| 		else
| 217| 217| 			ret[i] = tech;
| 218| 218| 	}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 212| 212| 
| 213| 213| 		let template = TechnologyTemplates.Get(tech);
| 214| 214| 		if (template.top)
| 215|    |-			ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom};
|    | 215|+			ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom };
| 216| 216| 		else
| 217| 217| 			ret[i] = tech;
| 218| 218| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 237| 237| 
| 238| 238| 	let template = TechnologyTemplates.Get(tech);
| 239| 239| 	if (template.top)
| 240|    |-	{
|    | 240|+	
| 241| 241| 		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top)
| 242| 242| 			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243|    |-	}
|    | 243|+	
| 244| 244| 	else
| 245| 245| 	{
| 246| 246| 		return (cmpTechnologyManager.IsTechnologyResearched(tech) || cmpTechnologyManager.IsInProgress(tech));
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '||' should be placed at the end of the line.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 238| 238| 	let template = TechnologyTemplates.Get(tech);
| 239| 239| 	if (template.top)
| 240| 240| 	{
| 241|    |-		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top)
| 242|    |-			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
|    | 241|+		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top) ||
|    | 242|+			cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243| 243| 	}
| 244| 244| 	else
| 245| 245| 	{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 242| 242| 			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243| 243| 	}
| 244| 244| 	else
| 245|    |-	{
|    | 245|+	
| 246| 246| 		return (cmpTechnologyManager.IsTechnologyResearched(tech) || cmpTechnologyManager.IsInProgress(tech));
| 247|    |-	}
|    | 247|+	
| 248| 248| };
| 249| 249| 
| 250| 250| /*
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 241| 241| 		return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top)
| 242| 242| 			|| cmpTechnologyManager.IsTechnologyResearched(template.bottom) || cmpTechnologyManager.IsInProgress(template.bottom));
| 243| 243| 	}
| 244|    |-	else
| 245|    |-	{
|    | 244|+	
| 246| 245| 		return (cmpTechnologyManager.IsTechnologyResearched(tech) || cmpTechnologyManager.IsInProgress(tech));
| 247|    |-	}
|    | 246|+	
| 248| 247| };
| 249| 248| 
| 250| 249| /*
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '+'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 300| 300| 				totalCosts[res] = Math.floor(count * costs[res]);
| 301| 301| 			}
| 302| 302| 
| 303|    |-			var population = ApplyValueModificationsToTemplate("Cost/Population",  +template.Cost.Population, cmpPlayer.GetPlayerID(), template);
|    | 303|+			var population = ApplyValueModificationsToTemplate("Cost/Population", +template.Cost.Population, cmpPlayer.GetPlayerID(), template);
| 304| 304| 
| 305| 305| 			// TrySubtractResources should report error to player (they ran out of resources)
| 306| 306| 			if (!cmpPlayer.TrySubtractResources(totalCosts))
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 329| 329| 
| 330| 330| 			// Call the related trigger event
| 331| 331| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 332|    |-			cmpTrigger.CallEvent("TrainingQueued", {"playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity});
|    | 332|+			cmpTrigger.CallEvent("TrainingQueued", { "playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity});
| 333| 333| 		}
| 334| 334| 		else if (type == "technology")
| 335| 335| 		{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 329| 329| 
| 330| 330| 			// Call the related trigger event
| 331| 331| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 332|    |-			cmpTrigger.CallEvent("TrainingQueued", {"playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity});
|    | 332|+			cmpTrigger.CallEvent("TrainingQueued", {"playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity });
| 333| 333| 		}
| 334| 334| 		else if (type == "technology")
| 335| 335| 		{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 378| 378| 
| 379| 379| 			// Call the related trigger event
| 380| 380| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 381|    |-			cmpTrigger.CallEvent("ResearchQueued", {"playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity});
|    | 381|+			cmpTrigger.CallEvent("ResearchQueued", { "playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity});
| 382| 382| 		}
| 383| 383| 		else
| 384| 384| 		{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 378| 378| 
| 379| 379| 			// Call the related trigger event
| 380| 380| 			var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
| 381|    |-			cmpTrigger.CallEvent("ResearchQueued", {"playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity});
|    | 381|+			cmpTrigger.CallEvent("ResearchQueued", {"playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity });
| 382| 382| 		}
| 383| 383| 		else
| 384| 384| 		{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 397| 397| 	}
| 398| 398| 	else
| 399| 399| 	{
| 400|    |-		var notification = {"players": [cmpPlayer.GetPlayerID()], "message": markForTranslation("The production queue is full."), "translateMessage": true };
|    | 400|+		var notification = { "players": [cmpPlayer.GetPlayerID()], "message": markForTranslation("The production queue is full."), "translateMessage": true };
| 401| 401| 		var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
| 402| 402| 		cmpGUIInterface.PushNotification(notification);
| 403| 403| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 411| 411| {
| 412| 412| 	// Destroy any cached entities (those which didn't spawn for some reason)
| 413| 413| 	for (var i = 0; i < this.entityCache.length; ++i)
| 414|    |-	{
|    | 414|+	
| 415| 415| 		Engine.DestroyEntity(this.entityCache[i]);
| 416|    |-	}
|    | 416|+	
| 417| 417| 	this.entityCache = [];
| 418| 418| 
| 419| 419| 	for (var i = 0; i < this.queue.length; ++i)
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'for-of'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 479| 479| {
| 480| 480| 	var out = [];
| 481| 481| 	for (var item of this.queue)
| 482|    |-	{
|    | 482|+	
| 483| 483| 		out.push({
| 484| 484| 			"id": item.id,
| 485| 485| 			"unitTemplate": item.unitTemplate,
| 490| 490| 			"timeRemaining": item.timeRemaining,
| 491| 491| 			"metadata": item.metadata,
| 492| 492| 		});
| 493|    |-	}
|    | 493|+	
| 494| 494| 	return out;
| 495| 495| };
| 496| 496| 
|    | [NORMAL] ESLintBear (space-in-parens):
|    | There should be no spaces inside this paren.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 486| 486| 			"technologyTemplate": item.technologyTemplate,
| 487| 487| 			"count": item.count,
| 488| 488| 			"neededSlots": item.neededSlots,
| 489|    |-			"progress": 1 - ( item.timeRemaining / (item.timeTotal || 1) ),
|    | 489|+			"progress": 1 - (item.timeRemaining / (item.timeTotal || 1) ),
| 490| 490| 			"timeRemaining": item.timeRemaining,
| 491| 491| 			"metadata": item.metadata,
| 492| 492| 		});
|    | [NORMAL] ESLintBear (space-in-parens):
|    | There should be no spaces inside this paren.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 486| 486| 			"technologyTemplate": item.technologyTemplate,
| 487| 487| 			"count": item.count,
| 488| 488| 			"neededSlots": item.neededSlots,
| 489|    |-			"progress": 1 - ( item.timeRemaining / (item.timeTotal || 1) ),
|    | 489|+			"progress": 1 - ( item.timeRemaining / (item.timeTotal || 1)),
| 490| 490| 			"timeRemaining": item.timeRemaining,
| 491| 491| 			"metadata": item.metadata,
| 492| 492| 		});
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 572| 572| 	var spawnedEnts = [];
| 573| 573| 
| 574| 574| 	if (this.entityCache.length == 0)
| 575|    |-	{
|    | 575|+	
| 576| 576| 		// We need entities to test spawning, but we don't want to waste resources,
| 577| 577| 		//	so only create them once and use as needed
| 578| 578| 		for (var i = 0; i < count; ++i)
| 591| 591| 				cmpPlayerEntityLimits.ChangeCount(unitCategory,-1);
| 592| 592| 			}
| 593| 593| 		}
| 594|    |-	}
|    | 594|+	
| 595| 595| 
| 596| 596| 	let cmpAutoGarrison;
| 597| 597| 	if (cmpRallyPoint)
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 588| 588| 			{
| 589| 589| 				var unitCategory = cmpTrainingRestrictions.GetCategory();
| 590| 590| 				var cmpPlayerEntityLimits = QueryOwnerInterface(this.entity, IID_EntityLimits);
| 591|    |-				cmpPlayerEntityLimits.ChangeCount(unitCategory,-1);
|    | 591|+				cmpPlayerEntityLimits.ChangeCount(unitCategory, -1);
| 592| 592| 			}
| 593| 593| 		}
| 594| 594| 	}
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 651| 651| 	}
| 652| 652| 
| 653| 653| 	if (spawnedEnts.length > 0 && !cmpAutoGarrison)
| 654|    |-	{
|    | 654|+	
| 655| 655| 		// If a rally point is set, walk towards it (in formation) using a suitable command based on where the
| 656| 656| 		// rally point is placed.
| 657| 657| 		if (cmpRallyPoint)
| 664| 664| 					ProcessCommand(cmpOwnership.GetOwner(), com);
| 665| 665| 			}
| 666| 666| 		}
| 667|    |-	}
|    | 667|+	
| 668| 668| 
| 669| 669| 	if (createdEnts.length > 0)
| 670| 670| 		Engine.PostMessage(this.entity, MT_TrainingFinished, {
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before '+'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 701| 701| 			{
| 702| 702| 				// If something change population cost
| 703| 703| 				var template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate(item.unitTemplate);
| 704|    |-				item.population = ApplyValueModificationsToTemplate("Cost/Population",  +template.Cost.Population, item.player, template);
|    | 704|+				item.population = ApplyValueModificationsToTemplate("Cost/Population", +template.Cost.Population, item.player, template);
| 705| 705| 
| 706| 706| 				// Batch's training hasn't started yet.
| 707| 707| 				// Try to reserve the necessary population slots
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 729| 729| 
| 730| 730| 			item.productionStarted = true;
| 731| 731| 			if (item.unitTemplate)
| 732|    |-				Engine.PostMessage(this.entity, MT_TrainingStarted, {"entity": this.entity});
|    | 732|+				Engine.PostMessage(this.entity, MT_TrainingStarted, { "entity": this.entity});
| 733| 733| 		}
| 734| 734| 
| 735| 735| 		// If we won't finish the batch now, just update its timer
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/ProductionQueue.js
| 729| 729| 
| 730| 730| 			item.productionStarted = true;
| 731| 731| 			if (item.unitTemplate)
| 732|    |-				Engine.PostMessage(this.entity, MT_TrainingStarted, {"entity": this.entity});
|    | 732|+				Engine.PostMessage(this.entity, MT_TrainingStarted, {"entity": this.entity });
| 733| 733| 		}
| 734| 734| 
| 735| 735| 		// If we won't finish the batch now, just update its timer

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 349| »   »   »   let·template·=·TechnologyTemplates.Get(templateName);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'template' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 351| »   »   »   let·time·=·techCostMultiplier.time·*·template.researchTime·*·cmpPlayer.GetTimeMultiplier();
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'time' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 604| »   for·(let·i·=·0;·i·<·count;·++i)
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 606| »   »   let·ent·=·this.entityCache[0];
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 788| »   »   »   let·template·=·TechnologyTemplates.Get(item.technologyTemplate);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'template' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 190| »   for·(var·i·in·techList)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 192| »   »   var·tech·=·techList[i];
|    | [NORMAL] JSHintBear:
|    | 'tech' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 204| »   for·(var·i·=·0;·i·<·techList.length;·i++)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 206| »   »   var·tech·=·techList[i];
|    | [NORMAL] JSHintBear:
|    | 'tech' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 242| »   »   »   ||·cmpTechnologyManager.IsTechnologyResearched(template.bottom)·||·cmpTechnologyManager.IsInProgress(template.bottom));
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 380| »   »   »   var·cmpTrigger·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_Trigger);
|    | [NORMAL] JSHintBear:
|    | 'cmpTrigger' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 419| »   for·(var·i·=·0;·i·<·this.queue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 774| »   »   »   »   »   var·cmpPlayer·=·QueryOwnerInterface(this.entity);
|    | [NORMAL] JSHintBear:
|    | 'cmpPlayer' is already defined.

binaries/data/mods/public/simulation/components/ProductionQueue.js
| 785| »   »   »   var·cmpTechnologyManager·=·QueryOwnerInterface(this.entity,·IID_TechnologyManager);
|    | [NORMAL] JSHintBear:
|    | 'cmpTechnologyManager' is already defined.
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_Pack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_Pack.js
| 127| 127| TS_ASSERT_EQUALS(cmpPack.timer, 7);
| 128| 128| TS_ASSERT(timerActivated);
| 129| 129| 
| 130|    |-// Cancel 
|    | 130|+// Cancel
| 131| 131| cmpPack.CancelPack();
| 132| 132| 
| 133| 133| TS_ASSERT(!cmpPack.IsPacking());
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_Pack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_Pack.js
| 131| 131| cmpPack.CancelPack();
| 132| 132| 
| 133| 133| TS_ASSERT(!cmpPack.IsPacking());
| 134|    |-TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(), 0)
|    | 134|+TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(), 0);
| 135| 135| TS_ASSERT_EQUALS(cmpPack.GetProgress(), 0);
| 136| 136| TS_ASSERT_EQUALS(cmpPack.timer, undefined);
| 137| 137| TS_ASSERT(!timerActivated);

binaries/data/mods/public/simulation/components/tests/test_Pack.js
|  45| »   "SetInterval":·(ent,·iid,·funcname,·time,·repeattime,·data)·=>·{·timerActivated·=·true;·return·7;·}
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/tests/test_Pack.js
| 134| TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(),·0)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property '20' found.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|  63|  63| };
|  64|  64| let entityTechModifications = {
|  65|  65| 	"without": {
|  66|    |-		'Upgrade/Cost/stone': { 20: { "origValue": 100, "newValue": 100 } },
|    |  66|+		'Upgrade/Cost/stone': { "20": { "origValue": 100, "newValue": 100 } },
|  67|  67| 		'Upgrade/Cost/wood': { 20: { "origValue": 50, "newValue": 50 } },
|  68|  68| 		'Upgrade/Time': { 20: { "origValue": 100, "newValue": 100 } }
|  69|  69| 	},
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property '20' found.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|  64|  64| let entityTechModifications = {
|  65|  65| 	"without": {
|  66|  66| 		'Upgrade/Cost/stone': { 20: { "origValue": 100, "newValue": 100 } },
|  67|    |-		'Upgrade/Cost/wood': { 20: { "origValue": 50, "newValue": 50 } },
|    |  67|+		'Upgrade/Cost/wood': { "20": { "origValue": 50, "newValue": 50 } },
|  68|  68| 		'Upgrade/Time': { 20: { "origValue": 100, "newValue": 100 } }
|  69|  69| 	},
|  70|  70| 	"with": {
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property '20' found.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|  65|  65| 	"without": {
|  66|  66| 		'Upgrade/Cost/stone': { 20: { "origValue": 100, "newValue": 100 } },
|  67|  67| 		'Upgrade/Cost/wood': { 20: { "origValue": 50, "newValue": 50 } },
|  68|    |-		'Upgrade/Time': { 20: { "origValue": 100, "newValue": 100 } }
|    |  68|+		'Upgrade/Time': { "20": { "origValue": 100, "newValue": 100 } }
|  69|  69| 	},
|  70|  70| 	"with": {
|  71|  71| 		'Upgrade/Cost/stone': { 20: { "origValue": 100, "newValue": 160 } },
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property '20' found.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|  68|  68| 		'Upgrade/Time': { 20: { "origValue": 100, "newValue": 100 } }
|  69|  69| 	},
|  70|  70| 	"with": {
|  71|    |-		'Upgrade/Cost/stone': { 20: { "origValue": 100, "newValue": 160 } },
|    |  71|+		'Upgrade/Cost/stone': { "20": { "origValue": 100, "newValue": 160 } },
|  72|  72| 		'Upgrade/Cost/wood': { 20: { "origValue": 50, "newValue": 25 } },
|  73|  73| 		'Upgrade/Time': { 20: { "origValue": 100, "newValue": 90 } }
|  74|  74| 	}
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property '20' found.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|  69|  69| 	},
|  70|  70| 	"with": {
|  71|  71| 		'Upgrade/Cost/stone': { 20: { "origValue": 100, "newValue": 160 } },
|  72|    |-		'Upgrade/Cost/wood': { 20: { "origValue": 50, "newValue": 25 } },
|    |  72|+		'Upgrade/Cost/wood': { "20": { "origValue": 50, "newValue": 25 } },
|  73|  73| 		'Upgrade/Time': { 20: { "origValue": 100, "newValue": 90 } }
|  74|  74| 	}
|  75|  75| };
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property '20' found.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|  70|  70| 	"with": {
|  71|  71| 		'Upgrade/Cost/stone': { 20: { "origValue": 100, "newValue": 160 } },
|  72|  72| 		'Upgrade/Cost/wood': { 20: { "origValue": 50, "newValue": 25 } },
|  73|    |-		'Upgrade/Time': { 20: { "origValue": 100, "newValue": 90 } }
|    |  73|+		'Upgrade/Time': { "20": { "origValue": 100, "newValue": 90 } }
|  74|  74| 	}
|  75|  75| };
|  76|  76| 

binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
| 100| »   "ApplyModificationsTemplate":·(valueName,·curValue,·template)·=>·{
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'template' is already declared in the upper scope.

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

This revision was not accepted when it landed; it landed in state Needs Review.Mar 3 2018, 11:05 AM
This revision was automatically updated to reflect the committed changes.