mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 00:23:48 +00:00
refactor(Core/Player): extract KillRewarder, TradeData and PlayerTaxi (#6804)
This commit is contained in:
@@ -7,18 +7,21 @@
|
||||
#ifndef _PLAYER_H
|
||||
#define _PLAYER_H
|
||||
|
||||
#include "ArenaTeam.h"
|
||||
#include "Battleground.h"
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "DBCStores.h"
|
||||
#include "GroupReference.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "ArenaTeam.h"
|
||||
#include "Item.h"
|
||||
#include "KillerRewarder.h"
|
||||
#include "MapReference.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PetDefines.h"
|
||||
#include "PlayerTaxi.h"
|
||||
#include "QuestDef.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "TradeData.h"
|
||||
#include "Unit.h"
|
||||
#include "WorldSession.h"
|
||||
#include <string>
|
||||
@@ -676,14 +679,6 @@ struct ItemPosCount
|
||||
};
|
||||
typedef std::vector<ItemPosCount> ItemPosCountVec;
|
||||
|
||||
enum TradeSlots
|
||||
{
|
||||
TRADE_SLOT_COUNT = 7,
|
||||
TRADE_SLOT_TRADED_COUNT = 6,
|
||||
TRADE_SLOT_NONTRADED = 6,
|
||||
TRADE_SLOT_INVALID = -1,
|
||||
};
|
||||
|
||||
enum TransferAbortReason
|
||||
{
|
||||
TRANSFER_ABORT_NONE = 0x00,
|
||||
@@ -917,64 +912,6 @@ enum EmoteBroadcastTextID
|
||||
EMOTE_BROADCAST_TEXT_ID_STRANGE_GESTURES = 91243
|
||||
};
|
||||
|
||||
class PlayerTaxi
|
||||
{
|
||||
public:
|
||||
PlayerTaxi();
|
||||
~PlayerTaxi() = default;
|
||||
// Nodes
|
||||
void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);
|
||||
void LoadTaxiMask(std::string const& data);
|
||||
|
||||
[[nodiscard]] bool IsTaximaskNodeKnown(uint32 nodeidx) const
|
||||
{
|
||||
uint8 field = uint8((nodeidx - 1) / 32);
|
||||
uint32 submask = 1 << ((nodeidx - 1) % 32);
|
||||
return (m_taximask[field] & submask) == submask;
|
||||
}
|
||||
bool SetTaximaskNode(uint32 nodeidx)
|
||||
{
|
||||
uint8 field = uint8((nodeidx - 1) / 32);
|
||||
uint32 submask = 1 << ((nodeidx - 1) % 32);
|
||||
if ((m_taximask[field] & submask) != submask)
|
||||
{
|
||||
m_taximask[field] |= submask;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
void AppendTaximaskTo(ByteBuffer& data, bool all);
|
||||
|
||||
// Destinations
|
||||
bool LoadTaxiDestinationsFromString(std::string const& values, TeamId teamId);
|
||||
std::string SaveTaxiDestinationsToString();
|
||||
|
||||
void ClearTaxiDestinations() { m_TaxiDestinations.clear(); _taxiSegment = 0; }
|
||||
void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
|
||||
[[nodiscard]] uint32 GetTaxiSource() const { return m_TaxiDestinations.size() <= _taxiSegment + 1 ? 0 : m_TaxiDestinations[_taxiSegment]; }
|
||||
[[nodiscard]] uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() <= _taxiSegment + 1 ? 0 : m_TaxiDestinations[_taxiSegment + 1]; }
|
||||
[[nodiscard]] uint32 GetCurrentTaxiPath() const;
|
||||
uint32 NextTaxiDestination()
|
||||
{
|
||||
++_taxiSegment;
|
||||
return GetTaxiDestination();
|
||||
}
|
||||
|
||||
// xinef:
|
||||
void SetTaxiSegment(uint32 segment) { _taxiSegment = segment; }
|
||||
[[nodiscard]] uint32 GetTaxiSegment() const { return _taxiSegment; }
|
||||
|
||||
[[nodiscard]] std::vector<uint32> const& GetPath() const { return m_TaxiDestinations; }
|
||||
[[nodiscard]] bool empty() const { return m_TaxiDestinations.empty(); }
|
||||
|
||||
friend std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
|
||||
private:
|
||||
TaxiMask m_taximask;
|
||||
std::vector<uint32> m_TaxiDestinations;
|
||||
uint32 _taxiSegment;
|
||||
};
|
||||
|
||||
std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
|
||||
|
||||
class Player;
|
||||
@@ -1012,87 +949,6 @@ struct EntryPointData
|
||||
[[nodiscard]] bool HasTaxiPath() const { return !taxiPath.empty(); }
|
||||
};
|
||||
|
||||
class TradeData
|
||||
{
|
||||
public: // constructors
|
||||
TradeData(Player* player, Player* trader) : m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false), m_money(0), m_spell(0)
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] Player* GetTrader() const { return m_trader; }
|
||||
[[nodiscard]] TradeData* GetTraderData() const;
|
||||
|
||||
[[nodiscard]] Item* GetItem(TradeSlots slot) const;
|
||||
[[nodiscard]] bool HasItem(ObjectGuid itemGuid) const;
|
||||
[[nodiscard]] TradeSlots GetTradeSlotForItem(ObjectGuid itemGuid) const;
|
||||
void SetItem(TradeSlots slot, Item* item);
|
||||
|
||||
[[nodiscard]] uint32 GetSpell() const { return m_spell; }
|
||||
void SetSpell(uint32 spell_id, Item* castItem = nullptr);
|
||||
|
||||
[[nodiscard]] Item* GetSpellCastItem() const;
|
||||
[[nodiscard]] bool HasSpellCastItem() const { return m_spellCastItem; }
|
||||
|
||||
[[nodiscard]] uint32 GetMoney() const { return m_money; }
|
||||
void SetMoney(uint32 money);
|
||||
|
||||
[[nodiscard]] bool IsAccepted() const { return m_accepted; }
|
||||
void SetAccepted(bool state, bool crosssend = false);
|
||||
|
||||
[[nodiscard]] bool IsInAcceptProcess() const { return m_acceptProccess; }
|
||||
void SetInAcceptProcess(bool state) { m_acceptProccess = state; }
|
||||
|
||||
private: // internal functions
|
||||
void Update(bool for_trader = true);
|
||||
|
||||
private: // fields
|
||||
Player* m_player; // Player who own of this TradeData
|
||||
Player* m_trader; // Player who trade with m_player
|
||||
|
||||
bool m_accepted; // m_player press accept for trade list
|
||||
bool m_acceptProccess; // one from player/trader press accept and this processed
|
||||
|
||||
uint32 m_money; // m_player place money to trade
|
||||
|
||||
uint32 m_spell; // m_player apply spell to non-traded slot item
|
||||
ObjectGuid m_spellCastItem; // applied spell casted by item use
|
||||
|
||||
ObjectGuid m_items[TRADE_SLOT_COUNT]; // traded itmes from m_player side including non-traded slot
|
||||
};
|
||||
|
||||
class KillRewarder
|
||||
{
|
||||
public:
|
||||
KillRewarder(Player* killer, Unit* victim, bool isBattleGround);
|
||||
|
||||
void Reward();
|
||||
|
||||
private:
|
||||
void _InitXP(Player* player);
|
||||
void _InitGroupData();
|
||||
|
||||
void _RewardHonor(Player* player);
|
||||
void _RewardXP(Player* player, float rate);
|
||||
void _RewardReputation(Player* player, float rate);
|
||||
void _RewardKillCredit(Player* player);
|
||||
void _RewardPlayer(Player* player, bool isDungeon);
|
||||
void _RewardGroup();
|
||||
|
||||
Player* _killer;
|
||||
Unit* _victim;
|
||||
Group* _group;
|
||||
float _groupRate;
|
||||
Player* _maxNotGrayMember;
|
||||
uint32 _count;
|
||||
uint32 _aliveSumLevel;
|
||||
uint32 _sumLevel;
|
||||
uint32 _xp;
|
||||
bool _isFullXP;
|
||||
uint8 _maxLevel;
|
||||
bool _isBattleGround;
|
||||
bool _isPvP;
|
||||
};
|
||||
|
||||
class Player : public Unit, public GridObject<Player>
|
||||
{
|
||||
friend class WorldSession;
|
||||
|
||||
Reference in New Issue
Block a user