Freeciv-3.3: /fast/freeciv/nightly/main/common/actres.h Source File

Freeciv-3.3

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 case ACTRES_UNUSED_1: \
39 fc_assert_msg(FALSE, "ACTRES_UNUSED_1"); \
40 break;
41
42/* When making changes to this, update also atk_helpnames at actions.c */
43#define SPECENUM_NAME action_target_kind
44#define SPECENUM_VALUE0 ATK_CITY
45#define SPECENUM_VALUE0NAME "City"
46#define SPECENUM_VALUE1 ATK_UNIT
47#define SPECENUM_VALUE1NAME "Unit"
48#define SPECENUM_VALUE2 ATK_UNITS
49#define SPECENUM_VALUE2NAME "Stack"
50#define SPECENUM_VALUE3 ATK_TILE
51#define SPECENUM_VALUE3NAME "Tile"
52#define SPECENUM_VALUE4 ATK_EXTRAS
53#define SPECENUM_VALUE4NAME "Extras"
54/* No target except the actor itself. */
55#define SPECENUM_VALUE5 ATK_SELF
56#define SPECENUM_VALUE5NAME "Self"
57#define SPECENUM_COUNT ATK_COUNT
58#include "specenum_gen.h"
59
60/* Values used in the network protocol. */
61#define SPECENUM_NAME action_sub_target_kind
62#define SPECENUM_VALUE0 ASTK_NONE
63#define SPECENUM_VALUE0NAME N_("nothing")
64#define SPECENUM_VALUE1 ASTK_BUILDING
65#define SPECENUM_VALUE1NAME N_("buildings in")
66#define SPECENUM_VALUE2 ASTK_TECH
67#define SPECENUM_VALUE2NAME N_("techs from")
68#define SPECENUM_VALUE3 ASTK_EXTRA
69#define SPECENUM_VALUE3NAME N_("extras on")
70#define SPECENUM_VALUE4 ASTK_EXTRA_NOT_THERE
71#define SPECENUM_VALUE4NAME N_("create extras on")
72#define SPECENUM_COUNT ASTK_COUNT
73#include "specenum_gen.h"
74
75/* Action target complexity */
76#define SPECENUM_NAME act_tgt_compl
77/* The action's target is just the primary target. (Just the tile, unit,
78 * city, etc). */
79#define SPECENUM_VALUE0 ACT_TGT_COMPL_SIMPLE
80#define SPECENUM_VALUE0NAME N_("simple")
81/* The action's target is complex because its target is the primary target
82 * and a sub target. (Examples: Tile + Extra and City + Building.) The
83 * player is able to specify details about this action but the server will
84 * fill in missing details so a client can choose to not specify the sub
85 * target. */
86#define SPECENUM_VALUE1 ACT_TGT_COMPL_FLEXIBLE
87#define SPECENUM_VALUE1NAME N_("flexible")
88/* The action's target is complex because its target is the primary target
89 * and a sub target. (Examples: Tile + Extra and City + Building.) The
90 * player is required to specify details about this action because the
91 * server won't fill inn the missing details when unspecified. A client must
92 * therefore specify the sub target of this action. */
93#define SPECENUM_VALUE2 ACT_TGT_COMPL_MANDATORY
94#define SPECENUM_VALUE2NAME N_("mandatory")
95#include "specenum_gen.h"
96
97/* A battle is against a defender that tries to stop the action where the
98 * defender is in danger. A dice roll without a defender risking anything,
99 * like the roll controlled by EFT_ACTION_ODDS_PCT, isn't a battle. */
100#define SPECENUM_NAME action_battle_kind
101#define SPECENUM_VALUE0 ABK_NONE
102#define SPECENUM_VALUE0NAME N_("no battle")
103#define SPECENUM_VALUE1 ABK_STANDARD
104#define SPECENUM_VALUE1NAME N_("battle")
105#define SPECENUM_VALUE2 ABK_DIPLOMATIC
106#define SPECENUM_VALUE2NAME N_("diplomatic battle")
107#define SPECENUM_COUNT ABK_COUNT
108#include "specenum_gen.h"
109
110 enum dice_roll_type { DRT_NONE, DRT_DIPLCHANCE, DRT_CERTAIN };
111
112 struct actres {
113 enum act_tgt_compl sub_tgt_compl;
114 enum action_battle_kind battle_kind;
115 bool hostile;
116 enum unit_activity activity;
117 enum dice_roll_type dice;
118 enum extra_cause ecause; /* Could deduct this from 'activity', but we should merge
119 * activities completely with actions in the future */
120 enum extra_rmcause ermcause;
121 enum action_target_kind def_tgt_kind;
122};
123
124void actres_init(void);
125void actres_free(void);
126
127enum act_tgt_compl actres_target_compl_calc(enum action_result result);
128enum action_battle_kind actres_get_battle_kind(enum action_result result);
129bool actres_is_hostile(enum action_result result);
130enum unit_activity actres_activity_result(enum action_result result);
131int actres_get_act_time(enum action_result result,
132 const struct unit *actor_unit,
133 const struct tile *tgt_tile,
134 const struct extra_type *tgt_extra);
135enum dice_roll_type actres_dice_type(enum action_result result);
136bool actres_creates_extra(enum action_result result,
137 const struct extra_type *pextra);
138bool actres_removes_extra(enum action_result result,
139 const struct extra_type *pextra);
140
141enum fc_tristate actres_possible(const struct civ_map *nmap,
142 enum action_result result,
143 const struct req_context *actor,
144 const struct req_context *target,
145 const struct extra_type *target_extra,
146 enum fc_tristate def,
147 bool omniscient,
148 const struct city *homecity);
149
150int actres_min_range_default(enum action_result result);
151int actres_max_range_default(enum action_result result);
152bool actres_legal_target_kind(enum action_result result,
153 enum action_target_kind tgt_kind);
154enum action_target_kind
155 actres_target_kind_default(enum action_result result);
156enum action_sub_target_kind
157 actres_sub_target_kind_default(enum action_result result);
158
159#ifdef __cplusplus
160}
161#endif /* __cplusplus */
162
163#endif /* FC__ACTRES_H */
actres_get_act_time
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:316
actres_min_range_default
int actres_min_range_default(enum action_result result)
Definition actres.c:376
actres_free
void actres_free(void)
Definition actres.c:250
actres_sub_target_kind_default
enum action_sub_target_kind actres_sub_target_kind_default(enum action_result result)
Definition actres.c:669
actres_target_compl_calc
enum act_tgt_compl actres_target_compl_calc(enum action_result result)
Definition actres.c:258
actres_removes_extra
bool actres_removes_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:806
actres_creates_extra
bool actres_creates_extra(enum action_result result, const struct extra_type *pextra)
Definition actres.c:785
actres_init
void actres_init(void)
Definition actres.c:243
actres_possible
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:831
actres_legal_target_kind
bool actres_legal_target_kind(enum action_result result, enum action_target_kind tgt_kind)
Definition actres.c:558
actres_activity_result
enum unit_activity actres_activity_result(enum action_result result)
Definition actres.c:301
actres_max_range_default
int actres_max_range_default(enum action_result result)
Definition actres.c:465
dice_roll_type
dice_roll_type
Definition actres.h:110
DRT_DIPLCHANCE
@ DRT_DIPLCHANCE
Definition actres.h:110
DRT_CERTAIN
@ DRT_CERTAIN
Definition actres.h:110
DRT_NONE
@ DRT_NONE
Definition actres.h:110
actres_is_hostile
bool actres_is_hostile(enum action_result result)
Definition actres.c:286
actres_dice_type
enum dice_roll_type actres_dice_type(enum action_result result)
Definition actres.c:364
actres_get_battle_kind
enum action_battle_kind actres_get_battle_kind(enum action_result result)
Definition actres.c:272
actres_target_kind_default
enum action_target_kind actres_target_kind_default(enum action_result result)
Definition actres.c:766
incite_cost
char * incite_cost
Definition comments.c:74
actor_unit
struct unit * actor_unit
Definition dialogs_g.h:55
actor
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
target_extra
struct unit struct city struct unit struct tile struct extra_type * target_extra
Definition dialogs_g.h:57
fc_types.h
fc_tristate
fc_tristate
Definition shared.h:46
specenum_gen.h
actres
Definition actres.h:112
actres::hostile
bool hostile
Definition actres.h:115
actres::activity
enum unit_activity activity
Definition actres.h:116
actres::def_tgt_kind
enum action_target_kind def_tgt_kind
Definition actres.h:121
actres::dice
enum dice_roll_type dice
Definition actres.h:117
actres::ermcause
enum extra_rmcause ermcause
Definition actres.h:120
actres::sub_tgt_compl
enum act_tgt_compl sub_tgt_compl
Definition actres.h:113
actres::battle_kind
enum action_battle_kind battle_kind
Definition actres.h:114
actres::ecause
enum extra_cause ecause
Definition actres.h:118
city
Definition city.h:320
civ_map
Definition map_types.h:71
extra_type
Definition extras.h:88
req_context
Definition requirements.h:100
tile
Definition tile.h:50
unit
Definition unit.h:140
world_object.h