1 #pragma once
2 #ifndef CATA_SRC_ENUMS_H
3 #define CATA_SRC_ENUMS_H
4 
5 #include <type_traits>
6 
7 template<typename T> struct enum_traits;
8 
9 template<typename T>
sgn(const T x)10 constexpr inline int sgn( const T x )
11 {
12     return x < 0 ? -1 : ( x > 0 ? 1 : 0 );
13 }
14 
15 enum class aim_exit : int {
16     none = 0,
17     okay,
18     re_entry
19 };
20 
21 // be explicit with the values
22 enum class aim_entry : int {
23     START     = 0,
24     VEHICLE   = 1,
25     MAP       = 2,
26     RESET     = 3
27 };
28 
29 using I = std::underlying_type_t<aim_entry>;
30 static constexpr aim_entry &operator++( aim_entry &lhs )
31 {
32     lhs = static_cast<aim_entry>( static_cast<I>( lhs ) + 1 );
33     return lhs;
34 }
35 
36 static constexpr aim_entry &operator--( aim_entry &lhs )
37 {
38     lhs = static_cast<aim_entry>( static_cast<I>( lhs ) - 1 );
39     return lhs;
40 }
41 
42 static constexpr aim_entry operator+( const aim_entry &lhs, const I &rhs )
43 {
44     return static_cast<aim_entry>( static_cast<I>( lhs ) + rhs );
45 }
46 
47 static constexpr aim_entry operator-( const aim_entry &lhs, const I &rhs )
48 {
49     return static_cast<aim_entry>( static_cast<I>( lhs ) - rhs );
50 }
51 
52 enum class bionic_ui_sort_mode : int {
53     NONE   = 0,
54     POWER  = 1,
55     NAME   = 2,
56     INVLET = 3,
57     nsort  = 4,
58 };
59 
60 template<>
61 struct enum_traits<bionic_ui_sort_mode> {
62     static constexpr bionic_ui_sort_mode last = bionic_ui_sort_mode::nsort;
63 };
64 
65 // When bool is not enough. NONE, SOME or ALL
66 enum class trinary : int {
67     NONE = 0,
68     SOME = 1,
69     ALL  = 2
70 };
71 
72 enum class holiday : int {
73     none = 0,
74     new_year,
75     easter,
76     independence_day,
77     halloween,
78     thanksgiving,
79     christmas,
80     num_holiday
81 };
82 
83 template<>
84 struct enum_traits<holiday> {
85     static constexpr holiday last = holiday::num_holiday;
86 };
87 
88 enum class temperature_flag : int {
89     NORMAL = 0,
90     HEATER,
91     FRIDGE,
92     FREEZER,
93     ROOT_CELLAR
94 };
95 
96 //Used for autopickup and safemode rules
97 enum class rule_state : int {
98     NONE,
99     WHITELISTED,
100     BLACKLISTED
101 };
102 
103 enum class visibility_type : int {
104     HIDDEN,
105     CLEAR,
106     LIT,
107     BOOMER,
108     DARK,
109     BOOMER_DARK
110 };
111 
112 // Matching rules for comparing a string to an overmap terrain id.
113 enum class ot_match_type : int {
114     // The provided string must completely match the overmap terrain id, including
115     // linear direction suffixes for linear terrain types or rotation suffixes
116     // for rotated terrain types.
117     exact,
118     // The provided string must completely match the base type id of the overmap
119     // terrain id, which means that suffixes for rotation and linear terrain types
120     // are ignored.
121     type,
122     // The provided string must be a complete prefix (with additional parts delimited
123     // by an underscore) of the overmap terrain id. For example, "forest" will match
124     // "forest" or "forest_thick" but not "forestcabin".
125     prefix,
126     // The provided string must be contained within the overmap terrain id, but may
127     // occur at the beginning, end, or middle and does not have any rules about
128     // underscore delimiting.
129     contains,
130     num_ot_match_type
131 };
132 
133 template<>
134 struct enum_traits<ot_match_type> {
135     static constexpr ot_match_type last = ot_match_type::num_ot_match_type;
136 };
137 
138 enum class special_game_type : int {
139     NONE = 0,
140     TUTORIAL,
141     DEFENSE,
142     NUM_SPECIAL_GAME_TYPES
143 };
144 
145 enum art_effect_passive : int {
146     AEP_NULL = 0,
147     // Good
148     AEP_STR_UP, // Strength + 4
149     AEP_DEX_UP, // Dexterity + 4
150     AEP_PER_UP, // Perception + 4
151     AEP_INT_UP, // Intelligence + 4
152     AEP_ALL_UP, // All stats + 2
153     AEP_SPEED_UP, // +20 speed
154     AEP_PBLUE, // Reduces radiation
155     AEP_SNAKES, // Summons friendly snakes when you're hit
156     AEP_INVISIBLE, // Makes you invisible
157     AEP_CLAIRVOYANCE, // See through walls
158     AEP_SUPER_CLAIRVOYANCE, // See through walls to a great distance
159     AEP_STEALTH, // Your steps are quieted
160     AEP_EXTINGUISH, // May extinguish nearby flames
161     AEP_GLOW, // Four-tile light source
162     AEP_PSYSHIELD, // Protection from fear paralyze attack
163     AEP_RESIST_ELECTRICITY, // Protection from electricity
164     AEP_CARRY_MORE, // Increases carrying capacity by 200
165     AEP_SAP_LIFE, // Killing non-zombie monsters may heal you
166     AEP_FUN, // Slight passive morale
167     // Splits good from bad
168     AEP_SPLIT,
169     // Bad
170     AEP_HUNGER, // Increases hunger
171     AEP_THIRST, // Increases thirst
172     AEP_SMOKE, // Emits smoke occasionally
173     AEP_EVIL, // Addiction to the power
174     AEP_SCHIZO, // Mimicks schizophrenia
175     AEP_RADIOACTIVE, // Increases your radiation
176     AEP_MUTAGENIC, // Mutates you slowly
177     AEP_ATTENTION, // Draws netherworld attention slowly
178     AEP_STR_DOWN, // Strength - 3
179     AEP_DEX_DOWN, // Dex - 3
180     AEP_PER_DOWN, // Per - 3
181     AEP_INT_DOWN, // Int - 3
182     AEP_ALL_DOWN, // All stats - 2
183     AEP_SPEED_DOWN, // -20 speed
184     AEP_FORCE_TELEPORT, // Occasionally force a teleport
185     AEP_MOVEMENT_NOISE, // Makes noise when you move
186     AEP_BAD_WEATHER, // More likely to experience bad weather
187     AEP_SICK, // Decreases health over time
188     AEP_CLAIRVOYANCE_PLUS, // See through walls to a larger distance; not bad effect, placement to preserve old saves.
189 
190     NUM_AEPS
191 };
192 
193 template<>
194 struct enum_traits<art_effect_passive> {
195     static constexpr art_effect_passive last = art_effect_passive::NUM_AEPS;
196 };
197 
198 enum artifact_natural_property {
199     ARTPROP_NULL,
200     ARTPROP_WRIGGLING, //
201     ARTPROP_GLOWING, //
202     ARTPROP_HUMMING, //
203     ARTPROP_MOVING, //
204     ARTPROP_WHISPERING, //
205     ARTPROP_BREATHING, //
206     ARTPROP_DEAD, //
207     ARTPROP_ITCHY, //
208     ARTPROP_GLITTERING, //
209     ARTPROP_ELECTRIC, //
210     ARTPROP_SLIMY, //
211     ARTPROP_ENGRAVED, //
212     ARTPROP_CRACKLING, //
213     ARTPROP_WARM, //
214     ARTPROP_RATTLING, //
215     ARTPROP_SCALED,
216     ARTPROP_FRACTAL,
217     ARTPROP_MAX
218 };
219 
220 enum class phase_id : int {
221     PNULL,
222     SOLID,
223     LIQUID,
224     GAS,
225     PLASMA,
226     num_phases
227 };
228 
229 template<>
230 struct enum_traits<phase_id> {
231     static constexpr phase_id last = phase_id::num_phases;
232 };
233 
234 // Return the class an in-world object uses to interact with the world.
235 //   ex; if ( player.grab_type == object_type::VEHICLE ) { ...
236 //   or; if ( baseactor_just_shot_at.object_type() == object_type::NPC ) { ...
237 enum class object_type : int {
238     NONE,      // Nothing, invalid.
239     ITEM,      // item.h
240     ACTOR,     // potential virtual base class, get_object_type() would return one of the types below
241     PLAYER,  // player.h, npc.h
242     NPC,   // nph.h
243     MONSTER, // monster.h
244     VEHICLE,   // vehicle.h
245     TRAP,      // trap.h
246     FIELD,     // field.h; field_entry
247     TERRAIN,   // Not a real object
248     FURNITURE, // Not a real object
249     NUM_OBJECT_TYPES,
250 };
251 
252 enum class liquid_source_type : int {
253     INFINITE_MAP = 1,
254     MAP_ITEM = 2,
255     VEHICLE = 3,
256     MONSTER = 4
257 };
258 
259 enum class liquid_target_type : int {
260     CONTAINER = 1,
261     VEHICLE = 2,
262     MAP = 3,
263     MONSTER = 4
264 };
265 
266 /**
267  *  Possible layers that a piece of clothing/armor can occupy
268  *
269  *  Every piece of clothing occupies one distinct layer on the body-part that
270  *  it covers.  This is used for example by @ref Character to calculate
271  *  encumbrance values, @ref player to calculate time to wear/remove the item,
272  *  and by @ref profession to place the characters' clothing in a sane order
273  *  when starting the game.
274  */
275 enum class layer_level : int {
276     /* "Personal effects" layer, corresponds to PERSONAL flag */
277     PERSONAL = 0,
278     /* "Close to skin" layer, corresponds to SKINTIGHT flag. */
279     UNDERWEAR,
280     /* "Normal" layer, default if no flags set */
281     REGULAR,
282     /* "Waist" layer, corresponds to WAIST flag. */
283     WAIST,
284     /* "Outer" layer, corresponds to OUTER flag. */
285     OUTER,
286     /* "Strapped" layer, corresponds to BELTED flag */
287     BELTED,
288     /* "Aura" layer, corresponds to AURA flag */
289     AURA,
290     /* Not a valid layer; used for C-style iteration through this enum */
291     NUM_LAYER_LEVELS
292 };
293 
294 template<>
295 struct enum_traits<layer_level> {
296     static constexpr layer_level last = layer_level::NUM_LAYER_LEVELS;
297 };
298 
299 inline layer_level &operator++( layer_level &l )
300 {
301     l = static_cast<layer_level>( static_cast<int>( l ) + 1 );
302     return l;
303 }
304 
305 /** Possible reasons to interrupt an activity. */
306 enum class distraction_type : int {
307     noise,
308     pain,
309     attacked,
310     hostile_spotted_far,
311     hostile_spotted_near,
312     talked_to,
313     asthma,
314     motion_alarm,
315     weather_change,
316 };
317 
318 enum game_message_type : int {
319     m_good,    /* something good happened to the player character, e.g. health boost, increasing in skill */
320     m_bad,      /* something bad happened to the player character, e.g. damage, decreasing in skill */
321     m_mixed,   /* something happened to the player character which is mixed (has good and bad parts),
322                   e.g. gaining a mutation with mixed effect*/
323     m_warning, /* warns the player about a danger. e.g. enemy appeared, an alarm sounds, noise heard. */
324     m_info,    /* informs the player about something, e.g. on examination, seeing an item,
325                   about how to use a certain function, etc. */
326     m_neutral,  /* neutral or indifferent events which aren’t informational or nothing really happened e.g.
327                   a miss, a non-critical failure. May also effect for good or bad effects which are
328                   just very slight to be notable. This is the default message type. */
329 
330     m_debug, /* only shown when debug_mode is true */
331     /* custom SCT colors */
332     m_headshot,
333     m_critical,
334     m_grazing,
335     num_game_message_type
336 };
337 
338 template<>
339 struct enum_traits<game_message_type> {
340     static constexpr game_message_type last = game_message_type::num_game_message_type;
341 };
342 
343 enum game_message_flags {
344     /* No specific game message flags */
345     gmf_none = 0,
346     /* Allow the message to bypass message cooldown. */
347     gmf_bypass_cooldown = 1,
348 };
349 
350 /** Structure allowing a combination of `game_message_type` and `game_message_flags`.
351  */
352 struct game_message_params {
353     // NOLINTNEXTLINE(google-explicit-constructor)
354     game_message_params( const game_message_type message_type ) : type( message_type ),
355         flags( gmf_none ) {}
356     game_message_params( const game_message_type message_type,
357                          const game_message_flags message_flags ) : type( message_type ), flags( message_flags ) {}
358 
359     /* Type of the message */
360     game_message_type type;
361     /* Flags pertaining to the message */
362     game_message_flags flags;
363 };
364 
365 struct social_modifiers {
366     int lie = 0;
367     int persuade = 0;
368     int intimidate = 0;
369 
370     social_modifiers &operator+=( const social_modifiers &other ) {
371         this->lie += other.lie;
372         this->persuade += other.persuade;
373         this->intimidate += other.intimidate;
374         return *this;
375     }
376     bool empty() const {
377         return this->lie != 0 || this->persuade != 0 || this->intimidate != 0;
378     }
379 };
380 
381 enum class reachability_cache_quadrant : int {
382     NE, SE, NW, SW
383 };
384 
385 template<>
386 struct enum_traits<reachability_cache_quadrant> {
387     static constexpr reachability_cache_quadrant last = reachability_cache_quadrant::SW;
388     static constexpr int size = static_cast<int>( last ) + 1;
389 
390     inline static reachability_cache_quadrant quadrant( bool S, bool W ) {
391         return static_cast<reachability_cache_quadrant>(
392                    ( static_cast<int>( W ) << 1 ) | static_cast<int>( S )
393                );
394     }
395 };
396 
397 enum class monotonically : int {
398     constant,
399     increasing,
400     decreasing,
401     unknown,
402 };
403 
404 constexpr bool is_increasing( monotonically m )
405 {
406     return m == monotonically::constant || m == monotonically::increasing;
407 }
408 
409 constexpr bool is_decreasing( monotonically m )
410 {
411     return m == monotonically::constant || m == monotonically::decreasing;
412 }
413 
414 #endif // CATA_SRC_ENUMS_H
415