Stop sharing requirement_unit_state_ereq().
[freeciv.git] / common / combat.h
blob1966f2c7e5addadbc5464b818ee8687889e9ea5a
1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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.
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__COMBAT_H
14 #define FC__COMBAT_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 #include "fc_types.h"
21 #include "unittype.h"
24 * attack_strength and defense_strength are multiplied by POWER_FACTOR
25 * to yield the base of attack_power and defense_power.
27 * The constant may be changed since it isn't externally visible used.
29 #define POWER_FACTOR 10
31 enum unit_attack_result {
32 ATT_OK,
33 ATT_NON_ATTACK,
34 ATT_UNREACHABLE,
35 ATT_NONNATIVE_SRC,
36 ATT_NONNATIVE_DST
39 bool is_unit_reachable_at(const struct unit *defender,
40 const struct unit *attacker,
41 const struct tile *location);
42 bool can_player_attack_tile(const struct player *pplayer,
43 const struct tile *ptile);
44 enum unit_attack_result unit_attack_unit_at_tile_result(const struct unit *punit,
45 const struct unit *pdefender,
46 const struct tile *dest_tile);
47 enum unit_attack_result unit_attack_units_at_tile_result(const struct unit *punit,
48 const struct tile *ptile);
49 bool can_unit_attack_tile(const struct unit *punit,
50 const struct tile *ptile);
52 double win_chance(int as, int ahp, int afp, int ds, int dhp, int dfp);
54 void get_modified_firepower(const struct unit *attacker,
55 const struct unit *defender,
56 int *att_fp, int *def_fp);
57 double unit_win_chance(const struct unit *attacker,
58 const struct unit *defender);
60 bool unit_really_ignores_citywalls(const struct unit *punit);
61 struct city *sdi_try_defend(const struct player *owner,
62 const struct tile *ptile);
64 int get_attack_power(const struct unit *punit);
65 int base_get_attack_power(const struct unit_type *punittype,
66 int veteran, int moves_left);
67 int base_get_defense_power(const struct unit *punit);
68 int get_total_defense_power(const struct unit *attacker,
69 const struct unit *defender);
70 int get_fortified_defense_power(const struct unit *attacker,
71 const struct unit *defender);
72 int get_virtual_defense_power(const struct unit_type *attacker,
73 const struct unit_type *defender,
74 const struct player *defending_player,
75 const struct tile *ptile,
76 bool fortified, int veteran);
77 int get_total_attack_power(const struct unit *attacker,
78 const struct unit *defender);
80 struct unit *get_defender(const struct unit *attacker,
81 const struct tile *ptile);
82 struct unit *get_attacker(const struct unit *defender,
83 const struct tile *ptile);
85 bool is_stack_vulnerable(const struct tile *ptile);
87 int combat_bonus_against(const struct combat_bonus_list *list,
88 const struct unit_type *enemy,
89 enum combat_bonus_type type);
91 #ifdef __cplusplus
93 #endif /* __cplusplus */
95 #endif /* FC__COMBAT_H */