1 | // TODO: Move that in another folder
|
---|
2 |
|
---|
3 | let template ={};
|
---|
4 |
|
---|
5 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), []);
|
---|
6 |
|
---|
7 | template.requirements = { "all": [{ "entity": { "class": "Village", "number": 5 } }, { "civ": "athen" }] };
|
---|
8 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ entities: [{ class:"Village", number:5, check:"count" }] }]);
|
---|
9 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "spart"), false);
|
---|
10 |
|
---|
11 | template.requirements = { "all": [{ "entity": { "class": "Village", "numberOfTypes": 5 } }, { "civ": "athen" }] };
|
---|
12 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ entities:[{ class:"Village", number:5, check:"variants" }] }]);
|
---|
13 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "spart"), false);
|
---|
14 |
|
---|
15 | template.requirements = { "all": [{ "tech": "phase_town" }, { "notciv": "maur" }, { "notciv": "spart" }] };
|
---|
16 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ "techs": ["phase_town"] }]);
|
---|
17 |
|
---|
18 | template.requirements = { "all": [{ "tech": "phase_town" }, { "all": [{ "notciv": "maur" }, { "notciv": "spart" }] }] };
|
---|
19 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ "techs": ["phase_town"] }]);
|
---|
20 |
|
---|
21 | template.requirements = { "all": [{ "entity": { "class": "Village", "numberOfTypes": 5 } }, { "entity": { "class": "Melee", "number": 6 } }, { "civ": "athen" }] };
|
---|
22 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"),
|
---|
23 | [{ entities: [{ class:"Village", number:5, check:"variants" }, { class:"Melee", number:6, check:"count" }] } ]);
|
---|
24 |
|
---|
25 | template.requirements = { "all": [{ "tech": "phase_city" }, { "any": [{ "civ": "brit"}, { "civ": "gaul"}, { "civ": "iber"}, { "civ": "mace"}, { "civ": "maur" }, { "civ": "rome" }] }] };
|
---|
26 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), false);
|
---|
27 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "brit"), [{ "techs": ["phase_city"] }]);
|
---|
28 |
|
---|
29 | template.requirements =
|
---|
30 | { "all": [{ "any":[{ "entity": { "class": "Village", "numberOfTypes": 5 } },
|
---|
31 | { "entity": { "class": "Melee", "number": 6 } }] }, { "civ": "athen" }] };
|
---|
32 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"),
|
---|
33 | [{ "entities" : [{ class:"Village", "number":5, "check":"variants" }] }, { "entities": [{ class: "Melee", "number": 6, "check": "count" }] }]);
|
---|
34 |
|
---|
35 | template.requirements =
|
---|
36 | { "all": [{ "tech": "tech1" }, { "any": [{ "civ": "civA" }, { "civ": "civB" }]}, { "notciv": "civC" }] };
|
---|
37 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }]);
|
---|
38 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civC"), false);
|
---|
39 |
|
---|
40 | template.requirements =
|
---|
41 | { "any": [{ "all": [{ "civ": "civA" }, { "tech": "tech1" }] }, { "tech": "tech2" }] };
|
---|
42 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }, { "techs": ["tech2"] }]);
|
---|
43 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civB"), [{ "techs": ["tech2"] }]);
|
---|
44 |
|
---|
45 | template.requirements =
|
---|
46 | { "any": [{ "all": [{ "civ": "civA" }, { "tech": "tech1" }] }, { "all": [{ "civ": "civB" }, { "tech": "tech2" }] }] };
|
---|
47 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }]);
|
---|
48 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civB"), [{ "techs": ["tech2"] }]);
|
---|
49 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civC"), false);
|
---|
50 |
|
---|
51 | template.requirements =
|
---|
52 | { "any": [{ "all": [{ "civ": "civA" }, { "tech": "tech1" }] }, { "all": [{ "any": [{ "civ": "civB" }, { "civ": "civC" }] }, { "tech": "tech2" }] }] };
|
---|
53 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }]);
|
---|
54 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civC"), [{ "techs": ["tech2"] }]);
|
---|
55 | TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civD"), false);
|
---|