Differential D2308 Diff 10230 binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
"GetPlayerByID": id => id | "GetPlayerByID": id => id | ||||
}); | }); | ||||
for (let i = 24; i <= 34; ++i) | for (let i = 24; i <= 34; ++i) | ||||
{ | { | ||||
AddMock(i, IID_Identity, { | AddMock(i, IID_Identity, { | ||||
"GetClassesList": () => "Infantry+Cavalry", | "GetClassesList": () => ["Infantry", "Cavalry"], | ||||
"GetSelectionGroupName": () => "mace_infantry_archer_a" | "GetSelectionGroupName": () => "mace_infantry_archer_a" | ||||
}); | }); | ||||
if (i < 28) | if (i < 28) | ||||
AddMock(i, IID_Ownership, { | AddMock(i, IID_Ownership, { | ||||
"GetOwner": () => player | "GetOwner": () => player | ||||
}); | }); | ||||
else if (i == 34) | else if (i == 34) | ||||
Show All 16 Lines | AddMock(i, IID_Position, { | ||||
"JumpTo": (posX, posZ) => {}, | "JumpTo": (posX, posZ) => {}, | ||||
"MoveOutOfWorld": () => {}, | "MoveOutOfWorld": () => {}, | ||||
"SetTurretParent": (entity, offset) => {}, | "SetTurretParent": (entity, offset) => {}, | ||||
"SetHeightOffset": height => {} | "SetHeightOffset": height => {} | ||||
}); | }); | ||||
} | } | ||||
AddMock(33, IID_Identity, { | AddMock(33, IID_Identity, { | ||||
"GetClassesList": () => "Infantry+Cavalry", | "GetClassesList": () => ["Infantry", "Cavalry"], | ||||
"GetSelectionGroupName": () => "spart_infantry_archer_a" | "GetSelectionGroupName": () => "spart_infantry_archer_a" | ||||
}); | }); | ||||
let cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { | let cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { | ||||
"Max": 10, | "Max": 10, | ||||
"List": { "_string": "Infantry+Cavalry" }, | "List": { "_string": "Infantry+Cavalry" }, | ||||
"EjectHealth": 0.1, | "EjectHealth": 0.1, | ||||
"EjectClassesOnDestroy": { "_string": "Infantry" }, | "EjectClassesOnDestroy": { "_string": "Infantry" }, | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.IsEjectable(25), false); | TS_ASSERT_EQUALS(cmpGarrisonHolder.IsEjectable(25), false); | ||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.PerformEject([25], false), false); | TS_ASSERT_EQUALS(cmpGarrisonHolder.PerformEject([25], false), false); | ||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.PerformEject([], false), true); | TS_ASSERT_EQUALS(cmpGarrisonHolder.PerformEject([], false), true); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetEntities(), [24, 26, 27]); | TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetEntities(), [24, 26, 27]); | ||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 3); | TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 3); | ||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.IsFull(), false); | TS_ASSERT_EQUALS(cmpGarrisonHolder.IsFull(), false); | ||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.UnloadAll(), true); | TS_ASSERT_EQUALS(cmpGarrisonHolder.UnloadAll(), true); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetEntities(), []); | TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetEntities(), []); | ||||
let siegeEngineId = 44; | |||||
AddMock(siegeEngineId, IID_Identity, { | |||||
"GetClassesList": () => ["Siege"] | |||||
}); | |||||
let archerId = 45; | |||||
AddMock(archerId, IID_Identity, { | |||||
"GetClassesList": () => ["Infantry", "Ranged"] | |||||
}); | |||||
// Test visible garrisoning restrictions. | |||||
cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { | |||||
"Max": 10, | |||||
"List": { "_string": "Infantry+Ranged Siege" }, | |||||
"EjectHealth": 0.1, | |||||
"EjectClassesOnDestroy": { "_string": "Infantry" }, | |||||
"BuffHeal": 1, | |||||
"LoadingRange": 2.1, | |||||
"Pickup": false, | |||||
"VisibleGarrisonPoints": { | |||||
"archer1": { | |||||
"X": 12, | |||||
"Y": 5, | |||||
"Z": 6 | |||||
}, | |||||
"archer2": { | |||||
"X": 15, | |||||
"Y": 5, | |||||
"Z": 6, | |||||
"AllowedClasses": { "_string": "Siege" } | |||||
}, | |||||
"archer3": { | |||||
"X": 15, | |||||
"Y": 5, | |||||
"Z": 6, | |||||
"AllowedClasses": { "_string": "Siege Infantry+Ranged Infantry+Cavalry" } | |||||
} | |||||
} | |||||
}); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(siegeEngineId, cmpGarrisonHolder.visibleGarrisonPoints[0]), false); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(siegeEngineId, cmpGarrisonHolder.visibleGarrisonPoints[1]), true); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(siegeEngineId, cmpGarrisonHolder.visibleGarrisonPoints[2]), true); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(archerId, cmpGarrisonHolder.visibleGarrisonPoints[0]), true); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(archerId, cmpGarrisonHolder.visibleGarrisonPoints[1]), false); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(archerId, cmpGarrisonHolder.visibleGarrisonPoints[2]), true); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(33, cmpGarrisonHolder.visibleGarrisonPoints[0]), false); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(33, cmpGarrisonHolder.visibleGarrisonPoints[1]), false); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToVisibleGarrisoning(33, cmpGarrisonHolder.visibleGarrisonPoints[2]), true); | |||||
Freagarach: I would state: `If an entity gets renamed (e.g. promotion)` for it could also be upgrade… | |||||
Done Inline ActionsOne could send an OwnershipChanged message here? Sounds cleaner. Freagarach: One could send an `OwnershipChanged` message here? Sounds cleaner. | |||||
Done Inline ActionsSure. Stan: Sure. | |||||
Done Inline ActionsWhy not use player directly? Freagarach: Why not use player directly? | |||||
Done Inline ActionsSo I can change it below :) Stan: So I can change it below :) | |||||
Done Inline Actions+\n Freagarach: +`\n` | |||||
Done Inline ActionsHere. Hence changing the result of the call. Stan: Here. Hence changing the result of the call. | |||||
Done Inline Actions-n. Freagarach: -`n`. |
Wildfire Games · Phabricator
I would state: If an entity gets renamed (e.g. promotion) for it could also be upgrade (Maurayan archer in DE, IIRC).