The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
contexts.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2009 - 2025
3 by Yurii Chernyi <terraninfo@terraninfo.net>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16/**
17 * @file
18 * Composite AI contexts
19 */
20
21#pragma once
22
24
25//============================================================================
26namespace ai {
27
28class ai_context : public virtual default_ai_context {
29public:
30
31 /**
32 * Unwrap
33 */
34 virtual ai_context& get_ai_context() = 0;
35
36};
37
38class rca_context : public virtual ai_context {
39public:
40
41 /**
42 * Constructor
43 */
45
46 /**
47 * Destructor
48 */
49 virtual ~rca_context();
50
51 /**
52 * Unwrap
53 */
55 bool is_offense(){ return is_offense_; }
56 void set_offense(){ is_offense_ = true; is_defense_ = false; strategy_set_ = true; }
57 bool is_defense(){ return is_defense_; }
58 void set_defense(){ is_defense_ = true; is_offense_ = false; strategy_set_ = true; }
59 void clear_strategy(){ strategy_set_ = false; }
60 bool has_strategy(){ return strategy_set_; }
61
62private:
63 static bool is_offense_;
64 static bool is_defense_;
65 static bool strategy_set_;
66};
67
68class candidate_action_context : public virtual rca_context {
69public:
70
71 /**
72 * Constructor
73 */
75
76 /**
77 * Destructor
78 */
80
81 /**
82 * Unwrap
83 */
85};
86
87// proxies
88class ai_context_proxy : public virtual ai_context, public virtual default_ai_context_proxy {
89public:
91
97
98 virtual ~ai_context_proxy();
99
101 {
102 return target_->get_ai_context();
103 }
104
105private:
107};
108
109class rca_context_proxy : public virtual rca_context, public virtual ai_context_proxy {
110public:
112
113 virtual ~rca_context_proxy();
114
120
122 {
123 return target_->get_rca_context();
124 }
125
126private:
128};
129
130} //end of namespace ai
ai_context * target_
Definition contexts.hpp:106
ai_context & get_ai_context()
Unwrap.
Definition contexts.hpp:100
virtual ~ai_context_proxy()
Definition contexts.cpp:32
void init_ai_context_proxy(ai_context &target)
Definition contexts.hpp:92
virtual ai_context & get_ai_context()=0
Unwrap.
virtual ~candidate_action_context()
Destructor.
Definition contexts.hpp:79
virtual candidate_action_context & get_candidate_action_context()=0
Unwrap.
candidate_action_context()
Constructor.
Definition contexts.hpp:74
void init_default_ai_context_proxy(default_ai_context &target)
Definition contexts.cpp:57
void init_rca_context_proxy(rca_context &target)
Definition contexts.hpp:115
rca_context * target_
Definition contexts.hpp:127
rca_context & get_rca_context()
Unwrap.
Definition contexts.hpp:121
virtual ~rca_context_proxy()
Definition contexts.cpp:52
rca_context()
Constructor.
Definition contexts.cpp:39
void set_defense()
Definition contexts.hpp:58
virtual rca_context & get_rca_context()=0
Unwrap.
bool is_offense()
Definition contexts.hpp:55
static bool strategy_set_
Definition contexts.hpp:65
virtual ~rca_context()
Destructor.
Definition contexts.cpp:43
bool has_strategy()
Definition contexts.hpp:60
bool is_defense()
Definition contexts.hpp:57
static bool is_offense_
Definition contexts.hpp:63
static bool is_defense_
Definition contexts.hpp:64
void set_offense()
Definition contexts.hpp:56
void clear_strategy()
Definition contexts.hpp:59
Default AI contexts.
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition actions.cpp:59