mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 22:33:56 -07:00
In f3ac9e9669 the fail condition was broken causing it to allow building on restricted areas.
Add a test to ensure correct behavior for this case.
Reported by: @wowgetoffyourcellphone
Pull Request: #8021
30 lines
795 B
JavaScript
30 lines
795 B
JavaScript
Engine.LoadComponentScript("interfaces/BuildRestrictions.js");
|
|
Engine.LoadComponentScript("BuildRestrictions.js");
|
|
|
|
{
|
|
const entity = 10;
|
|
const QueryOwnerInterface = () => ({
|
|
"GetPlayerID": () => 1,
|
|
"IsAI": () => false
|
|
});
|
|
Engine.RegisterGlobal("QueryOwnerInterface", QueryOwnerInterface);
|
|
const cmpBuildRestrictions = ConstructComponent(entity, "BuildRestrictions", {
|
|
"PlacementType": "land"
|
|
});
|
|
|
|
AddMock(SYSTEM_ENTITY, IID_RangeManager, {
|
|
"GetLosVisibility": (_, __) => "visible",
|
|
"GetEntitiesByPlayer": () => []
|
|
});
|
|
|
|
AddMock(entity, IID_Ownership, {
|
|
"GetOwner": () => 1
|
|
});
|
|
|
|
AddMock(entity, IID_Obstruction, {
|
|
"CheckFoundation": () => "fail_obstructs_foundation"
|
|
});
|
|
|
|
const result = cmpBuildRestrictions.CheckPlacement();
|
|
TS_ASSERT_EQUALS(result.success, false);
|
|
}
|