Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef WB_MOVE_HPP_
00021 #define WB_MOVE_HPP_
00022
00023 #include "action.hpp"
00024
00025 struct temporary_unit_mover;
00026
00027 namespace wb {
00028
00029
00030
00031
00032
00033 class move : public action
00034 {
00035 public:
00036 friend class validate_visitor;
00037 friend class highlight_visitor;
00038
00039 move(size_t team_index, bool hidden, unit& mover, const pathfind::marked_route& route,
00040 arrow_ptr arrow, fake_unit_ptr fake_unit);
00041 move(config const&, bool hidden);
00042 virtual ~move(){}
00043
00044 virtual std::ostream& print(std::ostream& s) const;
00045
00046 virtual void accept(visitor& v);
00047
00048 virtual void execute(bool& success, bool& complete);
00049
00050
00051 virtual unit* get_unit() const;
00052
00053 virtual fake_unit_ptr get_fake_unit() { return fake_unit_; }
00054
00055 virtual map_location get_source_hex() const;
00056 virtual map_location get_dest_hex() const;
00057
00058 virtual void set_route(const pathfind::marked_route& route);
00059 virtual const pathfind::marked_route& get_route() const { assert(route_); return *route_; }
00060
00061
00062 virtual bool calculate_new_route(const map_location& source_hex, const map_location& dest_hex);
00063
00064 virtual arrow_ptr get_arrow() { return arrow_; }
00065
00066
00067 virtual void apply_temp_modifier(unit_map& unit_map);
00068
00069 virtual void remove_temp_modifier(unit_map& unit_map);
00070
00071
00072 virtual void draw_hex(map_location const& hex);
00073
00074 virtual void set_turn_number(int turn) { turn_number_ = turn; }
00075
00076 virtual map_location get_numbering_hex() const;
00077
00078 virtual void set_valid(bool valid);
00079 virtual bool is_valid() const { return valid_; }
00080
00081 virtual config to_config() const;
00082
00083
00084 enum ARROW_BRIGHTNESS {ARROW_BRIGHTNESS_STANDARD, ARROW_BRIGHTNESS_HIGHLIGHTED, ARROW_BRIGHTNESS_FOCUS};
00085 void set_arrow_brightness(ARROW_BRIGHTNESS x) {arrow_brightness_=x; update_arrow_style();}
00086 enum ARROW_TEXTURE {ARROW_TEXTURE_VALID, ARROW_TEXTURE_INVALID};
00087 void set_arrow_texture(ARROW_TEXTURE x) {arrow_texture_=x; update_arrow_style();}
00088
00089 protected:
00090
00091 boost::shared_ptr<move> shared_from_this() {
00092 return boost::static_pointer_cast<move>(action::shared_from_this());
00093 }
00094
00095 void calculate_move_cost();
00096
00097 size_t unit_underlying_id_;
00098 std::string unit_id_;
00099 boost::scoped_ptr<pathfind::marked_route> route_;
00100 int movement_cost_;
00101
00102 int turn_number_;
00103
00104 arrow_ptr arrow_;
00105 fake_unit_ptr fake_unit_;
00106
00107 bool valid_;
00108
00109 ARROW_BRIGHTNESS arrow_brightness_;
00110 ARROW_TEXTURE arrow_texture_;
00111
00112 private:
00113 virtual void do_hide();
00114 virtual void do_show();
00115
00116 void hide_fake_unit();
00117 void show_fake_unit();
00118
00119 void init();
00120 void update_arrow_style();
00121 boost::scoped_ptr<temporary_unit_mover> mover_;
00122 bool fake_unit_hidden_;
00123 };
00124
00125
00126 std::ostream &operator<<(std::ostream &s, move_ptr move);
00127 std::ostream &operator<<(std::ostream &s, move_const_ptr move);
00128
00129 }
00130
00131 #endif