From be5b300abda22f0bc2147f433d6468fe9ba0eb23 Mon Sep 17 00:00:00 2001 From: fatherbushido Date: Mon, 31 Jul 2017 11:21:34 +0000 Subject: [PATCH] Add a test for the DeriveModificationsFromTech script. It emphasizes the syntax to use for editing specific affects in technologies files. Reviewed by s0600204. Differential Revision: https://code.wildfiregames.com/D696 This was SVN commit r19939. --- .../components/tests/test_Technologies.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/binaries/data/mods/public/simulation/components/tests/test_Technologies.js b/binaries/data/mods/public/simulation/components/tests/test_Technologies.js index db7e5a1c0a..47608c94a8 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Technologies.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Technologies.js @@ -508,3 +508,76 @@ template.requirements = { TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }]); TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civC"), [{ "techs": ["tech2"] }]); TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civD"), false); + +// Test DeriveModificationsFromTech +template = { + "modifications": [{ + "value": "ResourceGatherer/Rates/food.grain", + "multiply": 15, + "affects": "Spearman Swordman" + }, + { + "value": "ResourceGatherer/Rates/food.meat", + "multiply": 10 + }], + "affects": ["Female", "CitizenSoldier Melee"] +}; +let techMods = { + "ResourceGatherer/Rates/food.grain": [{ + "affects": [ + ["Female", "Spearman", "Swordman"], + ["CitizenSoldier", "Melee", "Spearman", "Swordman"] + ], + "multiply": 15 + }], + "ResourceGatherer/Rates/food.meat": [{ + "affects": [ + ["Female"], + ["CitizenSoldier", "Melee"] + ], + "multiply": 10 + }] +}; +TS_ASSERT_UNEVAL_EQUALS(DeriveModificationsFromTech(template), techMods); + +template = { + "modifications": [{ + "value": "ResourceGatherer/Rates/food.grain", + "multiply": 15, + "affects": "Spearman" + }, + { + "value": "ResourceGatherer/Rates/food.grain", + "multiply": 15, + "affects": "Swordman" + }, + { + "value": "ResourceGatherer/Rates/food.meat", + "multiply": 10 + }], + "affects": ["Female", "CitizenSoldier Melee"] +}; +techMods = { + "ResourceGatherer/Rates/food.grain": [{ + "affects": [ + ["Female", "Spearman"], + ["CitizenSoldier", "Melee", "Spearman"] + ], + "multiply": 15 + }, + { + "affects": [ + ["Female", "Swordman"], + ["CitizenSoldier", "Melee", "Swordman"] + ], + "multiply": 15 + }], + "ResourceGatherer/Rates/food.meat": [{ + "affects": [ + ["Female"], + ["CitizenSoldier", "Melee"] + ], + "multiply": 10 + }] +}; +TS_ASSERT_UNEVAL_EQUALS(DeriveModificationsFromTech(template), techMods);