whiteboard/recruit.hpp

Go to the documentation of this file.
00001 /* $Id: recruit.hpp 53789 2012-04-05 21:16:56Z ejls $ */
00002 /*
00003  Copyright (C) 2010 - 2012 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
00004  Part of the Battle for Wesnoth Project http://www.wesnoth.org
00005 
00006  This program is free software; you can redistribute it and/or modify
00007  it under the terms of the GNU General Public License as published by
00008  the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010  This program is distributed in the hope that it will be useful,
00011  but WITHOUT ANY WARRANTY.
00012 
00013  See the COPYING file for more details.
00014  */
00015 
00016 /**
00017  * @file
00018  */
00019 
00020 #ifndef WB_RECRUIT_HPP_
00021 #define WB_RECRUIT_HPP_
00022 
00023 
00024 #include "action.hpp"
00025 
00026 namespace wb
00027 {
00028 
00029 /*
00030  *
00031  */
00032 class recruit: public action
00033 {
00034 public:
00035     recruit(size_t team_index, bool hidden, const std::string& unit_name, const map_location& recruit_hex);
00036     recruit(config const&, bool hidden); // For deserialization
00037     virtual ~recruit();
00038 
00039     friend class validate_visitor;
00040     friend class highlight_visitor;
00041 
00042     virtual std::ostream& print(std::ostream& s) const;
00043 
00044     virtual void accept(visitor& v);
00045 
00046     virtual void execute(bool& success, bool& complete);
00047 
00048     /** Applies temporarily the result of this action to the specified unit map. */
00049     virtual void apply_temp_modifier(unit_map& unit_map);
00050     /** Removes the result of this action from the specified unit map. */
00051     virtual void remove_temp_modifier(unit_map& unit_map);
00052 
00053     /** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
00054     virtual void draw_hex(map_location const& hex);
00055 
00056     /**
00057      * @return the preferred hex to draw the numbering for this action.
00058      */
00059     virtual map_location get_numbering_hex() const { return recruit_hex_; }
00060 
00061     /** @return pointer to a fake unit representing the one that will eventually be recruited. */
00062     virtual unit* get_unit() const { return temp_unit_.get(); }
00063     /** @return pointer to the fake unit used only for visuals */
00064     virtual fake_unit_ptr get_fake_unit() { return fake_unit_; }
00065 
00066     map_location const get_recruit_hex() const { return recruit_hex_; }
00067 
00068     /**
00069      * Indicates to an action whether its status is invalid, and whether it should change its
00070      * display (and avoid any change to the game state) accordingly
00071      */
00072     virtual void set_valid(bool valid) { valid_ = valid; }
00073     virtual bool is_valid() const { return valid_; }
00074 
00075     virtual config to_config() const;
00076 
00077 protected:
00078 
00079     boost::shared_ptr<recruit> shared_from_this() {
00080         return boost::static_pointer_cast<recruit>(action::shared_from_this());
00081     }
00082 
00083     std::string unit_name_;
00084     map_location recruit_hex_;
00085     //Temp unit to insert in the future unit map when needed
00086     std::auto_ptr<unit> temp_unit_;
00087     bool valid_;
00088     fake_unit_ptr fake_unit_;
00089     int cost_;
00090 
00091 private:
00092     void init();
00093 
00094     virtual void do_hide();
00095     virtual void do_show();
00096 
00097     std::auto_ptr<unit> create_corresponding_unit();
00098 };
00099 
00100 std::ostream& operator<<(std::ostream& s, recruit_ptr recruit);
00101 std::ostream& operator<<(std::ostream& s, recruit_const_ptr recruit);
00102 
00103 }
00104 
00105 #endif /* WB_RECRUIT_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:15 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs