Freeciv-3.2
Loading...
Searching...
No Matches
api_game_effects.c
Go to the documentation of this file.
1/*****************************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12*****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* common */
19#include "effects.h"
20
21/* common/scriptcore */
22#include "luascript.h"
23
24#include "api_game_effects.h"
25
26/**********************************************************************/
29int api_effects_world_bonus(lua_State *L, const char *effect_type)
30{
31 enum effect_type etype = EFT_COUNT;
32
34 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 2, string, 0);
35
38 return 0;
39 }
40 return get_world_bonus(etype);
41}
42
43/**********************************************************************/
47 const char *effect_type)
48{
49 enum effect_type etype = EFT_COUNT;
50
52 LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, 0);
53 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 3, string, 0);
54
57 return 0;
58 }
59 return get_player_bonus(pplayer, etype);
60}
61
62/**********************************************************************/
66 const char *effect_type)
67{
68 enum effect_type etype = EFT_COUNT;
69
71 LUASCRIPT_CHECK_ARG_NIL(L, pcity, 2, City, 0);
72 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 3, string, 0);
73
76 return 0;
77 }
78 return get_city_bonus(pcity, etype);
79}
80
81/**********************************************************************/
86 const char *effect_type)
87{
88 enum effect_type etype = EFT_COUNT;
89
92 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 4, string, 0);
93
96 return 0;
97 }
98
100 &(const struct req_context) {
101 .player = unit_owner(punit),
102 .city = unit_tile(punit)
104 .tile = unit_tile(punit),
105 .unit = punit,
106 .unittype = unit_type_get(punit),
107 },
108 other_player,
109 etype);
110}
111
112/***********************************************************************/
125 const char *output_id, const char *effect_type)
126{
127 const struct player *pplayer;
128 const struct output_type *poutput = NULL;
129 enum effect_type etype;
130
132 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile, 0);
133 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 5, string, 0);
134
137 return 0;
138 }
139
140 if (output_id != NULL) {
142
143 if (id != O_LAST) {
145 } else {
146 log_warn(_("Unknown output identifier \"%s\""), output_id);
147 }
148 }
149
150 pplayer = (pcity != NULL ? city_owner(pcity) : NULL);
151
153 &(const struct req_context) {
154 .player = pplayer,
155 .city = pcity,
156 .tile = ptile,
157 .output = poutput,
158 },
159 NULL,
160 etype);
161}
162
163/***********************************************************************/
169 const char *effect_type)
170{
171 enum effect_type etype = EFT_COUNT;
172
175 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, 0);
176 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 4, string, 0);
177
180 return 0;
181 }
182
183 return get_unit_vs_tile_bonus(ptile, punit, etype);
184}
int api_effects_tile_bonus(lua_State *L, Tile *ptile, City *pcity, const char *output_id, const char *effect_type)
int api_effects_unit_vs_tile_bonus(lua_State *L, Unit *punit, Tile *ptile, const char *effect_type)
int api_effects_player_bonus(lua_State *L, Player *pplayer, const char *effect_type)
int api_effects_city_bonus(lua_State *L, City *pcity, const char *effect_type)
int api_effects_unit_bonus(lua_State *L, Unit *punit, Player *other_player, const char *effect_type)
int api_effects_world_bonus(lua_State *L, const char *effect_type)
Output_type_id output_type_by_identifier(const char *id)
Definition city.c:647
struct output_type * get_output_type(Output_type_id output)
Definition city.c:638
#define city_owner(_pcity_)
Definition city.h:563
char * incite_cost
Definition comments.c:75
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct player *other_player, enum effect_type effect_type)
Definition effects.c:748
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:846
int get_unit_vs_tile_bonus(const struct tile *ptile, const struct unit *punit, enum effect_type etype)
Definition effects.c:1094
int get_world_bonus(enum effect_type effect_type)
Definition effects.c:816
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:828
output_type_id
Definition fc_types.h:100
@ O_LAST
Definition fc_types.h:101
#define _(String)
Definition fcintl.h:67
#define log_warn(message,...)
Definition log.h:105
#define LUASCRIPT_CHECK_STATE(L,...)
Definition luascript.h:117
#define LUASCRIPT_CHECK_ARG_NIL(L, value, narg, type,...)
Definition luascript.h:138
Definition city.h:320
struct tile * tile
Definition city.h:322
Definition tile.h:50
Definition unit.h:138
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define unit_tile(_pu)
Definition unit.h:397
#define unit_owner(_pu)
Definition unit.h:396
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123