Differential D274 Diff 7220 binaries/data/mods/public/simulation/components/tests/test_Technologies_effects.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_Technologies_effects.js
- This file was added.
// TODO: Move this to a folder of tests for GlobalScripts (once one is created) | |||||
// This tests the GetTechModifiedProperty function. | |||||
let add = { | |||||
"Test_A": [{ "add": 10, "affects": "Unit" }] | |||||
}; | |||||
let add_add = { | |||||
"Test_A": [{ "add": 10, "affects": "Unit" }, { "add": 5, "affects": "Unit" }] | |||||
}; | |||||
let add_mul_add = { | |||||
"Test_A": [{ "add": 10, "affects": "Unit" }, { "multiply": 2, "affects": "Unit" }, { "add": 5, "affects": "Unit" }] | |||||
}; | |||||
let add_replace = { | |||||
"Test_A": [{ "add": 10, "affects": "Unit" }, { "replace": 10, "affects": "Unit" }] | |||||
}; | |||||
let replace_add = { | |||||
"Test_A": [{ "replace": 10, "affects": "Unit" }, { "add": 10, "affects": "Unit" }] | |||||
}; | |||||
let replace_replace = { | |||||
"Test_A": [{ "replace": 10, "affects": "Unit" }, { "replace": 30, "affects": "Unit" }] | |||||
}; | |||||
let replace_nonnum = { | |||||
"Test_A": [{ "replace": "alpha", "affects": "Unit" }] | |||||
}; | |||||
TS_ASSERT_EQUALS(GetTechModifiedProperty(add, "Unit", "Test_A", 5), 15); | |||||
TS_ASSERT_EQUALS(GetTechModifiedProperty(add_add, "Unit", "Test_A", 5), 20); | |||||
TS_ASSERT_EQUALS(GetTechModifiedProperty(add_add, "Other", "Test_A", 5), 5); | |||||
// Technologies work by multiplying then adding all. | |||||
TS_ASSERT_EQUALS(GetTechModifiedProperty(add_mul_add, "Unit", "Test_A", 5), 25); | |||||
TS_ASSERT_EQUALS(GetTechModifiedProperty(add_replace, "Unit", "Test_A", 5), 10); | |||||
// Only the first replace is taken into account | |||||
TS_ASSERT_EQUALS(GetTechModifiedProperty(replace_replace, "Unit", "Test_A", 5), 10); | |||||
TS_ASSERT_EQUALS(GetTechModifiedProperty(replace_nonnum, "Unit", "Test_A", "beta"), "alpha"); |
Wildfire Games · Phabricator