Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_Damage.js
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | let data = { | ||||
"attackerOwner": attackerOwner, | "attackerOwner": attackerOwner, | ||||
"position": targetPos, | "position": targetPos, | ||||
"isSplash": false, | "isSplash": false, | ||||
"projectileId": 9 | "projectileId": 9 | ||||
}; | }; | ||||
AddMock(atkPlayerEntity, IID_Player, { | AddMock(atkPlayerEntity, IID_Player, { | ||||
GetEnemies: () => [targetOwner], | GetEnemies: () => [targetOwner], | ||||
GetNeutrals: () => [] | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
GetPlayerByID: (id) => atkPlayerEntity, | GetPlayerByID: (id) => atkPlayerEntity, | ||||
GetNumPlayers: () => 5 | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, { | AddMock(SYSTEM_ENTITY, IID_RangeManager, { | ||||
ExecuteQueryAroundPos: () => [target], | ExecuteQueryAroundPos: () => [target], | ||||
GetElevationAdaptedRange: (pos, rot, max, bonus, a) => max, | GetElevationAdaptedRange: (pos, rot, max, bonus, a) => max, | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_ProjectileManager, { | AddMock(SYSTEM_ENTITY, IID_ProjectileManager, { | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
data.isSplash = true; | data.isSplash = true; | ||||
cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_Damage, "MissileHit", 1000, data); | cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_Damage, "MissileHit", 1000, data); | ||||
TestDamage(); | TestDamage(); | ||||
// Check for damage still being dealt if the attacker dies | // Check for damage still being dealt if the attacker dies | ||||
cmpAttack.PerformAttack("Ranged", target); | cmpAttack.PerformAttack("Ranged", target); | ||||
Engine.DestroyEntity(attacker); | Engine.DestroyEntity(attacker); | ||||
TestDamage(); | TestDamage(); | ||||
atkPlayerEntity = 1; | |||||
AddMock(atkPlayerEntity, IID_Player, { | |||||
GetEnemies: () => [2, 3], | |||||
GetAllPlayers: () => [0, 1, 2, 3, 4] | |||||
}); | |||||
TS_ASSERT_UNEVAL_EQUALS(cmpDamage.GetPlayersToDamage(atkPlayerEntity, true), [0, 1, 2, 3, 4]); | |||||
TS_ASSERT_UNEVAL_EQUALS(cmpDamage.GetPlayersToDamage(atkPlayerEntity, false), [2, 3]); |
Wildfire Games · Phabricator