The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
advancement.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 - 2025
3 Part of the Battle for Wesnoth Project https://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 * @file
17 * Various functions that implement advancements of units.
18 */
19
20#pragma once
21
22class unit;
23class config;
24
25#include "map/location.hpp"
26#include "units/ptr.hpp"
27#include "utils/variant.hpp"
28
29#include <string>
30
31/**
32 advances the unit at loc if it has enough experience, maximum 20 times.
33 if the unit is on the currently active side, and that side is controlled by a human, a dialog pops up.
34 if we are in a non mp game, and the side is controlled by a human then a dialog is shown too.
35 if the side is controlled by an ai, and if ai_advancement is passed, then ai_advancement will be used.
36 otherwise a random decision will be taken.
37*/
51void advance_unit_at(const advance_unit_params& params);
52/**
53 * Returns the advanced version of a unit (with traits and items retained).
54 */
55unit_ptr get_advanced_unit(const unit &u, const std::string &advance_to);
56
57/**
58 * Returns the AMLA-advanced version of a unit (with traits and items retained).
59 */
60unit_ptr get_amla_unit(const unit &u, const config &mod_option);
61
62using advancement_option = utils::variant<std::string /*change type*/, const config* /*apply amla*/>;
63
64/**
65 * Function which will advance the unit at @a loc to 'advance_to'.
66 * which is eigher a type to advance to or a config containing the
67 * [advancement] to perform an amla.
68 * Note that 'loc' is not a reference, because if it were a reference,
69 * we couldn't safely pass in a reference to the item in the map
70 * that we're going to delete, since deletion would invalidate the reference.
71 */
72void advance_unit(map_location loc, const advancement_option &advance_to, bool fire_event = true);
map_location loc
Definition move.cpp:172
void advance_unit(map_location loc, const advancement_option &advance_to, bool fire_event=true)
Function which will advance the unit at loc to 'advance_to'.
unit_ptr get_advanced_unit(const unit &u, const std::string &advance_to)
Returns the advanced version of a unit (with traits and items retained).
utils::variant< std::string, const config * > advancement_option
unit_ptr get_amla_unit(const unit &u, const config &mod_option)
Returns the AMLA-advanced version of a unit (with traits and items retained).
void advance_unit_at(const advance_unit_params &params)
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
This class represents a single unit of a specific type.
Definition unit.hpp:39
std::shared_ptr< unit > unit_ptr
Definition ptr.hpp:26
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
Definition sound.cpp:139
advances the unit at loc if it has enough experience, maximum 20 times.
advance_unit_params & force_dialog(bool value)
advance_unit_params & fire_events(bool value)
friend void advance_unit_at(const advance_unit_params &)
advance_unit_params(const map_location &loc)
advance_unit_params & animate(bool value)
Encapsulates the map of the game.
Definition location.hpp:46
MacOS doesn't support std::visit when targing MacOS < 10.14 (currently we target 10....