Freeciv-3.2
Loading...
Searching...
No Matches
actres.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2023 The Freeciv Team
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#ifndef FC__ACTRES_H
14#define FC__ACTRES_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* common */
21#include "fc_types.h"
22#include "world_object.h"
23
24struct req_context;
25
26/* If 'enum action_result' has currently unused values that should
27 * not be used in 'switch - cases', put those cases here. E.g.:
28 *
29 *#define ASSERT_UNUSED_ACTRES_CASES \
30 * case ACTRES_UNUSED_1: \
31 * fc_assert_msg(FALSE, "ACTRES_UNUSED_1"); \
32 * break; \
33 * case ACTRES_UNUSED_2: \
34 * fc_assert_msg(FALSE, "ACTRES_UNUSED_2"); \
35 * break;
36 */
37#define ASSERT_UNUSED_ACTRES_CASES \
38
39
40/* When making changes to this, update also atk_helpnames at actions.c */
41#define SPECENUM_NAME action_target_kind
42#define SPECENUM_VALUE0 ATK_CITY
43#define SPECENUM_VALUE0NAME "City"
44#define SPECENUM_VALUE1 ATK_UNIT
45#define SPECENUM_VALUE1NAME "Unit"
46#define SPECENUM_VALUE2 ATK_UNITS
47#define SPECENUM_VALUE2NAME "Stack"
48#define SPECENUM_VALUE3 ATK_TILE
49#define SPECENUM_VALUE3NAME "Tile"
50#define SPECENUM_VALUE4 ATK_EXTRAS
51#define SPECENUM_VALUE4NAME "Extras"
52/* No target except the actor itself. */
53#define SPECENUM_VALUE5 ATK_SELF
54#define SPECENUM_VALUE5NAME "Self"
55#define SPECENUM_COUNT ATK_COUNT
56#include "specenum_gen.h"
57
58/* Values used in the network protocol. */
59#define SPECENUM_NAME action_sub_target_kind
60#define SPECENUM_VALUE0 ASTK_NONE
61#define SPECENUM_VALUE0NAME N_("nothing")
62#define SPECENUM_VALUE1 ASTK_BUILDING
63#define SPECENUM_VALUE1NAME N_("buildings in")
64#define SPECENUM_VALUE2 ASTK_TECH
65#define SPECENUM_VALUE2NAME N_("techs from")
66#define SPECENUM_VALUE3 ASTK_EXTRA
67#define SPECENUM_VALUE3NAME N_("extras on")
68#define SPECENUM_VALUE4 ASTK_EXTRA_NOT_THERE
69#define SPECENUM_VALUE4NAME N_("create extras on")
70#define SPECENUM_COUNT ASTK_COUNT
71#include "specenum_gen.h"
72
73/* Action target complexity */
74#define SPECENUM_NAME act_tgt_compl
75/* The action's target is just the primary target. (Just the tile, unit,
76 * city, etc). */
77#define SPECENUM_VALUE0 ACT_TGT_COMPL_SIMPLE
78#define SPECENUM_VALUE0NAME N_("simple")
79/* The action's target is complex because its target is the primary target
80 * and a sub target. (Examples: Tile + Extra and City + Building.) The
81 * player is able to specify details about this action but the server will
82 * fill in missing details so a client can choose to not specify the sub
83 * target. */
84#define SPECENUM_VALUE1 ACT_TGT_COMPL_FLEXIBLE
85#define SPECENUM_VALUE1NAME N_("flexible")
86/* The action's target is complex because its target is the primary target
87 * and a sub target. (Examples: Tile + Extra and City + Building.) The
88 * player is required to specify details about this action because the
89 * server won't fill inn the missing details when unspecified. A client must
90 * therefore specify the sub target of this action. */
91#define SPECENUM_VALUE2 ACT_TGT_COMPL_MANDATORY
92#define SPECENUM_VALUE2NAME N_("mandatory")
93#include "specenum_gen.h"
94
95/* A battle is against a defender that tries to stop the action where the
96 * defender is in danger. A dice roll without a defender risking anything,
97 * like the roll controlled by EFT_ACTION_ODDS_PCT, isn't a battle. */
98#define SPECENUM_NAME action_battle_kind
99#define SPECENUM_VALUE0 ABK_NONE
100#define SPECENUM_VALUE0NAME N_("no battle")
101#define SPECENUM_VALUE1 ABK_STANDARD
102#define SPECENUM_VALUE1NAME N_("battle")
103#define SPECENUM_VALUE2 ABK_DIPLOMATIC
104#define SPECENUM_VALUE2NAME N_("diplomatic battle")
105#define SPECENUM_COUNT ABK_COUNT
106#include "specenum_gen.h"
107
109
110struct actres {
116 enum extra_cause ecause; /* Could deduct this from 'activity', but we should merge
117 * activities completely with actions in the future */
120};
121
122void actres_init(void);
123void actres_free(void);
124
127bool actres_is_hostile(enum action_result result);
129int actres_get_act_time(enum action_result result,
130 const struct unit *actor_unit,
131 const struct tile *tgt_tile,
132 const struct extra_type *tgt_extra);
134bool actres_creates_extra(enum action_result result,
135 const struct extra_type *pextra);
136bool actres_removes_extra(enum action_result result,
137 const struct extra_type *pextra);
138
139enum fc_tristate actres_possible(const struct civ_map *nmap,
140 enum action_result result,
141 const struct req_context *actor,
142 const struct req_context *target,
143 const struct extra_type *target_extra,
144 enum fc_tristate def,
145 bool omniscient,
146 const struct city *homecity);
147
151 enum action_target_kind tgt_kind);
156
157#ifdef __cplusplus
158}
159#endif /* __cplusplus */
160
161#endif /* FC__ACTRES_H */
int actres_get_act_time(enum action_result result, const struct unit *actor_unit, const struct tile *tgt_tile, const struct extra_type *tgt_extra)
Definition actres.c:313
int actres_min_range_default(enum action_result result)
Definition actres.c:373
void actres_free(void)
Definition actres.c:247
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:666
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:255
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:803
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:782
void actres_init(void)
Definition actres.c:240
enum fc_tristate actres_possible(const struct civ_map *nmap, enum action_result result, const struct req_context *actor, const struct req_context *target, const struct extra_type *target_extra, enum fc_tristate def, bool omniscient, const struct city *homecity)
Definition actres.c:828
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:555
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:298
int actres_max_range_default(enum action_result result)
Definition actres.c:462
dice_roll_type
Definition actres.h:108
@ DRT_DIPLCHANCE
Definition actres.h:108
@ DRT_CERTAIN
Definition actres.h:108
@ DRT_NONE
Definition actres.h:108
bool actres_is_hostile(enum action_result result)
Definition actres.c:283
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:361
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:269
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:763
char * incite_cost
Definition comments.c:75
struct unit * actor_unit
Definition dialogs_g.h:55
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
fc_tristate
Definition shared.h:46
bool hostile
Definition actres.h:113
enum unit_activity activity
Definition actres.h:114
enum action_target_kind def_tgt_kind
Definition actres.h:119
enum dice_roll_type dice
Definition actres.h:115
enum extra_rmcause ermcause
Definition actres.h:118
enum act_tgt_compl sub_tgt_compl
Definition actres.h:111
enum action_battle_kind battle_kind
Definition actres.h:112
enum extra_cause ecause
Definition actres.h:116
Definition city.h:320
Definition tile.h:50
Definition unit.h:138