Freeciv21
Develop your civilization from humble roots to a global empire
api_game_methods.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 
11 #pragma once
12 
13 /* common/scriptcore */
14 #include "luascript_types.h"
15 
16 struct lua_State;
17 
18 // Game
19 int api_methods_game_turn(lua_State *L);
20 int api_methods_game_turn_deprecated(lua_State *L);
21 int api_methods_game_year(lua_State *L);
22 int api_methods_game_year_fragment(lua_State *L);
23 const char *api_methods_game_year_text(lua_State *L);
24 const char *api_methods_game_rulesetdir(lua_State *L);
25 const char *api_methods_game_ruleset_name(lua_State *L);
26 
27 // Building Type
28 bool api_methods_building_type_is_wonder(lua_State *L,
29  Building_Type *pbuilding);
31  Building_Type *pbuilding);
33  Building_Type *pbuilding);
35  Building_Type *pbuilding);
36 const char *api_methods_building_type_rule_name(lua_State *L,
37  Building_Type *pbuilding);
38 const char *
40  Building_Type *pbuilding);
41 
42 // City
43 bool api_methods_city_has_building(lua_State *L, City *pcity,
44  Building_Type *building);
45 int api_methods_city_map_sq_radius(lua_State *L, City *pcity);
46 int api_methods_city_size_get(lua_State *L, City *pcity);
47 Tile *api_methods_city_tile_get(lua_State *L, City *pcity);
48 int api_methods_city_inspire_partisans(lua_State *L, City *self,
49  Player *inspirer);
50 
51 int api_methods_city_culture_get(lua_State *L, City *pcity);
52 
53 bool api_methods_is_city_happy(lua_State *L, City *pcity);
54 bool api_methods_is_city_unhappy(lua_State *L, City *pcity);
55 bool api_methods_is_city_celebrating(lua_State *L, City *pcity);
56 bool api_methods_is_gov_center(lua_State *L, City *pcity);
57 bool api_methods_is_capital(lua_State *L, City *pcity);
58 
59 // Government
60 const char *api_methods_government_rule_name(lua_State *L,
61  Government *pgovernment);
62 const char *api_methods_government_name_translation(lua_State *L,
63  Government *pgovernment);
64 
65 // Nation
66 const char *api_methods_nation_type_rule_name(lua_State *L,
67  Nation_Type *pnation);
68 const char *api_methods_nation_type_name_translation(lua_State *L,
69  Nation_Type *pnation);
70 const char *api_methods_nation_type_plural_translation(lua_State *L,
71  Nation_Type *pnation);
72 
73 // Player
74 const char *api_methods_player_controlling_gui(lua_State *L,
75  Player *pplayer);
76 bool api_methods_player_has_wonder(lua_State *L, Player *pplayer,
77  Building_Type *building);
78 int api_methods_player_number(lua_State *L, Player *pplayer);
79 int api_methods_player_num_cities(lua_State *L, Player *pplayer);
80 int api_methods_player_num_units(lua_State *L, Player *pplayer);
81 int api_methods_player_gold(lua_State *L, Player *pplayer);
82 bool api_methods_player_knows_tech(lua_State *L, Player *pplayer,
83  Tech_Type *ptech);
84 bool api_methods_player_shares_research(lua_State *L, Player *pplayer,
85  Player *aplayer);
86 const char *api_methods_research_rule_name(lua_State *L, Player *pplayer);
87 const char *api_methods_research_name_translation(lua_State *L,
88  Player *pplayer);
90  Player *pplayer);
92  Player *pplayer);
93 int api_methods_player_culture_get(lua_State *L, Player *pplayer);
94 
95 bool api_methods_player_has_flag(lua_State *L, Player *pplayer,
96  const char *flag);
97 
98 // Tech Type
99 const char *api_methods_tech_type_rule_name(lua_State *L, Tech_Type *ptech);
100 const char *api_methods_tech_type_name_translation(lua_State *L,
101  Tech_Type *ptech);
102 
103 // Terrain
104 const char *api_methods_terrain_rule_name(lua_State *L, Terrain *pterrain);
105 const char *api_methods_terrain_name_translation(lua_State *L,
106  Terrain *pterrain);
107 const char *api_methods_terrain_class_name(lua_State *L, Terrain *pterrain);
108 
109 // Disaster
110 const char *api_methods_disaster_rule_name(lua_State *L, Disaster *pdis);
111 const char *api_methods_disaster_name_translation(lua_State *L,
112  Disaster *pdis);
113 
114 // Achievement
115 const char *api_methods_achievement_rule_name(lua_State *L,
116  Achievement *pach);
117 const char *api_methods_achievement_name_translation(lua_State *L,
118  Achievement *pach);
119 
120 // Action
121 const char *api_methods_action_rule_name(lua_State *L, Action *pact);
122 const char *api_methods_action_name_translation(lua_State *L, Action *pact);
123 
124 // Tile
125 int api_methods_tile_nat_x(lua_State *L, Tile *ptile);
126 int api_methods_tile_nat_y(lua_State *L, Tile *ptile);
127 int api_methods_tile_map_x(lua_State *L, Tile *ptile);
128 int api_methods_tile_map_y(lua_State *L, Tile *ptile);
129 City *api_methods_tile_city(lua_State *L, Tile *ptile);
131  Tile *ptile,
132  bool may_be_on_center);
133 bool api_methods_tile_has_extra(lua_State *L, Tile *ptile, const char *name);
134 bool api_methods_tile_has_base(lua_State *L, Tile *ptile, const char *name);
135 bool api_methods_tile_has_road(lua_State *L, Tile *ptile, const char *name);
136 bool api_methods_enemy_tile(lua_State *L, Tile *ptile, Player *against);
137 int api_methods_tile_num_units(lua_State *L, Tile *ptile);
138 int api_methods_tile_sq_distance(lua_State *L, Tile *ptile1, Tile *ptile2);
139 int api_methods_private_tile_next_outward_index(lua_State *L, Tile *pstart,
140  int tindex, int max_dist);
142  int tindex);
144  Tile *ptile);
145 
146 // Unit
147 bool api_methods_unit_city_can_be_built_here(lua_State *L, Unit *punit);
148 Tile *api_methods_unit_tile_get(lua_State *L, Unit *punit);
149 const Direction *api_methods_unit_orientation_get(lua_State *L, Unit *punit);
150 Unit *api_methods_unit_transporter(lua_State *L, Unit *punit);
152  Unit *punit);
153 
154 // Unit Type
155 bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type,
156  const char *flag);
157 bool api_methods_unit_type_has_role(lua_State *L, Unit_Type *punit_type,
158  const char *role);
160  Unit_Type *punit_type,
161  Tile *ptile);
162 const char *api_methods_unit_type_rule_name(lua_State *L,
163  Unit_Type *punit_type);
164 const char *api_methods_unit_type_name_translation(lua_State *L,
165  Unit_Type *punit_type);
166 
167 // Unit_List_Link Type
170  Unit_List_Link *link);
171 
172 // City_List_Link Type
175  City_List_Link *link);
const char * api_methods_unit_type_rule_name(lua_State *L, Unit_Type *punit_type)
Return rule name for Unit_Type.
int api_methods_tile_nat_x(lua_State *L, Tile *ptile)
Return the native x coordinate of the tile.
int api_methods_tile_num_units(lua_State *L, Tile *ptile)
Return number of units on tile.
bool api_methods_is_city_unhappy(lua_State *L, City *pcity)
Return TRUE iff city is unhappy.
bool api_methods_is_gov_center(lua_State *L, City *pcity)
Return TRUE iff city is government center.
bool api_methods_unit_type_can_exist_at_tile(lua_State *L, Unit_Type *punit_type, Tile *ptile)
Return TRUE iff the unit type can exist on the tile.
int api_methods_player_num_cities(lua_State *L, Player *pplayer)
Return the number of cities pplayer has.
const char * api_methods_nation_type_name_translation(lua_State *L, Nation_Type *pnation)
Return translated adjective for Nation_Type.
const char * api_methods_achievement_rule_name(lua_State *L, Achievement *pach)
Return rule name for Achievement.
bool api_methods_player_has_wonder(lua_State *L, Player *pplayer, Building_Type *building)
Return TRUE iff player has wonder.
const char * api_methods_terrain_rule_name(lua_State *L, Terrain *pterrain)
Return rule name for Terrain.
Tile * api_methods_unit_tile_get(lua_State *L, Unit *punit)
Return the tile of the unit.
City_List_Link * api_methods_private_player_city_list_head(lua_State *L, Player *pplayer)
Return list head for city list for Player.
const char * api_methods_disaster_rule_name(lua_State *L, Disaster *pdis)
Return rule name for Disaster.
int api_methods_tile_nat_y(lua_State *L, Tile *ptile)
Return the native y coordinate of the tile.
int api_methods_game_year_fragment(lua_State *L)
Return the current year fragment.
int api_methods_city_culture_get(lua_State *L, City *pcity)
How much culture city has?
const char * api_methods_action_rule_name(lua_State *L, Action *pact)
Return rule name for Action.
const char * api_methods_unit_type_name_translation(lua_State *L, Unit_Type *punit_type)
Return translated name for Unit_Type.
Unit_List_Link * api_methods_private_player_unit_list_head(lua_State *L, Player *pplayer)
Return list head for unit list for Player.
int api_methods_player_num_units(lua_State *L, Player *pplayer)
Return the number of units pplayer has.
City_List_Link * api_methods_city_list_next_link(lua_State *L, City_List_Link *link)
Return next list link or nullptr when link is the last link.
int api_methods_tile_map_x(lua_State *L, Tile *ptile)
Return the map x coordinate of the tile.
City * api_methods_city_list_link_data(lua_State *L, City_List_Link *link)
Return City for list link.
bool api_methods_is_city_happy(lua_State *L, City *pcity)
Return TRUE iff city happy.
City * api_methods_tile_city(lua_State *L, Tile *ptile)
Return City on ptile, else nullptr.
Tile * api_methods_city_tile_get(lua_State *L, City *pcity)
Return the tile of the city.
int api_methods_player_number(lua_State *L, Player *pplayer)
Return player number.
const char * api_methods_government_name_translation(lua_State *L, Government *pgovernment)
Return translated name for Government.
const char * api_methods_government_rule_name(lua_State *L, Government *pgovernment)
Return rule name for Government.
bool api_methods_player_shares_research(lua_State *L, Player *pplayer, Player *aplayer)
Return TRUE if players share research.
int api_methods_city_size_get(lua_State *L, City *pcity)
Return the size of the city.
const char * api_methods_nation_type_plural_translation(lua_State *L, Nation_Type *pnation)
Return translated plural noun for Nation_Type.
Tile * api_methods_private_tile_for_outward_index(lua_State *L, Tile *pstart, int tindex)
Return tile for nth iteration index (for internal use)
bool api_methods_tile_has_extra(lua_State *L, Tile *ptile, const char *name)
Return TRUE if there is a extra with rule name name on ptile.
int api_methods_tile_sq_distance(lua_State *L, Tile *ptile1, Tile *ptile2)
Return squared distance between tiles 1 and 2.
Unit * api_methods_unit_list_link_data(lua_State *L, Unit_List_Link *link)
Return Unit for list link.
bool api_methods_unit_type_has_role(lua_State *L, Unit_Type *punit_type, const char *role)
Return TRUE if punit_type has role.
const char * api_methods_research_rule_name(lua_State *L, Player *pplayer)
Return name of the research group player belongs to.
const char * api_methods_disaster_name_translation(lua_State *L, Disaster *pdis)
Return translated name for Disaster.
const char * api_methods_research_name_translation(lua_State *L, Player *pplayer)
Return name of the research group player belongs to.
int api_methods_player_culture_get(lua_State *L, Player *pplayer)
How much culture player has?
const char * api_methods_tech_type_rule_name(lua_State *L, Tech_Type *ptech)
Return rule name for Tech_Type.
int api_methods_game_turn_deprecated(lua_State *L)
Return the current turn, as if real turns started from 0.
const char * api_methods_action_name_translation(lua_State *L, Action *pact)
Return translated name for Action.
const char * api_methods_terrain_name_translation(lua_State *L, Terrain *pterrain)
Return translated name for Terrain.
bool api_methods_building_type_is_great_wonder(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a great wonder.
int api_methods_private_tile_next_outward_index(lua_State *L, Tile *pstart, int tindex, int max_dist)
Return nth tile iteration index (for internal use) Will return the next index, or an index < 0 when d...
bool api_methods_tile_has_road(lua_State *L, Tile *ptile, const char *name)
Return TRUE if there is a road with rule name name on ptile.
int api_methods_game_turn(lua_State *L)
Return the current turn.
bool api_methods_player_knows_tech(lua_State *L, Player *pplayer, Tech_Type *ptech)
Return TRUE if Player knows advance ptech.
bool api_methods_enemy_tile(lua_State *L, Tile *ptile, Player *against)
Is tile occupied by enemies.
bool api_methods_building_type_is_small_wonder(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a small wonder.
int api_methods_game_year(lua_State *L)
Return the current year.
const char * api_methods_building_type_name_translation(lua_State *L, Building_Type *pbuilding)
Return translated name for Building_Type.
bool api_methods_building_type_is_wonder(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a wonder.
int api_methods_city_inspire_partisans(lua_State *L, City *self, Player *inspirer)
How much city inspires partisans for a player.
int api_methods_city_map_sq_radius(lua_State *L, City *pcity)
Return the square raduis of the city map.
bool api_methods_city_has_building(lua_State *L, City *pcity, Building_Type *building)
Return TRUE iff city has building.
const char * api_methods_achievement_name_translation(lua_State *L, Achievement *pach)
Return translated name for Achievement.
Unit_List_Link * api_methods_private_unit_cargo_list_head(lua_State *L, Unit *punit)
Return list head for cargo list for Unit.
const char * api_methods_game_ruleset_name(lua_State *L)
Return name of the current ruleset.
bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type, const char *flag)
Return TRUE if punit_type has flag.
bool api_methods_building_type_is_improvement(lua_State *L, Building_Type *pbuilding)
Return TRUE if pbuilding is a building.
bool api_methods_tile_city_exists_within_max_city_map(lua_State *L, Tile *ptile, bool may_be_on_center)
Return TRUE if there is a city inside the maximum city radius from ptile.
bool api_methods_player_has_flag(lua_State *L, Player *pplayer, const char *flag)
Does player have flag set?
const Direction * api_methods_unit_orientation_get(lua_State *L, Unit *punit)
Get unit orientation.
bool api_methods_unit_city_can_be_built_here(lua_State *L, Unit *punit)
Can punit found a city on its tile?
Unit_List_Link * api_methods_private_tile_unit_list_head(lua_State *L, Tile *ptile)
Return list head for unit list for Tile.
const char * api_methods_game_year_text(lua_State *L)
Return the current year fragment.
bool api_methods_tile_has_base(lua_State *L, Tile *ptile, const char *name)
Return TRUE if there is a base with rule name name on ptile.
const char * api_methods_game_rulesetdir(lua_State *L)
Return name of the current ruleset.
int api_methods_player_gold(lua_State *L, Player *pplayer)
Return gold for Player.
const char * api_methods_building_type_rule_name(lua_State *L, Building_Type *pbuilding)
Return rule name for Building_Type.
const char * api_methods_player_controlling_gui(lua_State *L, Player *pplayer)
Return gui type string of the controlling connection.
const char * api_methods_tech_type_name_translation(lua_State *L, Tech_Type *ptech)
Return translated name for Tech_Type.
Unit_List_Link * api_methods_unit_list_next_link(lua_State *L, Unit_List_Link *link)
Return next list link or nullptr when link is the last link.
int api_methods_tile_map_y(lua_State *L, Tile *ptile)
Return the map y coordinate of the tile.
Unit * api_methods_unit_transporter(lua_State *L, Unit *punit)
Return Unit that transports punit, if any.
const char * api_methods_nation_type_rule_name(lua_State *L, Nation_Type *pnation)
Return rule name for Nation_Type.
const char * api_methods_terrain_class_name(lua_State *L, Terrain *pterrain)
Return name of the terrain's class.
bool api_methods_is_city_celebrating(lua_State *L, City *pcity)
Return TRUE iff city is celebrating.
bool api_methods_is_capital(lua_State *L, City *pcity)
Return TRUE if city is capital.
const char * name
Definition: inputfile.cpp:118
const struct city_list_link City_List_Link
enum direction8 Direction
const struct unit_list_link Unit_List_Link
Definition: tech.h:113
Definition: city.h:291
Definition: player.h:231
Definition: tile.h:42
Definition: unit.h:134