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.
337{
338 switch (type)
339 {
341 return player->GetLevel() >= value;
343 return player->GetTotalPlayedTime() >= value;
345 return player->GetQuestStatus(value) == state;
347 return player->HasAchieved(value);
349 return player->GetReputationRank(value) >= state;
351 return player->GetTeamId() == value;
353 return (player->getRaceMask() & value) != 0;
355 return (player->getClassMask() & value) != 0;
357 return player->GetSession()->HasAccountFlag(value);
358 default:
359 [[unlikely]] LOG_ERROR("server.mail", "Unknown server mail condition type '{}'", static_cast<uint32>(type));
360 return false;
361 }
362}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
@ Quest
Requires the player to have completed a specific quest.
@ AccountFlags
Requires the player to have a specific AccountFlag (bit)
@ 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:1208
TeamId GetTeamId(bool original=false) const
Definition Player.h:2126
bool HasAchieved(uint32 achievementId) const
Definition Player.cpp:13887
WorldSession * GetSession() const
Definition Player.h:2016
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1430
ReputationRank GetReputationRank(uint32 faction_id) const
Definition Player.cpp:5895
uint32 getRaceMask() const
Definition Unit.h:788
uint32 getClassMask() const
Definition Unit.h:795
uint8 GetLevel() const
Definition Unit.h:1026
bool HasAccountFlag(uint32 flag) const
Definition WorldSession.h:336
uint32 state
Definition ServerMailMgr.h:93
ServerMailConditionType type
Definition ServerMailMgr.h:91
uint32 value
Definition ServerMailMgr.h:92

References AccountFlags, Achievement, Class, Faction, Unit::getClassMask(), Unit::GetLevel(), Player::GetQuestStatus(), Unit::getRaceMask(), Player::GetReputationRank(), Player::GetSession(), Player::GetTeamId(), Player::GetTotalPlayedTime(), WorldSession::HasAccountFlag(), 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: