The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
shroud_clearing_action.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "vision.hpp"
4 #include "map/location.hpp"
5 #include "units/ptr.hpp"
6 
7 #include <boost/noncopyable.hpp>
8 #include <boost/ptr_container/ptr_vector.hpp>
9 #include <boost/optional.hpp>
10 namespace actions
11 {
12 /// base class for classes that clear srhoud (move/recruit/recall)
14 {
15 
17  : route()
18  , view_info(cfg.child_or_empty("unit"))
19  , original_village_owner(cfg["village_owner"].to_int())
20  , take_village_timebonus(cfg["village_timebonus"].to_bool())
21  {
22  read_locations(cfg, route);
23  }
24 
25  shroud_clearing_action(const unit_const_ptr u, const map_location& loc, int village_owner, bool village_bonus)
26  : route(1, loc)
27  , view_info(*u)
28  , original_village_owner(village_owner)
29  , take_village_timebonus(village_bonus)
30  {
31 
32  }
33 
34  typedef std::vector<map_location> t_route;
35 
36  shroud_clearing_action(const unit_const_ptr u, const t_route::const_iterator& begin, const t_route::const_iterator& end, int village_owner, bool village_bonus)
37  : route(begin, end)
38  , view_info(*u)
39  , original_village_owner(village_owner)
40  , take_village_timebonus(village_bonus)
41  {
42 
43  }
44 
45  /// The hexes occupied by the affected unit during this action.
46  /// For recruits and recalls this only contains one hex.
47  t_route route;
48  /// A record of the affected unit's ability to see.
50  /// The number of the side that preivously owned the village that the unit stepped on
51  /// Note, that recruit/recall actions can also take a village if the unit was recruits/recalled onto a village.
53  /// Whether this actions got a timebonus becasue it took a village.
55 
56  /// Change village owner on undo.
57  void return_village();
58  /// Change village owner on redo.
59  void take_village();
60 
61  void write(config & cfg) const
62  {
63  write_locations(route, cfg);
64  view_info.write(cfg.add_child("unit"));
65  cfg["village_owner"] = original_village_owner;
66  cfg["village_timebonus"] = take_village_timebonus;
67  }
68 
70 };
71 }
Class that stores the part of a unit's data that is needed for fog clearing.
Definition: vision.hpp:42
base class for classes that clear srhoud (move/recruit/recall)
void read_locations(const config &cfg, std::vector< map_location > &locs)
Parse x,y keys of a config into a vector of locations.
Definition: location.cpp:413
void take_village()
Change village owner on redo.
Various functions implementing vision (through fog of war and shroud).
bool take_village_timebonus
Whether this actions got a timebonus becasue it took a village.
shroud_clearing_action(const unit_const_ptr u, const map_location &loc, int village_owner, bool village_bonus)
shroud_clearing_action(const unit_const_ptr u, const t_route::const_iterator &begin, const t_route::const_iterator &end, int village_owner, bool village_bonus)
void return_village()
Change village owner on undo.
GLuint GLuint end
Definition: glew.h:1221
std::vector< map_location > t_route
config & add_child(const std::string &key)
Definition: config.cpp:743
Encapsulates the map of the game.
Definition: location.hpp:38
clearer_info view_info
A record of the affected unit's ability to see.
t_route route
The hexes occupied by the affected unit during this action.
void write(config &cfg) const
Writes to a config.
Definition: vision.cpp:124
int original_village_owner
The number of the side that preivously owned the village that the unit stepped on Note...
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
void write_locations(const std::vector< map_location > &locs, config &cfg)
Write a vector of locations into a config adding keys x=x1,x2,..,xn and y=y1,y2,..,yn.
Definition: location.cpp:425