Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SpellValidation.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SF_SPELLVALIDATION_H
7#define SF_SPELLVALIDATION_H
8
9#include "SharedDefines.h"
10
11#include <initializer_list>
12
13namespace Skyfire
14{
15namespace Spells
16{
18
26
34
35 inline bool IsMaskBitRepresentable(uint32 bitIndex)
36 {
37 return bitIndex < SpellMaskBitCount;
38 }
39
40 inline uint32 GetMaskBit(uint32 bitIndex)
41 {
42 return IsMaskBitRepresentable(bitIndex) ? (1u << bitIndex) : 0;
43 }
44
45 inline bool IsMechanicRepresentable(uint32 mechanic)
46 {
47 return mechanic != MECHANIC_NONE && IsMaskBitRepresentable(mechanic);
48 }
49
50 inline uint32 GetMechanicMask(uint32 mechanic)
51 {
52 return IsMechanicRepresentable(mechanic) ? GetMaskBit(mechanic) : 0;
53 }
54
55 inline uint32 BuildMechanicMask(std::initializer_list<uint32> mechanics)
56 {
57 uint32 mask = 0;
58 for (uint32 mechanic : mechanics)
59 mask |= GetMechanicMask(mechanic);
60
61 return mask;
62 }
63
64 inline bool HasMechanic(uint32 mask, uint32 mechanic)
65 {
66 uint32 mechanicMask = GetMechanicMask(mechanic);
67 return mechanicMask != 0 && (mask & mechanicMask) != 0;
68 }
69
70 inline bool HasAnyMechanic(uint32 mask, std::initializer_list<uint32> mechanics)
71 {
72 return (mask & BuildMechanicMask(mechanics)) != 0;
73 }
74
76 {
77 return GetMaskBit(effIndex);
78 }
79
81 {
82 if (type == DISPEL_ALL)
83 return DISPEL_ALL_MASK;
84
85 return GetMaskBit(uint32(type));
86 }
87
103
105 {
106 switch (status)
107 {
109 return "supported";
111 return "intentionally unused";
113 return "no immediate effect";
115 default:
116 return "missing or unsupported";
117 }
118 }
119}
120}
121
122#endif
std::uint32_t uint32
Definition Define.h:77
#define DISPEL_ALL_MASK
@ MECHANIC_NONE
DispelType
@ DISPEL_ALL
bool HasAnyMechanic(uint32 mask, std::initializer_list< uint32 > mechanics)
uint32 BuildMechanicMask(std::initializer_list< uint32 > mechanics)
@ SPELL_DISPATCH_INTENTIONALLY_UNUSED
@ SPELL_DISPATCH_MISSING_OR_UNSUPPORTED
uint32 GetEffectIndexMask(uint32 effIndex)
uint32 GetDispelMask(DispelType type)
char const * GetSpellDispatchValidationStatusName(SpellDispatchValidationStatus status)
@ SPELL_DISPATCH_HANDLER_NO_IMMEDIATE_EFFECT
bool IsMechanicRepresentable(uint32 mechanic)
uint32 GetMaskBit(uint32 bitIndex)
uint32 GetMechanicMask(uint32 mechanic)
bool IsMaskBitRepresentable(uint32 bitIndex)
uint32 const SpellMaskBitCount
SpellDispatchValidationStatus ClassifySpellDispatchHandler(SpellDispatchHandlerKind kind)
bool HasMechanic(uint32 mask, uint32 mechanic)