Freeciv-3.3
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
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 &(const struct req_context) {
109 .player = other_player,
110 },
111 etype);
112}
113
114/***********************************************************************/
127 const char *output_id, const char *effect_type)
128{
129 const struct player *pplayer;
130 const struct output_type *poutput = NULL;
131 enum effect_type etype;
132
134 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile, 0);
135 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 5, string, 0);
136
139 return 0;
140 }
141
142 if (output_id != NULL) {
144
145 if (id != O_LAST) {
147 } else {
148 log_warn(_("Unknown output identifier \"%s\""), output_id);
149 }
150 }
151
152 pplayer = (pcity != NULL ? city_owner(pcity) : NULL);
153
155 &(const struct req_context) {
156 .player = pplayer,
157 .city = pcity,
158 .tile = ptile,
159 .output = poutput,
160 },
161 NULL,
162 etype);
163}
164
165/***********************************************************************/
171 const char *effect_type)
172{
173 enum effect_type etype = EFT_COUNT;
174
177 LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, 0);
178 LUASCRIPT_CHECK_ARG_NIL(L, effect_type, 4, string, 0);
179
182 return 0;
183 }
184
185 return get_unit_vs_tile_bonus(ptile, punit, etype);
186}
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:560
char * incite_cost
Definition comments.c:76
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
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
int get_unit_vs_tile_bonus(const struct tile *ptile, const struct unit *punit, enum effect_type etype)
Definition effects.c:1090
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct req_context *other_context, enum effect_type effect_type)
Definition effects.c:744
int get_world_bonus(enum effect_type effect_type)
Definition effects.c:812
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Definition effects.c:824
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:106
#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:317
Definition tile.h:50
Definition unit.h:140
struct tile * tile
Definition unit.h:142
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define unit_tile(_pu)
Definition unit.h:404
#define unit_owner(_pu)
Definition unit.h:403
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123