whiteboard/attack.hpp

Go to the documentation of this file.
00001 /* $Id: attack.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
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 ATTACK_HPP_
00021 #define ATTACK_HPP_
00022 
00023 #include "move.hpp"
00024 
00025 namespace wb
00026 {
00027 
00028 class attack: public move
00029 {
00030 public:
00031     friend class validate_visitor;
00032     friend class highlight_visitor;
00033 
00034     attack(size_t team_index, bool hidden, unit& mover, const map_location& target_hex, int weapon_choice, const pathfind::marked_route& route,
00035             arrow_ptr arrow, fake_unit_ptr fake_unit);
00036     attack(config const&, bool hidden); // For deserialization
00037     virtual ~attack();
00038 
00039     virtual std::ostream& print(std::ostream& s) const;
00040 
00041     virtual void accept(visitor& v);
00042 
00043     virtual void execute(bool& success, bool& complete);
00044 
00045     /** Applies temporarily the result of this action to the specified unit map. */
00046     virtual void apply_temp_modifier(unit_map& unit_map);
00047     /** Removes the result of this action from the specified unit map. */
00048     virtual void remove_temp_modifier(unit_map& unit_map);
00049 
00050     /** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
00051     virtual void draw_hex(const map_location& hex);
00052 
00053     map_location const& get_target_hex() const {return target_hex_; }
00054 
00055     virtual config to_config() const;
00056 
00057 protected:
00058 
00059     boost::shared_ptr<attack> shared_from_this() {
00060         return boost::static_pointer_cast<attack>(move::shared_from_this());
00061     }
00062 
00063 private:
00064 
00065     void init();
00066 
00067     virtual void do_hide() {invalidate();}
00068     virtual void do_show() {invalidate();}
00069 
00070     ///invalidates the move-destination and attack-target hexes
00071     void invalidate();
00072 
00073     ///the target of the attack
00074     map_location target_hex_;
00075 
00076     int weapon_choice_;
00077     int attack_movement_cost_;
00078     int temp_movement_subtracted_;
00079 };
00080 
00081 /** Dumps an attack on a stream, for debug purposes. */
00082 std::ostream& operator<<(std::ostream &s, attack_ptr attack);
00083 std::ostream& operator<<(std::ostream &s, attack_const_ptr attack);
00084 
00085 } // end namespace wb
00086 
00087 #endif /* ATTACK_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Wed May 23 2012 01:03:00 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs