Differential D274 Diff 1216 binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_VisionSharing.js
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadHelperScript("ValueModification.js"); | Engine.LoadHelperScript("ValueModification.js"); | ||||
Engine.LoadComponentScript("interfaces/GarrisonHolder.js"); | Engine.LoadComponentScript("interfaces/GarrisonHolder.js"); | ||||
Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | ||||
Engine.LoadComponentScript("interfaces/ModifiersManager.js"); | |||||
Engine.LoadComponentScript("interfaces/AuraManager.js"); | Engine.LoadComponentScript("interfaces/AuraManager.js"); | ||||
Engine.LoadComponentScript("interfaces/Timer.js"); | Engine.LoadComponentScript("interfaces/Timer.js"); | ||||
Engine.LoadComponentScript("interfaces/VisionSharing.js"); | Engine.LoadComponentScript("interfaces/VisionSharing.js"); | ||||
Engine.LoadComponentScript("VisionSharing.js"); | Engine.LoadComponentScript("VisionSharing.js"); | ||||
const ent = 170; | const ent = 170; | ||||
let template = { | let template = { | ||||
"Bribable": "true" | "Bribable": "true" | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | |||||
cmpVisionSharing.spyId = 20; | cmpVisionSharing.spyId = 20; | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
"GetPlayerByID": id => 14 | "GetPlayerByID": id => 14 | ||||
}); | }); | ||||
AddMock(14, IID_TechnologyManager, { | AddMock(14, IID_TechnologyManager, { | ||||
"CanProduce": entity => false, | "CanProduce": entity => false, | ||||
}); | |||||
AddMock(14, IID_ModifiersManager, { | |||||
"ApplyModificationsTemplate": (valueName, curValue, template) => curValue | "ApplyModificationsTemplate": (valueName, curValue, template) => curValue | ||||
}); | }); | ||||
TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.shared], [1, 2, 5]); | TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.shared], [1, 2, 5]); | ||||
TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.spies], [[5, 2], [17, 5]]); | TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.spies], [[5, 2], [17, 5]]); | ||||
TS_ASSERT_EQUALS(cmpVisionSharing.spyId, 20); | TS_ASSERT_EQUALS(cmpVisionSharing.spyId, 20); | ||||
AddMock(14, IID_TechnologyManager, { | AddMock(14, IID_TechnologyManager, { | ||||
"CanProduce": entity => entity == "special/spy", | "CanProduce": entity => entity == "special/spy", | ||||
}); | |||||
AddMock(14, IID_ModifiersManager, { | |||||
"ApplyModificationsTemplate": (valueName, curValue, template) => curValue | "ApplyModificationsTemplate": (valueName, curValue, template) => curValue | ||||
}); | }); | ||||
AddMock(14, IID_Player, { | AddMock(14, IID_Player, { | ||||
"GetSpyCostMultiplier": () => 1, | "GetSpyCostMultiplier": () => 1, | ||||
"TrySubtractResources": costs => false | "TrySubtractResources": costs => false | ||||
}); | }); | ||||
cmpVisionSharing.AddSpy(4, 25); | cmpVisionSharing.AddSpy(4, 25); | ||||
TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.shared], [1, 2, 5]); | TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.shared], [1, 2, 5]); | ||||
TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.spies], [[5, 2], [17, 5]]); | TS_ASSERT_UNEVAL_EQUALS([...cmpVisionSharing.spies], [[5, 2], [17, 5]]); | ||||
TS_ASSERT_EQUALS(cmpVisionSharing.spyId, 20); | TS_ASSERT_EQUALS(cmpVisionSharing.spyId, 20); | ||||
Show All 39 Lines |
Wildfire Games · Phabricator