diff --git a/binaries/data/mods/public/simulation/components/PopulationCapManager.js b/binaries/data/mods/public/simulation/components/PopulationCapManager.js
index aa6bebc917..5d1240ad96 100644
--- a/binaries/data/mods/public/simulation/components/PopulationCapManager.js
+++ b/binaries/data/mods/public/simulation/components/PopulationCapManager.js
@@ -1,9 +1,9 @@
-const CAPTYPE_PLAYER_POPULATION = "player";
-const CAPTYPE_TEAM_POPULATION = "team";
-const CAPTYPE_WORLD_POPULATION = "world";
-
function PopulationCapManager() {}
+PopulationCapManager.prototype.CAPTYPE_PLAYER_POPULATION = "player";
+PopulationCapManager.prototype.CAPTYPE_TEAM_POPULATION = "team";
+PopulationCapManager.prototype.CAPTYPE_WORLD_POPULATION = "world";
+
PopulationCapManager.prototype.Schema =
"";
@@ -17,7 +17,7 @@ PopulationCapManager.prototype.Init = function()
*/
PopulationCapManager.prototype.SetPopulationCapType = function(type)
{
- if ([CAPTYPE_PLAYER_POPULATION, CAPTYPE_TEAM_POPULATION, CAPTYPE_WORLD_POPULATION].includes(type))
+ if ([this.CAPTYPE_PLAYER_POPULATION, this.CAPTYPE_TEAM_POPULATION, this.CAPTYPE_WORLD_POPULATION].includes(type))
this.popCapType = type;
else
{
@@ -64,15 +64,15 @@ PopulationCapManager.prototype.InitializePopCaps = function()
{
switch (this.popCapType)
{
- case CAPTYPE_PLAYER_POPULATION:
+ case this.CAPTYPE_PLAYER_POPULATION:
this.InitializePlayerPopCaps();
break;
- case CAPTYPE_TEAM_POPULATION:
+ case this.CAPTYPE_TEAM_POPULATION:
this.InitializeTeamPopCaps();
break;
- case CAPTYPE_WORLD_POPULATION:
+ case this.CAPTYPE_WORLD_POPULATION:
this.RedistributeWorldPopCap();
break;
@@ -151,18 +151,18 @@ PopulationCapManager.prototype.OnGlobalPlayerDefeated = function(msg)
{
switch (this.popCapType)
{
- case CAPTYPE_TEAM_POPULATION:
+ case this.CAPTYPE_TEAM_POPULATION:
{
const team = QueryPlayerIDInterface(msg.playerId, IID_Diplomacy).GetTeam();
- if (team != -1)
+ if (team !== -1)
this.RedistributeTeamPopCap(team);
break;
}
- case CAPTYPE_WORLD_POPULATION:
+ case this.CAPTYPE_WORLD_POPULATION:
this.RedistributeWorldPopCap();
break;
- case CAPTYPE_PLAYER_POPULATION:
+ case this.CAPTYPE_PLAYER_POPULATION:
default: break;
}
};
@@ -175,7 +175,7 @@ PopulationCapManager.prototype.OnGlobalPlayerDefeated = function(msg)
*/
PopulationCapManager.prototype.OnTeamChanged = function(msg)
{
- if (this.popCapType != CAPTYPE_TEAM_POPULATION)
+ if (this.popCapType !== this.CAPTYPE_TEAM_POPULATION)
return;
this.RedistributeTeamPopCap(msg.oldTeam);
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 72386d38de..8d187b7967 100644
--- a/binaries/data/mods/public/simulation/components/tests/test_PopulationCapManager.js
+++ b/binaries/data/mods/public/simulation/components/tests/test_PopulationCapManager.js
@@ -4,10 +4,6 @@ Engine.LoadComponentScript("interfaces/Diplomacy.js");
Engine.LoadComponentScript("interfaces/PopulationCapManager.js");
Engine.LoadComponentScript("PopulationCapManager.js");
-const CAPTYPE_PLAYER_POPULATION = "player";
-const CAPTYPE_TEAM_POPULATION = "team";
-const CAPTYPE_WORLD_POPULATION = "world";
-
const DEFAULT_POPCAP = 999;
const cmpPopulationCapManager = ConstructComponent(SYSTEM_ENTITY, "PopulationCapManager");
@@ -54,7 +50,7 @@ const currentPopCaps = Object.keys(playerData).fill(DEFAULT_POPCAP);
AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
"GetNonGaiaPlayers": () => { return Object.keys(playerData).slice(1); },
- "GetActivePlayers": () => { return Object.keys(playerData.filter(player => player.state == "active")).slice(1); },
+ "GetActivePlayers": () => { return Object.keys(playerData.filter(player => player.state === "active")).slice(1); },
"GetPlayerByID": (id) => id
});
@@ -69,10 +65,10 @@ for (const playerID in Object.keys(playerData))
}
cmpPopulationCapManager.SetPopulationCap(400);
-cmpPopulationCapManager.SetPopulationCapType(CAPTYPE_PLAYER_POPULATION);
+cmpPopulationCapManager.SetPopulationCapType(cmpPopulationCapManager.CAPTYPE_PLAYER_POPULATION);
TS_ASSERT_UNEVAL_EQUALS(currentPopCaps, [DEFAULT_POPCAP, 400, 400, 400, 400, 400, 400, 400, 400]);
-cmpPopulationCapManager.SetPopulationCapType(CAPTYPE_TEAM_POPULATION);
+cmpPopulationCapManager.SetPopulationCapType(cmpPopulationCapManager.CAPTYPE_TEAM_POPULATION);
TS_ASSERT_UNEVAL_EQUALS(currentPopCaps, [DEFAULT_POPCAP, 400, 400, 400, 133, 133, 133, 200, 200]);
playerData[6].team = 2;
@@ -84,7 +80,7 @@ currentPopCaps.pop();
cmpPopulationCapManager.OnGlobalPlayerDefeated({ "playerId": 8 });
TS_ASSERT_UNEVAL_EQUALS(currentPopCaps, [DEFAULT_POPCAP, 400, 400, 400, 200, 200, 200, 200]);
-cmpPopulationCapManager.SetPopulationCapType(CAPTYPE_WORLD_POPULATION);
+cmpPopulationCapManager.SetPopulationCapType(cmpPopulationCapManager.CAPTYPE_WORLD_POPULATION);
TS_ASSERT_UNEVAL_EQUALS(currentPopCaps, [DEFAULT_POPCAP, 57, 57, 57, 57, 57, 57, 57]);
playerData[7].state = "defeated";