1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
#include "NewsArticle.hpp"
#include <openvic-dataloader/v2script/Parser.hpp>
#include "openvic-simulation/dataloader/NodeTools.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
node_callback_t Typed::expect_typed_objects(length_callback_t length_callback, callback_t<std::unique_ptr<Typed>&&> callback) {
return expect_dictionary_keys_and_length(
length_callback,
//_expect_instance<Typed, Actor>(callback)
/*"news_priority", ZERO_OR_MORE, expect_dictionary_keys(
"case", ZERO_OR_MORE, success_callback
),*/
"news_priority", ZERO_OR_MORE, _expect_instance<Typed, NewsPriority>(callback),
"generator_selector", ZERO_OR_MORE, expect_dictionary_keys(
"case", ZERO_OR_MORE, success_callback,
"@2@", ZERO_OR_MORE, success_callback//expect_identifier_or_string()
),
"generate_article", ZERO_OR_MORE, expect_dictionary_keys(
"size", ZERO_OR_MORE, success_callback,
"picture_case", ZERO_OR_MORE, success_callback,
"title_case", ZERO_OR_MORE, success_callback,
"description_case", ZERO_OR_MORE, success_callback
),
"on_printing", ZERO_OR_MORE, expect_dictionary_keys(
"effect", ZERO_OR_MORE, success_callback
)
);
}
/*
Case(size_t new_index, fixed_point_t new_value, fixed_point_t priority_add,
std::string_view picture_path, ConditionScript&& new_trigger);
*/
Case::Case( size_t new_index, fixed_point_t new_value,
fixed_point_t new_priority_add, std::string_view picture_path, ConditionScript&& new_trigger)
: HasIdentifier { std::to_string(new_index) }, value { 0 }, priority_add { 0 },
picture { }, trigger { std::move(new_trigger) } {}
bool Case::parse_scripts(DefinitionManager const& definition_manager) {
return trigger.parse_script(true, definition_manager);
}
bool Case::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
return add_key_map_entries(key_map,
"trigger", ZERO_OR_ONE, trigger.expect_script(),
"value", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(value)),
"picture", ZERO_OR_ONE, expect_string(assign_variable_callback_string(picture)),
"priority_add", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(priority_add))
);
}
//NewsPriority::NewsPriority() : priority_case { } {}
bool NewsPriority::_fill_key_map(NodeTools::case_insensitive_key_map_t &key_map){
return true;
}
/*
EffectScript effect;
bool ret = expect_dictionary_keys(
"alert", ZERO_OR_ONE, expect_bool(assign_variable_callback(alert)),
...
"effect", ONE_EXACTLY, effect.expect_script(),
*/
/*
0+ generator_selector
1 string type
1 string name = "default"
0+ case = { value = int }
case = {trigger = { news_printing_count = 1 value = -999}}
can have '@2@' ?? if generator_selector is in a pattern
*/
/*
node_callback_t Object::expect_objects(length_callback_t length_callback, callback_t<std::unique_ptr<Object>&&> callback) {
return expect_dictionary_keys_and_length(
length_callback,
"EMFXActorType", ZERO_OR_MORE, _expect_instance<Object, Actor>(callback),
*/
/*
"actorfile", ONE_EXACTLY, expect_string(assign_variable_callback_string(model_file)),
"scale", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(scale)),
"attach", ZERO_OR_MORE, [this](ast::NodeCPtr node) -> bool {
std::string_view actor_name {}, attach_node {};
Attachment::attach_id_t attach_id = 0;
if (!expect_dictionary_keys<StringMapCaseInsensitive>(
"name", ONE_EXACTLY, expect_string(assign_variable_callback(actor_name)),
"node", ONE_EXACTLY, expect_string(assign_variable_callback(attach_node)),
"attachId", ONE_EXACTLY, expect_uint(assign_variable_callback(attach_id))
)(node)) {
Logger::error("Failed to load attachment for actor ", get_name());
return false;
}
attachments.push_back({ actor_name, attach_node, attach_id });
return true;
},
*/
/*
bool Actor::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map) {
bool ret = Object::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"actorfile", ONE_EXACTLY,
*/
/*bool SongChanceManager::load_songs_file(ast::NodeCPtr root) {
bool ret = true;
ret &= expect_dictionary_reserve_length(
song_chances,
[this](std::string_view key, ast::NodeCPtr value) -> bool {
if (key != "song") {
Logger::error("Invalid song declaration ", key);
return false;
}
std::string_view name {};
ConditionalWeight chance { scope_t::COUNTRY, scope_t::COUNTRY, scope_t::NO_SCOPE };
bool ret = expect_dictionary_keys(
"name", ONE_EXACTLY, expect_string(assign_variable_callback(name)),
"chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::FACTOR)
)(value);
ret &= song_chances.add_item({ song_chances.size(), name, std::move(chance) });
return ret;
}
)(root);
if (song_chances.size() == 0) {
Logger::error("No songs found in Songs.txt");
return false;
}
return ret;
}
bool SongChanceManager::parse_scripts(DefinitionManager const& definition_manager) {
bool ret = true;
for (SongChance& songChance : song_chances.get_items()) {
ret &= songChance.parse_scripts(definition_manager);
}
return ret;
}*/
/*
"bonus", ZERO_OR_MORE, [&bonuses](ast::NodeCPtr bonus_node) -> bool {
ConditionScript trigger { scope_t::STATE, scope_t::NO_SCOPE, scope_t::NO_SCOPE };
fixed_point_t bonus_value {};
const bool ret = expect_dictionary_keys(
"trigger", ONE_EXACTLY, trigger.expect_script(),
"value", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(bonus_value))
)(bonus_node);
bonuses.emplace_back(std::move(trigger), bonus_value);
return ret;
},
*/
|