The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
recall.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13  */
14 
15 /**
16  * @file
17  */
18 
19 #ifndef WB_RECALL_HPP_
20 #define WB_RECALL_HPP_
21 
22 #include "action.hpp"
23 #include "map/location.hpp"
24 
25 namespace wb
26 {
27 
28 class recall: public action
29 {
30 public:
31  recall(size_t team_index, bool hidden, const unit& unit, const map_location& recall_hex);
32  recall(config const&, bool hidden); // For deserialization
33  virtual ~recall();
34 
35  virtual std::ostream& print(std::ostream& s) const;
36 
37  virtual void accept(visitor& v);
38 
39  virtual void execute(bool& success, bool& complete);
40 
41  /**
42  * Check the validity of the action.
43  *
44  * @return the error preventing the action from being executed.
45  * @retval OK if there isn't any error (the action can be executed.)
46  */
47  virtual error check_validity() const;
48 
49  /** Applies temporarily the result of this action to the specified unit map. */
50  virtual void apply_temp_modifier(unit_map& unit_map);
51  /** Removes the result of this action from the specified unit map. */
52  virtual void remove_temp_modifier(unit_map& unit_map);
53 
54  /** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
55  virtual void draw_hex(const map_location& hex);
56  /** Redrawing function, called each time the action situation might have changed. */
57  virtual void redraw();
58 
59  /**
60  * Indicates whether this hex is the preferred hex to draw the numbering for this action.
61  */
62  virtual map_location get_numbering_hex() const { return recall_hex_; }
63 
64  /** @return pointer to a copy of the recall unit. */
65  virtual unit_ptr get_unit() const { return temp_unit_; }
66  /** @return pointer to the fake unit used only for visuals */
67  virtual fake_unit_ptr get_fake_unit() { return fake_unit_; }
68 
69  map_location const get_recall_hex() const { return recall_hex_; }
70 
71  virtual config to_config() const;
72 
73 protected:
74 
76  return boost::static_pointer_cast<recall>(action::shared_from_this());
77  }
78 
79 private:
80  void init();
81 
82  virtual void do_hide();
83  virtual void do_show();
84 
88 };
89 
90 std::ostream& operator<<(std::ostream& s, recall_ptr recall);
91 std::ostream& operator<<(std::ostream& s, recall_const_ptr recall);
92 
93 }
94 
95 #endif /* WB_RECALL_HPP_ */
virtual unit_ptr get_unit() const
Definition: recall.hpp:65
virtual void do_show()
Definition: recall.cpp:243
Definition: unit.hpp:95
fake_unit_ptr fake_unit_
Definition: recall.hpp:87
bool hidden() const
Definition: action.hpp:64
virtual error check_validity() const
Check the validity of the action.
Definition: recall.cpp:203
virtual void do_hide()
Called by the non-virtual hide() and show(), respectively.
Definition: recall.cpp:242
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
Definition: recall.cpp:114
boost::shared_ptr< recall > shared_from_this()
Definition: recall.hpp:75
virtual config to_config() const
Definition: recall.cpp:226
recall(size_t team_index, bool hidden, const unit &unit, const map_location &recall_hex)
Definition: recall.cpp:59
virtual void accept(visitor &v)
Definition: recall.cpp:109
map_location const get_recall_hex() const
Definition: recall.hpp:69
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
Definition: recall.cpp:166
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
Definition: recall.cpp:139
virtual void draw_hex(const map_location &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
Definition: recall.cpp:175
size_t team_index() const
Returns the index of the team that owns this action.
Definition: action.hpp:82
error
Possible errors.
Definition: action.hpp:104
const GLdouble * v
Definition: glew.h:1359
map_location recall_hex_
Definition: recall.hpp:86
Encapsulates the map of the game.
Definition: location.hpp:38
virtual void redraw()
Redrawing function, called each time the action situation might have changed.
Definition: recall.cpp:198
virtual map_location get_numbering_hex() const
Indicates whether this hex is the preferred hex to draw the numbering for this action.
Definition: recall.hpp:62
virtual std::ostream & print(std::ostream &s) const
Definition: recall.cpp:53
void init()
Definition: recall.cpp:93
Container associating units to locations.
Definition: map.hpp:90
virtual ~recall()
Definition: recall.cpp:105
std::ostream & operator<<(std::ostream &s, action_ptr action)
Definition: action.cpp:33
Abstract base class for all the whiteboard planned actions.
Definition: action.hpp:33
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
unit_ptr temp_unit_
Definition: recall.hpp:85
GLdouble s
Definition: glew.h:1358
virtual fake_unit_ptr get_fake_unit()
Definition: recall.hpp:67
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
Definition: display.hpp:47
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses...
Definition: visitor.hpp:32