56 variant var0 = args()[0]->evaluate(variables, fdb);
57 variant var1 = args()[1]->evaluate(variables, fdb);
68 return variant(std::vector{var0, var1});
75 std::vector<variant> v;
78 v.emplace_back(std::make_shared<location_callable>(adj));
89 int range = args()[1]->evaluate(variables, fdb).as_int();
96 return variant(std::make_shared<location_callable>(
loc));
99 std::vector<map_location> res;
103 std::vector<variant> v;
104 v.reserve(res.size() + 1);
105 v.emplace_back(std::make_shared<location_callable>(
loc));
107 for(std::size_t
n = 0;
n != res.size(); ++
n) {
109 v.emplace_back(std::make_shared<location_callable>(res[
n]));
118 const std::string
type = args()[0]->evaluate(variables,
add_debug_info(fdb, 0,
"get_unit_type:name")).as_string();
122 return variant(std::make_shared<unit_type_callable>(*ut));
137 return variant(std::make_shared<unit_callable>(*
i));
160 const std::string
id = tc->get_value(
"id").as_string();
161 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
162 return id == p.second.id();
164 if(iter == tdata->map().end()) {
178 const unit& un = u_call->get_unit();
184 const unit_type& un = u_type->get_unit_type();
209 const std::string
id = tc->get_value(
"id").as_string();
210 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
211 return id == p.second.id();
213 if(iter == tdata->map().end()) {
227 const unit& un = u_call->get_unit();
233 const unit_type& un = u_type->get_unit_type();
258 const std::string
id = tc->get_value(
"id").as_string();
259 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
260 return id == p.second.id();
262 if(iter == tdata->map().end()) {
276 const unit& un = u_call->get_unit();
282 const unit_type& un = u_type->get_unit_type();
307 const std::string
id = tc->get_value(
"id").as_string();
308 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
309 return id == p.second.id();
311 if(iter == tdata->map().end()) {
325 const unit& un = u_call->get_unit();
331 const unit_type& un = u_type->get_unit_type();
356 const std::string
id = tc->get_value(
"id").as_string();
357 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
358 return id == p.second.id();
360 if(iter == tdata->map().end()) {
374 const unit& un = u_call->get_unit();
380 const unit_type& un = u_type->get_unit_type();
395 self = uc->get_value(
"side_number").
as_int();
397 self = tc->get_value(
"side_number").as_int();
403 other = uc->get_value(
"side_number").as_int();
405 other = tc->get_value(
"side_number").as_int();
411 if(self < 1 || self > num_teams || other < 1 || other > num_teams) {
424 std::string
type = args()[2]->evaluate(variables,
add_debug_info(fdb, 2,
"resistance_on:type")).as_string();
425 bool attacker = args().size() > 3 ? args()[3]->evaluate(variables,
add_debug_info(fdb, 3,
"resistance_on:attacker")).as_bool() :
false;
429 const unit& un = u_call->get_unit();
441 if(args().
size() > 0) {
447 if(args().
size() > 1) {
451 }
else if(!turn_arg.
is_null()) {
464 if(args().
size() > 0) {
470 if(args().
size() > 1) {
474 }
else if(!turn_arg.
is_null()) {
486 ->evaluate(variables,
add_debug_info(fdb, 0,
"unit_tod_modifier:unit"))
492 ->evaluate(variables,
add_debug_info(fdb, 1,
"unit_tod_modifier:location"))
503 variant var0 = args()[0]->evaluate(variables, fdb);
504 variant var1 = args()[1]->evaluate(variables, fdb);
510 }
catch(
const std::out_of_range&) {
517 variant var0 = args()[0]->evaluate(variables, fdb);
518 variant var1 = args()[1]->evaluate(variables, fdb);
524 }
catch(
const std::out_of_range&) {
532 using namespace gamestate;
int combat_modifier(const unit_map &units, const gamemap &map, const map_location &loc, unit_alignments::type alignment, bool is_fearless)
Returns the amount that a unit's damage should be multiplied by due to the current time of day.
Various functions that implement attacks and attack calculations.
static display * get_singleton()
Returns the display object if a display object exists.
virtual const std::vector< team > & teams() const override
virtual const unit_map & units() const override
virtual const gamemap & map() const override
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
const std::shared_ptr< terrain_type_data > & tdata() const
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const color_t color=font::NORMAL_COLOR, const bool visible_in_fog=true, const bool visible_in_shroud=false, const bool immutable=false, const std::string &category="", const t_string &tooltip="")
int defense_modifier(const t_translation::terrain_code &terrain) const
Returns the defensive value of the indicated terrain.
int jamming_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to "jam" through the indicated terrain.
int vision_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to see through the indicated terrain.
int movement_cost(const t_translation::terrain_code &terrain, bool slowed=false) const
Returns the cost to move through the indicated terrain.
This class stores all the data for a single 'side' (in game nomenclature).
const std::string & team_name() const
static color_t get_side_color(int side)
const time_of_day get_illuminated_time_of_day(const unit_map &units, const gamemap &map, const map_location &loc, int for_turn=0) const
Returns time of day object for the passed turn at a location.
const time_of_day & get_time_of_day(int for_turn=0) const
Returns global time of day for the passed turn.
unit_iterator find(std::size_t id)
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
A single unit type that the player may recruit.
const movetype & movement_type() const
This class represents a single unit of a specific type.
gamestate_function_symbol_table(const std::shared_ptr< function_symbol_table > &parent=nullptr)
std::shared_ptr< T > try_convert() const
int as_int(int fallback=0) const
Returns the variant's value as an integer.
std::shared_ptr< T > convert_to() const
const std::string & as_string() const
std::string to_debug_string(bool verbose=false, formula_seen_stack *seen=nullptr) const
bool is_null() const
Functions to test the type of the internal value.
Declarations for File-IO.
#define DECLARE_WFL_FUNCTION(name)
Declares a function name in the local function table functions_table.
unit_alignments::type alignment() const
The alignment of this unit.
int defense_modifier(const t_translation::terrain_code &terrain) const
The unit's defense on a given terrain.
int resistance_against(const std::string &damage_name, bool attacker, const map_location &loc, const_attack_ptr weapon=nullptr, const const_attack_ptr &opp_weapon=nullptr) const
The unit's resistance against a given damage type.
const map_location & get_location() const
The current map location this unit is at.
int movement_cost(const t_translation::terrain_code &terrain) const
Get the unit's movement cost on a particular terrain.
int vision_cost(const t_translation::terrain_code &terrain) const
Get the unit's vision cost on a particular terrain.
int jamming_cost(const t_translation::terrain_code &terrain) const
Get the unit's jamming cost on a particular terrain.
bool is_fearless() const
Gets whether this unit is fearless - ie, unaffected by time of day.
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
bool is_shrouded(const display *disp, const map_location &loc)
Our definition of map labels being obscured is if the tile is obscured, or the tile below is obscured...
bool is_fogged(const display *disp, const map_location &loc)
Rather simple test for a hex being fogged.
utils::optional< std::string > get_wml_location(const std::string &path, const utils::optional< std::string > ¤t_dir)
Returns a translated path to the actual file or directory, if it exists.
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
::tod_manager * tod_manager
play_controller * controller
terrain_code read_terrain_code(std::string_view str, const ter_layer filler)
Reads a single terrain from a string.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
DEFINE_WFL_FUNCTION(run_file, 1, 1)
formula_debugger * add_debug_info(formula_debugger *fdb, int arg_number, const std::string &f_name)
void get_tiles_in_radius(const map_location ¢er, const int radius, std::vector< map_location > &result)
Function that will add to result all locations within radius tiles of center (excluding center itself...
Encapsulates the map of the game.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
int lawful_bonus
The % bonus lawful units receive.
static map_location::direction n
unit_type_data unit_types
static const unit_type & get_unit_type(const std::string &type_id)
Converts a string ID to a unit_type.