18 #include "formula/callable_objects.hpp"
38 std::vector<variant> v;
41 v.emplace_back(std::make_shared<location_callable>(adj));
52 int range = args()[1]->evaluate(variables, fdb).as_int();
59 return variant(std::make_shared<location_callable>(
loc));
62 std::vector<map_location> res;
66 std::vector<variant> v;
67 v.reserve(res.size() + 1);
68 v.emplace_back(std::make_shared<location_callable>(
loc));
70 for(std::size_t
n = 0;
n != res.size(); ++
n) {
72 v.emplace_back(std::make_shared<location_callable>(res[
n]));
81 const std::string
type = args()[0]->evaluate(variables,
add_debug_info(fdb, 0,
"get_unit_type:name")).as_string();
85 return variant(std::make_shared<unit_type_callable>(*ut));
100 return variant(std::make_shared<unit_callable>(*
i));
123 const std::string
id = tc->get_value(
"id").as_string();
124 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
125 return id == p.second.id();
127 if(iter == tdata->map().end()) {
141 const unit& un = u_call->get_unit();
147 const unit_type& un = u_type->get_unit_type();
172 const std::string
id = tc->get_value(
"id").as_string();
173 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
174 return id == p.second.id();
176 if(iter == tdata->map().end()) {
190 const unit& un = u_call->get_unit();
196 const unit_type& un = u_type->get_unit_type();
221 const std::string
id = tc->get_value(
"id").as_string();
222 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
223 return id == p.second.id();
225 if(iter == tdata->map().end()) {
239 const unit& un = u_call->get_unit();
245 const unit_type& un = u_type->get_unit_type();
270 const std::string
id = tc->get_value(
"id").as_string();
271 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
272 return id == p.second.id();
274 if(iter == tdata->map().end()) {
288 const unit& un = u_call->get_unit();
294 const unit_type& un = u_type->get_unit_type();
319 const std::string
id = tc->get_value(
"id").as_string();
320 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
321 return id == p.second.id();
323 if(iter == tdata->map().end()) {
337 const unit& un = u_call->get_unit();
343 const unit_type& un = u_type->get_unit_type();
358 self = uc->get_value(
"side_number").
as_int();
360 self = tc->get_value(
"side_number").as_int();
366 other = uc->get_value(
"side_number").as_int();
368 other = tc->get_value(
"side_number").as_int();
374 if(self < 1 || self > num_teams || other < 1 || other > num_teams) {
387 std::string
type = args()[2]->evaluate(variables,
add_debug_info(fdb, 2,
"resistance_on:type")).as_string();
388 bool attacker = args().size() > 3 ? args()[3]->evaluate(variables,
add_debug_info(fdb, 3,
"resistance_on:attacker")).as_bool() :
false;
392 const unit& un = u_call->get_unit();
404 if(args().
size() > 0) {
410 if(args().
size() > 1) {
414 }
else if(!turn_arg.
is_null()) {
427 if(args().
size() > 0) {
433 if(args().
size() > 1) {
437 }
else if(!turn_arg.
is_null()) {
449 using namespace gamestate;
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
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.
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
std::shared_ptr< T > convert_to() const
const std::string & as_string() const
bool is_null() const
Functions to test the type of the internal value.
#define DECLARE_WFL_FUNCTION(name)
Declares a function name in the local function table functions_table.
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.
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.
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
::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(adjacent_locs, 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.