17 #include "formula/callable_objects.hpp"
37 std::vector<variant> v;
40 v.emplace_back(std::make_shared<location_callable>(adj));
51 int range = args()[1]->evaluate(variables, fdb).as_int();
58 return variant(std::make_shared<location_callable>(loc));
61 std::vector<map_location> res;
65 std::vector<variant> v;
66 v.reserve(res.size() + 1);
67 v.emplace_back(std::make_shared<location_callable>(loc));
69 for(std::size_t
n = 0;
n != res.size(); ++
n) {
71 v.emplace_back(std::make_shared<location_callable>(res[
n]));
80 const std::string
type = args()[0]->evaluate(variables,
add_debug_info(fdb, 0,
"get_unit_type:name")).as_string();
84 return variant(std::make_shared<unit_type_callable>(*ut));
99 return variant(std::make_shared<unit_callable>(*
i));
122 const std::string
id = tc->get_value(
"id").as_string();
123 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
124 return id == p.second.id();
126 if(iter == tdata->map().end()) {
140 const unit& un = u_call->get_unit();
146 const unit_type& un = u_type->get_unit_type();
171 const std::string
id = tc->get_value(
"id").as_string();
172 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
173 return id == p.second.id();
175 if(iter == tdata->map().end()) {
189 const unit& un = u_call->get_unit();
195 const unit_type& un = u_type->get_unit_type();
220 const std::string
id = tc->get_value(
"id").as_string();
221 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
222 return id == p.second.id();
224 if(iter == tdata->map().end()) {
238 const unit& un = u_call->get_unit();
244 const unit_type& un = u_type->get_unit_type();
269 const std::string
id = tc->get_value(
"id").as_string();
270 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
271 return id == p.second.id();
273 if(iter == tdata->map().end()) {
287 const unit& un = u_call->get_unit();
293 const unit_type& un = u_type->get_unit_type();
318 const std::string
id = tc->get_value(
"id").as_string();
319 auto iter = std::find_if(tdata->map().begin(), tdata->map().end(), [
id](
const std::pair<t_translation::terrain_code, terrain_type>&
p) {
320 return id == p.second.id();
322 if(iter == tdata->map().end()) {
336 const unit& un = u_call->get_unit();
342 const unit_type& un = u_type->get_unit_type();
357 self = uc->get_value(
"side_number").
as_int();
359 self = tc->get_value(
"side_number").as_int();
365 other = uc->get_value(
"side_number").as_int();
367 other = tc->get_value(
"side_number").as_int();
373 if(self < 1 || self > num_teams || other < 1 || other > num_teams) {
386 std::string
type = args()[2]->evaluate(variables,
add_debug_info(fdb, 2,
"resistance_on:type")).as_string();
387 bool attacker = args().size() > 3 ? args()[3]->evaluate(variables,
add_debug_info(fdb, 3,
"resistance_on:attacker")).as_bool() :
false;
391 const unit& un = u_call->get_unit();
403 if(args().
size() > 0) {
409 if(args().
size() > 1) {
413 }
else if(!turn_arg.
is_null()) {
426 if(args().
size() > 0) {
432 if(args().
size() > 1) {
436 }
else if(!turn_arg.
is_null()) {
448 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.