Differential D3792 Diff 17177 binaries/data/mods/public/simulation/components/tests/test_Foundation.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_Foundation.js
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | function testFoundation(...mocks) | ||||
for (let mock of mocks) | for (let mock of mocks) | ||||
AddMock(...mock); | AddMock(...mock); | ||||
// INITIALISE | // INITIALISE | ||||
Engine.AddLocalEntity = function(template) { | Engine.AddLocalEntity = function(template) { | ||||
TS_ASSERT_EQUALS(template, "construction|" + finalTemplate); | TS_ASSERT_EQUALS(template, "construction|" + finalTemplate); | ||||
return previewEnt; | return previewEnt; | ||||
}; | }; | ||||
cmpFoundation = ConstructComponent(foundationEnt, "Foundation", {}); | cmpFoundation = ConstructComponent(foundationEnt, "Foundation", { | ||||
"BuildTimeModifier": "0.7" | |||||
}); | |||||
cmpFoundation.InitialiseConstruction(finalTemplate); | cmpFoundation.InitialiseConstruction(finalTemplate); | ||||
TS_ASSERT_EQUALS(cmpFoundation.finalTemplateName, finalTemplate); | TS_ASSERT_EQUALS(cmpFoundation.finalTemplateName, finalTemplate); | ||||
TS_ASSERT_EQUALS(cmpFoundation.maxProgress, 0); | TS_ASSERT_EQUALS(cmpFoundation.maxProgress, 0); | ||||
TS_ASSERT_EQUALS(cmpFoundation.initialised, true); | TS_ASSERT_EQUALS(cmpFoundation.initialised, true); | ||||
// BUILDER COUNT, BUILD RATE, TIME REMAINING | // BUILDER COUNT, BUILD RATE, TIME REMAINING | ||||
AddMock(10, IID_Builder, { "GetRate": () => 1.0 }); | AddMock(10, IID_Builder, { "GetRate": () => 1.0 }); | ||||
Stan: Could test 0 :P | |||||
AddMock(11, IID_Builder, { "GetRate": () => 1.0 }); | AddMock(11, IID_Builder, { "GetRate": () => 1.0 }); | ||||
let twoBuilderMultiplier = Math.pow(2, cmpFoundation.buildTimePenalty) / 2; | let twoBuilderMultiplier = Math.pow(2, cmpFoundation.buildTimeModifier) / 2; | ||||
let threeBuilderMultiplier = Math.pow(3, cmpFoundation.buildTimePenalty) / 3; | let threeBuilderMultiplier = Math.pow(3, cmpFoundation.buildTimeModifier) / 3; | ||||
TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(1), 1); | TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(1), 1); | ||||
TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(2), twoBuilderMultiplier); | TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(2), twoBuilderMultiplier); | ||||
TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(3), threeBuilderMultiplier); | TS_ASSERT_EQUALS(cmpFoundation.CalculateBuildMultiplier(3), threeBuilderMultiplier); | ||||
TS_ASSERT_EQUALS(cmpFoundation.GetBuildRate(), 2); | TS_ASSERT_EQUALS(cmpFoundation.GetBuildRate(), 2); | ||||
TS_ASSERT_EQUALS(cmpFoundation.GetNumBuilders(), 0); | TS_ASSERT_EQUALS(cmpFoundation.GetNumBuilders(), 0); | ||||
TS_ASSERT_EQUALS(cmpFoundation.totalBuilderRate, 0); | TS_ASSERT_EQUALS(cmpFoundation.totalBuilderRate, 0); | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Could test 0 :P