AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AuraStub Class Reference

Lightweight stub for Aura proc-related functionality. More...

#include "AuraStub.h"

Inheritance diagram for AuraStub:
MockAuraStub

Public Types

using TimePoint = std::chrono::steady_clock::time_point
 

Public Member Functions

 AuraStub (uint32_t id=0, uint32_t spellFamilyName=0)
 
virtual ~AuraStub ()=default
 
uint32_t GetId () const
 
uint32_t GetSpellFamilyName () const
 
void SetId (uint32_t id)
 
void SetSpellFamilyName (uint32_t familyName)
 
AuraEffectStubGetEffect (uint8_t effIndex) const
 
bool HasEffect (uint8_t effIndex) const
 
uint8_t GetEffectMask () const
 
uint8_t GetCharges () const
 
bool IsUsingCharges () const
 
void SetCharges (uint8_t charges)
 
void SetUsingCharges (bool usingCharges)
 
virtual bool DropCharge ()
 
bool WasChargeDropped () const
 
void ResetChargeDropped ()
 
int32_t GetDuration () const
 
int32_t GetMaxDuration () const
 
bool IsPermanent () const
 
void SetDuration (int32_t duration)
 
void SetMaxDuration (int32_t maxDuration)
 
bool IsProcOnCooldown (TimePoint now) const
 
void AddProcCooldown (TimePoint cooldownEnd)
 
void ResetProcCooldown ()
 
uint8_t GetStackAmount () const
 
void SetStackAmount (uint8_t amount)
 
virtual bool ModStackAmount (int32_t amount, bool=true)
 Modify stack amount (for PROC_ATTR_USE_STACKS_FOR_CHARGES) Mimics Aura::ModStackAmount() - removes aura if stacks reach 0.
 
bool IsPassive () const
 
bool IsRemoved () const
 
void SetPassive (bool isPassive)
 
void SetRemoved (bool isRemoved)
 
virtual void Remove ()
 Mark aura as removed (for charge exhaustion) Mimics Aura::Remove()
 
AuraApplicationStubGetOrCreateApplication ()
 
AuraApplicationStubGetApplication () const
 

Private Attributes

uint32_t _id = 0
 
uint32_t _spellFamilyName = 0
 
std::unique_ptr< AuraEffectStub_effects [3]
 
std::unique_ptr< AuraApplicationStub_application
 
uint8_t _charges = 0
 
bool _isUsingCharges = false
 
bool _chargeDropped = false
 
int32_t _duration = -1
 
int32_t _maxDuration = -1
 
TimePoint _procCooldown = TimePoint::min()
 
uint8_t _stackAmount = 1
 
bool _isPassive = false
 
bool _isRemoved = false
 

Detailed Description

Lightweight stub for Aura proc-related functionality.

Member Typedef Documentation

◆ TimePoint

using AuraStub::TimePoint = std::chrono::steady_clock::time_point

Constructor & Destructor Documentation

◆ AuraStub()

AuraStub::AuraStub ( uint32_t  id = 0,
uint32_t  spellFamilyName = 0 
)
inline
114 : _id(id), _spellFamilyName(spellFamilyName)
115 {
116 // Create 3 effect slots by default
117 for (int i = 0; i < 3; ++i)
118 {
119 _effects[i] = std::make_unique<AuraEffectStub>(static_cast<uint8_t>(i));
120 }
121 }
uint32_t _spellFamilyName
Definition AuraStub.h:253
std::unique_ptr< AuraEffectStub > _effects[3]
Definition AuraStub.h:255
uint32_t _id
Definition AuraStub.h:252

References _effects.

◆ ~AuraStub()

virtual AuraStub::~AuraStub ( )
virtualdefault

Member Function Documentation

◆ AddProcCooldown()

void AuraStub::AddProcCooldown ( TimePoint  cooldownEnd)
inline
192 {
193 _procCooldown = cooldownEnd;
194 }
TimePoint _procCooldown
Definition AuraStub.h:265

References _procCooldown.

Referenced by ProcChanceTestHelper::ApplyProcCooldown().

◆ DropCharge()

virtual bool AuraStub::DropCharge ( )
inlinevirtual
162 {
163 if (_charges > 0)
164 {
165 --_charges;
166 _chargeDropped = true;
167 return true;
168 }
169 return false;
170 }
uint8_t _charges
Definition AuraStub.h:258
bool _chargeDropped
Definition AuraStub.h:260

References _chargeDropped, and _charges.

Referenced by ProcChanceTestHelper::SimulateConsumeProcCharges().

◆ GetApplication()

AuraApplicationStub * AuraStub::GetApplication ( ) const
inline
247 {
248 return _application.get();
249 }
std::unique_ptr< AuraApplicationStub > _application
Definition AuraStub.h:256

References _application.

◆ GetCharges()

uint8_t AuraStub::GetCharges ( ) const
inline
155{ return _charges; }

References _charges.

Referenced by ProcChanceTestHelper::SimulateConsumeProcCharges().

◆ GetDuration()

int32_t AuraStub::GetDuration ( ) const
inline
176{ return _duration; }
int32_t _duration
Definition AuraStub.h:262

References _duration.

◆ GetEffect()

AuraEffectStub * AuraStub::GetEffect ( uint8_t  effIndex) const
inline
134 {
135 return (effIndex < 3) ? _effects[effIndex].get() : nullptr;
136 }

References _effects.

◆ GetEffectMask()

uint8_t AuraStub::GetEffectMask ( ) const
inline
144 {
145 uint8_t mask = 0;
146 for (uint8_t i = 0; i < 3; ++i)
147 {
148 if (_effects[i])
149 mask |= (1 << i);
150 }
151 return mask;
152 }

References _effects.

◆ GetId()

uint32_t AuraStub::GetId ( ) const
inline
126{ return _id; }

References _id.

◆ GetMaxDuration()

int32_t AuraStub::GetMaxDuration ( ) const
inline
177{ return _maxDuration; }
int32_t _maxDuration
Definition AuraStub.h:263

References _maxDuration.

◆ GetOrCreateApplication()

AuraApplicationStub & AuraStub::GetOrCreateApplication ( )
inline
240 {
241 if (!_application)
242 _application = std::make_unique<AuraApplicationStub>();
243 return *_application;
244 }

References _application.

◆ GetSpellFamilyName()

uint32_t AuraStub::GetSpellFamilyName ( ) const
inline
127{ return _spellFamilyName; }

References _spellFamilyName.

◆ GetStackAmount()

uint8_t AuraStub::GetStackAmount ( ) const
inline
202{ return _stackAmount; }
uint8_t _stackAmount
Definition AuraStub.h:267

References _stackAmount.

◆ HasEffect()

bool AuraStub::HasEffect ( uint8_t  effIndex) const
inline
139 {
140 return effIndex < 3 && _effects[effIndex] != nullptr;
141 }

References _effects.

◆ IsPassive()

bool AuraStub::IsPassive ( ) const
inline
223{ return _isPassive; }
bool _isPassive
Definition AuraStub.h:268

References _isPassive.

◆ IsPermanent()

bool AuraStub::IsPermanent ( ) const
inline
178{ return _maxDuration == -1; }

References _maxDuration.

◆ IsProcOnCooldown()

bool AuraStub::IsProcOnCooldown ( TimePoint  now) const
inline
187 {
188 return now < _procCooldown;
189 }

References _procCooldown.

Referenced by ProcChanceTestHelper::IsProcOnCooldown().

◆ IsRemoved()

bool AuraStub::IsRemoved ( ) const
inline
224{ return _isRemoved; }
bool _isRemoved
Definition AuraStub.h:269

References _isRemoved.

◆ IsUsingCharges()

bool AuraStub::IsUsingCharges ( ) const
inline
156{ return _isUsingCharges; }
bool _isUsingCharges
Definition AuraStub.h:259

References _isUsingCharges.

Referenced by ProcChanceTestHelper::SimulateConsumeProcCharges().

◆ ModStackAmount()

virtual bool AuraStub::ModStackAmount ( int32_t  amount,
bool  = true 
)
inlinevirtual

Modify stack amount (for PROC_ATTR_USE_STACKS_FOR_CHARGES) Mimics Aura::ModStackAmount() - removes aura if stacks reach 0.

210 {
211 int32_t newAmount = static_cast<int32_t>(_stackAmount) + amount;
212 if (newAmount <= 0)
213 {
214 _stackAmount = 0;
215 Remove();
216 return true; // Aura removed
217 }
218 _stackAmount = static_cast<uint8_t>(newAmount);
219 return false;
220 }
virtual void Remove()
Mark aura as removed (for charge exhaustion) Mimics Aura::Remove()
Definition AuraStub.h:233

References _stackAmount, and Remove().

Referenced by ProcChanceTestHelper::SimulateConsumeProcCharges().

◆ Remove()

virtual void AuraStub::Remove ( )
inlinevirtual

Mark aura as removed (for charge exhaustion) Mimics Aura::Remove()

234 {
235 _isRemoved = true;
236 }

References _isRemoved.

Referenced by ModStackAmount(), and ProcChanceTestHelper::SimulateConsumeProcCharges().

◆ ResetChargeDropped()

void AuraStub::ResetChargeDropped ( )
inline
173{ _chargeDropped = false; }

References _chargeDropped.

◆ ResetProcCooldown()

void AuraStub::ResetProcCooldown ( )
inline
197 {
198 _procCooldown = TimePoint::min();
199 }

References _procCooldown.

◆ SetCharges()

void AuraStub::SetCharges ( uint8_t  charges)
inline
158{ _charges = charges; }

References _charges.

Referenced by ProcTestContext::WithAuraCharges().

◆ SetDuration()

void AuraStub::SetDuration ( int32_t  duration)
inline
180{ _duration = duration; }

References _duration.

◆ SetId()

void AuraStub::SetId ( uint32_t  id)
inline
129{ _id = id; }

References _id.

Referenced by ProcTestContext::WithAuraId().

◆ SetMaxDuration()

void AuraStub::SetMaxDuration ( int32_t  maxDuration)
inline
181{ _maxDuration = maxDuration; }

References _maxDuration.

◆ SetPassive()

void AuraStub::SetPassive ( bool  isPassive)
inline
226{ _isPassive = isPassive; }

References _isPassive.

◆ SetRemoved()

void AuraStub::SetRemoved ( bool  isRemoved)
inline
227{ _isRemoved = isRemoved; }

References _isRemoved.

◆ SetSpellFamilyName()

void AuraStub::SetSpellFamilyName ( uint32_t  familyName)
inline
130{ _spellFamilyName = familyName; }

References _spellFamilyName.

Referenced by ProcTestContext::WithAuraSpellFamily().

◆ SetStackAmount()

void AuraStub::SetStackAmount ( uint8_t  amount)
inline
203{ _stackAmount = amount; }

References _stackAmount.

◆ SetUsingCharges()

void AuraStub::SetUsingCharges ( bool  usingCharges)
inline
159{ _isUsingCharges = usingCharges; }

References _isUsingCharges.

Referenced by ProcTestContext::WithAuraCharges().

◆ WasChargeDropped()

bool AuraStub::WasChargeDropped ( ) const
inline
172{ return _chargeDropped; }

References _chargeDropped.

Member Data Documentation

◆ _application

std::unique_ptr<AuraApplicationStub> AuraStub::_application
private

◆ _chargeDropped

bool AuraStub::_chargeDropped = false
private

◆ _charges

uint8_t AuraStub::_charges = 0
private

Referenced by DropCharge(), GetCharges(), and SetCharges().

◆ _duration

int32_t AuraStub::_duration = -1
private

Referenced by GetDuration(), and SetDuration().

◆ _effects

std::unique_ptr<AuraEffectStub> AuraStub::_effects[3]
private

◆ _id

uint32_t AuraStub::_id = 0
private

Referenced by GetId(), and SetId().

◆ _isPassive

bool AuraStub::_isPassive = false
private

Referenced by IsPassive(), and SetPassive().

◆ _isRemoved

bool AuraStub::_isRemoved = false
private

Referenced by IsRemoved(), Remove(), and SetRemoved().

◆ _isUsingCharges

bool AuraStub::_isUsingCharges = false
private

Referenced by IsUsingCharges(), and SetUsingCharges().

◆ _maxDuration

int32_t AuraStub::_maxDuration = -1
private

◆ _procCooldown

TimePoint AuraStub::_procCooldown = TimePoint::min()
private

◆ _spellFamilyName

uint32_t AuraStub::_spellFamilyName = 0
private

◆ _stackAmount

uint8_t AuraStub::_stackAmount = 1
private

The documentation for this class was generated from the following file: