Differential D2374 Diff 10153 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 27 Lines | |||||
}); | }); | ||||
AddMock(garrisonHolderId, IID_Health, { | AddMock(garrisonHolderId, IID_Health, { | ||||
"GetHitpoints": () => 50, | "GetHitpoints": () => 50, | ||||
"GetMaxHitpoints": () => 600 | "GetMaxHitpoints": () => 600 | ||||
}); | }); | ||||
AddMock(player, IID_Player, { | AddMock(player, IID_Player, { | ||||
"IsAlly": id => true, | "IsAlly": id => id != enemyPlayer, | ||||
"IsMutualAlly": id => true, | "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 => id != enemyPlayer, | ||||
"IsMutualAlly": id => true, | "IsMutualAlly": id => id != enemyPlayer, | ||||
"GetPlayerID": () => friendlyPlayer | "GetPlayerID": () => friendlyPlayer | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_Timer, { | AddMock(SYSTEM_ENTITY, IID_Timer, { | ||||
"SetTimeout": (ent, iid, funcname, time, data) => 1 | "SetTimeout": (ent, iid, funcname, time, data) => 1 | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
▲ Show 20 Lines • Show All 111 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(), []); | ||||
// 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,,,