The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
aspect_attacks.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Yurii Chernyi <[email protected]>
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  * Aspect: attacks
17  * @file
18  */
19 
20 #ifndef AI_TESTING_ASPECT_ATTACKS_HPP_INCLUDED
21 #define AI_TESTING_ASPECT_ATTACKS_HPP_INCLUDED
22 
23 #include "ai/composite/aspect.hpp"
24 #include "units/filter.hpp"
25 
26 #ifdef _MSC_VER
27 #pragma warning(push)
28 //silence "inherits via dominance" warnings
29 #pragma warning(disable:4250)
30 #endif
31 
32 namespace ai {
33 
34 
35 namespace ai_default_rca {
36 
37 class aspect_attacks_base : public typesafe_aspect<attacks_vector> {
38 public:
39  aspect_attacks_base(readonly_context &context, const config &cfg, const std::string &id);
40 
41 
42  virtual ~aspect_attacks_base() {}
43 
44 
45  virtual void recalculate() const;
46 
47 
48  virtual bool is_allowed_attacker(const unit& u) const = 0;
49  virtual bool is_allowed_enemy(const unit& u) const = 0;
50 
51 
52 protected:
54 
55  void do_attack_analysis(const map_location& loc,
56  const move_map& srcdst, const move_map& dstsrc,
57  const move_map& fullmove_srcdst, const move_map& fullmove_dstsrc,
58  const move_map& enemy_srcdst, const move_map& enemy_dstsrc,
59  const map_location* tiles, bool* used_locations,
60  std::vector<map_location>& units,
61  std::vector<attack_analysis>& result,
62  attack_analysis& cur_analysis,
63  const team &current_team) const;
64  static int rate_terrain(const unit& u, const map_location& loc);
65 };
66 
68 public:
69  aspect_attacks(readonly_context &context, const config &cfg, const std::string &id);
70  virtual ~aspect_attacks() {}
71 
72  virtual bool is_allowed_attacker(const unit& u) const;
73  virtual bool is_allowed_enemy(const unit& u) const;
74  virtual config to_config() const;
75 private:
77 };
78 
79 } // end of namespace testing_ai_default
80 
85 };
86 
88 public:
90  virtual ~aspect_attacks_lua() {}
91 
92  virtual bool is_allowed_attacker(const unit& u) const;
93  virtual bool is_allowed_enemy(const unit& u) const;
94  virtual config to_config() const;
95  virtual void recalculate() const;
96 private:
101 };
102 
103 } // end of namespace ai
104 
105 #ifdef _MSC_VER
106 #pragma warning(pop)
107 #endif
108 
109 #endif
boost::shared_ptr< unit_filter > filter_own_
boost::shared_ptr< attacks_vector > analyze_targets() const
aspect_attacks_lua(readonly_context &context, const config &cfg, const std::string &id, boost::shared_ptr< lua_ai_context > &l_ctx)
Definition: unit.hpp:95
boost::shared_ptr< lua_object< aspect_attacks_lua_filter > > obj_
boost::shared_ptr< lua_ai_action_handler > handler_
aspect_attacks_base(readonly_context &context, const config &cfg, const std::string &id)
virtual config to_config() const
boost::shared_ptr< unit_filter > filter_enemy_
virtual config to_config() const
std::multimap< map_location, map_location > move_map
The standard way in which a map of possible moves is recorded.
Definition: game_info.hpp:47
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:57
boost::shared_ptr< unit_filter > filter_own_
GLuint64EXT * result
Definition: glew.h:10727
void do_attack_analysis(const map_location &loc, const move_map &srcdst, const move_map &dstsrc, const move_map &fullmove_srcdst, const move_map &fullmove_dstsrc, const move_map &enemy_srcdst, const move_map &enemy_dstsrc, const map_location *tiles, bool *used_locations, std::vector< map_location > &units, std::vector< attack_analysis > &result, attack_analysis &cur_analysis, const team &current_team) const
virtual bool is_allowed_enemy(const unit &u) const
boost::shared_ptr< unit_filter > filter_enemy_
aspect_attacks(readonly_context &context, const config &cfg, const std::string &id)
Encapsulates the map of the game.
Definition: location.hpp:38
virtual bool is_allowed_attacker(const unit &u) const =0
virtual bool is_allowed_attacker(const unit &u) const
virtual const team & current_team() const
Definition: contexts.hpp:539
virtual bool is_allowed_enemy(const unit &u) const =0
virtual bool is_allowed_attacker(const unit &u) const
virtual void recalculate() const
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
virtual bool is_allowed_enemy(const unit &u) const
static int rate_terrain(const unit &u, const map_location &loc)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
unit_map * units
Definition: resources.cpp:35