Differential D2374 Diff 16639 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 All 26 Lines | let cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { | ||||
"LoadingRange": "2.1", | "LoadingRange": "2.1", | ||||
"Pickup": false | "Pickup": false | ||||
}); | }); | ||||
AddMock(garrisonHolderId, IID_Ownership, { | AddMock(garrisonHolderId, IID_Ownership, { | ||||
"GetOwner": () => player | "GetOwner": () => player | ||||
}); | }); | ||||
AddMock(player, IID_Player, { | AddMock(player, IID_Player, { | ||||
"IsAlly": id => id != enemyPlayer, | "IsAlly": id => id != enemyPlayer, | ||||
"IsMutualAlly": id => id != enemyPlayer, | "IsMutualAlly": id => id != enemyPlayer, | ||||
Freagarach: This was wrong all the time,,, | |||||
"IsEnemy": id => id == enemyPlayer, | |||||
"GetPlayerID": () => player | "GetPlayerID": () => player | ||||
}); | }); | ||||
AddMock(friendlyPlayer, IID_Player, { | AddMock(friendlyPlayer, IID_Player, { | ||||
"IsAlly": id => true, | "IsAlly": id => true, | ||||
"IsMutualAlly": id => true, | "IsMutualAlly": id => true, | ||||
"GetPlayerID": () => friendlyPlayer | "GetPlayerID": () => friendlyPlayer | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | |||||
TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetAllowedClasses().split(/\s+/), ["Infantry+Ranged", "Cavalry", "Trader"]); | TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetAllowedClasses().split(/\s+/), ["Infantry+Ranged", "Cavalry", "Trader"]); | ||||
// The new classes are now cached so we can restore the behavior. | // The new classes are now cached so we can restore the behavior. | ||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity", oldApplyValueModificationsToEntity); | Engine.RegisterGlobal("ApplyValueModificationsToEntity", oldApplyValueModificationsToEntity); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetEntities(), []); | TS_ASSERT_UNEVAL_EQUALS(cmpGarrisonHolder.GetEntities(), []); | ||||
TS_ASSERT(!cmpGarrisonHolder.Garrison(siegeEngineId)); | TS_ASSERT(!cmpGarrisonHolder.Garrison(siegeEngineId)); | ||||
TS_ASSERT(cmpGarrisonHolder.Garrison(traderId)); | TS_ASSERT(cmpGarrisonHolder.Garrison(traderId)); | ||||
// Test allowed players. | |||||
cmpGarrisonHolder = ConstructComponent(garrisonHolderId, "GarrisonHolder", { | |||||
"Max": 10, | |||||
"List": { "_string": "Infantry+Cavalry" }, | |||||
"EjectHealth": 0.1, | |||||
"EjectClassesOnDestroy": { "_string": "Infantry" }, | |||||
"BuffHeal": 1, | |||||
"LoadingRange": 2.1, | |||||
"Pickup": false, | |||||
"AllowedPlayers": "Enemy", | |||||
"VisibleGarrisonPoints": { | |||||
"archer1": { | |||||
"X": 12, | |||||
"Y": 5, | |||||
"Z": 6 | |||||
}, | |||||
"archer2": { | |||||
"X": 15, | |||||
"Y": 5, | |||||
"Z": 6 | |||||
} | |||||
} | |||||
}); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.IsAllowedToGarrison(enemyUnitId), true); | |||||
TS_ASSERT_EQUALS(cmpGarrisonHolder.IsAllowedToGarrison(unitToGarrisonId), false); |
Wildfire Games · Phabricator
This was wrong all the time,,,