Index: ps/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js +++ ps/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js @@ -39,7 +39,7 @@ this.ActivateTimer(); }; -//// Message handlers //// +// Message handlers AttackDetection.prototype.OnGlobalAttacked = function(msg) { @@ -53,7 +53,7 @@ this.AttackAlert(msg.target, msg.attacker, msg.type, msg.attackerOwner); }; -//// External interface //// +// External interface AttackDetection.prototype.AttackAlert = function(target, attacker, type, attackerOwner) { @@ -103,8 +103,8 @@ isPriorityIncreased = element.targetIsDomesticAnimal && !targetIsDomesticAnimal; var isPriorityDescreased = !element.targetIsDomesticAnimal && targetIsDomesticAnimal; - if (isPriorityIncreased - || (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared)) + if (isPriorityIncreased || + (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared)) this.UpdateSuppressionEvent(i, event); // If priority has increased, exit the loop to send the upgraded notification below Index: ps/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js +++ ps/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js @@ -220,9 +220,9 @@ result.message = markForTranslation("%(name)s cannot be built in %(territoryType)s territory. Valid territories: %(validTerritories)s"); result.translateParameters.push("territoryType"); result.translateParameters.push("validTerritories"); - result.parameters.territoryType = {"context": "Territory type", "message": invalidTerritory}; + result.parameters.territoryType = { "context": "Territory type", "message": invalidTerritory }; // gui code will join this array to a string - result.parameters.validTerritories = {"context": "Territory type list", "list": this.GetTerritories()}; + result.parameters.validTerritories = { "context": "Territory type list", "list": this.GetTerritories() }; return result; // Fail } Index: ps/trunk/binaries/data/mods/public/simulation/components/Capturable.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Capturable.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Capturable.js @@ -19,7 +19,7 @@ this.capturePoints = []; }; -//// Interface functions //// +// Interface functions /** * Returns the current capture points array. @@ -150,7 +150,7 @@ return sourceEnemyCapturePoints > 0; }; -//// Private functions //// +// Private functions /** * This has to be called whenever the capture points are changed. @@ -292,7 +292,7 @@ this.CheckTimer(); }; -//// Message Listeners //// +// Message Listeners Capturable.prototype.OnValueModification = function(msg) { Index: ps/trunk/binaries/data/mods/public/simulation/components/CeasefireManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/CeasefireManager.js +++ ps/trunk/binaries/data/mods/public/simulation/components/CeasefireManager.js @@ -96,9 +96,9 @@ { let cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); this.ceasefireCountdownMessage = cmpGuiInterface.AddTimeNotification({ - "message": markForTranslation("You can attack in %(time)s"), - "translateMessage": true - }, this.countdownMessageDuration); + "message": markForTranslation("You can attack in %(time)s"), + "translateMessage": true + }, this.countdownMessageDuration); }; CeasefireManager.prototype.StopCeasefire = function() Index: ps/trunk/binaries/data/mods/public/simulation/components/EndGameManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/EndGameManager.js +++ ps/trunk/binaries/data/mods/public/simulation/components/EndGameManager.js @@ -107,7 +107,7 @@ cmpGUIInterface.PushNotification({ "type": "won", "players": [winningPlayers[0]], - "allies" : winningPlayers, + "allies": winningPlayers, "message": victoryString(winningPlayers.length) }); @@ -115,7 +115,7 @@ cmpGUIInterface.PushNotification({ "type": "defeat", "players": [defeatedPlayers[0]], - "allies" : defeatedPlayers, + "allies": defeatedPlayers, "message": defeatString(defeatedPlayers.length) }); @@ -170,7 +170,7 @@ cmpGuiInterface.PushNotification({ "type": "won", "players": [allies[0]], - "allies" : allies, + "allies": allies, "message": markForPluralTranslation( "%(lastPlayer)s has won (last player alive).", "%(players)s and %(lastPlayer)s have won (last players alive).", Index: ps/trunk/binaries/data/mods/public/simulation/components/EntityLimits.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/EntityLimits.js +++ ps/trunk/binaries/data/mods/public/simulation/components/EntityLimits.js @@ -135,8 +135,8 @@ EntityLimits.prototype.UpdateLimitsFromTech = function(tech) { for (var category in this.removers) - if ("RequiredTechs" in this.removers[category] && this.removers[category]["RequiredTechs"].indexOf(tech) !== -1) - this.removers[category]["RequiredTechs"].splice(this.removers[category]["RequiredTechs"].indexOf(tech), 1); + if ("RequiredTechs" in this.removers[category] && this.removers[category].RequiredTechs.indexOf(tech) !== -1) + this.removers[category].RequiredTechs.splice(this.removers[category].RequiredTechs.indexOf(tech), 1); this.UpdateLimitRemoval(); }; @@ -147,9 +147,9 @@ { var nolimit = true; if ("RequiredTechs" in this.removers[category]) - nolimit = !this.removers[category]["RequiredTechs"].length; + nolimit = !this.removers[category].RequiredTechs.length; if (nolimit && "RequiredClasses" in this.removers[category]) - for (var cls of this.removers[category]["RequiredClasses"]) + for (var cls of this.removers[category].RequiredClasses) nolimit = nolimit && this.classCount[cls] > 0; if (nolimit && this.limit[category] !== undefined) @@ -288,7 +288,7 @@ for (var category in this.removers) if ("RequiredClasses" in this.removers[category]) - for (var cls of this.removers[category]["RequiredClasses"]) + for (var cls of this.removers[category].RequiredClasses) if (classes.indexOf(cls) !== -1) this.classCount[cls] += modifier; Index: ps/trunk/binaries/data/mods/public/simulation/components/FormationAttack.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/FormationAttack.js +++ ps/trunk/binaries/data/mods/public/simulation/components/FormationAttack.js @@ -23,7 +23,7 @@ FormationAttack.prototype.GetRange = function(target) { - var result = {"min": 0, "max": this.canAttackAsFormation ? -1 : 0}; + var result = { "min": 0, "max": this.canAttackAsFormation ? -1 : 0 }; var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); if (!cmpFormation) { Index: ps/trunk/binaries/data/mods/public/simulation/components/RangeOverlayManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/RangeOverlayManager.js +++ ps/trunk/binaries/data/mods/public/simulation/components/RangeOverlayManager.js @@ -80,7 +80,7 @@ this.RegenerateRangeOverlays(false); }; -/** +/** * RangeOverlayManager component is deserialized before the TechnologyManager, so need to update the ranges here */ RangeOverlayManager.prototype.OnDeserialized = function(msg) Index: ps/trunk/binaries/data/mods/public/simulation/components/Repairable.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Repairable.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Repairable.js @@ -57,7 +57,7 @@ { for (let builder of builders) this.AddBuilder(builder); -} +}; Repairable.prototype.AddBuilder = function(builderEnt) { Index: ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js +++ ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js @@ -39,8 +39,8 @@ for (let key of this.unresearchedAutoResearchTechs) { let tech = TechnologyTemplates.Get(key); - if ((tech.autoResearch && this.CanResearch(key)) - || (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom)))) + if ((tech.autoResearch && this.CanResearch(key)) || + (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom)))) { this.unresearchedAutoResearchTechs.delete(key); this.ResearchTechnology(key); @@ -50,7 +50,7 @@ }; // Checks an entity template to see if its technology requirements have been met -TechnologyManager.prototype.CanProduce = function (templateName) +TechnologyManager.prototype.CanProduce = function(templateName) { var cmpTempManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); var template = cmpTempManager.GetTemplate(templateName); Index: ps/trunk/binaries/data/mods/public/simulation/components/Trigger.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Trigger.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Trigger.js @@ -186,7 +186,7 @@ } let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); data.timer = cmpTimer.SetInterval(this.entity, IID_Trigger, "DoAction", - data.delay || 0, data.interval, { "action" : action }); + data.delay || 0, data.interval, { "action": action }); } else if (event == "OnRange") { @@ -223,7 +223,7 @@ for (let action in this[eventString]) if (this[eventString][action].enabled) - this.DoAction({ "action": action, "data":data }); + this.DoAction({ "action": action, "data": data }); }; Trigger.prototype.OnGlobalInitGame = function(msg) Index: ps/trunk/binaries/data/mods/public/simulation/components/TriggerPoint.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/TriggerPoint.js +++ ps/trunk/binaries/data/mods/public/simulation/components/TriggerPoint.js @@ -68,11 +68,11 @@ for (var entity of msg.added) collection.push(entity); - var r = {"currentCollection": collection.slice()}; + var r = { "currentCollection": collection.slice() }; r.added = msg.added; r.removed = msg.removed; var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); - cmpTrigger.DoAction({"action":this.actions[msg.tag], "data": r}); + cmpTrigger.DoAction({ "action": this.actions[msg.tag], "data": r }); }; Index: ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js +++ ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js @@ -2184,8 +2184,8 @@ // until the next Timer event "Attacked": function(msg) { - if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) - && this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture") + if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) && + this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture") this.RespondToTargetedEntities([msg.data.attacker]); }, }, @@ -3636,7 +3636,7 @@ { let index = this.GetCurrentState().indexOf("."); if (index != -1) - this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index)); + this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index)); this.Stop(false); } @@ -3690,7 +3690,7 @@ if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity) continue; if (i == 0) - this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg}); + this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg }); else this.orderQueue.splice(i, 1); Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); @@ -3827,7 +3827,7 @@ }; -//// FSM linkage functions //// +// FSM linkage functions // Setting the next state to the current state will leave/re-enter the top-most substate. // Must be called from inside the FSM. @@ -3877,9 +3877,10 @@ if (this.orderQueue.length && (this.isGarrisoned || this.IsFormationController() || cmpPosition && cmpPosition.IsInWorld())) { - let ret = this.UnitFsm.ProcessMessage(this, - { "type": "Order."+this.order.type, "data": this.order.data } - ); + let ret = this.UnitFsm.ProcessMessage(this, { + "type": "Order."+this.order.type, + "data": this.order.data + }); Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); @@ -3925,9 +3926,10 @@ if (this.orderQueue.length == 1) { this.order = order; - this.UnitFsm.ProcessMessage(this, - { "type": "Order."+this.order.type, "data": this.order.data } - ); + this.UnitFsm.ProcessMessage(this, { + "type": "Order."+this.order.type, + "data": this.order.data + }); } Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); @@ -3950,9 +3952,10 @@ { this.orderQueue.unshift(order); this.order = order; - this.UnitFsm.ProcessMessage(this, - { "type": "Order."+this.order.type, "data": this.order.data } - ); + this.UnitFsm.ProcessMessage(this, { + "type": "Order."+this.order.type, + "data": this.order.data + }); } Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); @@ -3975,7 +3978,7 @@ continue; if (this.orderQueue[i].type == type) continue; - this.orderQueue.splice(i, 0, {"type": type, "data": data}); + this.orderQueue.splice(i, 0, { "type": type, "data": data }); Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); return; } @@ -4203,7 +4206,7 @@ if (data.timerRepeat === undefined) this.timer = undefined; - this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness}); + this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness }); }; /** @@ -4291,12 +4294,12 @@ if (msg.fromStatusEffect) return; - this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg}); + this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg }); }; UnitAI.prototype.OnGuardedAttacked = function(msg) { - this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data}); + this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data }); }; UnitAI.prototype.OnRangeUpdate = function(msg) @@ -4311,7 +4314,7 @@ UnitAI.prototype.OnPackFinished = function(msg) { - this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed}); + this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed }); }; /** @@ -4324,7 +4327,7 @@ this.UnitFsm.ProcessMessage(this, { "type": type, "data": msg }); }; -//// Helper functions to be called by the FSM //// +// Helper functions to be called by the FSM UnitAI.prototype.GetWalkSpeed = function() { @@ -5063,9 +5066,9 @@ UnitAI.prototype.AttackEntityInZone = function(ents) { var target = ents.find(target => - this.CanAttack(target) - && this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) - && (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target)) + this.CanAttack(target) && + this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) && + (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target)) ); if (!target) return false; @@ -5155,7 +5158,7 @@ let cmpAttack = Engine.QueryInterface(target, IID_Attack); if (cmpUnitAI && cmpAttack && cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type))) - return false; + return false; } if (this.GetStance().respondHoldGround) @@ -5185,7 +5188,7 @@ // If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker if (this.isGuardOf) { - let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); + let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI); let cmpAttack = Engine.QueryInterface(target, IID_Attack); if (cmpUnitAI && cmpAttack && cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type))) @@ -5195,7 +5198,7 @@ return force; }; -//// External interface functions //// +// External interface functions /** * Order a unit to leave the formation it is in. @@ -5368,8 +5371,7 @@ { if (this.isGuardOf == target && this.order && this.order.type == "Guard") return; - else - this.RemoveGuard(); + this.RemoveGuard(); } this.AddOrder("Guard", { "target": target, "force": false }, queued, pushFront); @@ -6063,11 +6065,11 @@ { var cmpIdentity = Engine.QueryInterface(targ, IID_Identity); var targetClasses = this.order.data.targetClasses; - if (targetClasses.attack && cmpIdentity - && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) + if (targetClasses.attack && cmpIdentity && + !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) continue; - if (targetClasses.avoid && cmpIdentity - && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) + if (targetClasses.avoid && cmpIdentity && + MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) continue; // Only used by the AIs to prevent some choices of targets if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ]) @@ -6089,11 +6091,11 @@ { var cmpIdentity = Engine.QueryInterface(targ, IID_Identity); var targetClasses = this.order.data.targetClasses; - if (cmpIdentity && targetClasses.attack - && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) + if (cmpIdentity && targetClasses.attack && + !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack)) continue; - if (cmpIdentity && targetClasses.avoid - && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) + if (cmpIdentity && targetClasses.avoid && + MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid)) continue; // Only used by the AIs to prevent some choices of targets if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ]) @@ -6250,7 +6252,7 @@ UnitAI.prototype.SetHeldPosition = function(x, z) { - this.heldPosition = {"x": x, "z": z}; + this.heldPosition = { "x": x, "z": z }; }; UnitAI.prototype.SetHeldPositionOnEntity = function(entity) @@ -6277,7 +6279,7 @@ return false; }; -//// Helper functions //// +// Helper functions /** * General getter for ranges. @@ -6296,7 +6298,7 @@ return undefined; return component.GetRange(type); -} +}; UnitAI.prototype.CanAttack = function(target) { @@ -6461,13 +6463,13 @@ return cmpPack && cmpPack.IsPacking(); }; -//// Formation specific functions //// +// Formation specific functions UnitAI.prototype.IsAttackingAsFormation = function() { var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); - return cmpAttack && cmpAttack.CanAttackAsFormation() - && this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING"; + return cmpAttack && cmpAttack.CanAttackAsFormation() && + this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING"; }; UnitAI.prototype.MoveRandomly = function(distance) @@ -6519,7 +6521,7 @@ { let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); return cmpUnitMotion && cmpUnitMotion.GetFacePointAfterMove(); -} +}; UnitAI.prototype.AttackEntitiesByPreference = function(ents) { Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Auras.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Auras.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Auras.js @@ -91,8 +91,8 @@ }); let cmpModifiersManager = ConstructComponent(SYSTEM_ENTITY, "ModifiersManager", {}); - cmpModifiersManager.OnGlobalPlayerEntityChanged({ player: playerID[1], from: -1, to: playerEnt[1] }); - cmpModifiersManager.OnGlobalPlayerEntityChanged({ player: playerID[2], from: -1, to: playerEnt[2] }); + cmpModifiersManager.OnGlobalPlayerEntityChanged({ "player": playerID[1], "from": -1, "to": playerEnt[1] }); + cmpModifiersManager.OnGlobalPlayerEntityChanged({ "player": playerID[2], "from": -1, "to": playerEnt[2] }); let cmpAuras = ConstructComponent(sourceEnt, "Auras", { "_string": name }); test_function(name, cmpAuras); } Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Capturable.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Capturable.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Capturable.js @@ -97,7 +97,7 @@ // Tests if the message is sent when capture points change testCapturable(testData, cmpCapturable => { - cmpCapturable.SetCapturePoints([0, 2000, 0 , 1000]); + cmpCapturable.SetCapturePoints([0, 2000, 0, 1000]); TS_ASSERT_UNEVAL_EQUALS(cmpCapturable.GetCapturePoints(), [0, 2000, 0, 1000]); Engine.PostMessage = function(ent, iid, message) { Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Heal.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Heal.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Heal.js @@ -10,7 +10,7 @@ const entity = 60; const player = 1; -const otherPlayer = 2 +const otherPlayer = 2; let template = { "Range": 20, Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Math.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Math.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Math.js @@ -2,7 +2,7 @@ * Tests for consistent and correct math results */ - // +0 is different than -0, but standard equality won't test that +// +0 is different than -0, but standard equality won't test that function isNegativeZero(z) { return z === 0 && 1/z === -Infinity; } function isPositiveZero(z) { return z === 0 && 1/z === Infinity; } @@ -126,7 +126,7 @@ TS_ASSERT(isPositiveZero(Math.square(0))); TS_ASSERT(isPositiveZero(Math.square(-0))); TS_ASSERT_EQUALS(Math.square(Infinity), Infinity); -TS_ASSERT_EQUALS(Math.square(1.772979291871526e-81),3.143455569405258e-162); +TS_ASSERT_EQUALS(Math.square(1.772979291871526e-81), 3.143455569405258e-162); TS_ASSERT_EQUALS(Math.square(1e+155), Infinity); TS_ASSERT_UNEVAL_EQUALS(Math.square(1), 1); TS_ASSERT_UNEVAL_EQUALS(Math.square(20), 400); Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Population.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Population.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Population.js @@ -76,7 +76,7 @@ cmpPlayer = AddMock(player, IID_Player, { "AddPopulationBonuses": bonus => TS_ASSERT_EQUALS(bonus, -3) }); -difference = 0 +difference = 0; Engine.RegisterGlobal("ApplyValueModificationsToEntity", (valueName, currentValue, entity) => currentValue + difference ); Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_TechnologyManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_TechnologyManager.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_TechnologyManager.js @@ -9,10 +9,10 @@ // Test CheckTechnologyRequirements let template = { "requirements": { "all": [{ "entity": { "class": "Village", "number": 5 } }, { "civ": "athen" }] } }; -cmpTechnologyManager.classCounts["Village"] = 2; +cmpTechnologyManager.classCounts.Village = 2; TS_ASSERT_EQUALS(cmpTechnologyManager.CheckTechnologyRequirements(DeriveTechnologyRequirements(template, "athen")), false); TS_ASSERT_EQUALS(cmpTechnologyManager.CheckTechnologyRequirements(DeriveTechnologyRequirements(template, "athen"), true), true); TS_ASSERT_EQUALS(cmpTechnologyManager.CheckTechnologyRequirements(DeriveTechnologyRequirements(template, "maur"), true), false); -cmpTechnologyManager.classCounts["Village"] = 6; +cmpTechnologyManager.classCounts.Village = 6; TS_ASSERT_EQUALS(cmpTechnologyManager.CheckTechnologyRequirements(DeriveTechnologyRequirements(template, "athen")), true); TS_ASSERT_EQUALS(cmpTechnologyManager.CheckTechnologyRequirements(DeriveTechnologyRequirements(template, "maur")), false); Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js @@ -8,14 +8,14 @@ var fired = []; AddMock(10, IID_Test, { - Callback: function(data, lateness) { + "Callback": function(data, lateness) { fired.push([data, lateness]); } }); var cancelId; AddMock(20, IID_Test, { - Callback: function(data, lateness) { + "Callback": function(data, lateness) { fired.push([data, lateness]); cmpTimer.CancelTimer(cancelId); } @@ -34,13 +34,13 @@ TS_ASSERT_UNEVAL_EQUALS(fired, []); cmpTimer.OnUpdate({ "turnLength": 0.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0]]); cmpTimer.OnUpdate({ "turnLength": 0.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0], ["b", 300]]); cmpTimer.OnUpdate({ "turnLength": 0.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0], ["b", 300]]); fired = []; @@ -49,35 +49,35 @@ var e = cmpTimer.SetTimeout(10, IID_Test, "Callback", 1000, "e"); cmpTimer.CancelTimer(d); cmpTimer.OnUpdate({ "turnLength": 1.0 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["c",0], ["e",0]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["c", 0], ["e", 0]]); fired = []; var r = cmpTimer.SetInterval(10, IID_Test, "Callback", 500, 1000, "r"); cmpTimer.OnUpdate({ "turnLength": 0.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0]]); cmpTimer.OnUpdate({ "turnLength": 0.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0]]); cmpTimer.OnUpdate({ "turnLength": 0.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r", 0]]); cmpTimer.OnUpdate({ "turnLength": 3.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r", 0], ["r", 2500], ["r", 1500], ["r", 500]]); cmpTimer.CancelTimer(r); cmpTimer.OnUpdate({ "turnLength": 3.5 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r", 0], ["r", 2500], ["r", 1500], ["r", 500]]); fired = []; cancelId = cmpTimer.SetInterval(20, IID_Test, "Callback", 500, 1000, "s"); cmpTimer.OnUpdate({ "turnLength": 3.0 }); -TS_ASSERT_UNEVAL_EQUALS(fired, [["s",2500]]); +TS_ASSERT_UNEVAL_EQUALS(fired, [["s", 2500]]); fired = []; let f = cmpTimer.SetInterval(10, IID_Test, "Callback", 1000, 1000, "f"); Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitAI.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitAI.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitAI.js @@ -118,33 +118,33 @@ AddMock(SYSTEM_ENTITY, IID_Timer, { - SetInterval: function() { }, - SetTimeout: function() { }, + "SetInterval": function() { }, + "SetTimeout": function() { }, }); AddMock(SYSTEM_ENTITY, IID_RangeManager, { - CreateActiveQuery: function(ent, minRange, maxRange, players, iid, flags, accountForSize) { + "CreateActiveQuery": function(ent, minRange, maxRange, players, iid, flags, accountForSize) { return 1; }, - EnableActiveQuery: function(id) { }, - ResetActiveQuery: function(id) { if (mode == 0) return []; else return [enemy]; }, - DisableActiveQuery: function(id) { }, - GetEntityFlagMask: function(identifier) { }, + "EnableActiveQuery": function(id) { }, + "ResetActiveQuery": function(id) { if (mode == 0) return []; return [enemy]; }, + "DisableActiveQuery": function(id) { }, + "GetEntityFlagMask": function(identifier) { }, }); AddMock(SYSTEM_ENTITY, IID_TemplateManager, { - GetCurrentTemplateName: function(ent) { return "special/formations/line_closed"; }, + "GetCurrentTemplateName": function(ent) { return "special/formations/line_closed"; }, }); AddMock(SYSTEM_ENTITY, IID_PlayerManager, { - GetPlayerByID: function(id) { return playerEntity; }, - GetNumPlayers: function() { return 2; }, + "GetPlayerByID": function(id) { return playerEntity; }, + "GetNumPlayers": function() { return 2; }, }); AddMock(playerEntity, IID_Player, { - IsAlly: function() { return false; }, - IsEnemy: function() { return true; }, - GetEnemies: function() { return [2]; }, + "IsAlly": function() { return false; }, + "IsEnemy": function() { return true; }, + "GetEnemies": function() { return [2]; }, }); AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { @@ -155,19 +155,19 @@ var unitAI = ConstructComponent(unit, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); AddMock(unit, IID_Identity, { - GetClassesList: function() { return []; }, + "GetClassesList": function() { return []; }, }); AddMock(unit, IID_Ownership, { - GetOwner: function() { return 1; }, + "GetOwner": function() { return 1; }, }); AddMock(unit, IID_Position, { - GetTurretParent: function() { return INVALID_ENTITY; }, - GetPosition: function() { return new Vector3D(); }, - GetPosition2D: function() { return new Vector2D(); }, - GetRotation: function() { return { "y": 0 }; }, - IsInWorld: function() { return true; }, + "GetTurretParent": function() { return INVALID_ENTITY; }, + "GetPosition": function() { return new Vector3D(); }, + "GetPosition2D": function() { return new Vector2D(); }, + "GetRotation": function() { return { "y": 0 }; }, + "IsInWorld": function() { return true; }, }); AddMock(unit, IID_UnitMotion, { @@ -181,17 +181,17 @@ }); AddMock(unit, IID_Vision, { - GetRange: function() { return 10; }, + "GetRange": function() { return 10; }, }); AddMock(unit, IID_Attack, { - GetRange: function() { return { "max": 10, "min": 0}; }, - GetFullAttackRange: function() { return { "max": 40, "min": 0}; }, - GetBestAttackAgainst: function(t) { return "melee"; }, - GetPreference: function(t) { return 0; }, - GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, - CanAttack: function(v) { return true; }, - CompareEntitiesByPreference: function(a, b) { return 0; }, + "GetRange": function() { return { "max": 10, "min": 0 }; }, + "GetFullAttackRange": function() { return { "max": 40, "min": 0 }; }, + "GetBestAttackAgainst": function(t) { return "melee"; }, + "GetPreference": function(t) { return 0; }, + "GetTimers": function() { return { "prepare": 500, "repeat": 1000 }; }, + "CanAttack": function(v) { return true; }, + "CompareEntitiesByPreference": function(a, b) { return 0; }, }); unitAI.OnCreate(); @@ -202,7 +202,7 @@ if (mode == 1) { AddMock(enemy, IID_Health, { - GetHitpoints: function() { return 10; }, + "GetHitpoints": function() { return 10; }, }); AddMock(enemy, IID_UnitAI, { "IsAnimal": () => "false", @@ -211,7 +211,7 @@ } else if (mode == 2) AddMock(enemy, IID_Health, { - GetHitpoints: function() { return 0; }, + "GetHitpoints": function() { return 0; }, }); let controllerFormation = ConstructComponent(controller, "Formation", { @@ -231,13 +231,13 @@ }); AddMock(controller, IID_Position, { - JumpTo: function(x, z) { this.x = x; this.z = z; }, - GetTurretParent: function() { return INVALID_ENTITY; }, - GetPosition: function() { return new Vector3D(this.x, 0, this.z); }, - GetPosition2D: function() { return new Vector2D(this.x, this.z); }, - GetRotation: function() { return { "y": 0 }; }, - IsInWorld: function() { return true; }, - MoveOutOfWorld: () => {} + "JumpTo": function(x, z) { this.x = x; this.z = z; }, + "GetTurretParent": function() { return INVALID_ENTITY; }, + "GetPosition": function() { return new Vector3D(this.x, 0, this.z); }, + "GetPosition2D": function() { return new Vector2D(this.x, this.z); }, + "GetRotation": function() { return { "y": 0 }; }, + "IsInWorld": function() { return true; }, + "MoveOutOfWorld": () => {} }); AddMock(controller, IID_UnitMotion, { @@ -289,28 +289,28 @@ var unitAIs = []; AddMock(SYSTEM_ENTITY, IID_Timer, { - SetInterval: function() { }, - SetTimeout: function() { }, + "SetInterval": function() { }, + "SetTimeout": function() { }, }); AddMock(SYSTEM_ENTITY, IID_RangeManager, { - CreateActiveQuery: function(ent, minRange, maxRange, players, iid, flags, accountForSize) { + "CreateActiveQuery": function(ent, minRange, maxRange, players, iid, flags, accountForSize) { return 1; }, - EnableActiveQuery: function(id) { }, - ResetActiveQuery: function(id) { return [enemy]; }, - DisableActiveQuery: function(id) { }, - GetEntityFlagMask: function(identifier) { }, + "EnableActiveQuery": function(id) { }, + "ResetActiveQuery": function(id) { return [enemy]; }, + "DisableActiveQuery": function(id) { }, + "GetEntityFlagMask": function(identifier) { }, }); AddMock(SYSTEM_ENTITY, IID_TemplateManager, { - GetCurrentTemplateName: function(ent) { return "special/formations/line_closed"; }, + "GetCurrentTemplateName": function(ent) { return "special/formations/line_closed"; }, }); AddMock(SYSTEM_ENTITY, IID_PlayerManager, { - GetPlayerByID: function(id) { return playerEntity; }, - GetNumPlayers: function() { return 2; }, + "GetPlayerByID": function(id) { return playerEntity; }, + "GetNumPlayers": function() { return 2; }, }); AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { @@ -318,32 +318,33 @@ }); AddMock(playerEntity, IID_Player, { - IsAlly: function() { return false; }, - IsEnemy: function() { return true; }, - GetEnemies: function() { return [2]; }, + "IsAlly": function() { return false; }, + "IsEnemy": function() { return true; }, + "GetEnemies": function() { return [2]; }, }); // create units - for (var i = 0; i < unitCount; i++) { + for (var i = 0; i < unitCount; i++) + { units.push(unit + i); var unitAI = ConstructComponent(unit + i, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); AddMock(unit + i, IID_Identity, { - GetClassesList: function() { return []; }, + "GetClassesList": function() { return []; }, }); AddMock(unit + i, IID_Ownership, { - GetOwner: function() { return 1; }, + "GetOwner": function() { return 1; }, }); AddMock(unit + i, IID_Position, { - GetTurretParent: function() { return INVALID_ENTITY; }, - GetPosition: function() { return new Vector3D(); }, - GetPosition2D: function() { return new Vector2D(); }, - GetRotation: function() { return { "y": 0 }; }, - IsInWorld: function() { return true; }, + "GetTurretParent": function() { return INVALID_ENTITY; }, + "GetPosition": function() { return new Vector3D(); }, + "GetPosition2D": function() { return new Vector2D(); }, + "GetRotation": function() { return { "y": 0 }; }, + "IsInWorld": function() { return true; }, }); AddMock(unit + i, IID_UnitMotion, { @@ -357,16 +358,16 @@ }); AddMock(unit + i, IID_Vision, { - GetRange: function() { return 10; }, + "GetRange": function() { return 10; }, }); AddMock(unit + i, IID_Attack, { - GetRange: function() { return {"max":10, "min": 0}; }, - GetFullAttackRange: function() { return { "max": 40, "min": 0}; }, - GetBestAttackAgainst: function(t) { return "melee"; }, - GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, - CanAttack: function(v) { return true; }, - CompareEntitiesByPreference: function(a, b) { return 0; }, + "GetRange": function() { return { "max": 10, "min": 0 }; }, + "GetFullAttackRange": function() { return { "max": 40, "min": 0 }; }, + "GetBestAttackAgainst": function(t) { return "melee"; }, + "GetTimers": function() { return { "prepare": 500, "repeat": 1000 }; }, + "CanAttack": function(v) { return true; }, + "CompareEntitiesByPreference": function(a, b) { return 0; }, }); unitAI.OnCreate(); @@ -378,7 +379,7 @@ // create enemy AddMock(enemy, IID_Health, { - GetHitpoints: function() { return 40; }, + "GetHitpoints": function() { return 40; }, }); let controllerFormation = ConstructComponent(controller, "Formation", { @@ -418,8 +419,8 @@ }); AddMock(controller, IID_Attack, { - GetRange: function() { return {"max":10, "min": 0}; }, - CanAttackAsFormation: function() { return false; }, + "GetRange": function() { return { "max": 10, "min": 0 }; }, + "CanAttackAsFormation": function() { return false; }, }); controllerAI.OnCreate(); @@ -431,7 +432,7 @@ for (let ent of unitAIs) TS_ASSERT_EQUALS(unitAI.fsmStateName, "INDIVIDUAL.COMBAT.ATTACKING"); - controllerAI.MoveIntoFormation({"name": "Circle"}); + controllerAI.MoveIntoFormation({ "name": "Circle" }); // let all units be in position for (let ent of unitAIs) Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitMotionFlying.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitMotionFlying.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UnitMotionFlying.js @@ -8,7 +8,7 @@ let height = 5; AddMock(SYSTEM_ENTITY, IID_Pathfinder, { - GetPassabilityClass: (name) => 1 << 8 + "GetPassabilityClass": (name) => 1 << 8 }); let cmpUnitMotionFlying = ConstructComponent(entity, "UnitMotionFlying", { Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js @@ -15,10 +15,13 @@ }; AddMock(SYSTEM_ENTITY, IID_TemplateManager, { - "GetTemplate": (name) => name == "special/spy" ? - ({ "Cost": { "Resources": { "wood": 1000 } }, - "VisionSharing": { "Duration": 15 } }) - : ({}) + "GetTemplate": (name) => { + return name == "special/spy" ? + { + "Cost": { "Resources": { "wood": 1000 } }, + "VisionSharing": { "Duration": 15 } } : + {}; + } }); AddMock(ent, IID_GarrisonHolder, { @@ -62,7 +65,7 @@ }); Engine.PostMessage = function(id, iid, message) { -TS_ASSERT(false); // One doesn't send message + TS_ASSERT(false); // One doesn't send message }; cmpVisionSharing.CheckVisionSharings(); TS_ASSERT_UNEVAL_EQUALS(cmpVisionSharing.shared, new Set([1]));