diff --git a/binaries/data/mods/public/simulation/components/tests/test_Attack.js b/binaries/data/mods/public/simulation/components/tests/test_Attack.js index 7c1111d4e3..4c9e8267e6 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Attack.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Attack.js @@ -38,7 +38,7 @@ let entityID = 903; function attackComponentTest(defenderClass, isEnemy, test_function) { - let playerEnt1 = 5; + const playerEnt1 = 5; AddMock(SYSTEM_ENTITY, IID_PlayerManager, { "GetPlayerByID": () => playerEnt1 @@ -52,7 +52,7 @@ function attackComponentTest(defenderClass, isEnemy, test_function) "IsEnemy": () => isEnemy }); - let attacker = entityID; + const attacker = entityID; AddMock(attacker, IID_Position, { "IsInWorld": () => true, @@ -64,7 +64,7 @@ function attackComponentTest(defenderClass, isEnemy, test_function) "GetOwner": () => 1 }); - let cmpAttack = ConstructComponent(attacker, "Attack", { + const cmpAttack = ConstructComponent(attacker, "Attack", { "Melee": { "Damage": { "Hack": 11, @@ -157,7 +157,7 @@ function attackComponentTest(defenderClass, isEnemy, test_function) } }); - let defender = ++entityID; + const defender = ++entityID; AddMock(defender, IID_Identity, { "GetClassesList": () => [defenderClass], @@ -281,14 +281,14 @@ attackComponentTest(undefined, true, (attacker, cmpAttack, defender) => { }); }); -for (let className of ["Infantry", "Cavalry"]) +for (const className of ["Infantry", "Cavalry"]) attackComponentTest(className, true, (attacker, cmpAttack, defender) => { TS_ASSERT_EQUALS(cmpAttack.GetAttackEffectsData("Melee").Bonuses.BonusCav.Multiplier, 2); TS_ASSERT_EQUALS(cmpAttack.GetAttackEffectsData("Capture").Bonuses || null, null); - let getAttackBonus = (s, t, e, splash) => AttackHelper.GetAttackBonus(s, e, t, cmpAttack.GetAttackEffectsData(t, splash).Bonuses || null); + const getAttackBonus = (s, t, e, splash) => AttackHelper.GetAttackBonus(s, e, t, cmpAttack.GetAttackEffectsData(t, splash).Bonuses || null); TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Melee", defender), className == "Cavalry" ? 2 : 1); TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Ranged", defender), 1); TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Ranged", defender, true), className == "Cavalry" ? 3 : 1); @@ -323,11 +323,11 @@ function testGetBestAttackAgainst(defenderClass, bestAttack, bestAllyAttack, isB TS_ASSERT_EQUALS(cmpAttack.CanAttack(defender, ["!Ranged", "!Melee"]), isBuilding || defenderClass == "Domestic"); TS_ASSERT_EQUALS(cmpAttack.CanAttack(defender, ["Melee", "!Melee"]), false); - let allowCapturing = [true]; + const allowCapturing = [true]; if (!isBuilding) allowCapturing.push(false); - for (let ac of allowCapturing) + for (const ac of allowCapturing) TS_ASSERT_EQUALS(cmpAttack.GetBestAttackAgainst(defender, ac), bestAttack); }); @@ -351,11 +351,11 @@ function testGetBestAttackAgainst(defenderClass, bestAttack, bestAllyAttack, isB TS_ASSERT_EQUALS(cmpAttack.CanAttack(defender, ["!Ranged", "!Melee"]), isBuilding || defenderClass == "Domestic"); TS_ASSERT_EQUALS(cmpAttack.CanAttack(defender, ["Melee", "!Melee"]), false); - let allowCapturing = [true]; + const allowCapturing = [true]; if (!isBuilding) allowCapturing.push(false); - for (let ac of allowCapturing) + for (const ac of allowCapturing) TS_ASSERT_EQUALS(cmpAttack.GetBestAttackAgainst(defender, ac), bestAllyAttack); }); } @@ -371,7 +371,7 @@ function testAttackPreference() { const attacker = 5; - let cmpAttack = ConstructComponent(attacker, "Attack", { + const cmpAttack = ConstructComponent(attacker, "Attack", { "Melee": { "Damage": { "Crush": 0 diff --git a/binaries/data/mods/public/simulation/components/tests/test_Auras.js b/binaries/data/mods/public/simulation/components/tests/test_Auras.js index f341ddb508..21ce9a7157 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Auras.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Auras.js @@ -18,7 +18,7 @@ var template = { "Identity": { "Classes": { "_string": "CorrectClass OtherClass" global.AuraTemplates = { "Get": name => { - let template = { + const template = { "type": name, "affectedPlayers": ["Ally"], "affects": ["CorrectClass"], @@ -96,10 +96,10 @@ function testAuras(name, test_function) "GetOwner": () => playerID[1] }); - let cmpModifiersManager = ConstructComponent(SYSTEM_ENTITY, "ModifiersManager", {}); + const 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] }); - let cmpAuras = ConstructComponent(sourceEnt, "Auras", { "_string": name }); + const cmpAuras = ConstructComponent(sourceEnt, "Auras", { "_string": name }); test_function(name, cmpAuras); } diff --git a/binaries/data/mods/public/simulation/components/tests/test_Barter.js b/binaries/data/mods/public/simulation/components/tests/test_Barter.js index dc47dbcdae..6c64eae582 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Barter.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Barter.js @@ -24,7 +24,7 @@ AddMock(SYSTEM_ENTITY, IID_PlayerManager, { let timerActivated = false; let bought = 0; let sold = 0; -let multiplier = { +const multiplier = { "buy": { "wood": 1.0, "stone": 1.0, @@ -36,7 +36,7 @@ let multiplier = { "metal": 1.0 } }; -let cmpBarter = ConstructComponent(SYSTEM_ENTITY, "Barter"); +const cmpBarter = ConstructComponent(SYSTEM_ENTITY, "Barter"); AddMock(SYSTEM_ENTITY, IID_Timer, { "CancelTimer": id => { timerActivated = false; }, @@ -52,7 +52,7 @@ AddMock(SYSTEM_ENTITY, IID_Timer, { TS_ASSERT_EQUALS(cmpBarter.restoreTimer, undefined); TS_ASSERT_UNEVAL_EQUALS(cmpBarter.priceDifferences, { "wood": 0, "stone": 0, "metal": 0 }); -let cmpPlayer = AddMock(playerEnt, IID_Player, { +const cmpPlayer = AddMock(playerEnt, IID_Player, { "TrySubtractResources": amounts => { sold = amounts[Object.keys(amounts)[0]]; return true; diff --git a/binaries/data/mods/public/simulation/components/tests/test_Builder.js b/binaries/data/mods/public/simulation/components/tests/test_Builder.js index b6d77f0f54..cf0562359b 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Builder.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Builder.js @@ -29,7 +29,7 @@ Engine.RegisterGlobal("ApplyValueModificationsToEntity", (prop, oVal, ent) => oV function testEntitiesList() { - let cmpBuilder = ConstructComponent(builderId, "Builder", { + const cmpBuilder = ConstructComponent(builderId, "Builder", { "Rate": "1.0", "Entities": { "_string": "structures/{civ}/barracks structures/{civ}/civil_centre structures/{native}/house" } }); @@ -106,7 +106,7 @@ testEntitiesList(); function testBuildingFoundation() { - let cmpBuilder = ConstructComponent(builderId, "Builder", { + const cmpBuilder = ConstructComponent(builderId, "Builder", { "Rate": "1.0", "Entities": { "_string": "" } }); @@ -128,7 +128,7 @@ function testBuildingFoundation() "AddBuilder": () => {} }); - let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); + const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); TS_ASSERT(cmpBuilder.StartRepairing(target)); cmpTimer.OnUpdate({ "turnLength": 1 }); @@ -145,7 +145,7 @@ function testRepairing() "IsAlly": (p) => p == playerId }); - let cmpBuilder = ConstructComponent(builderId, "Builder", { + const cmpBuilder = ConstructComponent(builderId, "Builder", { "Rate": "1.0", "Entities": { "_string": "" } }); @@ -158,7 +158,7 @@ function testRepairing() "GetBuildTime": () => 100 }); - let cmpTargetHealth = ConstructComponent(target, "Health", { + const cmpTargetHealth = ConstructComponent(target, "Health", { "Max": 100, "RegenRate": 0, "IdleRegenRate": 0, @@ -169,11 +169,11 @@ function testRepairing() cmpTargetHealth.SetHitpoints(50); DeleteMock(target, IID_Foundation); - let cmpTargetRepairable = ConstructComponent(target, "Repairable", { + const cmpTargetRepairable = ConstructComponent(target, "Repairable", { "RepairTimeRatio": 1, }); - let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); + const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); TS_ASSERT(cmpTargetRepairable.IsRepairable()); TS_ASSERT(cmpBuilder.StartRepairing(target)); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Capturable.js b/binaries/data/mods/public/simulation/components/tests/test_Capturable.js index 105f800e59..b326b08025 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Capturable.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Capturable.js @@ -75,7 +75,7 @@ function testCapturable(testData, test_function) "CapturedBuilding": () => {} }); - let cmpCapturable = ConstructComponent(testData.structure, "Capturable", { + const cmpCapturable = ConstructComponent(testData.structure, "Capturable", { "CapturePoints": testData.maxCapturePoints, "RegenRate": testData.regenRate, "GarrisonRegenRate": testData.garrisonRegenRate diff --git a/binaries/data/mods/public/simulation/components/tests/test_Damage.js b/binaries/data/mods/public/simulation/components/tests/test_Damage.js index ebaa28043e..ff98d81631 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Damage.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Damage.js @@ -32,12 +32,12 @@ function Test_Generic() { ResetState(); - let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); + const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); cmpTimer.OnUpdate({ "turnLength": 1 }); - let attacker = 11; + const attacker = 11; let atkPlayerEntity = 1; - let attackerOwner = 6; - let cmpAttack = ConstructComponent(attacker, "Attack", + const attackerOwner = 6; + const cmpAttack = ConstructComponent(attacker, "Attack", { "Ranged": { "Damage": { @@ -55,17 +55,17 @@ function Test_Generic() } } }); - let damage = 5; - let target = 21; - let targetOwner = 7; - let targetPos = new Vector3D(3, 0, 3); + const damage = 5; + const target = 21; + const targetOwner = 7; + const targetPos = new Vector3D(3, 0, 3); let type = "Melee"; let damageTaken = false; cmpAttack.GetAttackStrengths = attackType => ({ "Hack": 0, "Pierce": 0, "Crush": damage }); - let data = { + const data = { "type": "Melee", "attackData": { "Damage": { "Hack": 0, "Pierce": 0, "Crush": damage }, @@ -181,7 +181,7 @@ function TestLinearSplashDamage() const origin = new Vector2D(0, 0); - let data = { + const data = { "type": "Ranged", "attackData": { "Damage": { "Hack": 100, "Pierce": 0, "Crush": 0 } }, "attacker": attacker, @@ -193,12 +193,12 @@ function TestLinearSplashDamage() "friendlyFire": false, }; - let fallOff = function(x, y) + const fallOff = function(x, y) { return (1 - x * x / (data.radius * data.radius)) * (1 - 25 * y * y / (data.radius * data.radius)); }; - let hitEnts = new Set(); + const hitEnts = new Set(); AddMock(attackerOwner, IID_Diplomacy, { "GetEnemies": () => [2] @@ -289,9 +289,9 @@ function TestCircularSplashDamage() Engine.PostMessage = (ent, iid, message) => {}; const radius = 10; - let attackerOwner = 1; + const attackerOwner = 1; - let fallOff = function(r) + const fallOff = function(r) { return 1 - r * r / (radius * radius); }; @@ -373,21 +373,21 @@ function TestCircularSplashDamage() } }); - let cmphealth64 = AddMock(64, IID_Health, { + const cmphealth64 = AddMock(64, IID_Health, { "TakeDamage": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, 0); return { "healthChange": -amount }; } }); - let spy64 = new Spy(cmphealth64, "TakeDamage"); + const spy64 = new Spy(cmphealth64, "TakeDamage"); - let cmpHealth65 = AddMock(65, IID_Health, { + const cmpHealth65 = AddMock(65, IID_Health, { "TakeDamage": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, 100 * fallOff(2)); return { "healthChange": -amount }; } }); - let spy65 = new Spy(cmpHealth65, "TakeDamage"); + const spy65 = new Spy(cmpHealth65, "TakeDamage"); AttackHelper.CauseDamageOverArea({ "type": "Ranged", @@ -411,12 +411,12 @@ function Test_MissileHit() ResetState(); Engine.PostMessage = (ent, iid, message) => {}; - let cmpDelayedDamage = ConstructComponent(SYSTEM_ENTITY, "DelayedDamage"); + const cmpDelayedDamage = ConstructComponent(SYSTEM_ENTITY, "DelayedDamage"); - let target = 60; - let targetOwner = 1; - let targetPos = new Vector3D(3, 10, 0); - let hitEnts = new Set(); + const target = 60; + const targetOwner = 1; + const targetPos = new Vector3D(3, 10, 0); + const hitEnts = new Set(); AddMock(SYSTEM_ENTITY, IID_Timer, { "GetLatestTurnLength": () => 500 @@ -424,7 +424,7 @@ function Test_MissileHit() const radius = 10; - let data = { + const data = { "type": "Ranged", "attackData": { "Damage": { "Hack": 0, "Pierce": 100, "Crush": 0 } }, "target": 60, @@ -608,8 +608,8 @@ function Test_MissileHit() "DistanceToPoint": (ent) => 0 }); - let bonus = { "BonusCav": { "Classes": "Cavalry", "Multiplier": 400 } }; - let splashBonus = { "BonusCav": { "Classes": "Cavalry", "Multiplier": 10000 } }; + const bonus = { "BonusCav": { "Classes": "Cavalry", "Multiplier": 400 } }; + const splashBonus = { "BonusCav": { "Classes": "Cavalry", "Multiplier": 10000 } }; AddMock(61, IID_Identity, { "GetClassesList": () => ["Cavalry"], diff --git a/binaries/data/mods/public/simulation/components/tests/test_DeathDamage.js b/binaries/data/mods/public/simulation/components/tests/test_DeathDamage.js index c9dc334053..eed3b867c7 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_DeathDamage.js +++ b/binaries/data/mods/public/simulation/components/tests/test_DeathDamage.js @@ -8,8 +8,8 @@ Engine.LoadComponentScript("interfaces/DeathDamage.js"); Engine.LoadComponentScript("interfaces/ModifiersManager.js"); Engine.LoadComponentScript("DeathDamage.js"); -let deadEnt = 60; -let player = 1; +const deadEnt = 60; +const player = 1; ApplyValueModificationsToEntity = function(value, stat, ent) { @@ -18,7 +18,7 @@ ApplyValueModificationsToEntity = function(value, stat, ent) return stat; }; -let template = { +const template = { "Shape": "Circular", "Range": 10.7, "FriendlyFire": "false", @@ -29,7 +29,7 @@ let template = { } }; -let effects = { +const effects = { "Damage": { "Hack": 0.0, "Pierce": 215.0, @@ -39,10 +39,10 @@ let effects = { let cmpDeathDamage = ConstructComponent(deadEnt, "DeathDamage", template); -let playersToDamage = [2, 3, 7]; -let pos = new Vector2D(3, 4.2); +const playersToDamage = [2, 3, 7]; +const pos = new Vector2D(3, 4.2); -let result = { +const result = { "type": "Death", "attackData": effects, "attacker": deadEnt, diff --git a/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js b/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js index 7dbbcf69fc..f6ac1419c6 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js +++ b/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js @@ -1,10 +1,10 @@ Engine.LoadComponentScript("interfaces/EndGameManager.js"); Engine.LoadComponentScript("EndGameManager.js"); -let cmpEndGameManager = ConstructComponent(SYSTEM_ENTITY, "EndGameManager"); +const cmpEndGameManager = ConstructComponent(SYSTEM_ENTITY, "EndGameManager"); -let playerEnt1 = 1; -let wonderDuration = 2 * 60 * 1000; +const playerEnt1 = 1; +const wonderDuration = 2 * 60 * 1000; AddMock(SYSTEM_ENTITY, IID_PlayerManager, { "GetNumPlayers": () => 4 diff --git a/binaries/data/mods/public/simulation/components/tests/test_EntityLimits.js b/binaries/data/mods/public/simulation/components/tests/test_EntityLimits.js index d2aac05774..52961b9396 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_EntityLimits.js +++ b/binaries/data/mods/public/simulation/components/tests/test_EntityLimits.js @@ -5,7 +5,7 @@ Engine.LoadComponentScript("interfaces/TrainingRestrictions.js"); Engine.LoadComponentScript("interfaces/Player.js"); Engine.LoadComponentScript("EntityLimits.js"); -let template ={ +const template ={ "Limits": { "Tower": 5, "Wonder": 1, @@ -28,7 +28,7 @@ AddMock(SYSTEM_ENTITY, IID_GuiInterface, { "PushNotification": () => {} }); -let cmpEntityLimits = ConstructComponent(10, "EntityLimits", template); +const cmpEntityLimits = ConstructComponent(10, "EntityLimits", template); // Test getters TS_ASSERT_UNEVAL_EQUALS(cmpEntityLimits.GetCounts(), { "Tower": 0, "Wonder": 0, "Hero": 0, "Champion": 0 }); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Foundation.js b/binaries/data/mods/public/simulation/components/tests/test_Foundation.js index 0299602cf5..58252ac6bb 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Foundation.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Foundation.js @@ -23,21 +23,21 @@ Engine.LoadComponentScript("AutoBuildable.js"); Engine.LoadComponentScript("Foundation.js"); Engine.LoadComponentScript("Timer.js"); -let player = 1; -let playerEnt = 3; -let foundationEnt = 20; -let previewEnt = 21; -let newEnt = 22; -let finalTemplate = "structures/athen/civil_centre.xml"; +const player = 1; +const playerEnt = 3; +const foundationEnt = 20; +const previewEnt = 21; +const newEnt = 22; +const finalTemplate = "structures/athen/civil_centre.xml"; function testFoundation(...mocks) { ResetState(); let foundationHP = 1; - let maxHP = 100; - let rot = new Vector3D(1, 2, 3); - let pos = new Vector2D(4, 5); + const maxHP = 100; + const rot = new Vector3D(1, 2, 3); + const pos = new Vector2D(4, 5); let cmpFoundation; AddMock(SYSTEM_ENTITY, IID_Trigger, { @@ -131,7 +131,7 @@ function testFoundation(...mocks) "SetHeightOffset": () => {} }); - for (let mock of mocks) + for (const mock of mocks) AddMock(...mock); // INITIALISE @@ -151,8 +151,8 @@ function testFoundation(...mocks) // BUILDER COUNT, BUILD RATE, TIME REMAINING AddMock(10, IID_Builder, { "GetRate": () => 1.0 }); AddMock(11, IID_Builder, { "GetRate": () => 1.0 }); - let twoBuilderMultiplier = Math.pow(2, cmpFoundation.buildTimeModifier) / 2; - let threeBuilderMultiplier = Math.pow(3, cmpFoundation.buildTimeModifier) / 3; + const twoBuilderMultiplier = Math.pow(2, cmpFoundation.buildTimeModifier) / 2; + const threeBuilderMultiplier = Math.pow(3, cmpFoundation.buildTimeModifier) / 3; TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(1), 1); TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(2), twoBuilderMultiplier); @@ -191,7 +191,7 @@ function testFoundation(...mocks) // COMMIT FOUNDATION TS_ASSERT_EQUALS(cmpFoundation.committed, false); - let work = 5; + const work = 5; cmpFoundation.Build(10, work); TS_ASSERT_EQUALS(cmpFoundation.committed, true); TS_ASSERT_EQUALS(foundationHP, 1 + work * cmpFoundation.GetBuildRate() * cmpFoundation.buildMultiplier); @@ -231,9 +231,9 @@ testFoundation([playerEnt, IID_StatisticsTracker, { // Test autobuild feature. const foundationEnt2 = 42; -let turnLength = 0.2; +const turnLength = 0.2; let currentFoundationHP = 1; -let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); +const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); AddMock(foundationEnt2, IID_Cost, { "GetBuildTime": () => 50, @@ -269,9 +269,9 @@ for (let i = 0; i < 10; ++i) TS_ASSERT_EQUALS(cmpAutoBuildingFoundation.GetNumBuilders(), 0); } - let currentPercentage = cmpAutoBuildingFoundation.GetBuildPercentage(); + const currentPercentage = cmpAutoBuildingFoundation.GetBuildPercentage(); cmpTimer.OnUpdate({ "turnLength": turnLength * 5 }); - let newPercentage = cmpAutoBuildingFoundation.GetBuildPercentage(); + const newPercentage = cmpAutoBuildingFoundation.GetBuildPercentage(); if (i >= 8) TS_ASSERT_EQUALS(currentPercentage, newPercentage); diff --git a/binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js b/binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js index a5062a6305..30a4136fea 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js +++ b/binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js @@ -100,7 +100,7 @@ AddMock(33, IID_Identity, { "GetSelectionGroupName": () => "spart_infantry_archer_a" }); -let testGarrisonAllowed = function() +const testGarrisonAllowed = function() { TS_ASSERT_EQUALS(cmpGarrisonHolder.HasEnoughHealth(), true); TS_ASSERT_EQUALS(cmpGarrisonHolder.Garrison(enemyUnitId), false); @@ -110,7 +110,7 @@ let testGarrisonAllowed = function() TS_ASSERT_EQUALS(cmpGarrisonHolder.Unload(largeUnitId), true); TS_ASSERT_EQUALS(cmpGarrisonHolder.Unload(unitToGarrisonId), true); TS_ASSERT_EQUALS(cmpGarrisonHolder.Garrison(unitToGarrisonId), true); - for (let entity of garrisonedEntitiesList) + for (const entity of garrisonedEntitiesList) TS_ASSERT_EQUALS(cmpGarrisonHolder.Garrison(entity), true); TS_ASSERT_EQUALS(cmpGarrisonHolder.Garrison(largeUnitId), false); TS_ASSERT_EQUALS(cmpGarrisonHolder.IsFull(), true); @@ -185,16 +185,16 @@ cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { testGarrisonAllowed(); // Test entity renaming. -let siegeEngineId = 44; +const siegeEngineId = 44; AddMock(siegeEngineId, IID_Identity, { "GetClassesList": () => ["Siege"] }); -let archerId = 45; +const archerId = 45; AddMock(archerId, IID_Identity, { "GetClassesList": () => ["Infantry", "Ranged"] }); -let originalClassList = "Infantry+Ranged Siege Cavalry"; +const originalClassList = "Infantry+Ranged Siege Cavalry"; cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { "Max": 10, @@ -206,7 +206,7 @@ cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { "Pickup": false }); -let traderId = 32; +const traderId = 32; AddMock(traderId, IID_Identity, { "GetClassesList": () => ["Trader"] }); @@ -219,7 +219,7 @@ AddMock(siegeEngineId, IID_Position, { "MoveOutOfWorld": () => {}, "SetHeightOffset": height => {} }); -let currentSiegePlayer = player; +const currentSiegePlayer = player; AddMock(siegeEngineId, IID_Ownership, { "GetOwner": () => currentSiegePlayer }); @@ -229,7 +229,7 @@ AddMock(siegeEngineId, IID_Garrisonable, { "Garrison": (entity, renamed) => cmpGarrisonHolder.Garrison(siegeEngineId, renamed), "UnGarrison": () => true }); -let cavalryId = 46; +const cavalryId = 46; AddMock(cavalryId, IID_Identity, { "GetClassesList": () => ["Infantry", "Ranged"] }); @@ -263,7 +263,7 @@ cmpGarrisonHolder.OnGlobalOwnershipChanged({ }); TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 0); -let oldApplyValueModificationsToEntity = ApplyValueModificationsToEntity; +const oldApplyValueModificationsToEntity = ApplyValueModificationsToEntity; TS_ASSERT(cmpGarrisonHolder.Garrison(siegeEngineId)); TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetEntities(), [siegeEngineId]); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Garrisonable.js b/binaries/data/mods/public/simulation/components/tests/test_Garrisonable.js index 26e91725ea..f2c09e5b14 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Garrisonable.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Garrisonable.js @@ -20,15 +20,15 @@ AddMock(garrisonHolderID, IID_Footprint, { "PickSpawnPoint": entity => new Vector3D(4, 3, 30) }); -let size = 1; -let cmpGarrisonable = ConstructComponent(garrisonableID, "Garrisonable", { +const size = 1; +const cmpGarrisonable = ConstructComponent(garrisonableID, "Garrisonable", { "Size": size }); TS_ASSERT_EQUALS(cmpGarrisonable.UnitSize(), size); TS_ASSERT_EQUALS(cmpGarrisonable.TotalSize(), size); -let extraSize = 2; +const extraSize = 2; AddMock(garrisonableID, IID_GarrisonHolder, { "OccupiedSlots": () => extraSize }); @@ -49,7 +49,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonable.HolderID(), INVALID_ENTITY); // Test renaming. const newGarrisonableID = 3; -let cmpGarrisonableNew = ConstructComponent(newGarrisonableID, "Garrisonable", { +const cmpGarrisonableNew = ConstructComponent(newGarrisonableID, "Garrisonable", { "Size": 1 }); TS_ASSERT(cmpGarrisonable.Garrison(garrisonHolderID)); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Garrisoning.js b/binaries/data/mods/public/simulation/components/tests/test_Garrisoning.js index c4346b3964..1c2dbfba8a 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Garrisoning.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Garrisoning.js @@ -17,7 +17,7 @@ const friendlyPlayer = 3; const garrison = 10; const holder = 11; -let createGarrisonCmp = entity => { +const createGarrisonCmp = entity => { AddMock(entity, IID_Identity, { "GetClassesList": () => ["Ranged"], "GetSelectionGroupName": () => "mace_infantry_archer_a" @@ -88,11 +88,11 @@ AddMock(garrison, IID_Position, { "SetYRotation": angle => {} }); -let cmpGarrisonable = ConstructComponent(garrison, "Garrisonable", { +const cmpGarrisonable = ConstructComponent(garrison, "Garrisonable", { "Size": "1" }); -let cmpGarrisonHolder = ConstructComponent(holder, "GarrisonHolder", { +const cmpGarrisonHolder = ConstructComponent(holder, "GarrisonHolder", { "Max": "10", "List": { "_string": "Ranged" }, "EjectHealth": "0.1", @@ -122,8 +122,8 @@ TS_ASSERT(cmpGarrisonHolder.Unload(garrison)); TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 0); // Test initGarrison. -let entities = [21, 22, 23, 24]; -for (let entity of entities) +const entities = [21, 22, 23, 24]; +for (const entity of entities) createGarrisonCmp(entity); cmpGarrisonHolder.SetInitGarrison(entities); cmpGarrisonHolder.OnGlobalInitGame(); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Gate.js b/binaries/data/mods/public/simulation/components/tests/test_Gate.js index a3d3064fc4..8caf0e721e 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Gate.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Gate.js @@ -14,22 +14,22 @@ function testBasicBehaviour() })); Engine.RegisterGlobal("PlaySound", () => {}); - let cmpRangeMgr = AddMock(SYSTEM_ENTITY, IID_RangeManager, { + const cmpRangeMgr = AddMock(SYSTEM_ENTITY, IID_RangeManager, { "GetEntityFlagMask": () => {}, "CreateActiveQuery": () => {}, "EnableActiveQuery": () => {}, }); - let querySpy = new Spy(cmpRangeMgr, "CreateActiveQuery"); + const querySpy = new Spy(cmpRangeMgr, "CreateActiveQuery"); - let ownUnitAI = AddMock(own, IID_UnitAI, { + const ownUnitAI = AddMock(own, IID_UnitAI, { "AbleToMove": () => true }); - let cmpGate = ConstructComponent(gate, "Gate", { + const cmpGate = ConstructComponent(gate, "Gate", { "PassRange": passRange }); - let setupSpy = new Spy(cmpGate, "SetupRangeQuery"); - let cmpGateObst = AddMock(gate, IID_Obstruction, { + const setupSpy = new Spy(cmpGate, "SetupRangeQuery"); + const cmpGateObst = AddMock(gate, IID_Obstruction, { "SetDisableBlockMovementPathfinding": () => {}, "GetEntitiesBlockingConstruction": () => [], "GetBlockMovementFlag": () => false, @@ -85,7 +85,7 @@ function testBasicBehaviour() function testShouldOpen() { - let cmpGate = ConstructComponent(5, "Gate", {}); + const cmpGate = ConstructComponent(5, "Gate", {}); cmpGate.allies = [1, 2, 3, 4]; cmpGate.ignoreList = []; TS_ASSERT_EQUALS(cmpGate.ShouldOpen(), true); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Heal.js b/binaries/data/mods/public/simulation/components/tests/test_Heal.js index e0cace5b2e..c9714aa20e 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Heal.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Heal.js @@ -19,7 +19,7 @@ AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { "IsInTargetRange": () => true }); -let template = { +const template = { "Range": "20", "RangeOverlay": { "LineTexture": "heal_overlay_range.png", @@ -65,7 +65,7 @@ ApplyValueModificationsToEntity = function(value, stat, ent) } }; -let cmpHeal = ConstructComponent(60, "Heal", template); +const cmpHeal = ConstructComponent(60, "Heal", template); // Test Getters TS_ASSERT_EQUALS(cmpHeal.GetInterval(), 2000 + 200); @@ -88,7 +88,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmpHeal.GetRangeOverlays(), [{ }]); // Test healing. -let target = 70; +const target = 70; AddMock(target, IID_Ownership, { "GetOwner": () => player }); @@ -98,7 +98,7 @@ AddMock(target, IID_Identity, { "GetClassesList": () => targetClasses }); -let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); +const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); let increased; let unhealable = false; AddMock(target, IID_Health, { @@ -180,7 +180,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmpHeal.CanHeal(target), true); unhealable = true; TS_ASSERT_UNEVAL_EQUALS(cmpHeal.CanHeal(target), false); -let otherTarget = 71; +const otherTarget = 71; AddMock(otherTarget, IID_Ownership, { "GetOwner": () => otherPlayer }); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Health.js b/binaries/data/mods/public/simulation/components/tests/test_Health.js index 1ad5d70885..51a69f3488 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Health.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Health.js @@ -26,7 +26,7 @@ var corpse_entity; function setEntityUp() { - let cmpHealth = ConstructComponent(entity_id, "Health", health_template); + const cmpHealth = ConstructComponent(entity_id, "Health", health_template); AddMock(entity_id, IID_DeathDamage, { "CauseDeathDamage": () => {} diff --git a/binaries/data/mods/public/simulation/components/tests/test_Loot.js b/binaries/data/mods/public/simulation/components/tests/test_Loot.js index bd9f75d469..76dcee7fa8 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Loot.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Loot.js @@ -5,7 +5,7 @@ Resources = { "GetResource": () => ({}), "BuildSchema": (type) => { let schema = ""; - for (let res of Resources.GetCodes()) + for (const res of Resources.GetCodes()) schema += "" + "" + diff --git a/binaries/data/mods/public/simulation/components/tests/test_Looter.js b/binaries/data/mods/public/simulation/components/tests/test_Looter.js index bda2cb2052..b622df7d4b 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Looter.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Looter.js @@ -5,7 +5,7 @@ Resources = { "GetResource": () => ({}), "BuildSchema": (type) => { let schema = ""; - for (let res of Resources.GetCodes()) + for (const res of Resources.GetCodes()) schema += "" + "" + @@ -47,10 +47,10 @@ AddMock(SYSTEM_ENTITY, IID_PlayerManager, { "GetPlayerByID": () => playerEntity }); -let resourceCount = {}; +const resourceCount = {}; AddMock(playerEntity, IID_Player, { "AddResources": (amounts) => { - for (let type in amounts) + for (const type in amounts) resourceCount[type] = (resourceCount[type] ?? 0) +amounts[type]; } }); diff --git a/binaries/data/mods/public/simulation/components/tests/test_ModifiersManager.js b/binaries/data/mods/public/simulation/components/tests/test_ModifiersManager.js index f84e8d02d0..64fada50c9 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_ModifiersManager.js +++ b/binaries/data/mods/public/simulation/components/tests/test_ModifiersManager.js @@ -23,8 +23,8 @@ AddMock(PLAYER_ENTITY_ID, IID_Player, { "GetPlayerID": () => PLAYER_ID_FOR_TEST }); -let entitiesToTest = [STRUCTURE_ENTITY_ID, 6, 7, 8]; -for (let ent of entitiesToTest) +const entitiesToTest = [STRUCTURE_ENTITY_ID, 6, 7, 8]; +for (const ent of entitiesToTest) AddMock(ent, IID_Ownership, { "GetOwner": () => PLAYER_ID_FOR_TEST }); @@ -48,7 +48,7 @@ AddMock(8, IID_Identity, { // Sprinkle random serialisation cycles. function SerializationCycle() { - let data = cmpModifiersManager.Serialize(); + const data = cmpModifiersManager.Serialize(); cmpModifiersManager = ConstructComponent(SYSTEM_ENTITY, "ModifiersManager", {}); cmpModifiersManager.Deserialize(data); } diff --git a/binaries/data/mods/public/simulation/components/tests/test_Player.js b/binaries/data/mods/public/simulation/components/tests/test_Player.js index c0908ca289..e825da5af3 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Player.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Player.js @@ -5,7 +5,7 @@ Resources = { "GetResource": () => ({}), "BuildSchema": (type) => { let schema = ""; - for (let res of Resources.GetCodes()) + for (const res of Resources.GetCodes()) schema += "" + "" + diff --git a/binaries/data/mods/public/simulation/components/tests/test_Population.js b/binaries/data/mods/public/simulation/components/tests/test_Population.js index aa8b125459..cadec8f7fd 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Population.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Population.js @@ -6,7 +6,7 @@ Engine.LoadComponentScript("Population.js"); const player = 1; const entity = 11; -let entPopBonus = 5; +const entPopBonus = 5; Engine.RegisterGlobal("ApplyValueModificationsToEntity", (valueName, currentValue, entity) => currentValue @@ -16,7 +16,7 @@ AddMock(SYSTEM_ENTITY, IID_PlayerManager, { "GetPlayerByID": () => player }); -let cmpPopulation = ConstructComponent(entity, "Population", { +const cmpPopulation = ConstructComponent(entity, "Population", { "Bonus": entPopBonus }); diff --git a/binaries/data/mods/public/simulation/components/tests/test_PopulationCapManager.js b/binaries/data/mods/public/simulation/components/tests/test_PopulationCapManager.js index dc0e9457af..d3a59805be 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_PopulationCapManager.js +++ b/binaries/data/mods/public/simulation/components/tests/test_PopulationCapManager.js @@ -48,7 +48,7 @@ const playerData = [ } ]; -let currentPopCaps = []; +const currentPopCaps = []; AddMock(SYSTEM_ENTITY, IID_PlayerManager, { "GetNonGaiaPlayers": () => { return Object.keys(playerData).slice(1); }, diff --git a/binaries/data/mods/public/simulation/components/tests/test_Promotion.js b/binaries/data/mods/public/simulation/components/tests/test_Promotion.js index cca36797ba..1251c5fcd5 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Promotion.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Promotion.js @@ -9,20 +9,20 @@ let cmpPromotion; const entity = 60; let modifier = 0; -let ApplyValueModificationsToEntity = (_, val) => val + modifier; +const ApplyValueModificationsToEntity = (_, val) => val + modifier; Engine.RegisterGlobal("ApplyValueModificationsToEntity", ApplyValueModificationsToEntity); Engine.RegisterGlobal("ApplyValueModificationsToTemplate", ApplyValueModificationsToEntity); -let QueryOwnerInterface = () => ({ "GetPlayerID": () => 1 }); +const QueryOwnerInterface = () => ({ "GetPlayerID": () => 1 }); Engine.RegisterGlobal("QueryOwnerInterface", QueryOwnerInterface); -let entTemplates = { +const entTemplates = { "60": "template_b", "61": "template_f", "62": "end" }; -let promote = { +const promote = { "template_b": "template_c", "template_c": "template_d", "template_d": "template_e", @@ -38,10 +38,10 @@ AddMock(SYSTEM_ENTITY, IID_TemplateManager, { }), }); -let ChangeEntityTemplate = function(ent, template) +const ChangeEntityTemplate = function(ent, template) { - let newEnt = ent + 1; - let cmpNewPromotion = ConstructComponent(newEnt, "Promotion", { + const newEnt = ent + 1; + const cmpNewPromotion = ConstructComponent(newEnt, "Promotion", { "Entity": entTemplates[newEnt], "RequiredXp": 1000 }); @@ -89,7 +89,7 @@ cmpPromotion = ConstructComponent(entity, "Promotion", { "RequiredXp": 1000 }); -let cmpHealth = AddMock(entity, IID_Health, { +const cmpHealth = AddMock(entity, IID_Health, { "GetHitpoints": () => 0, }); @@ -99,7 +99,7 @@ TS_ASSERT_EQUALS(cmpPromotion.GetCurrentXp(), 0); DeleteMock(entity, IID_Health); // Test XP trickle. -let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer", {}); +const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer", {}); cmpPromotion = ConstructComponent(entity, "Promotion", { "Entity": "template_b", "RequiredXp": "100", diff --git a/binaries/data/mods/public/simulation/components/tests/test_RallyPoint.js b/binaries/data/mods/public/simulation/components/tests/test_RallyPoint.js index 4f5b976869..8b83ff6710 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_RallyPoint.js +++ b/binaries/data/mods/public/simulation/components/tests/test_RallyPoint.js @@ -7,8 +7,8 @@ function initialRallyPointTest(test_function) { ResetState(); - let entityID = 123; - let cmpRallyPoint = ConstructComponent(entityID, "RallyPoint", {}); + const entityID = 123; + const cmpRallyPoint = ConstructComponent(entityID, "RallyPoint", {}); TS_ASSERT_UNEVAL_EQUALS(cmpRallyPoint.GetData(), []); TS_ASSERT_UNEVAL_EQUALS(cmpRallyPoint.GetPositions(), []); @@ -19,14 +19,14 @@ function initialRallyPointTest(test_function) cmpRallyPoint.AddPosition(926, 535); TS_ASSERT_UNEVAL_EQUALS(cmpRallyPoint.GetPositions(), [{ "x": 3, "z": 1415 }, { "x": 926, "z": 535 }]); - let targetID = 456; - let myData = { "command": "write a unit test", "target": targetID }; + const targetID = 456; + const myData = { "command": "write a unit test", "target": targetID }; cmpRallyPoint.AddData(myData); TS_ASSERT_UNEVAL_EQUALS(cmpRallyPoint.GetPositions(), [{ "x": 3, "z": 1415 }, { "x": 926, "z": 535 }]); TS_ASSERT_UNEVAL_EQUALS(cmpRallyPoint.GetData(), [myData]); - let targetID2 = 789; - let myData2 = { "command": "this time really", "target": targetID2 }; + const targetID2 = 789; + const myData2 = { "command": "this time really", "target": targetID2 }; cmpRallyPoint.AddData(myData2); TS_ASSERT_UNEVAL_EQUALS(cmpRallyPoint.GetData(), [myData, myData2]); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Resistance.js b/binaries/data/mods/public/simulation/components/tests/test_Resistance.js index 18136ade50..8739885e64 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Resistance.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Resistance.js @@ -60,20 +60,20 @@ class testResistance { this.Reset(); - let damage = 5; - let attackData = { "Damage": { "Name": damage } }; - let attackType = "Test"; + const damage = 5; + const attackData = { "Damage": { "Name": damage } }; + const attackType = "Test"; TS_ASSERT(!this.cmpResistance.IsInvulnerable()); - let cmpHealth = AddMock(this.EntityID, IID_Health, { + const cmpHealth = AddMock(this.EntityID, IID_Health, { "TakeDamage": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, damage); return { "healthChange": -amount }; } }); - let spy = new Spy(cmpHealth, "TakeDamage"); - let data = { + const spy = new Spy(cmpHealth, "TakeDamage"); + const data = { "type": attackType, "attackData": attackData, "attacker": this.AttackerID, @@ -94,10 +94,10 @@ class testResistance { this.Reset(); - let damage = 5; - let bonus = 2; - let classes = "Entity"; - let attackData = { + const damage = 5; + const bonus = 2; + const classes = "Entity"; + const attackData = { "Damage": { "Name": damage }, "Bonuses": { "bonus": { @@ -112,13 +112,13 @@ class testResistance "GetCiv": () => "civ" }); - let cmpHealth = AddMock(this.EntityID, IID_Health, { + const cmpHealth = AddMock(this.EntityID, IID_Health, { "TakeDamage": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, damage * bonus); return { "healthChange": -amount }; } }); - let spy = new Spy(cmpHealth, "TakeDamage"); + const spy = new Spy(cmpHealth, "TakeDamage"); AttackHelper.HandleAttackEffects(this.EntityID, { "type": "Test", @@ -131,8 +131,8 @@ class testResistance TestDamageResistanceApplies() { - let resistanceValue = 2; - let damageType = "Name"; + const resistanceValue = 2; + const damageType = "Name"; this.Reset({ "Entity": { "Damage": { @@ -141,18 +141,18 @@ class testResistance } }); - let damage = 5; - let attackData = { + const damage = 5; + const attackData = { "Damage": { "Name": damage } }; - let cmpHealth = AddMock(this.EntityID, IID_Health, { + const cmpHealth = AddMock(this.EntityID, IID_Health, { "TakeDamage": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, damage * Math.pow(0.9, resistanceValue)); return { "healthChange": -amount }; } }); - let spy = new Spy(cmpHealth, "TakeDamage"); + const spy = new Spy(cmpHealth, "TakeDamage"); AttackHelper.HandleAttackEffects(this.EntityID, { "type": "Test", @@ -165,25 +165,25 @@ class testResistance TestCaptureResistanceApplies() { - let resistanceValue = 2; + const resistanceValue = 2; this.Reset({ "Entity": { "Capture": resistanceValue } }); - let damage = 5; - let attackData = { + const damage = 5; + const attackData = { "Capture": damage }; - let cmpCapturable = AddMock(this.EntityID, IID_Capturable, { + const cmpCapturable = AddMock(this.EntityID, IID_Capturable, { "Capture": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, damage * Math.pow(0.9, resistanceValue)); return { "captureChange": amount }; } }); - let spy = new Spy(cmpCapturable, "Capture"); + const spy = new Spy(cmpCapturable, "Capture"); AttackHelper.HandleAttackEffects(this.EntityID, { "type": "Test", @@ -197,8 +197,8 @@ class testResistance TestStatusEffectsResistancesApplies() { // Test duration reduction. - let durationFactor = 0.5; - let statusName = "statusName"; + const durationFactor = 0.5; + const statusName = "statusName"; this.Reset({ "Entity": { "ApplyStatus": { @@ -209,7 +209,7 @@ class testResistance } }); - let duration = 10; + const duration = 10; let attackData = { "ApplyStatus": { [statusName]: { @@ -262,8 +262,8 @@ class testResistance TS_ASSERT_EQUALS(spy._called, 1); // Test multiple resistances. - let reducedStatusName = "reducedStatus"; - let blockedStatusName = "blockedStatus"; + const reducedStatusName = "reducedStatus"; + const blockedStatusName = "blockedStatus"; this.Reset({ "Entity": { "ApplyStatus": { @@ -308,8 +308,8 @@ class testResistance TestResistanceAndBonus() { - let resistanceValue = 2; - let damageType = "Name"; + const resistanceValue = 2; + const damageType = "Name"; this.Reset({ "Entity": { "Damage": { @@ -318,10 +318,10 @@ class testResistance } }); - let damage = 5; - let bonus = 2; - let classes = "Entity"; - let attackData = { + const damage = 5; + const bonus = 2; + const classes = "Entity"; + const attackData = { "Damage": { "Name": damage }, "Bonuses": { "bonus": { @@ -336,13 +336,13 @@ class testResistance "GetCiv": () => "civ" }); - let cmpHealth = AddMock(this.EntityID, IID_Health, { + const cmpHealth = AddMock(this.EntityID, IID_Health, { "TakeDamage": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, damage * bonus * Math.pow(0.9, resistanceValue)); return { "healthChange": -amount }; } }); - let spy = new Spy(cmpHealth, "TakeDamage"); + const spy = new Spy(cmpHealth, "TakeDamage"); AttackHelper.HandleAttackEffects(this.EntityID, { "type": "Test", @@ -355,17 +355,17 @@ class testResistance TestMultipleEffects() { - let captureResistanceValue = 2; + const captureResistanceValue = 2; this.Reset({ "Entity": { "Capture": captureResistanceValue } }); - let damage = 5; - let bonus = 2; - let classes = "Entity"; - let attackData = { + const damage = 5; + const bonus = 2; + const classes = "Entity"; + const attackData = { "Damage": { "Name": damage }, "Capture": damage, "Bonuses": { @@ -381,13 +381,13 @@ class testResistance "GetCiv": () => "civ" }); - let cmpCapturable = AddMock(this.EntityID, IID_Capturable, { + const cmpCapturable = AddMock(this.EntityID, IID_Capturable, { "Capture": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, damage * bonus * Math.pow(0.9, captureResistanceValue)); return { "captureChange": amount }; } }); - let cmpHealth = AddMock(this.EntityID, IID_Health, { + const cmpHealth = AddMock(this.EntityID, IID_Health, { "TakeDamage": (amount, __, ___) => { TS_ASSERT_EQUALS(amount, damage * bonus); return { "healthChange": -amount }; @@ -395,8 +395,8 @@ class testResistance "GetHitpoints": () => 1, "GetMaxHitpoints": () => 1 }); - let healthSpy = new Spy(cmpHealth, "TakeDamage"); - let captureSpy = new Spy(cmpCapturable, "Capture"); + const healthSpy = new Spy(cmpHealth, "TakeDamage"); + const captureSpy = new Spy(cmpCapturable, "Capture"); AttackHelper.HandleAttackEffects(this.EntityID, { "type": "Test", @@ -409,7 +409,7 @@ class testResistance } } -let cmp = new testResistance(); +const cmp = new testResistance(); cmp.TestInvulnerability(); cmp.TestBonus(); cmp.TestDamageResistanceApplies(); diff --git a/binaries/data/mods/public/simulation/components/tests/test_ResourceDropsite.js b/binaries/data/mods/public/simulation/components/tests/test_ResourceDropsite.js index cd404bdc06..58403df104 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_ResourceDropsite.js +++ b/binaries/data/mods/public/simulation/components/tests/test_ResourceDropsite.js @@ -1,9 +1,9 @@ Resources = { "BuildChoicesSchema": () => { let schema = ""; - for (let res of ["food", "metal"]) + for (const res of ["food", "metal"]) { - for (let subtype in ["meat", "grain"]) + for (const subtype in ["meat", "grain"]) schema += "" + res + "." + subtype + ""; schema += " treasure." + res + ""; } @@ -19,14 +19,14 @@ Engine.RegisterGlobal("ApplyValueModificationsToEntity", (prop, oVal, ent) => oV const owner = 1; const entity = 11; -let dropper = 12; +const dropper = 12; -let template = { +const template = { "Sharable": "true", "Types": "food" }; -let cmpResourceDropsite = ConstructComponent(entity, "ResourceDropsite", template); +const cmpResourceDropsite = ConstructComponent(entity, "ResourceDropsite", template); TS_ASSERT(cmpResourceDropsite.IsSharable()); AddMock(dropper, IID_Ownership, { diff --git a/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js b/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js index 6fb77e6e26..737a740e5e 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js +++ b/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js @@ -1,9 +1,9 @@ Resources = { "BuildSchema": () => { let schema = ""; - for (let res of ["food", "metal", "wood"]) + for (const res of ["food", "metal", "wood"]) { - for (let subtype in ["meat", "grain"]) + for (const subtype in ["meat", "grain"]) schema += "" + res + "." + subtype + ""; schema += " treasure." + res + ""; } @@ -42,7 +42,7 @@ const gathererID = 11; const dropsiteID = 12; const supplyID = 13; -let template = { +const template = { "MaxDistance": "10", "BaseSpeed": "1", "Rates": { diff --git a/binaries/data/mods/public/simulation/components/tests/test_ResourceSupply.js b/binaries/data/mods/public/simulation/components/tests/test_ResourceSupply.js index 2ae91fc2b1..9c765170be 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_ResourceSupply.js +++ b/binaries/data/mods/public/simulation/components/tests/test_ResourceSupply.js @@ -1,9 +1,9 @@ Resources = { "BuildChoicesSchema": () => { let schema = ""; - for (let res of ["food", "metal"]) + for (const res of ["food", "metal"]) { - for (let subtype in ["meat", "grain"]) + for (const subtype in ["meat", "grain"]) schema += "" + res + "." + subtype + ""; schema += " treasure." + res + ""; } @@ -19,7 +19,7 @@ Engine.LoadComponentScript("interfaces/Timer.js"); Engine.LoadComponentScript("ResourceSupply.js"); Engine.LoadComponentScript("Timer.js"); -let entity = 60; +const entity = 60; AddMock(entity, IID_Fogging, { "Activate": () => {} diff --git a/binaries/data/mods/public/simulation/components/tests/test_ResourceTrickle.js b/binaries/data/mods/public/simulation/components/tests/test_ResourceTrickle.js index df5c2cdc7b..6faa14dd48 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_ResourceTrickle.js +++ b/binaries/data/mods/public/simulation/components/tests/test_ResourceTrickle.js @@ -5,7 +5,7 @@ Resources = { "GetResource": () => ({}), "BuildSchema": (type) => { let schema = ""; - for (let res of Resources.GetCodes()) + for (const res of Resources.GetCodes()) schema += "" + "" + @@ -26,12 +26,12 @@ Engine.LoadComponentScript("Timer.js"); // Resource Trickle requires this function to be defined before the component is built. let ApplyValueModificationsToEntity = (valueName, currentValue, entity) => currentValue; Engine.RegisterGlobal("ApplyValueModificationsToEntity", ApplyValueModificationsToEntity); -let wonderEnt = 1; -let turnLength = 0.2; -let playerEnt = 10; -let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer", {}); +const wonderEnt = 1; +const turnLength = 0.2; +const playerEnt = 10; +const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer", {}); -let cmpResourceTrickle = ConstructComponent(wonderEnt, "ResourceTrickle", { +const cmpResourceTrickle = ConstructComponent(wonderEnt, "ResourceTrickle", { "Interval": "200", "Rates": { "food": "0", @@ -39,7 +39,7 @@ let cmpResourceTrickle = ConstructComponent(wonderEnt, "ResourceTrickle", { } }); -let cmpPlayer = ConstructComponent(playerEnt, "Player", { +const cmpPlayer = ConstructComponent(playerEnt, "Player", { "SpyCostMultiplier": "1", "BarterMultiplier": { "Buy": { @@ -54,7 +54,7 @@ let cmpPlayer = ConstructComponent(playerEnt, "Player", { "Formations": { "_string": "" }, }); -let QueryOwnerInterface = () => cmpPlayer; +const QueryOwnerInterface = () => cmpPlayer; Engine.RegisterGlobal("QueryOwnerInterface", QueryOwnerInterface); TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetResourceCounts(), { "food": 300, "metal": 300 }); TS_ASSERT_EQUALS(cmpResourceTrickle.GetInterval(), 200); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Resources.js b/binaries/data/mods/public/simulation/components/tests/test_Resources.js index 231ae41741..447192cda2 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Resources.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Resources.js @@ -4,9 +4,9 @@ Resources = { "GetBarterableCodes": () => ["food", "metal", "stone", "wood"], "BuildSchema": () => { let schema = ""; - for (let res of ["food", "metal"]) + for (const res of ["food", "metal"]) { - for (let subtype in ["meat", "grain"]) + for (const subtype in ["meat", "grain"]) schema += "" + res + "." + subtype + ""; schema += " treasure." + res + ""; } @@ -14,9 +14,9 @@ Resources = { }, "BuildChoicesSchema": () => { let schema = ""; - for (let res of ["food", "metal"]) + for (const res of ["food", "metal"]) { - for (let subtype in ["meat", "grain"]) + for (const subtype in ["meat", "grain"]) schema += "" + res + "." + subtype + ""; schema += " treasure." + res + ""; } @@ -47,7 +47,7 @@ Engine.LoadComponentScript("ResourceSupply.js"); Engine.LoadComponentScript("Timer.js"); Engine.RegisterGlobal("ApplyValueModificationsToEntity", (prop, oVal, ent) => oVal); -let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer", null); +const cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer", null); AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { "IsInTargetRange": () => true @@ -70,7 +70,7 @@ AddMock(SYSTEM_ENTITY, IID_PlayerManager, { "GetPlayerByID": (id) => owner }); -let cmpPlayer = ConstructComponent(owner, "Player", { +const cmpPlayer = ConstructComponent(owner, "Player", { "SpyCostMultiplier": "1", "BarterMultiplier": { "Buy": {}, @@ -78,9 +78,9 @@ let cmpPlayer = ConstructComponent(owner, "Player", { }, "Formations": { "_string": "" } }); -let playerSpy = new Spy(cmpPlayer, "AddResources"); +const playerSpy = new Spy(cmpPlayer, "AddResources"); -let cmpResourceGatherer = ConstructComponent(gatherer, "ResourceGatherer", { +const cmpResourceGatherer = ConstructComponent(gatherer, "ResourceGatherer", { "MaxDistance": "10", "BaseSpeed": "1", "Rates": { @@ -91,14 +91,14 @@ let cmpResourceGatherer = ConstructComponent(gatherer, "ResourceGatherer", { } }); cmpResourceGatherer.OnGlobalInitGame(); -let cmpResourceSupply = ConstructComponent(supply, "ResourceSupply", { +const cmpResourceSupply = ConstructComponent(supply, "ResourceSupply", { "Max": 1000, "Type": "food.meat", "KillBeforeGather": false, "MaxGatherers": 2 }); cmpResourceSupply.RecalculateValues(); -let cmpResourceDropsite = ConstructComponent(dropsite, "ResourceDropsite", { +const cmpResourceDropsite = ConstructComponent(dropsite, "ResourceDropsite", { "Sharable": "true", "Types": "food" });