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