1 #ifndef _Conditions_h_
2 #define _Conditions_h_
3
4
5 #include "EnumsFwd.h"
6 #include "Condition.h"
7 #include "ConditionSource.h"
8 #include "ConditionAll.h"
9
10 #include "../util/Export.h"
11 #include "../util/CheckSums.h"
12
13 #include <boost/serialization/nvp.hpp>
14
15 #include <memory>
16 #include <string>
17 #include <vector>
18
19
20 namespace ValueRef {
21 template <typename T>
22 struct ValueRef;
23 }
24
25 /** this namespace holds Condition and its subclasses; these classes
26 * represent predicates about UniverseObjects used by, for instance, the
27 * Effect system. */
28 namespace Condition {
29
30 enum SortingMethod : int {
31 SORT_MAX, ///< Objects with the largest sort key will be selected
32 SORT_MIN, ///< Objects with the smallest sort key will be selected
33 SORT_MODE, ///< Objects with the most common sort key will be selected
34 SORT_RANDOM ///< Objects will be selected randomly, without consideration of property values
35 };
36
37 enum ComparisonType : int {
38 INVALID_COMPARISON = -1,
39 EQUAL,
40 GREATER_THAN,
41 GREATER_THAN_OR_EQUAL,
42 LESS_THAN,
43 LESS_THAN_OR_EQUAL,
44 NOT_EQUAL
45 };
46
47 enum ContentType : int {
48 CONTENT_BUILDING,
49 CONTENT_SPECIES,
50 CONTENT_SHIP_HULL,
51 CONTENT_SHIP_PART,
52 CONTENT_SPECIAL,
53 CONTENT_FOCUS
54 };
55
56 /** Same as ConditionDescription, but returns a string only with conditions that have not been met. */
57 FO_COMMON_API std::string ConditionFailedDescription(const std::vector<Condition*>& conditions,
58 std::shared_ptr<const UniverseObject> candidate_object = nullptr,
59 std::shared_ptr<const UniverseObject> source_object = nullptr);
60
61 /** Returns a single string which describes a vector of Conditions. If multiple
62 * conditions are passed, they are treated as if they were contained by an And
63 * condition. Subconditions within an And (or nested And) are listed as
64 * lines in a list, with duplicates removed, titled something like "All of...".
65 * Subconditions within an Or (or nested Ors) are similarly listed as lines in
66 * a list, with duplicates removed, titled something like "One of...". If a
67 * candidate object is provided, the returned string will indicate which
68 * subconditions the candidate matches, and indicate if the overall combination
69 * of conditions matches the object. */
70 FO_COMMON_API std::string ConditionDescription(const std::vector<Condition*>& conditions,
71 std::shared_ptr<const UniverseObject> candidate_object = nullptr,
72 std::shared_ptr<const UniverseObject> source_object = nullptr);
73
74 /** Matches all objects if the number of objects that match Condition
75 * \a condition is is >= \a low and < \a high. Matched objects may
76 * or may not themselves match the condition. */
77 struct FO_COMMON_API Number final : public Condition {
78 Number(std::unique_ptr<ValueRef::ValueRef<int>>&& low,
79 std::unique_ptr<ValueRef::ValueRef<int>>&& high,
80 std::unique_ptr<Condition>&& condition);
81
82 bool operator==(const Condition& rhs) const override;
83 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
84 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
85 std::string Description(bool negated = false) const override;
86 std::string Dump(unsigned short ntabs = 0) const override;
87 void SetTopLevelContent(const std::string& content_name) override;
88 unsigned int GetCheckSum() const override;
89
90 private:
91 bool Match(const ScriptingContext& local_context) const override;
92
93 std::unique_ptr<ValueRef::ValueRef<int>> m_low;
94 std::unique_ptr<ValueRef::ValueRef<int>> m_high;
95 std::unique_ptr<Condition> m_condition;
96
97 friend class boost::serialization::access;
98 template <typename Archive>
99 void serialize(Archive& ar, const unsigned int version);
100 };
101
102 /** Matches all objects if the current game turn is >= \a low and < \a high. */
103 struct FO_COMMON_API Turn final : public Condition {
104 explicit Turn(std::unique_ptr<ValueRef::ValueRef<int>>&& low,
105 std::unique_ptr<ValueRef::ValueRef<int>>&& high = nullptr);
106
107 bool operator==(const Condition& rhs) const override;
108 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
109 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
110 std::string Description(bool negated = false) const override;
111 std::string Dump(unsigned short ntabs = 0) const override;
112 void SetTopLevelContent(const std::string& content_name) override;
113 unsigned int GetCheckSum() const override;
114
115 private:
116 bool Match(const ScriptingContext& local_context) const override;
117
118 std::unique_ptr<ValueRef::ValueRef<int>> m_low;
119 std::unique_ptr<ValueRef::ValueRef<int>> m_high;
120
121 friend class boost::serialization::access;
122 template <typename Archive>
123 void serialize(Archive& ar, const unsigned int version);
124 };
125
126 /** Matches a specified \a number of objects that match Condition \a condition
127 * or as many objects as match the condition if the number of objects is less
128 * than the number requested. If more objects match the condition than are
129 * requested, the objects are sorted according to the value of the specified
130 * \a property_name and objects are matched according to whether they have
131 * the specified \a sorting_type of those property values. For example,
132 * objects with the largest, smallest or most common property value may be
133 * selected preferentially. */
134 struct FO_COMMON_API SortedNumberOf final : public Condition {
135 /** Sorts randomly, without considering a sort key. */
136 SortedNumberOf(std::unique_ptr<ValueRef::ValueRef<int>>&& number,
137 std::unique_ptr<Condition>&& condition);
138
139 /** Sorts according to the specified method, based on the key values
140 * evaluated for each object. */
141 SortedNumberOf(std::unique_ptr<ValueRef::ValueRef<int>>&& number,
142 std::unique_ptr<ValueRef::ValueRef<double>>&& sort_key_ref,
143 SortingMethod sorting_method,
144 std::unique_ptr<Condition>&& condition);
145
146 bool operator==(const Condition& rhs) const override;
147 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
148 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
149 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
150 ObjectSet& condition_non_targets) const override;
151 std::string Description(bool negated = false) const override;
152 std::string Dump(unsigned short ntabs = 0) const override;
153 void SetTopLevelContent(const std::string& content_name) override;
154 unsigned int GetCheckSum() const override;
155
156 private:
157 std::unique_ptr<ValueRef::ValueRef<int>> m_number;
158 std::unique_ptr<ValueRef::ValueRef<double>> m_sort_key;
159 SortingMethod m_sorting_method;
160 std::unique_ptr<Condition> m_condition;
161
162 friend class boost::serialization::access;
163 template <typename Archive>
164 void serialize(Archive& ar, const unsigned int version);
165 };
166
167 /** Matches no objects. Currently only has an experimental use for efficient immediate rejection as the top-line condition.
168 * Essentially the entire point of this Condition is to provide the specialized GetDefaultInitialCandidateObjects() */
169 struct FO_COMMON_API None final : public Condition {
170 None();
171 bool operator==(const Condition& rhs) const override;
172 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
173 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
GetDefaultInitialCandidateObjectsfinal174 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
175 ObjectSet& condition_non_targets) const override
176 { /* efficient rejection of everything. */ }
177 std::string Description(bool negated = false) const override;
178 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal179 void SetTopLevelContent(const std::string& content_name) override
180 {}
181 unsigned int GetCheckSum() const override;
182
183 private:
184 friend class boost::serialization::access;
185 template <typename Archive>
186 void serialize(Archive& ar, const unsigned int version);
187 };
188
189 /** Matches all objects that are owned (if \a exclusive == false) or only owned
190 * (if \a exclusive == true) by an empire that has affilitation type
191 * \a affilitation with Empire \a empire_id. */
192 struct FO_COMMON_API EmpireAffiliation final : public Condition {
193 EmpireAffiliation(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id, EmpireAffiliationType affiliation);
194 explicit EmpireAffiliation(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id);
195 explicit EmpireAffiliation(EmpireAffiliationType affiliation);
196
197 bool operator==(const Condition& rhs) const override;
198 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
199 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
200 std::string Description(bool negated = false) const override;
201 std::string Dump(unsigned short ntabs = 0) const override;
202 void SetTopLevelContent(const std::string& content_name) override;
203 unsigned int GetCheckSum() const override;
204
205 private:
206 bool Match(const ScriptingContext& local_context) const override;
207
208 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
209 EmpireAffiliationType m_affiliation;
210
211 friend class boost::serialization::access;
212 template <typename Archive>
213 void serialize(Archive& ar, const unsigned int version);
214 };
215
216 /** Matches the root candidate object in a condition tree. This is useful
217 * within a subcondition to match the object actually being matched by the
218 * whole compound condition, rather than an object just being matched in a
219 * subcondition in order to evaluate the outer condition. */
220 struct FO_COMMON_API RootCandidate final : public Condition {
221 RootCandidate();
222 bool operator==(const Condition& rhs) const override;
223 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
224 ObjectSet& condition_non_targets) const override;
225 std::string Description(bool negated = false) const override;
226 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal227 void SetTopLevelContent(const std::string& content_name) override
228 {}
229 unsigned int GetCheckSum() const override;
230
231 private:
232 bool Match(const ScriptingContext& local_context) const override;
233
234 friend class boost::serialization::access;
235 template <typename Archive>
236 void serialize(Archive& ar, const unsigned int version);
237 };
238
239 /** There is no LocalCandidate condition. To match any local candidate object,
240 * use the All condition. */
241
242 /** Matches the target of an effect being executed. */
243 struct FO_COMMON_API Target final : public Condition {
244 Target();
245 bool operator==(const Condition& rhs) const override;
246 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
247 ObjectSet& condition_non_targets) const override;
248 std::string Description(bool negated = false) const override;
249 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal250 void SetTopLevelContent(const std::string& content_name) override
251 {}
252 unsigned int GetCheckSum() const override;
253
254 private:
255 bool Match(const ScriptingContext& local_context) const override;
256
257 friend class boost::serialization::access;
258 template <typename Archive>
259 void serialize(Archive& ar, const unsigned int version);
260 };
261
262 /** Matches planets that are a homeworld for any of the species specified in
263 * \a names. If \a names is empty, matches any planet that is a homeworld for
264 * any species in the current game Universe. */
265 struct FO_COMMON_API Homeworld final : public Condition {
266 Homeworld();
267 explicit Homeworld(std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>>&& names);
268
269 bool operator==(const Condition& rhs) const override;
270 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
271 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
272 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
273 ObjectSet& condition_non_targets) const override;
274 std::string Description(bool negated = false) const override;
275 std::string Dump(unsigned short ntabs = 0) const override;
276 void SetTopLevelContent(const std::string& content_name) override;
277 unsigned int GetCheckSum() const override;
278
279 private:
280 bool Match(const ScriptingContext& local_context) const override;
281
282 std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>> m_names;
283
284 friend class boost::serialization::access;
285 template <typename Archive>
286 void serialize(Archive& ar, const unsigned int version);
287 };
288
289 /** Matches planets that are an empire's capital. */
290 struct FO_COMMON_API Capital final : public Condition {
291 Capital();
292 bool operator==(const Condition& rhs) const override;
293 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
294 ObjectSet& condition_non_targets) const override;
295 std::string Description(bool negated = false) const override;
296 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal297 void SetTopLevelContent(const std::string& content_name) override
298 {}
299 unsigned int GetCheckSum() const override;
300
301 private:
302 bool Match(const ScriptingContext& local_context) const override;
303
304 friend class boost::serialization::access;
305 template <typename Archive>
306 void serialize(Archive& ar, const unsigned int version);
307 };
308
309 /** Matches space monsters. */
310 struct FO_COMMON_API Monster final : public Condition {
311 Monster();
312 bool operator==(const Condition& rhs) const override;
313 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
314 ObjectSet& condition_non_targets) const override;
315 std::string Description(bool negated = false) const override;
316 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal317 void SetTopLevelContent(const std::string& content_name) override
318 {}
319 unsigned int GetCheckSum() const override;
320
321 private:
322 bool Match(const ScriptingContext& local_context) const override;
323
324 friend class boost::serialization::access;
325 template <typename Archive>
326 void serialize(Archive& ar, const unsigned int version);
327 };
328
329 /** Matches armed ships and monsters. */
330 struct FO_COMMON_API Armed final : public Condition {
331 Armed();
332 bool operator==(const Condition& rhs) const override;
333 std::string Description(bool negated = false) const override;
334 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal335 void SetTopLevelContent(const std::string& content_name) override
336 {}
337 unsigned int GetCheckSum() const override;
338
339 private:
340 bool Match(const ScriptingContext& local_context) const override;
341
342 friend class boost::serialization::access;
343 template <typename Archive>
344 void serialize(Archive& ar, const unsigned int version);
345 };
346
347 /** Matches all objects that are of UniverseObjectType \a type. */
348 struct FO_COMMON_API Type final : public Condition {
349 explicit Type(std::unique_ptr<ValueRef::ValueRef<UniverseObjectType>>&& type);
350 explicit Type(UniverseObjectType type);
351
352 bool operator==(const Condition& rhs) const override;
353 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
354 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
355 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
356 ObjectSet& condition_non_targets) const override;
357 std::string Description(bool negated = false) const override;
358 std::string Dump(unsigned short ntabs = 0) const override;
359 void SetTopLevelContent(const std::string& content_name) override;
360 unsigned int GetCheckSum() const override;
361
362 private:
363 bool Match(const ScriptingContext& local_context) const override;
364
365 std::unique_ptr<ValueRef::ValueRef<UniverseObjectType>> m_type;
366
367 friend class boost::serialization::access;
368 template <typename Archive>
369 void serialize(Archive& ar, const unsigned int version);
370 };
371
372 /** Matches all Building objects that are one of the building types specified
373 * in \a names. */
374 struct FO_COMMON_API Building final : public Condition {
375 explicit Building(std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>>&& names);
376
377 bool operator==(const Condition& rhs) const override;
378 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
379 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
380 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
381 ObjectSet& condition_non_targets) const override;
382 std::string Description(bool negated = false) const override;
383 std::string Dump(unsigned short ntabs = 0) const override;
384 void SetTopLevelContent(const std::string& content_name) override;
385 unsigned int GetCheckSum() const override;
386
387 private:
388 bool Match(const ScriptingContext& local_context) const override;
389
390 std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>> m_names;
391
392 friend class boost::serialization::access;
393 template <typename Archive>
394 void serialize(Archive& ar, const unsigned int version);
395 };
396
397 /** Matches all objects that have an attached Special named \a name. */
398 struct FO_COMMON_API HasSpecial final : public Condition {
399 HasSpecial();
400 explicit HasSpecial(std::string name);
401 explicit HasSpecial(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
402 explicit HasSpecial(ValueRef::ValueRef<std::string>* name);
403 HasSpecial(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
404 std::unique_ptr<ValueRef::ValueRef<int>>&& since_turn_low,
405 std::unique_ptr<ValueRef::ValueRef<int>>&& since_turn_high = nullptr);
406 HasSpecial(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
407 std::unique_ptr<ValueRef::ValueRef<double>>&& capacity_low,
408 std::unique_ptr<ValueRef::ValueRef<double>>&& capacity_high = nullptr);
409
410 bool operator==(const Condition& rhs) const override;
411 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
412 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
413 std::string Description(bool negated = false) const override;
414 std::string Dump(unsigned short ntabs = 0) const override;
415 void SetTopLevelContent(const std::string& content_name) override;
416 unsigned int GetCheckSum() const override;
417
418 private:
419 bool Match(const ScriptingContext& local_context) const override;
420
421 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
422 std::unique_ptr<ValueRef::ValueRef<double>> m_capacity_low;
423 std::unique_ptr<ValueRef::ValueRef<double>> m_capacity_high;
424 std::unique_ptr<ValueRef::ValueRef<int>> m_since_turn_low;
425 std::unique_ptr<ValueRef::ValueRef<int>> m_since_turn_high;
426
427 friend class boost::serialization::access;
428 template <typename Archive>
429 void serialize(Archive& ar, const unsigned int version);
430 };
431
432 /** Matches all objects that have the tag \a tag. */
433 struct FO_COMMON_API HasTag final : public Condition {
434 HasTag();
435 explicit HasTag(const std::string& name);
436 explicit HasTag(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
437
438 bool operator==(const Condition& rhs) const override;
439 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
440 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
441 std::string Description(bool negated = false) const override;
442 std::string Dump(unsigned short ntabs = 0) const override;
443 void SetTopLevelContent(const std::string& content_name) override;
444 unsigned int GetCheckSum() const override;
445
446 private:
447 bool Match(const ScriptingContext& local_context) const override;
448
449 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
450
451 friend class boost::serialization::access;
452 template <typename Archive>
453 void serialize(Archive& ar, const unsigned int version);
454 };
455
456 /** Matches all objects that were created on turns within the specified range. */
457 struct FO_COMMON_API CreatedOnTurn final : public Condition {
458 CreatedOnTurn(std::unique_ptr<ValueRef::ValueRef<int>>&& low,
459 std::unique_ptr<ValueRef::ValueRef<int>>&& high);
460
461 bool operator==(const Condition& rhs) const override;
462 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
463 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
464 std::string Description(bool negated = false) const override;
465 std::string Dump(unsigned short ntabs = 0) const override;
466 void SetTopLevelContent(const std::string& content_name) override;
467 unsigned int GetCheckSum() const override;
468
469 private:
470 bool Match(const ScriptingContext& local_context) const override;
471
472 std::unique_ptr<ValueRef::ValueRef<int>> m_low;
473 std::unique_ptr<ValueRef::ValueRef<int>> m_high;
474
475 friend class boost::serialization::access;
476 template <typename Archive>
477 void serialize(Archive& ar, const unsigned int version);
478 };
479
480 /** Matches all objects that contain an object that matches Condition
481 * \a condition. Container objects are Systems, Planets (which contain
482 * Buildings), and Fleets (which contain Ships). */
483 struct FO_COMMON_API Contains final : public Condition {
484 Contains(std::unique_ptr<Condition>&& condition);
485 bool operator==(const Condition& rhs) const override;
486 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
487 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
488 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
489 ObjectSet& condition_non_targets) const override;
490 std::string Description(bool negated = false) const override;
491 std::string Dump(unsigned short ntabs = 0) const override;
492 void SetTopLevelContent(const std::string& content_name) override;
493 unsigned int GetCheckSum() const override;
494
495 private:
496 bool Match(const ScriptingContext& local_context) const override;
497
498 std::unique_ptr<Condition> m_condition;
499
500 friend class boost::serialization::access;
501 template <typename Archive>
502 void serialize(Archive& ar, const unsigned int version);
503 };
504
505 /** Matches all objects that are contained by an object that matches Condition
506 * \a condition. Container objects are Systems, Planets (which contain
507 * Buildings), and Fleets (which contain Ships). */
508 struct FO_COMMON_API ContainedBy final : public Condition {
509 ContainedBy(std::unique_ptr<Condition>&& condition);
510 bool operator==(const Condition& rhs) const override;
511 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
512 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
513 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
514 ObjectSet& condition_non_targets) const override;
515 std::string Description(bool negated = false) const override;
516 std::string Dump(unsigned short ntabs = 0) const override;
517 void SetTopLevelContent(const std::string& content_name) override;
518 unsigned int GetCheckSum() const override;
519
520 private:
521 bool Match(const ScriptingContext& local_context) const override;
522
523 std::unique_ptr<Condition> m_condition;
524
525 friend class boost::serialization::access;
526 template <typename Archive>
527 void serialize(Archive& ar, const unsigned int version);
528 };
529
530 /** Matches all objects that are in the system with the indicated \a system_id
531 * or that are that system. If \a system_id is INVALID_OBJECT_ID then matches
532 * all objects in any system*/
533 struct FO_COMMON_API InOrIsSystem final : public Condition {
534 InOrIsSystem(std::unique_ptr<ValueRef::ValueRef<int>>&& system_id);
535
536 bool operator==(const Condition& rhs) const override;
537 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
538 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
539 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
540 ObjectSet& condition_non_targets) const override;
541 std::string Description(bool negated = false) const override;
542 std::string Dump(unsigned short ntabs = 0) const override;
543 void SetTopLevelContent(const std::string& content_name) override;
544 unsigned int GetCheckSum() const override;
545
546 private:
547 bool Match(const ScriptingContext& local_context) const override;
548
549 std::unique_ptr<ValueRef::ValueRef<int>> m_system_id;
550
551 friend class boost::serialization::access;
552 template <typename Archive>
553 void serialize(Archive& ar, const unsigned int version);
554 };
555
556 /** Matches all objects that are on the planet with the indicated \a planet_id
557 * or that are that planet. If \a planet_id is INVALID_OBJECT_ID then matches
558 * all objects on any planet */
559 struct FO_COMMON_API OnPlanet final : public Condition {
560 OnPlanet(std::unique_ptr<ValueRef::ValueRef<int>>&& planet_id);
561
562 bool operator==(const Condition& rhs) const override;
563 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
564 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
565 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
566 ObjectSet& condition_non_targets) const override;
567 std::string Description(bool negated = false) const override;
568 std::string Dump(unsigned short ntabs = 0) const override;
569 void SetTopLevelContent(const std::string& content_name) override;
570 unsigned int GetCheckSum() const override;
571
572 private:
573 bool Match(const ScriptingContext& local_context) const override;
574
575 std::unique_ptr<ValueRef::ValueRef<int>> m_planet_id;
576
577 friend class boost::serialization::access;
578 template <typename Archive>
579 void serialize(Archive& ar, const unsigned int version);
580 };
581
582 /** Matches the object with the id \a object_id */
583 struct FO_COMMON_API ObjectID final : public Condition {
584 ObjectID(std::unique_ptr<ValueRef::ValueRef<int>>&& object_id);
585
586 bool operator==(const Condition& rhs) const override;
587 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
588 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
589 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
590 ObjectSet& condition_non_targets) const override;
591 std::string Description(bool negated = false) const override;
592 std::string Dump(unsigned short ntabs = 0) const override;
593 void SetTopLevelContent(const std::string& content_name) override;
594 unsigned int GetCheckSum() const override;
595
596 private:
597 bool Match(const ScriptingContext& local_context) const override;
598
599 std::unique_ptr<ValueRef::ValueRef<int>> m_object_id;
600
601 friend class boost::serialization::access;
602 template <typename Archive>
603 void serialize(Archive& ar, const unsigned int version);
604 };
605
606 /** Matches all Planet objects that have one of the PlanetTypes in \a types.
607 * Note that all Building objects which are on matching planets are also
608 * matched. */
609 struct FO_COMMON_API PlanetType final : public Condition {
610 PlanetType(std::vector<std::unique_ptr<ValueRef::ValueRef< ::PlanetType>>>&& types);
611
612 bool operator==(const Condition& rhs) const override;
613 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
614 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
615 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
616 ObjectSet& condition_non_targets) const override;
617 std::string Description(bool negated = false) const override;
618 std::string Dump(unsigned short ntabs = 0) const override;
619 void SetTopLevelContent(const std::string& content_name) override;
620 unsigned int GetCheckSum() const override;
621
622 private:
623 bool Match(const ScriptingContext& local_context) const override;
624
625 std::vector<std::unique_ptr<ValueRef::ValueRef<::PlanetType>>> m_types;
626
627 friend class boost::serialization::access;
628 template <typename Archive>
629 void serialize(Archive& ar, const unsigned int version);
630 };
631
632 /** Matches all Planet objects that have one of the PlanetSizes in \a sizes.
633 * Note that all Building objects which are on matching planets are also
634 * matched. */
635 struct FO_COMMON_API PlanetSize final : public Condition {
636 PlanetSize(std::vector<std::unique_ptr<ValueRef::ValueRef< ::PlanetSize>>>&& sizes);
637
638 bool operator==(const Condition& rhs) const override;
639 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
640 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
641 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
642 ObjectSet& condition_non_targets) const override;
643 std::string Description(bool negated = false) const override;
644 std::string Dump(unsigned short ntabs = 0) const override;
645 void SetTopLevelContent(const std::string& content_name) override;
646 unsigned int GetCheckSum() const override;
647
648 private:
649 bool Match(const ScriptingContext& local_context) const override;
650
651 std::vector<std::unique_ptr<ValueRef::ValueRef<::PlanetSize>>> m_sizes;
652
653 friend class boost::serialization::access;
654 template <typename Archive>
655 void serialize(Archive& ar, const unsigned int version);
656 };
657
658 /** Matches all Planet objects that have one of the PlanetEnvironments in
659 * \a environments. Note that all Building objects which are on matching
660 * planets are also matched. */
661 struct FO_COMMON_API PlanetEnvironment final : public Condition {
662 PlanetEnvironment(std::vector<std::unique_ptr<ValueRef::ValueRef< ::PlanetEnvironment>>>&& environments,
663 std::unique_ptr<ValueRef::ValueRef<std::string>>&& species_name_ref = nullptr);
664
665 bool operator==(const Condition& rhs) const override;
666 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
667 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
668 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
669 ObjectSet& condition_non_targets) const override;
670 std::string Description(bool negated = false) const override;
671 std::string Dump(unsigned short ntabs = 0) const override;
672 void SetTopLevelContent(const std::string& content_name) override;
673 unsigned int GetCheckSum() const override;
674
675 private:
676 bool Match(const ScriptingContext& local_context) const override;
677
678 std::vector<std::unique_ptr<ValueRef::ValueRef<::PlanetEnvironment>>> m_environments;
679 std::unique_ptr<ValueRef::ValueRef<std::string>> m_species_name;
680
681 friend class boost::serialization::access;
682 template <typename Archive>
683 void serialize(Archive& ar, const unsigned int version);
684 };
685
686 /** Matches all planets or ships that have one of the species in \a species.
687 * Note that all Building object which are on matching planets are also
688 * matched. */
689 struct FO_COMMON_API Species final : public Condition {
690 explicit Species(std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>>&& names);
691 Species();
692
693 bool operator==(const Condition& rhs) const override;
694 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
695 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
696 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
697 ObjectSet& condition_non_targets) const override;
698 std::string Description(bool negated = false) const override;
699 std::string Dump(unsigned short ntabs = 0) const override;
700 void SetTopLevelContent(const std::string& content_name) override;
701 unsigned int GetCheckSum() const override;
702
703 private:
704 bool Match(const ScriptingContext& local_context) const override;
705
706 std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>> m_names;
707
708 friend class boost::serialization::access;
709 template <typename Archive>
710 void serialize(Archive& ar, const unsigned int version);
711 };
712
713 /** Matches planets where the indicated number of the indicated building type
714 * or ship design are enqueued on the production queue. */
715 struct FO_COMMON_API Enqueued final : public Condition {
716 Enqueued(BuildType build_type,
717 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
718 std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id = nullptr,
719 std::unique_ptr<ValueRef::ValueRef<int>>&& low = nullptr,
720 std::unique_ptr<ValueRef::ValueRef<int>>&& high = nullptr);
721 explicit Enqueued(std::unique_ptr<ValueRef::ValueRef<int>>&& design_id,
722 std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id = nullptr,
723 std::unique_ptr<ValueRef::ValueRef<int>>&& low = nullptr,
724 std::unique_ptr<ValueRef::ValueRef<int>>&& high = nullptr);
725 Enqueued();
726
727 bool operator==(const Condition& rhs) const override;
728 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
729 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
730 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
731 ObjectSet& condition_non_targets) const override;
732 std::string Description(bool negated = false) const override;
733 std::string Dump(unsigned short ntabs = 0) const override;
734 void SetTopLevelContent(const std::string& content_name) override;
735 unsigned int GetCheckSum() const override;
736
737 private:
738 bool Match(const ScriptingContext& local_context) const override;
739
740 BuildType m_build_type;
741 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
742 std::unique_ptr<ValueRef::ValueRef<int>> m_design_id;
743 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
744 std::unique_ptr<ValueRef::ValueRef<int>> m_low;
745 std::unique_ptr<ValueRef::ValueRef<int>> m_high;
746
747 friend class boost::serialization::access;
748 template <typename Archive>
749 void serialize(Archive& ar, const unsigned int version);
750 };
751
752 /** Matches all ProdCenter objects that have one of the FocusTypes in \a foci. */
753 struct FO_COMMON_API FocusType final : public Condition {
754 FocusType(std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>>&& names);
755
756 bool operator==(const Condition& rhs) const override;
757 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
758 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
759 std::string Description(bool negated = false) const override;
760 std::string Dump(unsigned short ntabs = 0) const override;
761 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
762 ObjectSet& condition_non_targets) const override;
763 void SetTopLevelContent(const std::string& content_name) override;
764 unsigned int GetCheckSum() const override;
765
766 private:
767 bool Match(const ScriptingContext& local_context) const override;
768
769 std::vector<std::unique_ptr<ValueRef::ValueRef<std::string>>> m_names;
770
771 friend class boost::serialization::access;
772 template <typename Archive>
773 void serialize(Archive& ar, const unsigned int version);
774 };
775
776 /** Matches all System objects that have one of the StarTypes in \a types. Note that all objects
777 in matching Systems are also matched (Ships, Fleets, Buildings, Planets, etc.). */
778 struct FO_COMMON_API StarType final : public Condition {
779 StarType(std::vector<std::unique_ptr<ValueRef::ValueRef< ::StarType>>>&& types);
780
781 bool operator==(const Condition& rhs) const override;
782 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
783 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
784 std::string Description(bool negated = false) const override;
785 std::string Dump(unsigned short ntabs = 0) const override;
786 void SetTopLevelContent(const std::string& content_name) override;
787 unsigned int GetCheckSum() const override;
788
789 private:
790 bool Match(const ScriptingContext& local_context) const override;
791
792 std::vector<std::unique_ptr<ValueRef::ValueRef<::StarType>>> m_types;
793
794 friend class boost::serialization::access;
795 template <typename Archive>
796 void serialize(Archive& ar, const unsigned int version);
797 };
798
799 /** Matches all ships whose ShipDesign has the hull specified by \a name. */
800 struct FO_COMMON_API DesignHasHull final : public Condition {
801 explicit DesignHasHull(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
802
803 bool operator==(const Condition& rhs) const override;
804 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
805 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
806 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
807 ObjectSet& condition_non_targets) const override;
808 std::string Description(bool negated = false) const override;
809 std::string Dump(unsigned short ntabs = 0) const override;
810 void SetTopLevelContent(const std::string& content_name) override;
811 unsigned int GetCheckSum() const override;
812
813 private:
814 bool Match(const ScriptingContext& local_context) const override;
815
816 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
817
818 friend class boost::serialization::access;
819 template <typename Archive>
820 void serialize(Archive& ar, const unsigned int version);
821 };
822
823 /** Matches all ships whose ShipDesign has >= \a low and < \a high of the ship
824 * part specified by \a name. */
825 struct FO_COMMON_API DesignHasPart final : public Condition {
826 DesignHasPart(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
827 std::unique_ptr<ValueRef::ValueRef<int>>&& low = nullptr,
828 std::unique_ptr<ValueRef::ValueRef<int>>&& high = nullptr);
829
830 bool operator==(const Condition& rhs) const override;
831 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
832 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
833 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
834 ObjectSet& condition_non_targets) const override;
835 std::string Description(bool negated = false) const override;
836 std::string Dump(unsigned short ntabs = 0) const override;
837 void SetTopLevelContent(const std::string& content_name) override;
838 unsigned int GetCheckSum() const override;
839
840 private:
841 bool Match(const ScriptingContext& local_context) const override;
842
843 std::unique_ptr<ValueRef::ValueRef<int>> m_low;
844 std::unique_ptr<ValueRef::ValueRef<int>> m_high;
845 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
846
847 friend class boost::serialization::access;
848 template <typename Archive>
849 void serialize(Archive& ar, const unsigned int version);
850 };
851
852 /** Matches ships whose ShipDesign has >= \a low and < \a high of ship parts of
853 * the specified \a part_class */
854 struct FO_COMMON_API DesignHasPartClass final : public Condition {
855 DesignHasPartClass(ShipPartClass part_class,
856 std::unique_ptr<ValueRef::ValueRef<int>>&& low,
857 std::unique_ptr<ValueRef::ValueRef<int>>&& high);
858
859 bool operator==(const Condition& rhs) const override;
860 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
861 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
862 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
863 ObjectSet& condition_non_targets) const override;
864 std::string Description(bool negated = false) const override;
865 std::string Dump(unsigned short ntabs = 0) const override;
866 void SetTopLevelContent(const std::string& content_name) override;
867 unsigned int GetCheckSum() const override;
868
869 private:
870 bool Match(const ScriptingContext& local_context) const override;
871
872 std::unique_ptr<ValueRef::ValueRef<int>> m_low;
873 std::unique_ptr<ValueRef::ValueRef<int>> m_high;
874 ShipPartClass m_class;
875
876 friend class boost::serialization::access;
877 template <typename Archive>
878 void serialize(Archive& ar, const unsigned int version);
879 };
880
881 /** Matches ships who ShipDesign is a predefined shipdesign with the name
882 * \a name */
883 struct FO_COMMON_API PredefinedShipDesign final : public Condition {
884 explicit PredefinedShipDesign(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
885
886 bool operator==(const Condition& rhs) const override;
887 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
888 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
889 std::string Description(bool negated = false) const override;
890 std::string Dump(unsigned short ntabs = 0) const override;
891 void SetTopLevelContent(const std::string& content_name) override;
892 unsigned int GetCheckSum() const override;
893
894 private:
895 bool Match(const ScriptingContext& local_context) const override;
896
897 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
898
899 friend class boost::serialization::access;
900 template <typename Archive>
901 void serialize(Archive& ar, const unsigned int version);
902 };
903
904 /** Matches ships whose design id \a id. */
905 struct FO_COMMON_API NumberedShipDesign final : public Condition {
906 explicit NumberedShipDesign(std::unique_ptr<ValueRef::ValueRef<int>>&& design_id);
907
908 bool operator==(const Condition& rhs) const override;
909 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
910 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
911 std::string Description(bool negated = false) const override;
912 std::string Dump(unsigned short ntabs = 0) const override;
913 void SetTopLevelContent(const std::string& content_name) override;
914 unsigned int GetCheckSum() const override;
915
916 private:
917 bool Match(const ScriptingContext& local_context) const override;
918
919 std::unique_ptr<ValueRef::ValueRef<int>> m_design_id;
920
921 friend class boost::serialization::access;
922 template <typename Archive>
923 void serialize(Archive& ar, const unsigned int version);
924 };
925
926 /** Matches ships or buildings produced by the empire with id \a empire_id.*/
927 struct FO_COMMON_API ProducedByEmpire final : public Condition {
928 explicit ProducedByEmpire(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id);
929
930 bool operator==(const Condition& rhs) const override;
931 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
932 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
933 std::string Description(bool negated = false) const override;
934 std::string Dump(unsigned short ntabs = 0) const override;
935 void SetTopLevelContent(const std::string& content_name) override;
936 unsigned int GetCheckSum() const override;
937
938 private:
939 bool Match(const ScriptingContext& local_context) const override;
940
941 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
942
943 friend class boost::serialization::access;
944 template <typename Archive>
945 void serialize(Archive& ar, const unsigned int version);
946 };
947
948 /** Matches a given object with a linearly distributed probability of \a chance. */
949 struct FO_COMMON_API Chance final : public Condition {
950 explicit Chance(std::unique_ptr<ValueRef::ValueRef<double>>&& chance);
951
952 bool operator==(const Condition& rhs) const override;
953 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
954 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
955 std::string Description(bool negated = false) const override;
956 std::string Dump(unsigned short ntabs = 0) const override;
957 void SetTopLevelContent(const std::string& content_name) override;
958 unsigned int GetCheckSum() const override;
959
960 private:
961 bool Match(const ScriptingContext& local_context) const override;
962
963 std::unique_ptr<ValueRef::ValueRef<double>> m_chance;
964
965 friend class boost::serialization::access;
966 template <typename Archive>
967 void serialize(Archive& ar, const unsigned int version);
968 };
969
970 /** Matches all objects that have a meter of type \a meter, and whose current
971 * value is >= \a low and <= \a high. */
972 struct FO_COMMON_API MeterValue final : public Condition {
973 MeterValue(MeterType meter,
974 std::unique_ptr<ValueRef::ValueRef<double>>&& low,
975 std::unique_ptr<ValueRef::ValueRef<double>>&& high);
976
977 bool operator==(const Condition& rhs) const override;
978 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
979 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
980 std::string Description(bool negated = false) const override;
981 std::string Dump(unsigned short ntabs = 0) const override;
982 void SetTopLevelContent(const std::string& content_name) override;
983 unsigned int GetCheckSum() const override;
984
985 private:
986 bool Match(const ScriptingContext& local_context) const override;
987
988 MeterType m_meter;
989 std::unique_ptr<ValueRef::ValueRef<double>> m_low;
990 std::unique_ptr<ValueRef::ValueRef<double>> m_high;
991
992 friend class boost::serialization::access;
993 template <typename Archive>
994 void serialize(Archive& ar, const unsigned int version);
995 };
996
997 /** Matches ships that have a ship part meter of type \a meter for part \a part
998 * whose current value is >= low and <= high. */
999 struct FO_COMMON_API ShipPartMeterValue final : public Condition {
1000 ShipPartMeterValue(std::unique_ptr<ValueRef::ValueRef<std::string>>&& ship_part_name,
1001 MeterType meter,
1002 std::unique_ptr<ValueRef::ValueRef<double>>&& low,
1003 std::unique_ptr<ValueRef::ValueRef<double>>&& high);
1004
1005 bool operator==(const Condition& rhs) const override;
1006 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1007 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1008 std::string Description(bool negated = false) const override;
1009 std::string Dump(unsigned short ntabs = 0) const override;
1010 void SetTopLevelContent(const std::string& content_name) override;
1011 unsigned int GetCheckSum() const override;
1012
1013 private:
1014 bool Match(const ScriptingContext& local_context) const override;
1015
1016 std::unique_ptr<ValueRef::ValueRef<std::string>> m_part_name;
1017 MeterType m_meter;
1018 std::unique_ptr<ValueRef::ValueRef<double>> m_low;
1019 std::unique_ptr<ValueRef::ValueRef<double>> m_high;
1020 };
1021
1022 /** Matches all objects if the empire with id \a empire_id has an empire meter
1023 * \a meter whose current value is >= \a low and <= \a high. */
1024 struct FO_COMMON_API EmpireMeterValue final : public Condition {
1025 EmpireMeterValue(const std::string& meter,
1026 std::unique_ptr<ValueRef::ValueRef<double>>&& low,
1027 std::unique_ptr<ValueRef::ValueRef<double>>&& high);
1028 EmpireMeterValue(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
1029 const std::string& meter,
1030 std::unique_ptr<ValueRef::ValueRef<double>>&& low,
1031 std::unique_ptr<ValueRef::ValueRef<double>>&& high);
1032
1033 bool operator==(const Condition& rhs) const override;
1034 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1035 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1036 std::string Description(bool negated = false) const override;
1037 std::string Dump(unsigned short ntabs = 0) const override;
1038 void SetTopLevelContent(const std::string& content_name) override;
1039 unsigned int GetCheckSum() const override;
1040
1041 private:
1042 bool Match(const ScriptingContext& local_context) const override;
1043
1044 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1045 const std::string m_meter;
1046 std::unique_ptr<ValueRef::ValueRef<double>> m_low;
1047 std::unique_ptr<ValueRef::ValueRef<double>> m_high;
1048 };
1049
1050 /** Matches all objects whose owner's stockpile of \a stockpile is between
1051 * \a low and \a high, inclusive. */
1052 struct FO_COMMON_API EmpireStockpileValue final : public Condition {
1053 EmpireStockpileValue(ResourceType stockpile,
1054 std::unique_ptr<ValueRef::ValueRef<double>>&& low,
1055 std::unique_ptr<ValueRef::ValueRef<double>>&& high);
1056 EmpireStockpileValue(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
1057 ResourceType stockpile,
1058 std::unique_ptr<ValueRef::ValueRef<double>>&& low,
1059 std::unique_ptr<ValueRef::ValueRef<double>>&& high);
1060
1061 bool operator==(const Condition& rhs) const override;
1062 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1063 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1064 std::string Description(bool negated = false) const override;
1065 std::string Dump(unsigned short ntabs = 0) const override;
1066 void SetTopLevelContent(const std::string& content_name) override;
1067 unsigned int GetCheckSum() const override;
1068
1069 private:
1070 bool Match(const ScriptingContext& local_context) const override;
1071
1072 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1073 ResourceType m_stockpile;
1074 std::unique_ptr<ValueRef::ValueRef<double>> m_low;
1075 std::unique_ptr<ValueRef::ValueRef<double>> m_high;
1076
1077 friend class boost::serialization::access;
1078 template <typename Archive>
1079 void serialize(Archive& ar, const unsigned int version);
1080 };
1081
1082 /** Matches all objects whose owner who has tech \a name. */
1083 struct FO_COMMON_API OwnerHasTech final : public Condition {
1084 OwnerHasTech(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
1085 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
1086 explicit OwnerHasTech(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
1087
1088 bool operator==(const Condition& rhs) const override;
1089 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1090 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1091 std::string Description(bool negated = false) const override;
1092 std::string Dump(unsigned short ntabs = 0) const override;
1093 void SetTopLevelContent(const std::string& content_name) override;
1094 unsigned int GetCheckSum() const override;
1095
1096 private:
1097 bool Match(const ScriptingContext& local_context) const override;
1098
1099 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
1100 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1101
1102 friend class boost::serialization::access;
1103 template <typename Archive>
1104 void serialize(Archive& ar, const unsigned int version);
1105 };
1106
1107 /** Matches all objects whose owner who has the building type \a name available. */
1108 struct FO_COMMON_API OwnerHasBuildingTypeAvailable final : public Condition {
1109 OwnerHasBuildingTypeAvailable(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
1110 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
1111 explicit OwnerHasBuildingTypeAvailable(const std::string& name);
1112 explicit OwnerHasBuildingTypeAvailable(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
1113
1114 bool operator==(const Condition& rhs) const override;
1115 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1116 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1117 std::string Description(bool negated = false) const override;
1118 std::string Dump(unsigned short ntabs = 0) const override;
1119 void SetTopLevelContent(const std::string& content_name) override;
1120 unsigned int GetCheckSum() const override;
1121
1122 private:
1123 bool Match(const ScriptingContext& local_context) const override;
1124
1125 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
1126 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1127
1128 friend class boost::serialization::access;
1129 template <typename Archive>
1130 void serialize(Archive& ar, const unsigned int version);
1131 };
1132
1133 /** Matches all objects whose owner who has the ship design \a id available. */
1134 struct FO_COMMON_API OwnerHasShipDesignAvailable final : public Condition {
1135 OwnerHasShipDesignAvailable(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
1136 std::unique_ptr<ValueRef::ValueRef<int>>&& design_id);
1137 explicit OwnerHasShipDesignAvailable(int design_id);
1138 explicit OwnerHasShipDesignAvailable(std::unique_ptr<ValueRef::ValueRef<int>>&& design_id);
1139
1140 bool operator==(const Condition& rhs) const override;
1141 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1142 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1143 std::string Description(bool negated = false) const override;
1144 std::string Dump(unsigned short ntabs = 0) const override;
1145 void SetTopLevelContent(const std::string& content_name) override;
1146 unsigned int GetCheckSum() const override;
1147
1148 private:
1149 bool Match(const ScriptingContext& local_context) const override;
1150
1151 std::unique_ptr<ValueRef::ValueRef<int>> m_id;
1152 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1153
1154 friend class boost::serialization::access;
1155 template <typename Archive>
1156 void serialize(Archive& ar, const unsigned int version);
1157 };
1158
1159 /** Matches all objects whose owner who has the ship part @a name available. */
1160 struct FO_COMMON_API OwnerHasShipPartAvailable final : public Condition {
1161 OwnerHasShipPartAvailable(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
1162 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
1163 explicit OwnerHasShipPartAvailable(const std::string& name);
1164 explicit OwnerHasShipPartAvailable(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
1165
1166 bool operator==(const Condition& rhs) const override;
1167 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1168 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1169 std::string Description(bool negated = false) const override;
1170 std::string Dump(unsigned short ntabs = 0) const override;
1171 void SetTopLevelContent(const std::string& content_name) override;
1172 unsigned int GetCheckSum() const override;
1173
1174 private:
1175 bool Match(const ScriptingContext& local_context) const override;
1176
1177 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
1178 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1179
1180 friend class boost::serialization::access;
1181 template <typename Archive>
1182 void serialize(Archive& ar, const unsigned int version);
1183 };
1184
1185 /** Matches all objects that are visible to at least one Empire in \a empire_ids. */
1186 struct FO_COMMON_API VisibleToEmpire final : public Condition {
1187 explicit VisibleToEmpire(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id);
1188
1189 bool operator==(const Condition& rhs) const override;
1190 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1191 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1192 std::string Description(bool negated = false) const override;
1193 std::string Dump(unsigned short ntabs = 0) const override;
1194 void SetTopLevelContent(const std::string& content_name) override;
1195 unsigned int GetCheckSum() const override;
1196
1197 private:
1198 bool Match(const ScriptingContext& local_context) const override;
1199
1200 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1201
1202 friend class boost::serialization::access;
1203 template <typename Archive>
1204 void serialize(Archive& ar, const unsigned int version);
1205 };
1206
1207 /** Matches all objects that are within \a distance units of at least one
1208 * object that meets \a condition. Warning: this Condition can slow things
1209 * down considerably if overused. It is best to use Conditions that yield
1210 * relatively few matches. */
1211 struct FO_COMMON_API WithinDistance final : public Condition {
1212 WithinDistance(std::unique_ptr<ValueRef::ValueRef<double>>&& distance,
1213 std::unique_ptr<Condition>&& condition);
1214
1215 bool operator==(const Condition& rhs) const override;
1216 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1217 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1218 std::string Description(bool negated = false) const override;
1219 std::string Dump(unsigned short ntabs = 0) const override;
1220 void SetTopLevelContent(const std::string& content_name) override;
1221 unsigned int GetCheckSum() const override;
1222
1223 private:
1224 bool Match(const ScriptingContext& local_context) const override;
1225
1226 std::unique_ptr<ValueRef::ValueRef<double>> m_distance;
1227 std::unique_ptr<Condition> m_condition;
1228
1229 friend class boost::serialization::access;
1230 template <typename Archive>
1231 void serialize(Archive& ar, const unsigned int version);
1232 };
1233
1234 /** Matches all objects that are within \a jumps starlane jumps of at least one
1235 * object that meets \a condition. Warning: this Condition can slow things
1236 * down considerably if overused. It is best to use Conditions that yield
1237 * relatively few matches. */
1238 struct FO_COMMON_API WithinStarlaneJumps final : public Condition {
1239 WithinStarlaneJumps(std::unique_ptr<ValueRef::ValueRef<int>>&& jumps,
1240 std::unique_ptr<Condition>&& condition);
1241
1242 bool operator==(const Condition& rhs) const override;
1243 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1244 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1245 std::string Description(bool negated = false) const override;
1246 std::string Dump(unsigned short ntabs = 0) const override;
1247 void SetTopLevelContent(const std::string& content_name) override;
1248 unsigned int GetCheckSum() const override;
1249
1250 private:
1251 bool Match(const ScriptingContext& local_context) const override;
1252
1253 std::unique_ptr<ValueRef::ValueRef<int>> m_jumps;
1254 std::unique_ptr<Condition> m_condition;
1255
1256 friend class boost::serialization::access;
1257 template <typename Archive>
1258 void serialize(Archive& ar, const unsigned int version);
1259 };
1260
1261 /** Matches objects that are in systems that could have starlanes added between
1262 * them and all (not just one) of the systems containing (or that are) one of
1263 * the objects matched by \a condition. "Could have starlanes added" means
1264 * that a lane would be geometrically acceptable, meaning it wouldn't cross
1265 * any other lanes, pass too close to another system, or be too close in angle
1266 * to an existing lane. */
1267 struct FO_COMMON_API CanAddStarlaneConnection : Condition {
1268 explicit CanAddStarlaneConnection(std::unique_ptr<Condition>&& condition);
1269
1270 bool operator==(const Condition& rhs) const override;
1271 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1272 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1273 std::string Description(bool negated = false) const override;
1274 std::string Dump(unsigned short ntabs = 0) const override;
1275 void SetTopLevelContent(const std::string& content_name) override;
1276 unsigned int GetCheckSum() const override;
1277
1278 private:
1279 bool Match(const ScriptingContext& local_context) const override;
1280
1281 std::unique_ptr<Condition> m_condition;
1282
1283 friend class boost::serialization::access;
1284 template <typename Archive>
1285 void serialize(Archive& ar, const unsigned int version);
1286 };
1287
1288 /** Matches systems that have been explored by at least one Empire
1289 * in \a empire_ids. */
1290 struct FO_COMMON_API ExploredByEmpire final : public Condition {
1291 explicit ExploredByEmpire(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id);
1292
1293 bool operator==(const Condition& rhs) const override;
1294 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1295 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1296 std::string Description(bool negated = false) const override;
1297 std::string Dump(unsigned short ntabs = 0) const override;
1298 void SetTopLevelContent(const std::string& content_name) override;
1299 unsigned int GetCheckSum() const override;
1300
1301 private:
1302 bool Match(const ScriptingContext& local_context) const override;
1303
1304 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1305
1306 friend class boost::serialization::access;
1307 template <typename Archive>
1308 void serialize(Archive& ar, const unsigned int version);
1309 };
1310
1311 /** Matches objects that are moving. ... What does that mean? Departing this
1312 * turn, or were located somewhere else last turn...? */
1313 struct FO_COMMON_API Stationary final : public Condition {
1314 Stationary();
1315
1316 bool operator==(const Condition& rhs) const override;
1317 std::string Description(bool negated = false) const override;
1318 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal1319 void SetTopLevelContent(const std::string& content_name) override
1320 {}
1321 unsigned int GetCheckSum() const override;
1322
1323 private:
1324 bool Match(const ScriptingContext& local_context) const override;
1325
1326 friend class boost::serialization::access;
1327 template <typename Archive>
1328 void serialize(Archive& ar, const unsigned int version);
1329 };
1330
1331 /** Matches objects that are aggressive fleets or are in aggressive fleets. */
1332 struct FO_COMMON_API Aggressive final : public Condition {
1333 Aggressive();
1334 explicit Aggressive(bool aggressive);
1335
1336 bool operator==(const Condition& rhs) const override;
1337 std::string Description(bool negated = false) const override;
1338 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal1339 void SetTopLevelContent(const std::string& content_name) override
1340 {}
GetAggressivefinal1341 bool GetAggressive() const
1342 { return m_aggressive; }
1343 unsigned int GetCheckSum() const override;
1344
1345 private:
1346 bool Match(const ScriptingContext& local_context) const override;
1347
1348 bool m_aggressive; // false to match passive ships/fleets
1349
1350 friend class boost::serialization::access;
1351 template <typename Archive>
1352 void serialize(Archive& ar, const unsigned int version);
1353 };
1354
1355 /** Matches objects that are in systems that can be fleet supplied by the
1356 * empire with id \a empire_id */
1357 struct FO_COMMON_API FleetSupplyableByEmpire final : public Condition {
1358 explicit FleetSupplyableByEmpire(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id);
1359
1360 bool operator==(const Condition& rhs) const override;
1361 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1362 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1363 std::string Description(bool negated = false) const override;
1364 std::string Dump(unsigned short ntabs = 0) const override;
1365 void SetTopLevelContent(const std::string& content_name) override;
1366 unsigned int GetCheckSum() const override;
1367
1368 private:
1369 bool Match(const ScriptingContext& local_context) const override;
1370
1371 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1372
1373 friend class boost::serialization::access;
1374 template <typename Archive>
1375 void serialize(Archive& ar, const unsigned int version);
1376 };
1377
1378 /** Matches objects that are in systems that are connected by resource-sharing
1379 * to at least one object that meets \a condition using the resource-sharing
1380 * network of the empire with id \a empire_id */
1381 struct FO_COMMON_API ResourceSupplyConnectedByEmpire final : public Condition {
1382 ResourceSupplyConnectedByEmpire(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
1383 std::unique_ptr<Condition>&& condition);
1384
1385 bool operator==(const Condition& rhs) const override;
1386 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1387 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1388 std::string Description(bool negated = false) const override;
1389 std::string Dump(unsigned short ntabs = 0) const override;
1390 void SetTopLevelContent(const std::string& content_name) override;
1391 unsigned int GetCheckSum() const override;
1392
1393 private:
1394 bool Match(const ScriptingContext& local_context) const override;
1395
1396 std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
1397 std::unique_ptr<Condition> m_condition;
1398
1399 friend class boost::serialization::access;
1400 template <typename Archive>
1401 void serialize(Archive& ar, const unsigned int version);
1402 };
1403
1404 /** Matches objects whose species has the ability to found new colonies. */
1405 struct FO_COMMON_API CanColonize final : public Condition {
1406 CanColonize();
1407
1408 bool operator==(const Condition& rhs) const override;
1409 std::string Description(bool negated = false) const override;
1410 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal1411 void SetTopLevelContent(const std::string& content_name) override
1412 {}
1413 unsigned int GetCheckSum() const override;
1414
1415 private:
1416 bool Match(const ScriptingContext& local_context) const override;
1417
1418 friend class boost::serialization::access;
1419 template <typename Archive>
1420 void serialize(Archive& ar, const unsigned int version);
1421 };
1422
1423 /** Matches objects whose species has the ability to produce ships. */
1424 struct FO_COMMON_API CanProduceShips final : public Condition {
1425 CanProduceShips();
1426
1427 bool operator==(const Condition& rhs) const override;
1428 std::string Description(bool negated = false) const override;
1429 std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContentfinal1430 void SetTopLevelContent(const std::string& content_name) override
1431 {}
1432 unsigned int GetCheckSum() const override;
1433
1434 private:
1435 bool Match(const ScriptingContext& local_context) const override;
1436
1437 friend class boost::serialization::access;
1438 template <typename Archive>
1439 void serialize(Archive& ar, const unsigned int version);
1440 };
1441
1442 /** Matches the objects that have been targeted for bombardment by at least one
1443 * object that matches \a m_by_object_condition. */
1444 struct FO_COMMON_API OrderedBombarded final : public Condition {
1445 explicit OrderedBombarded(std::unique_ptr<Condition>&& by_object_condition);
1446
1447 bool operator==(const Condition& rhs) const override;
1448 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1449 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1450 std::string Description(bool negated = false) const override;
1451 std::string Dump(unsigned short ntabs = 0) const override;
1452 virtual void SetTopLevelContent(const std::string& content_name) override;
1453 unsigned int GetCheckSum() const override;
1454
1455 private:
1456 bool Match(const ScriptingContext& local_context) const override;
1457
1458 std::unique_ptr<Condition> m_by_object_condition;
1459
1460 friend class boost::serialization::access;
1461 template <typename Archive>
1462 void serialize(Archive& ar, const unsigned int version);
1463 };
1464
1465 /** Matches all objects if the comparisons between values of ValueRefs meet the
1466 * specified comparison types. */
1467 struct FO_COMMON_API ValueTest final : public Condition {
1468 ValueTest(std::unique_ptr<ValueRef::ValueRef<double>>&& value_ref1,
1469 ComparisonType comp1,
1470 std::unique_ptr<ValueRef::ValueRef<double>>&& value_ref2,
1471 ComparisonType comp2 = INVALID_COMPARISON,
1472 std::unique_ptr<ValueRef::ValueRef<double>>&& value_ref3 = nullptr);
1473
1474 ValueTest(std::unique_ptr<ValueRef::ValueRef<std::string>>&& value_ref1,
1475 ComparisonType comp1,
1476 std::unique_ptr<ValueRef::ValueRef<std::string>>&& value_ref2,
1477 ComparisonType comp2 = INVALID_COMPARISON,
1478 std::unique_ptr<ValueRef::ValueRef<std::string>>&& value_ref3 = nullptr);
1479
1480 ValueTest(std::unique_ptr<ValueRef::ValueRef<int>>&& value_ref1,
1481 ComparisonType comp1,
1482 std::unique_ptr<ValueRef::ValueRef<int>>&& value_ref2,
1483 ComparisonType comp2 = INVALID_COMPARISON,
1484 std::unique_ptr<ValueRef::ValueRef<int>>&& value_ref3 = nullptr);
1485
1486 bool operator==(const Condition& rhs) const override;
1487 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1488 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1489 std::string Description(bool negated = false) const override;
1490 std::string Dump(unsigned short ntabs = 0) const override;
1491 void SetTopLevelContent(const std::string& content_name) override;
1492 unsigned int GetCheckSum() const override;
1493
1494 private:
1495 bool Match(const ScriptingContext& local_context) const override;
1496
1497 std::unique_ptr<ValueRef::ValueRef<double>> m_value_ref1;
1498 std::unique_ptr<ValueRef::ValueRef<double>> m_value_ref2;
1499 std::unique_ptr<ValueRef::ValueRef<double>> m_value_ref3;
1500 std::unique_ptr<ValueRef::ValueRef<std::string>> m_string_value_ref1;
1501 std::unique_ptr<ValueRef::ValueRef<std::string>> m_string_value_ref2;
1502 std::unique_ptr<ValueRef::ValueRef<std::string>> m_string_value_ref3;
1503 std::unique_ptr<ValueRef::ValueRef<int>> m_int_value_ref1;
1504 std::unique_ptr<ValueRef::ValueRef<int>> m_int_value_ref2;
1505 std::unique_ptr<ValueRef::ValueRef<int>> m_int_value_ref3;
1506
1507 ComparisonType m_compare_type1 = INVALID_COMPARISON;
1508 ComparisonType m_compare_type2 = INVALID_COMPARISON;
1509
1510 friend class boost::serialization::access;
1511 template <typename Archive>
1512 void serialize(Archive& ar, const unsigned int version);
1513 };
1514
1515 /** Matches objects that match the location condition of the specified
1516 * content. */
1517 struct FO_COMMON_API Location final : public Condition {
1518 public:
1519 Location(ContentType content_type,
1520 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name1,
1521 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name2 = nullptr);
1522
1523 bool operator==(const Condition& rhs) const override;
1524 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1525 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1526 std::string Description(bool negated = false) const override;
1527 std::string Dump(unsigned short ntabs = 0) const override;
1528 void SetTopLevelContent(const std::string& content_name) override;
1529 unsigned int GetCheckSum() const override;
1530
1531 private:
1532 bool Match(const ScriptingContext& local_context) const override;
1533
1534 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name1;
1535 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name2;
1536 ContentType m_content_type;
1537
1538 friend class boost::serialization::access;
1539 template <typename Archive>
1540 void serialize(Archive& ar, const unsigned int version);
1541 };
1542
1543 /** Matches objects that match the combat targeting condition of the specified
1544 * content. */
1545 struct FO_COMMON_API CombatTarget final : public Condition {
1546 public:
1547 CombatTarget(ContentType content_type,
1548 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
1549
1550 bool operator==(const Condition& rhs) const override;
1551 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1552 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1553 std::string Description(bool negated = false) const override;
1554 std::string Dump(unsigned short ntabs = 0) const override;
1555 void SetTopLevelContent(const std::string& content_name) override;
1556 unsigned int GetCheckSum() const override;
1557
1558 private:
1559 bool Match(const ScriptingContext& local_context) const override;
1560
1561 std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
1562 ContentType m_content_type;
1563
1564 friend class boost::serialization::access;
1565 template <typename Archive>
1566 void serialize(Archive& ar, const unsigned int version);
1567 };
1568
1569 /** Matches all objects that match every Condition in \a operands. */
1570 struct FO_COMMON_API And final : public Condition {
1571 explicit And(std::vector<std::unique_ptr<Condition>>&& operands);
1572 And(std::unique_ptr<Condition>&& operand1,
1573 std::unique_ptr<Condition>&& operand2,
1574 std::unique_ptr<Condition>&& operand3 = nullptr,
1575 std::unique_ptr<Condition>&& operand4 = nullptr);
1576
1577 bool operator==(const Condition& rhs) const override;
1578 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1579 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1580 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
1581 ObjectSet& condition_non_targets) const override;
1582 std::string Description(bool negated = false) const override;
1583 std::string Dump(unsigned short ntabs = 0) const override;
1584 void SetTopLevelContent(const std::string& content_name) override;
1585 const std::vector<Condition*> Operands() const;
1586 unsigned int GetCheckSum() const override;
1587
1588 private:
1589 std::vector<std::unique_ptr<Condition>> m_operands;
1590
1591 friend class boost::serialization::access;
1592 template <typename Archive>
1593 void serialize(Archive& ar, const unsigned int version);
1594 };
1595
1596 /** Matches all objects that match at least one Condition in \a operands. */
1597 struct FO_COMMON_API Or final : public Condition {
1598 explicit Or(std::vector<std::unique_ptr<Condition>>&& operands);
1599 Or(std::unique_ptr<Condition>&& operand1,
1600 std::unique_ptr<Condition>&& operand2,
1601 std::unique_ptr<Condition>&& operand3 = nullptr,
1602 std::unique_ptr<Condition>&& operand4 = nullptr);
1603
1604 bool operator==(const Condition& rhs) const override;
1605 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1606 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1607 void GetDefaultInitialCandidateObjects(const ScriptingContext& parent_context,
1608 ObjectSet& condition_non_targets) const override;
1609 std::string Description(bool negated = false) const override;
1610 std::string Dump(unsigned short ntabs = 0) const override;
1611 virtual void SetTopLevelContent(const std::string& content_name) override;
1612 unsigned int GetCheckSum() const override;
1613
1614 private:
1615 std::vector<std::unique_ptr<Condition>> m_operands;
1616
1617 friend class boost::serialization::access;
1618 template <typename Archive>
1619 void serialize(Archive& ar, const unsigned int version);
1620 };
1621
1622 /** Matches all objects that do not match the Condition \a operand. */
1623 struct FO_COMMON_API Not final : public Condition {
1624 explicit Not(std::unique_ptr<Condition>&& operand);
1625
1626 bool operator==(const Condition& rhs) const override;
1627 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1628 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1629 std::string Description(bool negated = false) const override;
1630 std::string Dump(unsigned short ntabs = 0) const override;
1631 void SetTopLevelContent(const std::string& content_name) override;
1632 unsigned int GetCheckSum() const override;
1633
1634 private:
1635 std::unique_ptr<Condition> m_operand;
1636
1637 friend class boost::serialization::access;
1638 template <typename Archive>
1639 void serialize(Archive& ar, const unsigned int version);
1640 };
1641
1642 /** Tests conditions in \a operands in order, to find the first condition that
1643 * matches at least one candidate object. Matches all objects that match that
1644 * condaition, ignoring any conditions listed later. If no candidate matches
1645 * any of the conditions, it matches nothing. */
1646 struct FO_COMMON_API OrderedAlternativesOf final : public Condition {
1647 explicit OrderedAlternativesOf(std::vector<std::unique_ptr<Condition>>&& operands);
1648
1649 bool operator==(const Condition& rhs) const override;
1650 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1651 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1652 std::string Description(bool negated = false) const override;
1653 std::string Dump(unsigned short ntabs = 0) const override;
1654 void SetTopLevelContent(const std::string& content_name) override;
1655 const std::vector<Condition*> Operands() const;
1656 unsigned int GetCheckSum() const override;
1657
1658 private:
1659 std::vector<std::unique_ptr<Condition>> m_operands;
1660
1661 friend class boost::serialization::access;
1662 template <typename Archive>
1663 void serialize(Archive& ar, const unsigned int version);
1664 };
1665
1666 /** Matches whatever its subcondition matches, but has a customized description
1667 * string that is returned by Description() by looking up in the stringtable. */
1668 struct FO_COMMON_API Described final : public Condition {
1669 Described(std::unique_ptr<Condition>&& condition, const std::string& desc_stringtable_key);
1670
1671 bool operator==(const Condition& rhs) const override;
1672 void Eval(const ScriptingContext& parent_context, ObjectSet& matches,
1673 ObjectSet& non_matches, SearchDomain search_domain = NON_MATCHES) const override;
1674 std::string Description(bool negated = false) const override;
1675 std::string Dump(unsigned short ntabs = 0) const override
1676 { return m_condition ? m_condition->Dump(ntabs) : ""; }
1677 void SetTopLevelContent(const std::string& content_name) override;
1678 unsigned int GetCheckSum() const override;
1679
1680 private:
1681 std::unique_ptr<Condition> m_condition;
1682 std::string m_desc_stringtable_key;
1683
1684 friend class boost::serialization::access;
1685 template <typename Archive>
1686 void serialize(Archive& ar, const unsigned int version);
1687 };
1688
1689 // template implementations
1690 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1691 void Condition::serialize(Archive& ar, const unsigned int version)
1692 {
1693 ar & BOOST_SERIALIZATION_NVP(m_root_candidate_invariant)
1694 & BOOST_SERIALIZATION_NVP(m_target_invariant)
1695 & BOOST_SERIALIZATION_NVP(m_source_invariant);
1696 }
1697
1698 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1699 void Number::serialize(Archive& ar, const unsigned int version)
1700 {
1701 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1702 & BOOST_SERIALIZATION_NVP(m_low)
1703 & BOOST_SERIALIZATION_NVP(m_high)
1704 & BOOST_SERIALIZATION_NVP(m_condition);
1705 }
1706
1707 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1708 void Turn::serialize(Archive& ar, const unsigned int version)
1709 {
1710 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1711 & BOOST_SERIALIZATION_NVP(m_low)
1712 & BOOST_SERIALIZATION_NVP(m_high);
1713 }
1714
1715 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1716 void SortedNumberOf::serialize(Archive& ar, const unsigned int version)
1717 {
1718 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1719 & BOOST_SERIALIZATION_NVP(m_number)
1720 & BOOST_SERIALIZATION_NVP(m_sort_key)
1721 & BOOST_SERIALIZATION_NVP(m_sorting_method)
1722 & BOOST_SERIALIZATION_NVP(m_condition);
1723 }
1724
1725 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1726 void All::serialize(Archive& ar, const unsigned int version)
1727 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1728
1729 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1730 void None::serialize(Archive& ar, const unsigned int version)
1731 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1732
1733 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1734 void EmpireAffiliation::serialize(Archive& ar, const unsigned int version)
1735 {
1736 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1737 & BOOST_SERIALIZATION_NVP(m_empire_id)
1738 & BOOST_SERIALIZATION_NVP(m_affiliation);
1739 }
1740
1741 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1742 void Source::serialize(Archive& ar, const unsigned int version)
1743 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1744
1745 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1746 void RootCandidate::serialize(Archive& ar, const unsigned int version)
1747 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1748
1749 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1750 void Target::serialize(Archive& ar, const unsigned int version)
1751 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1752
1753 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1754 void Homeworld::serialize(Archive& ar, const unsigned int version)
1755 {
1756 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1757 & BOOST_SERIALIZATION_NVP(m_names);
1758 }
1759
1760 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1761 void Capital::serialize(Archive& ar, const unsigned int version)
1762 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1763
1764 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1765 void Monster::serialize(Archive& ar, const unsigned int version)
1766 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1767
1768 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1769 void Armed::serialize(Archive& ar, const unsigned int version)
1770 { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition); }
1771
1772 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1773 void Type::serialize(Archive& ar, const unsigned int version)
1774 {
1775 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1776 & BOOST_SERIALIZATION_NVP(m_type);
1777 }
1778
1779 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1780 void Building::serialize(Archive& ar, const unsigned int version)
1781 {
1782 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1783 & BOOST_SERIALIZATION_NVP(m_names);
1784 }
1785
1786 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1787 void HasSpecial::serialize(Archive& ar, const unsigned int version)
1788 {
1789 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1790 & BOOST_SERIALIZATION_NVP(m_name)
1791 & BOOST_SERIALIZATION_NVP(m_capacity_low)
1792 & BOOST_SERIALIZATION_NVP(m_capacity_high)
1793 & BOOST_SERIALIZATION_NVP(m_since_turn_low)
1794 & BOOST_SERIALIZATION_NVP(m_since_turn_high);
1795 }
1796
1797 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1798 void HasTag::serialize(Archive& ar, const unsigned int version)
1799 {
1800 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1801 & BOOST_SERIALIZATION_NVP(m_name);
1802 }
1803
1804 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1805 void CreatedOnTurn::serialize(Archive& ar, const unsigned int version)
1806 {
1807 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1808 & BOOST_SERIALIZATION_NVP(m_low)
1809 & BOOST_SERIALIZATION_NVP(m_high);
1810 }
1811
1812 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1813 void Contains::serialize(Archive& ar, const unsigned int version)
1814 {
1815 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1816 & BOOST_SERIALIZATION_NVP(m_condition);
1817 }
1818
1819 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1820 void ContainedBy::serialize(Archive& ar, const unsigned int version)
1821 {
1822 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1823 & BOOST_SERIALIZATION_NVP(m_condition);
1824 }
1825
1826 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1827 void InOrIsSystem::serialize(Archive& ar, const unsigned int version)
1828 {
1829 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1830 & BOOST_SERIALIZATION_NVP(m_system_id);
1831 }
1832
1833 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1834 void OnPlanet::serialize(Archive& ar, const unsigned int version)
1835 {
1836 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1837 & BOOST_SERIALIZATION_NVP(m_planet_id);
1838 }
1839
1840 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1841 void ObjectID::serialize(Archive& ar, const unsigned int version)
1842 {
1843 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1844 & BOOST_SERIALIZATION_NVP(m_object_id);
1845 }
1846
1847 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1848 void PlanetType::serialize(Archive& ar, const unsigned int version)
1849 {
1850 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1851 & BOOST_SERIALIZATION_NVP(m_types);
1852 }
1853
1854 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1855 void PlanetSize::serialize(Archive& ar, const unsigned int version)
1856 {
1857 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1858 & BOOST_SERIALIZATION_NVP(m_sizes);
1859 }
1860
1861 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1862 void PlanetEnvironment::serialize(Archive& ar, const unsigned int version)
1863 {
1864 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1865 & BOOST_SERIALIZATION_NVP(m_environments)
1866 & BOOST_SERIALIZATION_NVP(m_species_name);
1867 }
1868
1869 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1870 void Species::serialize(Archive& ar, const unsigned int version)
1871 {
1872 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1873 & BOOST_SERIALIZATION_NVP(m_names);
1874 }
1875
1876 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1877 void Enqueued::serialize(Archive& ar, const unsigned int version)
1878 {
1879 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1880 & BOOST_SERIALIZATION_NVP(m_build_type)
1881 & BOOST_SERIALIZATION_NVP(m_name)
1882 & BOOST_SERIALIZATION_NVP(m_design_id)
1883 & BOOST_SERIALIZATION_NVP(m_empire_id)
1884 & BOOST_SERIALIZATION_NVP(m_low)
1885 & BOOST_SERIALIZATION_NVP(m_high);
1886 }
1887
1888 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1889 void FocusType::serialize(Archive& ar, const unsigned int version)
1890 {
1891 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1892 & BOOST_SERIALIZATION_NVP(m_names);
1893 }
1894
1895 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1896 void StarType::serialize(Archive& ar, const unsigned int version)
1897 {
1898 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1899 & BOOST_SERIALIZATION_NVP(m_types);
1900 }
1901
1902 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1903 void DesignHasHull::serialize(Archive& ar, const unsigned int version)
1904 {
1905 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1906 & BOOST_SERIALIZATION_NVP(m_name);
1907 }
1908
1909 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1910 void DesignHasPart::serialize(Archive& ar, const unsigned int version)
1911 {
1912 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1913 & BOOST_SERIALIZATION_NVP(m_low)
1914 & BOOST_SERIALIZATION_NVP(m_high)
1915 & BOOST_SERIALIZATION_NVP(m_name);
1916 }
1917
1918 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1919 void DesignHasPartClass::serialize(Archive& ar, const unsigned int version)
1920 {
1921 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1922 & BOOST_SERIALIZATION_NVP(m_low)
1923 & BOOST_SERIALIZATION_NVP(m_high)
1924 & BOOST_SERIALIZATION_NVP(m_class);
1925 }
1926
1927 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1928 void PredefinedShipDesign::serialize(Archive& ar, const unsigned int version)
1929 {
1930 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1931 & BOOST_SERIALIZATION_NVP(m_name);
1932 }
1933
1934 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1935 void NumberedShipDesign::serialize(Archive& ar, const unsigned int version)
1936 {
1937 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1938 & BOOST_SERIALIZATION_NVP(m_design_id);
1939 }
1940
1941 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1942 void ProducedByEmpire::serialize(Archive& ar, const unsigned int version)
1943 {
1944 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1945 & BOOST_SERIALIZATION_NVP(m_empire_id);
1946 }
1947
1948 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1949 void Chance::serialize(Archive& ar, const unsigned int version)
1950 {
1951 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1952 & BOOST_SERIALIZATION_NVP(m_chance);
1953 }
1954
1955 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1956 void MeterValue::serialize(Archive& ar, const unsigned int version)
1957 {
1958 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1959 & BOOST_SERIALIZATION_NVP(m_meter)
1960 & BOOST_SERIALIZATION_NVP(m_low)
1961 & BOOST_SERIALIZATION_NVP(m_high);
1962 }
1963
1964 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1965 void EmpireStockpileValue::serialize(Archive& ar, const unsigned int version)
1966 {
1967 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1968 & BOOST_SERIALIZATION_NVP(m_low)
1969 & BOOST_SERIALIZATION_NVP(m_high)
1970 & BOOST_SERIALIZATION_NVP(m_empire_id);
1971 }
1972
1973 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1974 void OwnerHasTech::serialize(Archive& ar, const unsigned int version)
1975 {
1976 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1977 & BOOST_SERIALIZATION_NVP(m_name)
1978 & BOOST_SERIALIZATION_NVP(m_empire_id);
1979 }
1980
1981 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1982 void OwnerHasBuildingTypeAvailable::serialize(Archive& ar, const unsigned int version)
1983 {
1984 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1985 & BOOST_SERIALIZATION_NVP(m_name)
1986 & BOOST_SERIALIZATION_NVP(m_empire_id);
1987 }
1988
1989 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1990 void OwnerHasShipDesignAvailable::serialize(Archive& ar, const unsigned int version)
1991 {
1992 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
1993 & BOOST_SERIALIZATION_NVP(m_id)
1994 & BOOST_SERIALIZATION_NVP(m_empire_id);
1995 }
1996
1997 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1998 void OwnerHasShipPartAvailable::serialize(Archive& ar,
1999 const unsigned int version)
2000 {
2001 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2002 & BOOST_SERIALIZATION_NVP(m_name)
2003 & BOOST_SERIALIZATION_NVP(m_empire_id);
2004 }
2005
2006 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2007 void VisibleToEmpire::serialize(Archive& ar, const unsigned int version)
2008 {
2009 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2010 & BOOST_SERIALIZATION_NVP(m_empire_id);
2011 }
2012
2013 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2014 void WithinDistance::serialize(Archive& ar, const unsigned int version)
2015 {
2016 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2017 & BOOST_SERIALIZATION_NVP(m_distance)
2018 & BOOST_SERIALIZATION_NVP(m_condition);
2019 }
2020
2021 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2022 void WithinStarlaneJumps::serialize(Archive& ar, const unsigned int version)
2023 {
2024 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2025 & BOOST_SERIALIZATION_NVP(m_jumps)
2026 & BOOST_SERIALIZATION_NVP(m_condition);
2027 }
2028
2029 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2030 void CanAddStarlaneConnection::serialize(Archive& ar, const unsigned int version)
2031 {
2032 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2033 & BOOST_SERIALIZATION_NVP(m_condition);
2034 }
2035
2036 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2037 void ExploredByEmpire::serialize(Archive& ar, const unsigned int version)
2038 {
2039 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2040 & BOOST_SERIALIZATION_NVP(m_empire_id);
2041 }
2042
2043 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2044 void Stationary::serialize(Archive& ar, const unsigned int version)
2045 {
2046 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition);
2047 }
2048
2049 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2050 void Aggressive::serialize(Archive& ar, const unsigned int version)
2051 {
2052 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2053 & BOOST_SERIALIZATION_NVP(m_aggressive);
2054 }
2055
2056 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2057 void FleetSupplyableByEmpire::serialize(Archive& ar, const unsigned int version)
2058 {
2059 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2060 & BOOST_SERIALIZATION_NVP(m_empire_id);
2061 }
2062
2063 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2064 void ResourceSupplyConnectedByEmpire::serialize(Archive& ar, const unsigned int version)
2065 {
2066 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2067 & BOOST_SERIALIZATION_NVP(m_empire_id)
2068 & BOOST_SERIALIZATION_NVP(m_condition);
2069 }
2070
2071 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2072 void CanColonize::serialize(Archive& ar, const unsigned int version)
2073 {
2074 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition);
2075 }
2076
2077 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2078 void CanProduceShips::serialize(Archive& ar, const unsigned int version)
2079 {
2080 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition);
2081 }
2082
2083 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2084 void OrderedBombarded::serialize(Archive& ar, const unsigned int version)
2085 {
2086 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2087 & BOOST_SERIALIZATION_NVP(m_by_object_condition);
2088 }
2089
2090 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2091 void ValueTest::serialize(Archive& ar, const unsigned int version)
2092 {
2093 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2094 & BOOST_SERIALIZATION_NVP(m_value_ref1)
2095 & BOOST_SERIALIZATION_NVP(m_value_ref2)
2096 & BOOST_SERIALIZATION_NVP(m_value_ref3)
2097 & BOOST_SERIALIZATION_NVP(m_string_value_ref1)
2098 & BOOST_SERIALIZATION_NVP(m_string_value_ref2)
2099 & BOOST_SERIALIZATION_NVP(m_string_value_ref3)
2100 & BOOST_SERIALIZATION_NVP(m_int_value_ref1)
2101 & BOOST_SERIALIZATION_NVP(m_int_value_ref2)
2102 & BOOST_SERIALIZATION_NVP(m_int_value_ref3)
2103 & BOOST_SERIALIZATION_NVP(m_compare_type1)
2104 & BOOST_SERIALIZATION_NVP(m_compare_type2);
2105 }
2106
2107 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2108 void Location::serialize(Archive& ar, const unsigned int version)
2109 {
2110 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2111 & BOOST_SERIALIZATION_NVP(m_name1)
2112 & BOOST_SERIALIZATION_NVP(m_name2)
2113 & BOOST_SERIALIZATION_NVP(m_content_type);
2114 }
2115
2116 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2117 void CombatTarget::serialize(Archive& ar, const unsigned int version)
2118 {
2119 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2120 & BOOST_SERIALIZATION_NVP(m_name)
2121 & BOOST_SERIALIZATION_NVP(m_content_type);
2122 }
2123
2124 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2125 void And::serialize(Archive& ar, const unsigned int version)
2126 {
2127 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2128 & BOOST_SERIALIZATION_NVP(m_operands);
2129 }
2130
2131 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2132 void Or::serialize(Archive& ar, const unsigned int version)
2133 {
2134 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2135 & BOOST_SERIALIZATION_NVP(m_operands);
2136 }
2137
2138 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2139 void Not::serialize(Archive& ar, const unsigned int version)
2140 {
2141 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2142 & BOOST_SERIALIZATION_NVP(m_operand);
2143 }
2144
2145 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2146 void OrderedAlternativesOf::serialize(Archive& ar, const unsigned int version)
2147 {
2148 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2149 & BOOST_SERIALIZATION_NVP(m_operands);
2150 }
2151
2152 template <typename Archive>
serialize(Archive & ar,const unsigned int version)2153 void Described::serialize(Archive& ar, const unsigned int version)
2154 {
2155 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Condition)
2156 & BOOST_SERIALIZATION_NVP(m_condition)
2157 & BOOST_SERIALIZATION_NVP(m_desc_stringtable_key);
2158 }
2159 } // namespace Condition
2160
2161 #endif // _Conditions_h_
2162