Differential D152 Diff 944 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js
Engine.LoadComponentScript("interfaces/EndGameManager.js"); | Engine.LoadComponentScript("interfaces/EndGameManager.js"); | ||||
Engine.LoadComponentScript("EndGameManager.js"); | Engine.LoadComponentScript("EndGameManager.js"); | ||||
let cmpEndGameManager = ConstructComponent(SYSTEM_ENTITY, "EndGameManager"); | let cmpEndGameManager = ConstructComponent(SYSTEM_ENTITY, "EndGameManager"); | ||||
let playerEnt1 = 1; | let playerEnt1 = 1; | ||||
let wonderDuration = 2 * 60 * 1000; | let victoryDuration = 2 * 60 * 1000; | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
"GetNumPlayers": () => 4 | "GetNumPlayers": () => 4 | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_GuiInterface, { | AddMock(SYSTEM_ENTITY, IID_GuiInterface, { | ||||
"DeleteTimeNotification": () => null, | "DeleteTimeNotification": () => null, | ||||
"AddTimeNotification": () => 1 | "AddTimeNotification": () => 1 | ||||
}); | }); | ||||
AddMock(playerEnt1, IID_Player, { | AddMock(playerEnt1, IID_Player, { | ||||
"GetName": () => "Player 1", | "GetName": () => "Player 1", | ||||
"GetState": () => "active", | "GetState": () => "active", | ||||
}); | }); | ||||
TS_ASSERT_EQUALS(cmpEndGameManager.skipAlliedVictoryCheck, true); | TS_ASSERT_EQUALS(cmpEndGameManager.skipAlliedVictoryCheck, true); | ||||
cmpEndGameManager.SetAlliedVictory(true); | cmpEndGameManager.SetAlliedVictory(true); | ||||
TS_ASSERT_EQUALS(cmpEndGameManager.GetAlliedVictory(), true); | TS_ASSERT_EQUALS(cmpEndGameManager.GetAlliedVictory(), true); | ||||
cmpEndGameManager.SetGameType("wonder", { "wonderDuration": wonderDuration }); | cmpEndGameManager.SetGameType("wonder", { "victoryDuration": victoryDuration }); | ||||
TS_ASSERT_EQUALS(cmpEndGameManager.skipAlliedVictoryCheck, false); | TS_ASSERT_EQUALS(cmpEndGameManager.skipAlliedVictoryCheck, false); | ||||
TS_ASSERT(cmpEndGameManager.GetGameType() == "wonder"); | TS_ASSERT(cmpEndGameManager.GetGameType() == "wonder"); | ||||
TS_ASSERT_EQUALS(cmpEndGameManager.GetGameTypeSettings().wonderDuration, wonderDuration); | TS_ASSERT_EQUALS(cmpEndGameManager.GetGameTypeSettings().victoryDuration, victoryDuration); |
Wildfire Games · Phabricator