The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
suppose_dead.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2016 by Tommy Schmitz
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_SUPPOSE_DEAD_HPP_
20 #define WB_SUPPOSE_DEAD_HPP_
21 
22 #include "action.hpp"
23 
24 namespace wb {
25 
26 /**
27  * A planned action that temporarily removes a unit from the map
28  * for planning purposes
29  */
30 class suppose_dead: public action
31 {
32 public:
33  suppose_dead(size_t team_index, bool hidden, unit& curr_unit, map_location const& loc);
34  suppose_dead(config const&, bool hidden); // For deserialization
35  virtual ~suppose_dead();
36 
37  /** Return the unit targeted by this action. Null if unit doesn't exist. */
38  virtual unit_ptr get_unit() const;
39  /** @return null pointer */
40  virtual fake_unit_ptr get_fake_unit() { return fake_unit_ptr(); }
41  /** Return the location at which this action was planned. */
42  virtual map_location get_source_hex() const { return loc_; }
43 
44  virtual std::ostream& print(std::ostream& s) const;
45 
46  virtual void accept(visitor &v);
47 
48  virtual void execute(bool& success, bool& complete);
49 
50  /**
51  * Check the validity of the action.
52  *
53  * @return the error preventing the action from being executed.
54  * @retval OK if there isn't any error (the action can be executed.)
55  */
56  virtual error check_validity() const;
57 
58  /** Applies temporarily the result of this action to the specified unit map. */
59  virtual void apply_temp_modifier(unit_map& unit_map);
60  /** Removes the result of this action from the specified unit map. */
61  virtual void remove_temp_modifier(unit_map& unit_map);
62 
63  /** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
64  virtual void draw_hex(const map_location& hex);
65  /** Redrawing function, called each time the action situation might have changed. */
66  virtual void redraw();
67 
68  virtual map_location get_numbering_hex() const { return loc_; }
69 
70  virtual config to_config() const;
71 
72 protected:
73 
75  return boost::static_pointer_cast<suppose_dead>(action::shared_from_this());
76  }
77 
81 
82 private:
83  void init();
84 };
85 
86 /** Dumps a suppose_dead on a stream, for debug purposes. */
87 std::ostream &operator<<(std::ostream &s, suppose_dead_ptr sup_d);
88 std::ostream &operator<<(std::ostream &s, suppose_dead_const_ptr sup_d);
89 } // end namespace wb
90 
91 #endif /* WB_SUPPOSE_DEAD_HPP_ */
92 
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
virtual unit_ptr get_unit() const
Return the unit targeted by this action.
suppose_dead(size_t team_index, bool hidden, unit &curr_unit, map_location const &loc)
virtual map_location get_source_hex() const
Return the location at which this action was planned.
Definition: unit.hpp:95
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
virtual void redraw()
Redrawing function, called each time the action situation might have changed.
size_t unit_underlying_id_
bool hidden() const
Definition: action.hpp:64
virtual error check_validity() const
Check the validity of the action.
virtual std::ostream & print(std::ostream &s) const
std::string unit_id_
virtual void accept(visitor &v)
virtual map_location get_numbering_hex() const
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
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
virtual config to_config() const
Constructs and returns a config object representing this object.
Encapsulates the map of the game.
Definition: location.hpp:38
boost::shared_ptr< suppose_dead > shared_from_this()
virtual ~suppose_dead()
map_location loc_
Container associating units to locations.
Definition: map.hpp:90
std::ostream & operator<<(std::ostream &s, action_ptr action)
Definition: action.cpp:33
virtual void draw_hex(const map_location &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
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
GLdouble s
Definition: glew.h:1358
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
Definition: display.hpp:47
virtual fake_unit_ptr get_fake_unit()
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses...
Definition: visitor.hpp:32
A planned action that temporarily removes a unit from the map for planning purposes.