The Battle for Wesnoth  1.19.5+dev
formula_manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
3  by Chris Beck <render787@gmail.com>
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 #pragma once
17 
18 #include "formula/callable.hpp"
19 
20 #include<string>
21 
22 class config;
23 
25 public:
31  formula_vars_(o.formula_vars_ ? std::make_shared<wfl::map_formula_callable>(*o.formula_vars_) : o.formula_vars_)
32  {}
33 
35  void add_formula_var(std::string str, wfl::variant var);
36  bool has_formula() const { return !unit_formula_.empty(); }
37  bool has_loop_formula() const { return !unit_loop_formula_.empty(); }
38  bool has_priority_formula() const { return !unit_priority_formula_.empty(); }
39  const std::string& get_formula() const { return unit_formula_; }
40  const std::string& get_loop_formula() const { return unit_loop_formula_; }
41  const std::string& get_priority_formula() const { return unit_priority_formula_; }
42 
43  void read(const config & ai);
44  void write(config & cfg);
45 
46 private:
47  std::string unit_formula_;
48  std::string unit_loop_formula_;
51 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
std::string unit_loop_formula_
unit_formula_manager(const unit_formula_manager &o)
std::string unit_priority_formula_
void read(const config &ai)
void write(config &cfg)
const std::string & get_formula() const
const wfl::map_formula_callable_ptr & formula_vars() const
bool has_loop_formula() const
bool has_priority_formula() const
const std::string & get_loop_formula() const
void add_formula_var(std::string str, wfl::variant var)
const std::string & get_priority_formula() const
wfl::map_formula_callable_ptr formula_vars_
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:59
Definition: contexts.hpp:43
std::shared_ptr< map_formula_callable > map_formula_callable_ptr
Definition: callable.hpp:312