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.
347{
348 switch (type)
349 {
351 return player->GetLevel() >= value;
353 return player->GetTotalPlayedTime() >= value;
355 return player->GetQuestStatus(value) == state;
357 return player->HasAchieved(value);
359 return player->GetReputationRank(value) >= state;
361 return player->GetTeamId() == value;
363 return (player->getRaceMask() & value) != 0;
365 return (player->getClassMask() & value) != 0;
367 return player->GetSession()->HasAccountFlag(value);
368 default:
369 [[unlikely]] LOG_ERROR("server.mail", "Unknown server mail condition type '{}'", static_cast<uint32>(type));
370 return false;
371 }
372}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
@ 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:1206
TeamId GetTeamId(bool original=false) const
Definition Player.h:2131
bool HasAchieved(uint32 achievementId) const
Definition Player.cpp:14060
WorldSession * GetSession() const
Definition Player.h:2023
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1466
ReputationRank GetReputationRank(uint32 faction_id) const
Definition Player.cpp:5870
uint32 getRaceMask() const
Definition Unit.h:838
uint32 getClassMask() const
Definition Unit.h:845
uint8 GetLevel() const
Definition Unit.h:1103
bool HasAccountFlag(uint32 flag) const
Definition WorldSession.h:400
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: