17 #include "formula/callable_objects.hpp"
36 std::vector<variant> v;
39 v.emplace_back(std::make_shared<location_callable>(adj));
50 int range = args()[1]->evaluate(variables, fdb).as_int();
57 return variant(std::make_shared<location_callable>(loc));
60 std::vector<map_location> res;
64 std::vector<variant> v;
65 v.reserve(res.size() + 1);
66 v.emplace_back(std::make_shared<location_callable>(loc));
68 for(std::size_t
n = 0;
n != res.size(); ++
n) {
70 v.emplace_back(std::make_shared<location_callable>(res[
n]));
79 const std::string
type = args()[0]->evaluate(variables,
add_debug_info(fdb, 0,
"get_unit_type:name")).as_string();
83 return variant(std::make_shared<unit_type_callable>(*ut));
98 return variant(std::make_shared<unit_callable>(*
i));
121 const std::string
id = tc->get_value(
"id").as_string();
122 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
123 return id == p.second.id();
125 if(iter == tdata->map().end()) {
139 const unit& un = u_call->get_unit();
145 const unit_type& un = u_type->get_unit_type();
170 const std::string
id = tc->get_value(
"id").as_string();
171 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
172 return id == p.second.id();
174 if(iter == tdata->map().end()) {
188 const unit& un = u_call->get_unit();
194 const unit_type& un = u_type->get_unit_type();
219 const std::string
id = tc->get_value(
"id").as_string();
220 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
221 return id == p.second.id();
223 if(iter == tdata->map().end()) {
237 const unit& un = u_call->get_unit();
243 const unit_type& un = u_type->get_unit_type();
268 const std::string
id = tc->get_value(
"id").as_string();
269 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
270 return id == p.second.id();
272 if(iter == tdata->map().end()) {
286 const unit& un = u_call->get_unit();
292 const unit_type& un = u_type->get_unit_type();
317 const std::string
id = tc->get_value(
"id").as_string();
318 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
319 return id == p.second.id();
321 if(iter == tdata->map().end()) {
335 const unit& un = u_call->get_unit();
341 const unit_type& un = u_type->get_unit_type();
356 self = uc->get_value(
"side_number").
as_int();
358 self = tc->get_value(
"side_number").as_int();
364 other = uc->get_value(
"side_number").as_int();
366 other = tc->get_value(
"side_number").as_int();
372 if(self < 1 || self > num_teams || other < 1 || other > num_teams) {
385 std::string
type = args()[2]->evaluate(variables,
add_debug_info(fdb, 2,
"resistance_on:type")).as_string();
386 bool attacker = args().size() > 3 ? args()[3]->evaluate(variables,
add_debug_info(fdb, 3,
"resistance_on:attacker")).as_bool() :
false;
390 const unit& un = u_call->get_unit();
402 if(args().
size() > 0) {
408 if(args().
size() > 1) {
412 }
else if(!turn_arg.
is_null()) {
425 if(args().
size() > 0) {
431 if(args().
size() > 1) {
435 }
else if(!turn_arg.
is_null()) {
447 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(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_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(const std::string &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.