Differential D3223 Diff 16124 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js
Engine.LoadHelperScript("ValueModification.js"); | Engine.LoadHelperScript("ValueModification.js"); | ||||
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadComponentScript("interfaces/GarrisonHolder.js"); | Engine.LoadComponentScript("interfaces/GarrisonHolder.js"); | ||||
Engine.LoadComponentScript("interfaces/Garrisonable.js"); | Engine.LoadComponentScript("interfaces/Garrisonable.js"); | ||||
Engine.LoadComponentScript("interfaces/TurretHolder.js"); | Engine.LoadComponentScript("interfaces/TurretHolder.js"); | ||||
Engine.LoadComponentScript("GarrisonHolder.js"); | Engine.LoadComponentScript("GarrisonHolder.js"); | ||||
Engine.LoadComponentScript("interfaces/Auras.js"); | |||||
Engine.LoadComponentScript("interfaces/Health.js"); | Engine.LoadComponentScript("interfaces/Health.js"); | ||||
Engine.LoadComponentScript("interfaces/ProductionQueue.js"); | |||||
Engine.LoadComponentScript("interfaces/ModifiersManager.js"); | Engine.LoadComponentScript("interfaces/ModifiersManager.js"); | ||||
Engine.LoadComponentScript("interfaces/Timer.js"); | Engine.LoadComponentScript("interfaces/Timer.js"); | ||||
Engine.LoadComponentScript("interfaces/UnitAI.js"); | |||||
const garrisonedEntitiesList = [25, 26, 27, 28, 29, 30, 31, 32, 33]; | const garrisonedEntitiesList = [25, 26, 27, 28, 29, 30, 31, 32, 33]; | ||||
const garrisonHolderId = 15; | const garrisonHolderId = 15; | ||||
const unitToGarrisonId = 24; | const unitToGarrisonId = 24; | ||||
const enemyUnitId = 34; | const enemyUnitId = 34; | ||||
const player = 1; | const player = 1; | ||||
const friendlyPlayer = 2; | const friendlyPlayer = 2; | ||||
const enemyPlayer = 3; | const enemyPlayer = 3; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | else if (i == 34) | ||||
}); | }); | ||||
else | else | ||||
AddMock(i, IID_Ownership, { | AddMock(i, IID_Ownership, { | ||||
"GetOwner": () => friendlyPlayer | "GetOwner": () => friendlyPlayer | ||||
}); | }); | ||||
AddMock(i, IID_Garrisonable, { | AddMock(i, IID_Garrisonable, { | ||||
"Garrison": entity => true, | "Garrison": entity => true, | ||||
"UnGarrison": () => {} | "UnGarrison": () => true | ||||
}); | }); | ||||
AddMock(i, IID_Position, { | AddMock(i, IID_Position, { | ||||
"GetHeightOffset": () => 0, | "GetHeightOffset": () => 0, | ||||
"GetPosition": () => new Vector3D(4, 3, 25), | "GetPosition": () => new Vector3D(4, 3, 25), | ||||
"GetRotation": () => new Vector3D(4, 0, 6), | "GetRotation": () => new Vector3D(4, 0, 6), | ||||
"JumpTo": (posX, posZ) => {}, | "JumpTo": (posX, posZ) => {}, | ||||
"MoveOutOfWorld": () => {}, | "MoveOutOfWorld": () => {}, | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | AddMock(siegeEngineId, IID_Position, { | ||||
"SetHeightOffset": height => {} | "SetHeightOffset": height => {} | ||||
}); | }); | ||||
let currentSiegePlayer = player; | let currentSiegePlayer = player; | ||||
AddMock(siegeEngineId, IID_Ownership, { | AddMock(siegeEngineId, IID_Ownership, { | ||||
"GetOwner": () => currentSiegePlayer | "GetOwner": () => currentSiegePlayer | ||||
}); | }); | ||||
AddMock(siegeEngineId, IID_Garrisonable, { | AddMock(siegeEngineId, IID_Garrisonable, { | ||||
"Garrison": entity => true, | "Garrison": entity => true, | ||||
"UnGarrison": () => {} | "UnGarrison": () => true | ||||
}); | }); | ||||
let cavalryId = 46; | let cavalryId = 46; | ||||
AddMock(cavalryId, IID_Identity, { | AddMock(cavalryId, IID_Identity, { | ||||
"GetClassesList": () => ["Infantry", "Ranged"] | "GetClassesList": () => ["Infantry", "Ranged"] | ||||
}); | }); | ||||
AddMock(cavalryId, IID_Position, { | AddMock(cavalryId, IID_Position, { | ||||
"GetHeightOffset": () => 0, | "GetHeightOffset": () => 0, | ||||
"GetPosition": () => new Vector3D(4, 3, 25), | "GetPosition": () => new Vector3D(4, 3, 25), | ||||
"GetRotation": () => new Vector3D(4, 0, 6), | "GetRotation": () => new Vector3D(4, 0, 6), | ||||
"JumpTo": (posX, posZ) => {}, | "JumpTo": (posX, posZ) => {}, | ||||
"MoveOutOfWorld": () => {}, | "MoveOutOfWorld": () => {}, | ||||
"SetHeightOffset": height => {} | "SetHeightOffset": height => {} | ||||
}); | }); | ||||
let currentCavalryPlayer = player; | let currentCavalryPlayer = player; | ||||
AddMock(cavalryId, IID_Ownership, { | AddMock(cavalryId, IID_Ownership, { | ||||
"GetOwner": () => currentCavalryPlayer | "GetOwner": () => currentCavalryPlayer | ||||
}); | }); | ||||
AddMock(cavalryId, IID_Garrisonable, { | AddMock(cavalryId, IID_Garrisonable, { | ||||
"Garrison": entity => true, | "Garrison": entity => true, | ||||
"UnGarrison": () => {} | "UnGarrison": () => true | ||||
}); | }); | ||||
TS_ASSERT(cmpGarrisonHolder.Garrison(siegeEngineId)); | TS_ASSERT(cmpGarrisonHolder.Garrison(siegeEngineId)); | ||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 1); | TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 1); | ||||
cmpGarrisonHolder.OnGlobalEntityRenamed({ | cmpGarrisonHolder.OnGlobalEntityRenamed({ | ||||
"entity": siegeEngineId, | "entity": siegeEngineId, | ||||
"newentity": cavalryId | "newentity": cavalryId | ||||
}); | }); | ||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 1); | TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 1); | ||||
Show All 34 Lines |
Wildfire Games · Phabricator