16 #define GETTEXT_DOMAIN "wesnoth-lib"
35 namespace tip_of_the_day
39 std::vector<game_tip> result;
42 result.emplace_back(
tip[
"text"].t_str(),
tip[
"source"].t_str(),
tip[
"encountered_units"].str());
48 std::vector<game_tip>
shuffle(
const std::vector<game_tip>&
tips)
50 std::vector<game_tip> result =
tips;
55 const auto& filters =
tip.unit_filter_;
59 const bool passes_filter = filters.empty()
61 : std::any_of(filters.begin(), filters.end(), [&units](
const std::string& u) {
62 return units.find(u) != units.end();
65 return !passes_filter;
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.
void erase_if(Container &container, const Predicate &predicate)
Convenience wrapper for using std::remove_if on a container.
std::vector< std::string > split(const config_attribute_value &val)