16 #define GETTEXT_DOMAIN "wesnoth-lib"
34 namespace tip_of_the_day
38 std::vector<game_tip> result;
41 result.emplace_back(
tip[
"text"],
tip[
"source"],
tip[
"encountered_units"]);
47 std::vector<game_tip>
shuffle(
const std::vector<game_tip>&
tips)
49 std::vector<game_tip> result =
tips;
53 const auto iter = std::remove_if(result.begin(), result.end(), [&units](
const game_tip&
tip) {
54 const auto& filters = tip.unit_filter_;
58 const bool passes_filter = filters.empty()
60 : std::any_of(filters.begin(), filters.end(), [&units](const std::string& u) {
61 return units.find(u) != units.end();
64 return !passes_filter;
68 result.erase(iter, result.end());
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
The tips of day structure.
game_tip(const t_string &text, const t_string &source, const std::string &unit_filter)
std::set< std::string > & encountered_units()
static rng & default_instance()
Definitions for the interface to Wesnoth Markup Language (WML).
static std::unique_ptr< tooltip > tip
std::vector< game_tip > tips
std::vector< game_tip > load(const config &cfg)
Loads the tips from a config.
std::vector< game_tip > shuffle(const std::vector< game_tip > &tips)
Shuffles the tips.
std::vector< std::string > split(const config_attribute_value &val)