1 #ifndef _Effects_h_
2 #define _Effects_h_
3 
4 #include "Effect.h"
5 
6 #include "../util/Export.h"
7 
8 #include <boost/serialization/nvp.hpp>
9 #include <boost/optional/optional.hpp>
10 
11 namespace Condition {
12     typedef std::vector<std::shared_ptr<const UniverseObject>> ObjectSet;
13 }
14 
15 namespace ValueRef {
16     template <typename T>
17     struct ValueRef;
18 }
19 
20 namespace Effect {
21 /** Does nothing when executed. Useful for triggering side-effects of effect
22   * execution without modifying the gamestate. */
23 class FO_COMMON_API NoOp final : public Effect {
24 public:
25     NoOp();
26 
27     void            Execute(ScriptingContext& context) const override;
28     std::string     Dump(unsigned short ntabs = 0) const override;
SetTopLevelContent(const std::string & content_name)29     void            SetTopLevelContent(const std::string& content_name) override {}
30     unsigned int    GetCheckSum() const override;
31 
32 private:
33     friend class boost::serialization::access;
34     template <typename Archive>
35     void serialize(Archive& ar, const unsigned int version);
36 };
37 
38 /** Sets the meter of the given kind to \a value.  The max value of the meter
39   * is set if \a max == true; otherwise the current value of the meter is set.
40   * If the target of the Effect does not have the requested meter, nothing is
41   * done. */
42 class FO_COMMON_API SetMeter final : public Effect {
43 public:
44 
45     SetMeter(MeterType meter,
46              std::unique_ptr<ValueRef::ValueRef<double>>&& value,
47              const boost::optional<std::string>& accounting_label = boost::none);
48 
49     void Execute(ScriptingContext& context) const override;
50 
51     void Execute(ScriptingContext& context, const TargetSet& targets) const override;
52 
53     void Execute(ScriptingContext& context,
54                  const TargetSet& targets,
55                  AccountingMap* accounting_map,
56                  const EffectCause& effect_cause,
57                  bool only_meter_effects = false,
58                  bool only_appearance_effects = false,
59                  bool include_empire_meter_effects = false,
60                  bool only_generate_sitrep_effects = false) const override;
61 
62     std::string         Dump(unsigned short ntabs = 0) const override;
IsMeterEffect()63     bool                IsMeterEffect() const override { return true; }
64     void                SetTopLevelContent(const std::string& content_name) override;
GetMeterType()65     MeterType           GetMeterType() const { return m_meter; };
AccountingLabel()66     const std::string&  AccountingLabel() const { return m_accounting_label; }
67     unsigned int        GetCheckSum() const override;
68 
69 private:
70     MeterType m_meter;
71     std::unique_ptr<ValueRef::ValueRef<double>> m_value;
72     std::string m_accounting_label;
73 
74     friend class boost::serialization::access;
75     template <typename Archive>
76     void serialize(Archive& ar, const unsigned int version);
77 };
78 
79 /** Sets the indicated meter on all ship parts in the indicated subset.  This
80   * has no effect on non-Ship targets.  If slot_type is specified, only parts
81   * that can mount in the indicated slot type (internal or external) are
82   * affected (this is not the same at the slot type in which the part is
83   * actually located, as a part might be mountable in both types, and
84   * located in a different type than specified, and would be matched). */
85 class FO_COMMON_API SetShipPartMeter final : public Effect {
86 public:
87     /** Affects the \a meter_type meter that belongs to part(s) named \a
88         part_name. */
89     SetShipPartMeter(MeterType meter_type,
90                      std::unique_ptr<ValueRef::ValueRef<std::string>>&& part_name,
91                      std::unique_ptr<ValueRef::ValueRef<double>>&& value);
92 
93     void Execute(ScriptingContext& context) const override;
94     void Execute(ScriptingContext& context, const TargetSet& targets) const override;
95     void Execute(ScriptingContext& context,
96                  const TargetSet& targets,
97                  AccountingMap* accounting_map,
98                  const EffectCause& effect_cause,
99                  bool only_meter_effects = false,
100                  bool only_appearance_effects = false,
101                  bool include_empire_meter_effects = false,
102                  bool only_generate_sitrep_effects = false) const override;
103 
104     std::string     Dump(unsigned short ntabs = 0) const override;
IsMeterEffect()105     bool            IsMeterEffect() const override { return true; }
106     void            SetTopLevelContent(const std::string& content_name) override;
GetPartName()107     const           ValueRef::ValueRef<std::string>* GetPartName() const { return m_part_name.get(); }
GetMeterType()108     MeterType       GetMeterType() const { return m_meter; }
109     unsigned int    GetCheckSum() const override;
110 
111 private:
112     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_part_name;
113     MeterType                                           m_meter;
114     std::unique_ptr<ValueRef::ValueRef<double>>         m_value;
115 
116     friend class boost::serialization::access;
117     template <typename Archive>
118     void serialize(Archive& ar, const unsigned int version);
119 };
120 
121 /** Sets the indicated meter on the empire with the indicated id to the
122   * indicated value.  If \a meter is not a valid meter for empires,
123   * does nothing. */
124 class FO_COMMON_API SetEmpireMeter final : public Effect {
125 public:
126     SetEmpireMeter(const std::string& meter, std::unique_ptr<ValueRef::ValueRef<double>>&& value);
127 
128     SetEmpireMeter(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id, const std::string& meter,
129                    std::unique_ptr<ValueRef::ValueRef<double>>&& value);
130 
131     void Execute(ScriptingContext& context) const override;
132     void Execute(ScriptingContext& context, const TargetSet& targets) const override;
133     void Execute(ScriptingContext& context,
134                  const TargetSet& targets,
135                  AccountingMap* accounting_map,
136                  const EffectCause& effect_cause,
137                  bool only_meter_effects = false,
138                  bool only_appearance_effects = false,
139                  bool include_empire_meter_effects = false,
140                  bool only_generate_sitrep_effects = false) const override;
141 
142     std::string     Dump(unsigned short ntabs = 0) const override;
IsMeterEffect()143     bool            IsMeterEffect() const override { return true; }
IsEmpireMeterEffect()144     bool            IsEmpireMeterEffect() const override { return true; }
145     void            SetTopLevelContent(const std::string& content_name) override;
146     unsigned int    GetCheckSum() const override;
147 
148 private:
149     std::unique_ptr<ValueRef::ValueRef<int>>    m_empire_id;
150     std::string                                 m_meter;
151     std::unique_ptr<ValueRef::ValueRef<double>> m_value;
152 
153     friend class boost::serialization::access;
154     template <typename Archive>
155     void serialize(Archive& ar, const unsigned int version);
156 };
157 
158 /** Sets the empire stockpile of the target's owning empire to \a value.  If
159   * the target does not have exactly one owner, nothing is done. */
160 class FO_COMMON_API SetEmpireStockpile final : public Effect {
161 public:
162     SetEmpireStockpile(ResourceType stockpile,
163                        std::unique_ptr<ValueRef::ValueRef<double>>&& value);
164     SetEmpireStockpile(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
165                        ResourceType stockpile,
166                        std::unique_ptr<ValueRef::ValueRef<double>>&& value);
167 
168     void Execute(ScriptingContext& context) const override;
169     std::string Dump(unsigned short ntabs = 0) const override;
170     void SetTopLevelContent(const std::string& content_name) override;
171     unsigned int GetCheckSum() const override;
172 
173 private:
174     std::unique_ptr<ValueRef::ValueRef<int>>    m_empire_id;
175     ResourceType                                m_stockpile;
176     std::unique_ptr<ValueRef::ValueRef<double>> m_value;
177 
178     friend class boost::serialization::access;
179     template <typename Archive>
180     void serialize(Archive& ar, const unsigned int version);
181 };
182 
183 /** Makes the target planet the capital of its owner's empire.  If the target
184   * object is not a planet, does not have an owner, or has more than one owner
185   * the effect does nothing. */
186 class FO_COMMON_API SetEmpireCapital final : public Effect {
187 public:
188     explicit SetEmpireCapital();
189     explicit SetEmpireCapital(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id);
190 
191     void            Execute(ScriptingContext& context) const override;
192     std::string     Dump(unsigned short ntabs = 0) const override;
193     void            SetTopLevelContent(const std::string& content_name) override;
194     unsigned int    GetCheckSum() const override;
195 
196 private:
197     std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
198 
199     friend class boost::serialization::access;
200     template <typename Archive>
201     void serialize(Archive& ar, const unsigned int version);
202 };
203 
204 /** Sets the planet type of the target to \a type.  This has no effect on non-Planet targets.  Note that changing the
205     type of a PT_ASTEROID or PT_GASGIANT planet will also change its size to SZ_TINY or SZ_HUGE, respectively.
206     Similarly, changing type to PT_ASTEROID or PT_GASGIANT will also cause the size to change to SZ_ASTEROID or
207     SZ_GASGIANT, respectively. */
208 class FO_COMMON_API SetPlanetType final : public Effect {
209 public:
210     explicit SetPlanetType(std::unique_ptr<ValueRef::ValueRef<PlanetType>>&& type);
211 
212     void Execute(ScriptingContext& context) const override;
213     std::string Dump(unsigned short ntabs = 0) const override;
214     void SetTopLevelContent(const std::string& content_name) override;
215     unsigned int GetCheckSum() const override;
216 
217 private:
218     std::unique_ptr<ValueRef::ValueRef<PlanetType>> m_type;
219 
220     friend class boost::serialization::access;
221     template <typename Archive>
222     void serialize(Archive& ar, const unsigned int version);
223 };
224 
225 /** Sets the planet size of the target to \a size.  This has no effect on non-
226   * Planet targets.  Note that changing the size of a PT_ASTEROID or PT_GASGIANT
227   * planet will also change its type to PT_BARREN.  Similarly, changing size to
228   * SZ_ASTEROID or SZ_GASGIANT will also cause the type to change to PT_ASTEROID
229   * or PT_GASGIANT, respectively. */
230 class FO_COMMON_API SetPlanetSize final : public Effect {
231 public:
232     explicit SetPlanetSize(std::unique_ptr<ValueRef::ValueRef<PlanetSize>>&& size);
233 
234     void Execute(ScriptingContext& context) const override;
235     std::string Dump(unsigned short ntabs = 0) const override;
236     void SetTopLevelContent(const std::string& content_name) override;
237     unsigned int GetCheckSum() const override;
238 
239 private:
240     std::unique_ptr<ValueRef::ValueRef<PlanetSize>> m_size;
241 
242     friend class boost::serialization::access;
243     template <typename Archive>
244     void serialize(Archive& ar, const unsigned int version);
245 };
246 
247 /** Sets the species on the target to \a species_name.  This works on planets
248   * and ships, but has no effect on other objects. */
249 class FO_COMMON_API SetSpecies final : public Effect {
250 public:
251     explicit SetSpecies(std::unique_ptr<ValueRef::ValueRef<std::string>>&& species);
252 
253     void Execute(ScriptingContext& context) const override;
254     std::string Dump(unsigned short ntabs = 0) const override;
255     void SetTopLevelContent(const std::string& content_name) override;
256     unsigned int GetCheckSum() const override;
257 
258 private:
259     std::unique_ptr<ValueRef::ValueRef<std::string>> m_species_name;
260 
261     friend class boost::serialization::access;
262     template <typename Archive>
263     void serialize(Archive& ar, const unsigned int version);
264 };
265 
266 /** Sets empire \a empire_id as the owner of the target.  This has no effect if
267   * \a empire_id was already the owner of the target object. */
268 class FO_COMMON_API SetOwner final : public Effect {
269 public:
270     explicit SetOwner(std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id);
271 
272     void Execute(ScriptingContext& context) const override;
273     std::string Dump(unsigned short ntabs = 0) const override;
274     void SetTopLevelContent(const std::string& content_name) override;
275     unsigned int GetCheckSum() const override;
276 
277 private:
278     std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
279 
280     friend class boost::serialization::access;
281     template <typename Archive>
282     void serialize(Archive& ar, const unsigned int version);
283 };
284 
285 /** Sets the opinion of Species \a species for empire with id \a empire_id to
286   * \a opinion */
287 class FO_COMMON_API SetSpeciesEmpireOpinion final : public Effect {
288 public:
289     SetSpeciesEmpireOpinion(std::unique_ptr<ValueRef::ValueRef<std::string>>&& species_name,
290                             std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
291                             std::unique_ptr<ValueRef::ValueRef<double>>&& opinion);
292 
293     void Execute(ScriptingContext& context) const override;
294     std::string Dump(unsigned short ntabs = 0) const override;
295     void SetTopLevelContent(const std::string& content_name) override;
296     unsigned int GetCheckSum() const override;
297 
298 private:
299     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_species_name;
300     std::unique_ptr<ValueRef::ValueRef<int>>            m_empire_id;
301     std::unique_ptr<ValueRef::ValueRef<double>>         m_opinion;
302 
303     friend class boost::serialization::access;
304     template <typename Archive>
305     void serialize(Archive& ar, const unsigned int version);
306 };
307 
308 /** Sets the opinion of Species \a opinionated_species for other species
309   * \a rated_species to \a opinion */
310 class FO_COMMON_API SetSpeciesSpeciesOpinion final : public Effect {
311 public:
312     SetSpeciesSpeciesOpinion(std::unique_ptr<ValueRef::ValueRef<std::string>>&& opinionated_species_name,
313                              std::unique_ptr<ValueRef::ValueRef<std::string>>&& rated_species_name,
314                              std::unique_ptr<ValueRef::ValueRef<double>>&& opinion);
315 
316     void Execute(ScriptingContext& context) const override;
317     std::string Dump(unsigned short ntabs = 0) const override;
318     void SetTopLevelContent(const std::string& content_name) override;
319     unsigned int GetCheckSum() const override;
320 
321 private:
322     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_opinionated_species_name;
323     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_rated_species_name;
324     std::unique_ptr<ValueRef::ValueRef<double>>         m_opinion;
325 
326     friend class boost::serialization::access;
327     template <typename Archive>
328     void serialize(Archive& ar, const unsigned int version);
329 };
330 
331 /** Creates a new Planet with specified \a type and \a size at the system with
332   * specified \a location_id */
333 class FO_COMMON_API CreatePlanet final : public Effect {
334 public:
335     CreatePlanet(std::unique_ptr<ValueRef::ValueRef<PlanetType>>&& type,
336                  std::unique_ptr<ValueRef::ValueRef<PlanetSize>>&& size,
337                  std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
338                  std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
339 
340     void Execute(ScriptingContext& context) const override;
341     std::string Dump(unsigned short ntabs = 0) const override;
342     void SetTopLevelContent(const std::string& content_name) override;
343     unsigned int GetCheckSum() const override;
344 
345 private:
346     std::unique_ptr<ValueRef::ValueRef<PlanetType>>     m_type;
347     std::unique_ptr<ValueRef::ValueRef<PlanetSize>>     m_size;
348     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_name;
349     std::vector<std::unique_ptr<Effect>>                m_effects_to_apply_after;
350 
351     friend class boost::serialization::access;
352     template <typename Archive>
353     void serialize(Archive& ar, const unsigned int version);
354 };
355 
356 /** Creates a new Building with specified \a type on the \a target Planet. */
357 class FO_COMMON_API CreateBuilding final : public Effect {
358 public:
359     CreateBuilding(std::unique_ptr<ValueRef::ValueRef<std::string>>&& building_type_name,
360                    std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
361                    std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
362 
363     void Execute(ScriptingContext& context) const override;
364     std::string Dump(unsigned short ntabs = 0) const override;
365     void SetTopLevelContent(const std::string& content_name) override;
366     unsigned int GetCheckSum() const override;
367 
368 private:
369     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_building_type_name;
370     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_name;
371     std::vector<std::unique_ptr<Effect>>                m_effects_to_apply_after;
372 
373     friend class boost::serialization::access;
374     template <typename Archive>
375     void serialize(Archive& ar, const unsigned int version);
376 };
377 
378 /** Creates a new Ship with specified \a predefined_ship_design_name design
379   * from those in the list of PredefinedShipDesignManager, and owned by the
380   * empire with the specified \a empire_id */
381 class FO_COMMON_API CreateShip final : public Effect {
382 public:
383     CreateShip(std::unique_ptr<ValueRef::ValueRef<std::string>>&& predefined_ship_design_name,
384                std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
385                std::unique_ptr<ValueRef::ValueRef<std::string>>&& species_name,
386                std::unique_ptr<ValueRef::ValueRef<std::string>>&& ship_name,
387                std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
388 
389     CreateShip(std::unique_ptr<ValueRef::ValueRef<int>>&& ship_design_id,
390                std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id,
391                std::unique_ptr<ValueRef::ValueRef<std::string>>&& species_name,
392                std::unique_ptr<ValueRef::ValueRef<std::string>>&& ship_name,
393                std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
394 
395     void Execute(ScriptingContext& context) const override;
396     std::string Dump(unsigned short ntabs = 0) const override;
397     void SetTopLevelContent(const std::string& content_name) override;
398     unsigned int GetCheckSum() const override;
399 
400 private:
401     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_design_name;
402     std::unique_ptr<ValueRef::ValueRef<int>>            m_design_id;
403     std::unique_ptr<ValueRef::ValueRef<int>>            m_empire_id;
404     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_species_name;
405     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_name;
406     std::vector<std::unique_ptr<Effect>>                m_effects_to_apply_after;
407 
408     friend class boost::serialization::access;
409     template <typename Archive>
410     void serialize(Archive& ar, const unsigned int version);
411 };
412 
413 /** Creates a new Field with specified \a field_type_name FieldType
414   * of the specified \a size. */
415 class FO_COMMON_API CreateField final : public Effect {
416 public:
417     CreateField(std::unique_ptr<ValueRef::ValueRef<std::string>>&& field_type_name,
418                          std::unique_ptr<ValueRef::ValueRef<double>>&& size,
419                          std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
420                          std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
421 
422     CreateField(std::unique_ptr<ValueRef::ValueRef<std::string>>&& field_type_name,
423                 std::unique_ptr<ValueRef::ValueRef<double>>&& x,
424                 std::unique_ptr<ValueRef::ValueRef<double>>&& y,
425                 std::unique_ptr<ValueRef::ValueRef<double>>&& size,
426                 std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
427                 std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
428 
429     void Execute(ScriptingContext& context) const override;
430     std::string Dump(unsigned short ntabs = 0) const override;
431     void SetTopLevelContent(const std::string& content_name) override;
432     unsigned int GetCheckSum() const override;
433 
434 private:
435     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_field_type_name;
436     std::unique_ptr<ValueRef::ValueRef<double>>         m_x;
437     std::unique_ptr<ValueRef::ValueRef<double>>         m_y;
438     std::unique_ptr<ValueRef::ValueRef<double>>         m_size;
439     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_name;
440     std::vector<std::unique_ptr<Effect>>                m_effects_to_apply_after;
441 
442     friend class boost::serialization::access;
443     template <typename Archive>
444     void serialize(Archive& ar, const unsigned int version);
445 };
446 
447 /** Creates a new system with the specified \a colour and at the specified
448   * location. */
449 class FO_COMMON_API CreateSystem final : public Effect {
450 public:
451     CreateSystem(std::unique_ptr<ValueRef::ValueRef< ::StarType>>&& type,
452                  std::unique_ptr<ValueRef::ValueRef<double>>&& x,
453                  std::unique_ptr<ValueRef::ValueRef<double>>&& y,
454                  std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
455                  std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
456 
457     CreateSystem(std::unique_ptr<ValueRef::ValueRef<double>>&& x,
458                  std::unique_ptr<ValueRef::ValueRef<double>>&& y,
459                  std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
460                  std::vector<std::unique_ptr<Effect>>&& effects_to_apply_after);
461 
462     void Execute(ScriptingContext& context) const override;
463     std::string Dump(unsigned short ntabs = 0) const override;
464     void SetTopLevelContent(const std::string& content_name) override;
465     unsigned int GetCheckSum() const override;
466 
467 private:
468     std::unique_ptr<ValueRef::ValueRef< ::StarType>>    m_type;
469     std::unique_ptr<ValueRef::ValueRef<double>>         m_x;
470     std::unique_ptr<ValueRef::ValueRef<double>>         m_y;
471     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_name;
472     std::vector<std::unique_ptr<Effect>>                m_effects_to_apply_after;
473 
474     friend class boost::serialization::access;
475     template <typename Archive>
476     void serialize(Archive& ar, const unsigned int version);
477 };
478 
479 /** Destroys the target object.  When executed on objects that contain other
480   * objects (such as Fleets and Planets), all contained objects are destroyed
481   * as well.  Destroy effects delay the desctruction of their targets until
482   * after other all effects have executed, to ensure the source or target of
483   * other effects are present when they execute. */
484 class FO_COMMON_API Destroy final : public Effect {
485 public:
486     Destroy();
487 
488     void Execute(ScriptingContext& context) const override;
489     std::string Dump(unsigned short ntabs = 0) const override;
SetTopLevelContent(const std::string & content_name)490     void SetTopLevelContent(const std::string& content_name) override {}
491     unsigned int GetCheckSum() const override;
492 
493 private:
494     friend class boost::serialization::access;
495     template <typename Archive>
496     void serialize(Archive& ar, const unsigned int version);
497 };
498 
499 /** Adds the Special with the name \a name to the target object. */
500 class FO_COMMON_API AddSpecial final : public Effect {
501 public:
502     explicit AddSpecial(const std::string& name, float capacity = 1.0f);
503     explicit AddSpecial(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name,
504                         std::unique_ptr<ValueRef::ValueRef<double>>&& capacity = nullptr);
505 
506     void Execute(ScriptingContext& context) const override;
507 
508     std::string Dump(unsigned short ntabs = 0) const override;
509     void SetTopLevelContent(const std::string& content_name) override;
GetSpecialName()510     const ValueRef::ValueRef<std::string>* GetSpecialName() const { return m_name.get(); }
511     unsigned int GetCheckSum() const override;
512 
513 private:
514     std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
515     std::unique_ptr<ValueRef::ValueRef<double>> m_capacity;
516 
517     friend class boost::serialization::access;
518     template <typename Archive>
519     void serialize(Archive& ar, const unsigned int version);
520 };
521 
522 /** Removes the Special with the name \a name to the target object.  This has
523   * no effect if no such Special was already attached to the target object. */
524 class FO_COMMON_API RemoveSpecial final : public Effect {
525 public:
526     explicit RemoveSpecial(const std::string& name);
527     explicit RemoveSpecial(std::unique_ptr<ValueRef::ValueRef<std::string>>&& name);
528 
529     void Execute(ScriptingContext& context) const override;
530     std::string Dump(unsigned short ntabs = 0) const override;
531     void SetTopLevelContent(const std::string& content_name) override;
532     unsigned int GetCheckSum() const override;
533 
534 private:
535     std::unique_ptr<ValueRef::ValueRef<std::string>> m_name;
536 
537     friend class boost::serialization::access;
538     template <typename Archive>
539     void serialize(Archive& ar, const unsigned int version);
540 };
541 
542 /** Creates starlane(s) between the target system and systems that match
543   * \a other_lane_endpoint_condition */
544 class FO_COMMON_API AddStarlanes final : public Effect {
545 public:
546     explicit AddStarlanes(std::unique_ptr<Condition::Condition>&& other_lane_endpoint_condition);
547 
548     void Execute(ScriptingContext& context) const override;
549     std::string Dump(unsigned short ntabs = 0) const override;
550     void SetTopLevelContent(const std::string& content_name) override;
551     unsigned int GetCheckSum() const override;
552 
553 private:
554     std::unique_ptr<Condition::Condition> m_other_lane_endpoint_condition;
555 
556     friend class boost::serialization::access;
557     template <typename Archive>
558     void serialize(Archive& ar, const unsigned int version);
559 };
560 
561 /** Removes starlane(s) between the target system and systems that match
562   * \a other_lane_endpoint_condition */
563 class FO_COMMON_API RemoveStarlanes final : public Effect {
564 public:
565     explicit RemoveStarlanes(std::unique_ptr<Condition::Condition>&& other_lane_endpoint_condition);
566 
567     void            Execute(ScriptingContext& context) 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     std::unique_ptr<Condition::Condition> m_other_lane_endpoint_condition;
574 
575     friend class boost::serialization::access;
576     template <typename Archive>
577     void serialize(Archive& ar, const unsigned int version);
578 };
579 
580 /** Sets the star type of the target to \a type.  This has no effect on
581   * non-System targets. */
582 class FO_COMMON_API SetStarType final : public Effect {
583 public:
584     explicit SetStarType(std::unique_ptr<ValueRef::ValueRef<StarType>>&& type);
585 
586     void            Execute(ScriptingContext& context) const override;
587     std::string     Dump(unsigned short ntabs = 0) const override;
588     void            SetTopLevelContent(const std::string& content_name) override;
589     unsigned int    GetCheckSum() const override;
590 
591 private:
592     std::unique_ptr<ValueRef::ValueRef<StarType>> m_type;
593 
594     friend class boost::serialization::access;
595     template <typename Archive>
596     void serialize(Archive& ar, const unsigned int version);
597 };
598 
599 /** Moves an UniverseObject to a location of another UniverseObject that matches
600   * the condition \a location_condition.  If multiple objects match the
601   * condition, then one is chosen.  If no objects match the condition, then
602   * nothing is done. */
603 class FO_COMMON_API MoveTo final : public Effect {
604 public:
605     explicit MoveTo(std::unique_ptr<Condition::Condition>&& location_condition);
606 
607     void            Execute(ScriptingContext& context) const override;
608     std::string     Dump(unsigned short ntabs = 0) const override;
609     void            SetTopLevelContent(const std::string& content_name) override;
610     unsigned int    GetCheckSum() const override;
611 
612 private:
613     std::unique_ptr<Condition::Condition> m_location_condition;
614 
615     friend class boost::serialization::access;
616     template <typename Archive>
617     void serialize(Archive& ar, const unsigned int version);
618 };
619 
620 /** Moves an UniverseObject to a location as though it was moving in orbit of
621   * some object or position on the map.  Sign of \a speed indicates CCW / CW
622   * rotation.*/
623 class FO_COMMON_API MoveInOrbit final : public Effect {
624 public:
625     MoveInOrbit(std::unique_ptr<ValueRef::ValueRef<double>>&& speed,
626                 std::unique_ptr<Condition::Condition>&& focal_point_condition);
627     MoveInOrbit(std::unique_ptr<ValueRef::ValueRef<double>>&& speed,
628                 std::unique_ptr<ValueRef::ValueRef<double>>&& focus_x = nullptr,
629                 std::unique_ptr<ValueRef::ValueRef<double>>&& focus_y = nullptr);
630 
631     void            Execute(ScriptingContext& context) const override;
632     std::string     Dump(unsigned short ntabs = 0) const override;
633     void            SetTopLevelContent(const std::string& content_name) override;
634     unsigned int    GetCheckSum() const override;
635 
636 private:
637     std::unique_ptr<ValueRef::ValueRef<double>> m_speed;
638     std::unique_ptr<Condition::Condition>       m_focal_point_condition;
639     std::unique_ptr<ValueRef::ValueRef<double>> m_focus_x;
640     std::unique_ptr<ValueRef::ValueRef<double>> m_focus_y;
641 
642     friend class boost::serialization::access;
643     template <typename Archive>
644     void serialize(Archive& ar, const unsigned int version);
645 };
646 
647 /** Moves an UniverseObject a specified distance towards some object or
648   * position on the map. */
649 class FO_COMMON_API MoveTowards final : public Effect {
650 public:
651     MoveTowards(std::unique_ptr<ValueRef::ValueRef<double>>&& speed,
652                 std::unique_ptr<Condition::Condition>&& dest_condition);
653     MoveTowards(std::unique_ptr<ValueRef::ValueRef<double>>&& speed,
654                 std::unique_ptr<ValueRef::ValueRef<double>>&& dest_x = nullptr,
655                 std::unique_ptr<ValueRef::ValueRef<double>>&& dest_y = nullptr);
656 
657     void            Execute(ScriptingContext& context) const override;
658     std::string     Dump(unsigned short ntabs = 0) const override;
659     void            SetTopLevelContent(const std::string& content_name) override;
660     unsigned int    GetCheckSum() const override;
661 
662 private:
663     std::unique_ptr<ValueRef::ValueRef<double>> m_speed;
664     std::unique_ptr<Condition::Condition>       m_dest_condition;
665     std::unique_ptr<ValueRef::ValueRef<double>> m_dest_x;
666     std::unique_ptr<ValueRef::ValueRef<double>> m_dest_y;
667 
668     friend class boost::serialization::access;
669     template <typename Archive>
670     void serialize(Archive& ar, const unsigned int version);
671 };
672 
673 /** Sets the route of the target fleet to move to an UniverseObject that
674   * matches the condition \a location_condition.  If multiple objects match the
675   * condition, then one is chosen.  If no objects match the condition, then
676   * nothing is done. */
677 class FO_COMMON_API SetDestination final : public Effect {
678 public:
679     explicit SetDestination(std::unique_ptr<Condition::Condition>&& location_condition);
680 
681     void            Execute(ScriptingContext& context) const override;
682     std::string     Dump(unsigned short ntabs = 0) const override;
683     void            SetTopLevelContent(const std::string& content_name) override;
684     unsigned int    GetCheckSum() const override;
685 
686 private:
687     std::unique_ptr<Condition::Condition> m_location_condition;
688 
689     friend class boost::serialization::access;
690     template <typename Archive>
691     void serialize(Archive& ar, const unsigned int version);
692 };
693 
694 /** Sets aggression level of the target object. */
695 class FO_COMMON_API SetAggression final : public Effect {
696 public:
697     explicit SetAggression(bool aggressive);
698 
699     void            Execute(ScriptingContext& context) const override;
700     std::string     Dump(unsigned short ntabs = 0) const override;
SetTopLevelContent(const std::string & content_name)701     void            SetTopLevelContent(const std::string& content_name) override {}
702     unsigned int    GetCheckSum() const override;
703 
704 private:
705     bool m_aggressive;
706 
707     friend class boost::serialization::access;
708     template <typename Archive>
709     void serialize(Archive& ar, const unsigned int version);
710 };
711 
712 /** Causes the owner empire of the target object to win the game.  If the
713   * target object has multiple owners, nothing is done. */
714 class FO_COMMON_API Victory final : public Effect {
715 public:
716     explicit Victory(const std::string& reason_string); // TODO: Make this a ValueRef<std::string>*
717 
718     void            Execute(ScriptingContext& context) const override;
719     std::string     Dump(unsigned short ntabs = 0) const override;
SetTopLevelContent(const std::string & content_name)720     void            SetTopLevelContent(const std::string& content_name) override {}
721     unsigned int    GetCheckSum() const override;
722 
723 private:
724     std::string m_reason_string;
725 
726     friend class boost::serialization::access;
727     template <typename Archive>
728     void serialize(Archive& ar, const unsigned int version);
729 };
730 
731 /** Sets whether an empire has researched at tech, and how much research
732   * progress towards that tech has been completed. */
733 class FO_COMMON_API SetEmpireTechProgress final : public Effect {
734 public:
735     SetEmpireTechProgress(std::unique_ptr<ValueRef::ValueRef<std::string>>&& tech_name,
736                           std::unique_ptr<ValueRef::ValueRef<double>>&& research_progress,
737                           std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id = nullptr);
738 
739     void            Execute(ScriptingContext& context) const override;
740     std::string     Dump(unsigned short ntabs = 0) const override;
741     void            SetTopLevelContent(const std::string& content_name) override;
742     unsigned int    GetCheckSum() const override;
743 
744 private:
745     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_tech_name;
746     std::unique_ptr<ValueRef::ValueRef<double>>         m_research_progress;
747     std::unique_ptr<ValueRef::ValueRef<int>>            m_empire_id;
748 
749     friend class boost::serialization::access;
750     template <typename Archive>
751     void serialize(Archive& ar, const unsigned int version);
752 };
753 
754 class FO_COMMON_API GiveEmpireTech final : public Effect {
755 public:
756     explicit GiveEmpireTech(std::unique_ptr<ValueRef::ValueRef<std::string>>&& tech_name,
757                             std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id = nullptr);
758 
759     void            Execute(ScriptingContext& context) const override;
760     std::string     Dump(unsigned short ntabs = 0) const override;
761     void            SetTopLevelContent(const std::string& content_name) override;
762     unsigned int    GetCheckSum() const override;
763 
764 private:
765     std::unique_ptr<ValueRef::ValueRef<std::string>>    m_tech_name;
766     std::unique_ptr<ValueRef::ValueRef<int>>            m_empire_id;
767 
768     friend class boost::serialization::access;
769     template <typename Archive>
770     void serialize(Archive& ar, const unsigned int version);
771 };
772 
773 /** Generates a sitrep message for the empire with id \a recipient_empire_id.
774   * The message text is the user string specified in \a message_string with
775   * string substitutions into the message text as specified in \a message_parameters
776   * which are substituted as string parameters %1%, %2%, %3%, etc. in the order
777   * they are specified.  Extra parameters beyond those needed by \a message_string
778   * are ignored, and missing parameters are left as blank text. */
779 class FO_COMMON_API GenerateSitRepMessage final : public Effect {
780 public:
781     using MessageParams =  std::vector<std::pair<
782         std::string, std::unique_ptr<ValueRef::ValueRef<std::string>>>>;
783 
784     GenerateSitRepMessage(const std::string& message_string, const std::string& icon,
785                           MessageParams&& message_parameters,
786                           std::unique_ptr<ValueRef::ValueRef<int>>&& recipient_empire_id,
787                           EmpireAffiliationType affiliation,
788                           const std::string label = "",
789                           bool stringtable_lookup = true);
790     GenerateSitRepMessage(const std::string& message_string, const std::string& icon,
791                           MessageParams&& message_parameters,
792                           EmpireAffiliationType affiliation,
793                           std::unique_ptr<Condition::Condition>&& condition,
794                           const std::string label = "",
795                           bool stringtable_lookup = true);
796     GenerateSitRepMessage(const std::string& message_string, const std::string& icon,
797                           MessageParams&& message_parameters,
798                           EmpireAffiliationType affiliation,
799                           const std::string& label = "",
800                           bool stringtable_lookup = true);
801 
802     void                Execute(ScriptingContext& context) const override;
IsSitrepEffect()803     bool                IsSitrepEffect() const override     { return true; }
804     std::string         Dump(unsigned short ntabs = 0) const override;
805     void                SetTopLevelContent(const std::string& content_name) override;
MessageString()806     const std::string&  MessageString() const               { return m_message_string; }
Icon()807     const std::string&  Icon() const                        { return m_icon; }
808 
809     std::vector<std::pair<std::string, ValueRef::ValueRef<std::string>* >> MessageParameters() const;
810 
RecipientID()811     ValueRef::ValueRef<int>*    RecipientID() const     { return m_recipient_empire_id.get(); }
GetCondition()812     Condition::Condition*       GetCondition() const    { return m_condition.get(); }
Affiliation()813     EmpireAffiliationType           Affiliation() const     { return m_affiliation; }
814     unsigned int                    GetCheckSum() const override;
815 
816 private:
817     std::string             m_message_string;
818     std::string             m_icon;
819     std::vector<std::pair<std::string, std::unique_ptr<ValueRef::ValueRef<std::string>>>>
820                             m_message_parameters;
821     std::unique_ptr<ValueRef::ValueRef<int>>
822                             m_recipient_empire_id;
823     std::unique_ptr<Condition::Condition>
824                             m_condition;
825     EmpireAffiliationType   m_affiliation;
826     std::string             m_label;
827     bool                    m_stringtable_lookup;
828 
829     friend class boost::serialization::access;
830     template <typename Archive>
831     void serialize(Archive& ar, const unsigned int version);
832 };
833 
834 /** Applies an overlay texture to Systems. */
835 class FO_COMMON_API SetOverlayTexture final : public Effect {
836 public:
837     SetOverlayTexture(const std::string& texture, std::unique_ptr<ValueRef::ValueRef<double>>&& size);
838     SetOverlayTexture(const std::string& texture, ValueRef::ValueRef<double>* size);
839 
840     void Execute(ScriptingContext& context) const override;
841     std::string Dump(unsigned short ntabs = 0) const override;
IsAppearanceEffect()842     bool IsAppearanceEffect() const override { return true; }
843     void SetTopLevelContent(const std::string& content_name) override;
844     unsigned int GetCheckSum() const override;
845 
846 private:
847     std::string m_texture;
848     std::unique_ptr<ValueRef::ValueRef<double>> m_size;
849 
850     friend class boost::serialization::access;
851     template <typename Archive>
852     void serialize(Archive& ar, const unsigned int version);
853 };
854 
855 /** Applies a texture to Planets. */
856 class FO_COMMON_API SetTexture final : public Effect {
857 public:
858     explicit SetTexture(const std::string& texture);
859 
860     void Execute(ScriptingContext& context) const override;
861 
862     std::string Dump(unsigned short ntabs = 0) const override;
IsAppearanceEffect()863     bool IsAppearanceEffect() const override { return true; }
SetTopLevelContent(const std::string & content_name)864     void SetTopLevelContent(const std::string& content_name) override {}
865     unsigned int GetCheckSum() const override;
866 
867 private:
868     std::string m_texture;
869 
870     friend class boost::serialization::access;
871     template <typename Archive>
872     void serialize(Archive& ar, const unsigned int version);
873 };
874 
875 /** Sets visibility of an object for an empire, independent of standard
876   * visibility mechanics. */
877 class FO_COMMON_API SetVisibility final : public Effect {
878 public:
879     SetVisibility(std::unique_ptr<ValueRef::ValueRef<Visibility>> vis,
880                   EmpireAffiliationType affiliation,
881                   std::unique_ptr<ValueRef::ValueRef<int>>&& empire_id = nullptr,
882                   std::unique_ptr<Condition::Condition>&& of_objects = nullptr);    // if not specified, acts on target. if specified, acts on all matching objects
883 
884     void Execute(ScriptingContext& context) const override;
885     std::string Dump(unsigned short ntabs = 0) const override;
886     void SetTopLevelContent(const std::string& content_name) override;
887 
GetVisibility()888     ValueRef::ValueRef<Visibility>* GetVisibility() const
889     { return m_vis.get(); }
890 
EmpireID()891     ValueRef::ValueRef<int>* EmpireID() const
892     { return m_empire_id.get(); }
893 
Affiliation()894     EmpireAffiliationType Affiliation() const
895     { return m_affiliation; }
896 
OfObjectsCondition()897     Condition::Condition* OfObjectsCondition() const
898     { return m_condition.get(); }
899 
900     unsigned int GetCheckSum() const override;
901 
902 private:
903     std::unique_ptr<ValueRef::ValueRef<Visibility>> m_vis;
904     std::unique_ptr<ValueRef::ValueRef<int>> m_empire_id;
905     EmpireAffiliationType m_affiliation;
906     std::unique_ptr<Condition::Condition> m_condition;
907 
908     friend class boost::serialization::access;
909     template <typename Archive>
910     void serialize(Archive& ar, const unsigned int version);
911 };
912 
913 /** Executes a set of effects if an execution-time condition is met, or an
914   * alterative set of effects if the condition is not met. */
915 class FO_COMMON_API Conditional final : public Effect {
916 public:
917     Conditional(std::unique_ptr<Condition::Condition>&& target_condition,
918                 std::vector<std::unique_ptr<Effect>>&& true_effects,
919                 std::vector<std::unique_ptr<Effect>>&& false_effects);
920 
921     void Execute(ScriptingContext& context) const override;
922     /** Note: executes all of the true or all of the false effects on each
923         target, without considering any of the only_* type flags. */
924 
925     void Execute(ScriptingContext& context, const TargetSet& targets) const override;
926 
927     void Execute(ScriptingContext& context,
928                  const TargetSet& targets,
929                  AccountingMap* accounting_map,
930                  const EffectCause& effect_cause,
931                  bool only_meter_effects = false,
932                  bool only_appearance_effects = false,
933                  bool include_empire_meter_effects = false,
934                  bool only_generate_sitrep_effects = false) const override;
935 
936     std::string Dump(unsigned short ntabs = 0) const override;
937 
938     bool IsMeterEffect() const override;
939     bool IsAppearanceEffect() const override;
940     bool IsSitrepEffect() const override;
IsConditionalEffect()941     bool IsConditionalEffect() const override { return true; }
942 
943     void SetTopLevelContent(const std::string& content_name) override;
944 
945     unsigned int GetCheckSum() const override;
946 
947 private:
948     std::unique_ptr<Condition::Condition> m_target_condition; // condition to apply to each target object to determine which effects to execute
949     std::vector<std::unique_ptr<Effect>> m_true_effects;      // effects to execute if m_target_condition matches target object
950     std::vector<std::unique_ptr<Effect>> m_false_effects;     // effects to execute if m_target_condition does not match target object
951 
952     friend class boost::serialization::access;
953     template <typename Archive>
954     void serialize(Archive& ar, const unsigned int version);
955 };
956 
957 
958 // template implementations
959 template <typename Archive>
serialize(Archive & ar,const unsigned int version)960 void EffectsGroup::serialize(Archive& ar, const unsigned int version)
961 {
962     ar  & BOOST_SERIALIZATION_NVP(m_scope)
963         & BOOST_SERIALIZATION_NVP(m_activation)
964         & BOOST_SERIALIZATION_NVP(m_stacking_group)
965         & BOOST_SERIALIZATION_NVP(m_effects)
966         & BOOST_SERIALIZATION_NVP(m_description)
967         & BOOST_SERIALIZATION_NVP(m_content_name);
968 }
969 
970 template <typename Archive>
serialize(Archive & ar,const unsigned int version)971 void Effect::serialize(Archive& ar, const unsigned int version)
972 {}
973 
974 template <typename Archive>
serialize(Archive & ar,const unsigned int version)975 void NoOp::serialize(Archive& ar, const unsigned int version)
976 {
977     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect);
978 }
979 
980 template <typename Archive>
serialize(Archive & ar,const unsigned int version)981 void SetMeter::serialize(Archive& ar, const unsigned int version)
982 {
983     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
984         & BOOST_SERIALIZATION_NVP(m_meter)
985         & BOOST_SERIALIZATION_NVP(m_value)
986         & BOOST_SERIALIZATION_NVP(m_accounting_label);
987 }
988 
989 template <typename Archive>
serialize(Archive & ar,const unsigned int version)990 void SetShipPartMeter::serialize(Archive& ar, const unsigned int version)
991 {
992     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
993         & BOOST_SERIALIZATION_NVP(m_part_name)
994         & BOOST_SERIALIZATION_NVP(m_meter)
995         & BOOST_SERIALIZATION_NVP(m_value);
996 }
997 
998 template <typename Archive>
serialize(Archive & ar,const unsigned int version)999 void SetEmpireMeter::serialize(Archive& ar, const unsigned int version)
1000 {
1001     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1002         & BOOST_SERIALIZATION_NVP(m_empire_id)
1003         & BOOST_SERIALIZATION_NVP(m_meter)
1004         & BOOST_SERIALIZATION_NVP(m_value);
1005 }
1006 
1007 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1008 void SetEmpireStockpile::serialize(Archive& ar, const unsigned int version)
1009 {
1010     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1011         & BOOST_SERIALIZATION_NVP(m_empire_id)
1012         & BOOST_SERIALIZATION_NVP(m_stockpile)
1013         & BOOST_SERIALIZATION_NVP(m_value);
1014 }
1015 
1016 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1017 void SetEmpireCapital::serialize(Archive& ar, const unsigned int version)
1018 {
1019     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1020         & BOOST_SERIALIZATION_NVP(m_empire_id);
1021 }
1022 
1023 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1024 void SetPlanetType::serialize(Archive& ar, const unsigned int version)
1025 {
1026     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1027         & BOOST_SERIALIZATION_NVP(m_type);
1028 }
1029 
1030 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1031 void SetPlanetSize::serialize(Archive& ar, const unsigned int version)
1032 {
1033     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1034         & BOOST_SERIALIZATION_NVP(m_size);
1035 }
1036 
1037 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1038 void SetSpecies::serialize(Archive& ar, const unsigned int version)
1039 {
1040     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1041         & BOOST_SERIALIZATION_NVP(m_species_name);
1042 }
1043 
1044 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1045 void SetOwner::serialize(Archive& ar, const unsigned int version)
1046 {
1047     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1048         & BOOST_SERIALIZATION_NVP(m_empire_id);
1049 }
1050 
1051 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1052 void CreatePlanet::serialize(Archive& ar, const unsigned int version)
1053 {
1054     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1055         & BOOST_SERIALIZATION_NVP(m_type)
1056         & BOOST_SERIALIZATION_NVP(m_size)
1057         & BOOST_SERIALIZATION_NVP(m_name)
1058         & BOOST_SERIALIZATION_NVP(m_effects_to_apply_after);
1059 }
1060 
1061 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1062 void CreateBuilding::serialize(Archive& ar, const unsigned int version)
1063 {
1064     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1065         & BOOST_SERIALIZATION_NVP(m_building_type_name)
1066         & BOOST_SERIALIZATION_NVP(m_name)
1067         & BOOST_SERIALIZATION_NVP(m_effects_to_apply_after);
1068 }
1069 
1070 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1071 void CreateShip::serialize(Archive& ar, const unsigned int version)
1072 {
1073     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1074         & BOOST_SERIALIZATION_NVP(m_design_name)
1075         & BOOST_SERIALIZATION_NVP(m_design_id)
1076         & BOOST_SERIALIZATION_NVP(m_empire_id)
1077         & BOOST_SERIALIZATION_NVP(m_species_name)
1078         & BOOST_SERIALIZATION_NVP(m_name)
1079         & BOOST_SERIALIZATION_NVP(m_effects_to_apply_after);
1080 }
1081 
1082 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1083 void CreateField::serialize(Archive& ar, const unsigned int version)
1084 {
1085     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1086         & BOOST_SERIALIZATION_NVP(m_field_type_name)
1087         & BOOST_SERIALIZATION_NVP(m_x)
1088         & BOOST_SERIALIZATION_NVP(m_y)
1089         & BOOST_SERIALIZATION_NVP(m_size)
1090         & BOOST_SERIALIZATION_NVP(m_name)
1091         & BOOST_SERIALIZATION_NVP(m_effects_to_apply_after);
1092 }
1093 
1094 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1095 void CreateSystem::serialize(Archive& ar, const unsigned int version)
1096 {
1097     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1098         & BOOST_SERIALIZATION_NVP(m_type)
1099         & BOOST_SERIALIZATION_NVP(m_x)
1100         & BOOST_SERIALIZATION_NVP(m_y)
1101         & BOOST_SERIALIZATION_NVP(m_name)
1102         & BOOST_SERIALIZATION_NVP(m_effects_to_apply_after);
1103 }
1104 
1105 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1106 void Destroy::serialize(Archive& ar, const unsigned int version)
1107 {
1108     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect);
1109 }
1110 
1111 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1112 void AddSpecial::serialize(Archive& ar, const unsigned int version)
1113 {
1114     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1115         & BOOST_SERIALIZATION_NVP(m_name)
1116         & BOOST_SERIALIZATION_NVP(m_capacity);
1117 }
1118 
1119 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1120 void RemoveSpecial::serialize(Archive& ar, const unsigned int version)
1121 {
1122     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1123         & BOOST_SERIALIZATION_NVP(m_name);
1124 }
1125 
1126 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1127 void AddStarlanes::serialize(Archive& ar, const unsigned int version)
1128 {
1129     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1130         & BOOST_SERIALIZATION_NVP(m_other_lane_endpoint_condition);
1131 }
1132 
1133 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1134 void RemoveStarlanes::serialize(Archive& ar, const unsigned int version)
1135 {
1136     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1137         & BOOST_SERIALIZATION_NVP(m_other_lane_endpoint_condition);
1138 }
1139 
1140 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1141 void SetStarType::serialize(Archive& ar, const unsigned int version)
1142 {
1143     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1144         & BOOST_SERIALIZATION_NVP(m_type);
1145 }
1146 
1147 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1148 void MoveTo::serialize(Archive& ar, const unsigned int version)
1149 {
1150     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1151         & BOOST_SERIALIZATION_NVP(m_location_condition);
1152 }
1153 
1154 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1155 void MoveInOrbit::serialize(Archive& ar, const unsigned int version)
1156 {
1157     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1158         & BOOST_SERIALIZATION_NVP(m_speed)
1159         & BOOST_SERIALIZATION_NVP(m_focal_point_condition)
1160         & BOOST_SERIALIZATION_NVP(m_focus_x)
1161         & BOOST_SERIALIZATION_NVP(m_focus_y);
1162 }
1163 
1164 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1165 void MoveTowards::serialize(Archive& ar, const unsigned int version)
1166 {
1167     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1168         & BOOST_SERIALIZATION_NVP(m_speed)
1169         & BOOST_SERIALIZATION_NVP(m_dest_condition)
1170         & BOOST_SERIALIZATION_NVP(m_dest_x)
1171         & BOOST_SERIALIZATION_NVP(m_dest_y);
1172 }
1173 
1174 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1175 void SetDestination::serialize(Archive& ar, const unsigned int version)
1176 {
1177     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1178         & BOOST_SERIALIZATION_NVP(m_location_condition);
1179 }
1180 
1181 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1182 void SetAggression::serialize(Archive& ar, const unsigned int version)
1183 {
1184     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1185         & BOOST_SERIALIZATION_NVP(m_aggressive);
1186 }
1187 
1188 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1189 void Victory::serialize(Archive& ar, const unsigned int version)
1190 {
1191     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1192         & BOOST_SERIALIZATION_NVP(m_reason_string);
1193 }
1194 
1195 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1196 void SetEmpireTechProgress::serialize(Archive& ar, const unsigned int version)
1197 {
1198     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1199         & BOOST_SERIALIZATION_NVP(m_tech_name)
1200         & BOOST_SERIALIZATION_NVP(m_research_progress)
1201         & BOOST_SERIALIZATION_NVP(m_empire_id);
1202 }
1203 
1204 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1205 void GiveEmpireTech::serialize(Archive& ar, const unsigned int version)
1206 {
1207     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1208         & BOOST_SERIALIZATION_NVP(m_tech_name)
1209         & BOOST_SERIALIZATION_NVP(m_empire_id);
1210 }
1211 
1212 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1213 void GenerateSitRepMessage::serialize(Archive& ar, const unsigned int version)
1214 {
1215     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1216         & BOOST_SERIALIZATION_NVP(m_message_string)
1217         & BOOST_SERIALIZATION_NVP(m_icon)
1218         & BOOST_SERIALIZATION_NVP(m_message_parameters)
1219         & BOOST_SERIALIZATION_NVP(m_recipient_empire_id)
1220         & BOOST_SERIALIZATION_NVP(m_condition)
1221         & BOOST_SERIALIZATION_NVP(m_affiliation)
1222         & BOOST_SERIALIZATION_NVP(m_label)
1223         & BOOST_SERIALIZATION_NVP(m_stringtable_lookup);
1224 }
1225 
1226 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1227 void SetOverlayTexture::serialize(Archive& ar, const unsigned int version)
1228 {
1229     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1230         & BOOST_SERIALIZATION_NVP(m_texture)
1231         & BOOST_SERIALIZATION_NVP(m_size);
1232 }
1233 
1234 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1235 void SetTexture::serialize(Archive& ar, const unsigned int version)
1236 {
1237     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1238         & BOOST_SERIALIZATION_NVP(m_texture);
1239 }
1240 
1241 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1242 void SetVisibility::serialize(Archive& ar, const unsigned int version)
1243 {
1244     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1245         & BOOST_SERIALIZATION_NVP(m_vis)
1246         & BOOST_SERIALIZATION_NVP(m_empire_id)
1247         & BOOST_SERIALIZATION_NVP(m_affiliation)
1248         & BOOST_SERIALIZATION_NVP(m_condition);
1249 }
1250 
1251 template <typename Archive>
serialize(Archive & ar,const unsigned int version)1252 void Conditional::serialize(Archive& ar, const unsigned int version)
1253 {
1254     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Effect)
1255         & BOOST_SERIALIZATION_NVP(m_target_condition)
1256         & BOOST_SERIALIZATION_NVP(m_true_effects)
1257         & BOOST_SERIALIZATION_NVP(m_false_effects);
1258 }
1259 } // namespace Effect
1260 
1261 #endif // _Effects_h_
1262