Differential D2652 Diff 13450 binaries/data/mods/public/simulation/components/tests/test_ProductionQueue.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_ProductionQueue.js
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadHelperScript("Sound.js"); | Engine.LoadHelperScript("Sound.js"); | ||||
Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | ||||
Engine.LoadComponentScript("interfaces/ProductionQueue.js"); | Engine.LoadComponentScript("interfaces/ProductionQueue.js"); | ||||
Engine.LoadComponentScript("interfaces/BuildRestrictions.js"); | Engine.LoadComponentScript("interfaces/BuildRestrictions.js"); | ||||
Engine.LoadComponentScript("interfaces/EntityLimits.js"); | Engine.LoadComponentScript("interfaces/EntityLimits.js"); | ||||
Engine.LoadComponentScript("interfaces/Foundation.js"); | Engine.LoadComponentScript("interfaces/Foundation.js"); | ||||
Engine.LoadComponentScript("interfaces/StatisticsTracker.js"); | Engine.LoadComponentScript("interfaces/StatisticsTracker.js"); | ||||
Engine.LoadComponentScript("interfaces/Timer.js"); | Engine.LoadComponentScript("interfaces/Timer.js"); | ||||
Engine.LoadComponentScript("interfaces/TrainingRestrictions.js"); | Engine.LoadComponentScript("interfaces/TrainingRestrictions.js"); | ||||
Engine.LoadComponentScript("interfaces/Trigger.js"); | Engine.LoadComponentScript("interfaces/Trigger.js"); | ||||
Engine.LoadComponentScript("interfaces/Upgrade.js"); | |||||
Engine.LoadComponentScript("EntityLimits.js"); | Engine.LoadComponentScript("EntityLimits.js"); | ||||
Engine.RegisterGlobal("Resources", { | Engine.RegisterGlobal("Resources", { | ||||
"BuildSchema": (a, b) => {} | "BuildSchema": (a, b) => {} | ||||
}); | }); | ||||
Engine.LoadComponentScript("ProductionQueue.js"); | Engine.LoadComponentScript("ProductionQueue.js"); | ||||
Engine.LoadComponentScript("TrainingRestrictions.js"); | Engine.LoadComponentScript("TrainingRestrictions.js"); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | function testEntitiesList() | ||||
AddMock(productionQueueId, IID_Ownership, { | AddMock(productionQueueId, IID_Ownership, { | ||||
"GetOwner": () => playerId | "GetOwner": () => playerId | ||||
}); | }); | ||||
AddMock(productionQueueId, IID_Identity, { | AddMock(productionQueueId, IID_Identity, { | ||||
"GetCiv": () => "iber" | "GetCiv": () => "iber" | ||||
}); | }); | ||||
AddMock(productionQueueId, IID_Upgrade, { | |||||
"IsUpgrading": () => false | |||||
}); | |||||
cmpProductionQueue.CalculateEntitiesMap(); | cmpProductionQueue.CalculateEntitiesMap(); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
cmpProductionQueue.GetEntitiesList(), | cmpProductionQueue.GetEntitiesList(), | ||||
["units/iber_cavalry_javelineer_b", "units/iber_infantry_swordsman_b", "units/iber_support_female_citizen"] | ["units/iber_cavalry_javelineer_b", "units/iber_infantry_swordsman_b", "units/iber_support_female_citizen"] | ||||
); | ); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
cmpProductionQueue.GetTechnologiesList(), | cmpProductionQueue.GetTechnologiesList(), | ||||
["gather_fishing_net", "phase_town_generic", "phase_city_generic"] | ["gather_fishing_net", "phase_town_generic", "phase_city_generic"] | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | function regression_test_d1879() | ||||
TS_ASSERT_EQUALS(cmpEntLimits.GetCounts().some_limit, 3); | TS_ASSERT_EQUALS(cmpEntLimits.GetCounts().some_limit, 3); | ||||
// Now check that it doesn't get updated when the spawn doesn't succeed. | // Now check that it doesn't get updated when the spawn doesn't succeed. | ||||
AddMock(testEntity, IID_Footprint, { | AddMock(testEntity, IID_Footprint, { | ||||
"PickSpawnPoint": () => ({ "x": -1, "y": -1, "z": -1 }) | "PickSpawnPoint": () => ({ "x": -1, "y": -1, "z": -1 }) | ||||
}); | }); | ||||
AddMock(testEntity, IID_Upgrade, { | |||||
"IsUpgrading": () => false | |||||
}); | |||||
cmpProdQueue.AddBatch("some_template", "unit", 3); | cmpProdQueue.AddBatch("some_template", "unit", 3); | ||||
Engine.QueryInterface(testEntity, IID_ProductionQueue).ProgressTimeout(); | Engine.QueryInterface(testEntity, IID_ProductionQueue).ProgressTimeout(); | ||||
TS_ASSERT_EQUALS(cmpProdQueue.GetQueue().length, 1); | TS_ASSERT_EQUALS(cmpProdQueue.GetQueue().length, 1); | ||||
TS_ASSERT_EQUALS(cmpEntLimits.GetCounts().some_limit, 6); | TS_ASSERT_EQUALS(cmpEntLimits.GetCounts().some_limit, 6); | ||||
} | } | ||||
function test_token_changes() | function test_token_changes() | ||||
{ | { | ||||
const ent = 10; | const ent = 10; | ||||
Freagarach: Comment not needed. | |||||
Not Done Inline Actions^ Freagarach: ^ | |||||
let cmpProductionQueue = ConstructComponent(10, "ProductionQueue", { | let cmpProductionQueue = ConstructComponent(10, "ProductionQueue", { | ||||
"Entities": { "_string": "units/{civ}_a " + | "Entities": { "_string": "units/{civ}_a " + | ||||
"units/{civ}_b" }, | "units/{civ}_b" }, | ||||
"Technologies": { "_string": "a " + | "Technologies": { "_string": "a " + | ||||
"b_{civ} " + | "b_{civ} " + | ||||
"c_{civ}" }, | "c_{civ}" }, | ||||
"BatchTimeModifier": 1 | "BatchTimeModifier": 1 | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Comment not needed.