AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ServerMailCondition Struct Reference

Represents a condition that must be met for a player to receive a server mail. More...

#include "ServerMailMgr.h"

Public Member Functions

 ServerMailCondition ()=default
 
bool CheckCondition (Player *player) const
 Checks if a player meets this condition.
 

Public Attributes

ServerMailConditionType type = ServerMailConditionType::Invalid
 
uint32 value { 0 }
 
uint32 state { 0 }
 

Detailed Description

Represents a condition that must be met for a player to receive a server mail.

Each condition has a type (see ServerMailConditionType) and a value associated with the type. For example, for a level condition, the value represents the required player level.

Some condition also have a state associated with the value. For example, for a reputation condition, the state represents the current reputation state, like Exalted.

Conditions are attached to server mail templates and are evaluated when players log in.

Constructor & Destructor Documentation

◆ ServerMailCondition()

ServerMailCondition::ServerMailCondition ( )
default

Member Function Documentation

◆ CheckCondition()

bool ServerMailCondition::CheckCondition ( Player player) const

Checks if a player meets this condition.

Evaluates the condition type and compares the player's attributes to the required value.

Parameters
playerThe player to check.
Returns
True if the player meets the condition, otherwise false.
328{
329 switch (type)
330 {
332 return player->GetLevel() >= value;
334 return player->GetTotalPlayedTime() >= value;
336 return player->GetQuestStatus(value) == state;
338 return player->HasAchieved(value);
340 return player->GetReputationRank(value) >= state;
342 return player->GetTeamId() == value;
344 return (player->getRaceMask() & value) != 0;
346 return (player->getClassMask() & value) != 0;
347 default:
348 [[unlikely]] LOG_ERROR("server.mail", "Unknown server mail condition type '{}'", static_cast<uint32>(type));
349 return false;
350 }
351}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
@ Quest
Requires the player to have completed a specific quest.
@ Faction
Requires the player to be a part of a specific faction. Horde/Alliance.
@ Race
Requires the player to be a specific race.
@ Reputation
Requires the player to have earned reputation with a specific faction.
@ Class
Requires the player to be a specific class.
@ Level
Requires the player to be at least a specific level.
@ PlayTime
Requires the player to have played for a minimum amount of time (in milliseconds).
@ Achievement
Requires the player to have earned a specific achievement.
uint32 GetTotalPlayedTime()
Definition Player.h:1203
TeamId GetTeamId(bool original=false) const
Definition Player.h:2116
bool HasAchieved(uint32 achievementId) const
Definition Player.cpp:13974
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1430
ReputationRank GetReputationRank(uint32 faction_id) const
Definition Player.cpp:5903
uint32 getRaceMask() const
Definition Unit.h:804
uint32 getClassMask() const
Definition Unit.h:811
uint8 GetLevel() const
Definition Unit.h:1033
uint32 state
Definition ServerMailMgr.h:91
ServerMailConditionType type
Definition ServerMailMgr.h:89
uint32 value
Definition ServerMailMgr.h:90

References Achievement, Class, Faction, Unit::getClassMask(), Unit::GetLevel(), Player::GetQuestStatus(), Unit::getRaceMask(), Player::GetReputationRank(), Player::GetTeamId(), Player::GetTotalPlayedTime(), Player::HasAchieved(), Level, LOG_ERROR, PlayTime, Quest, Race, Reputation, state, type, and value.

Member Data Documentation

◆ state

uint32 ServerMailCondition::state { 0 }

◆ type

◆ value

uint32 ServerMailCondition::value { 0 }

The documentation for this struct was generated from the following files: