Differential D12 Diff 102 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Auras.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Auras.js
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadHelperScript("ValueModification.js"); | Engine.LoadHelperScript("ValueModification.js"); | ||||
Engine.LoadComponentScript("interfaces/Auras.js"); | Engine.LoadComponentScript("interfaces/Auras.js"); | ||||
Engine.LoadComponentScript("interfaces/AuraManager.js"); | Engine.LoadComponentScript("interfaces/AuraManager.js"); | ||||
Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | ||||
Engine.LoadComponentScript("Auras.js"); | Engine.LoadComponentScript("Auras.js"); | ||||
Engine.LoadComponentScript("AuraManager.js"); | Engine.LoadComponentScript("AuraManager.js"); | ||||
let playerID = [0, 1, 2]; | let playerID = [0, 1, 2]; | ||||
let playerEnt = [10, 11, 12]; | let playerEnt = [10, 11, 12]; | ||||
let playerState = "active"; | |||||
let giverEnt = 20; | let giverEnt = 20; | ||||
let targetEnt = 30; | let targetEnt = 30; | ||||
let auraRange = 40; | let auraRange = 40; | ||||
let template = { "Identity" : { "Classes" : { "_string" : "CorrectClass OtherClass" } } }; | let template = { "Identity" : { "Classes" : { "_string" : "CorrectClass OtherClass" } } }; | ||||
function testAuras(name, test_function) | function testAuras(name, test_function) | ||||
{ | { | ||||
ResetState(); | ResetState(); | ||||
Show All 27 Lines | "GetAuraTemplate": (name) => { | ||||
template.radius = auraRange; | template.radius = auraRange; | ||||
return template; | return template; | ||||
} | } | ||||
}); | }); | ||||
AddMock(playerEnt[1], IID_Player, { | AddMock(playerEnt[1], IID_Player, { | ||||
"IsAlly": id => id == 1, | "IsAlly": id => id == 1, | ||||
"IsEnemy": id => id != 1, | "IsEnemy": id => id != 1, | ||||
"GetPlayerID": () => playerID[1] | "GetPlayerID": () => playerID[1], | ||||
"GetState": () => playerState | |||||
}); | }); | ||||
AddMock(targetEnt, IID_Identity, { | AddMock(targetEnt, IID_Identity, { | ||||
"GetClassesList": () => ["CorrectClass", "OtherClass"] | "GetClassesList": () => ["CorrectClass", "OtherClass"] | ||||
}); | }); | ||||
AddMock(giverEnt, IID_Position, { | AddMock(giverEnt, IID_Position, { | ||||
"GetPosition2D": () => new Vector2D() | "GetPosition2D": () => new Vector2D() | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
testAuras("formation", (name, cmpAuras) => { | testAuras("formation", (name, cmpAuras) => { | ||||
TS_ASSERT_EQUALS(cmpAuras.HasFormationAura(), true); | TS_ASSERT_EQUALS(cmpAuras.HasFormationAura(), true); | ||||
cmpAuras.ApplyFormationBonus([targetEnt]); | cmpAuras.ApplyFormationBonus([targetEnt]); | ||||
TS_ASSERT_EQUALS(ApplyValueModificationsToEntity("Component/Value", 5, targetEnt), 15); | TS_ASSERT_EQUALS(ApplyValueModificationsToEntity("Component/Value", 5, targetEnt), 15); | ||||
cmpAuras.RemoveFormationBonus([targetEnt]); | cmpAuras.RemoveFormationBonus([targetEnt]); | ||||
TS_ASSERT_EQUALS(ApplyValueModificationsToEntity("Component/Value", 5, targetEnt), 5); | TS_ASSERT_EQUALS(ApplyValueModificationsToEntity("Component/Value", 5, targetEnt), 5); | ||||
}); | }); | ||||
playerState = "defeated"; | |||||
testAuras("global", (name, cmpAuras) => { | |||||
TS_ASSERT_EQUALS(ApplyValueModificationsToTemplate("Component/Value", 5, playerID[1], template), 5); | |||||
}); |
Wildfire Games · Phabricator