TrinityCore
Loading...
Searching...
No Matches
TradeData.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TradeData_h__
19#define TradeData_h__
20
21#include "ObjectGuid.h"
22
30
31class Item;
32class Player;
33
35{
36public:
37 TradeData(Player* player, Player* trader) :
38 _player(player), _trader(trader), _accepted(false), _acceptProccess(false),
39 _money(0), _spell(0), _spellCastItem() { }
40
41 Player* GetTrader() const { return _trader; }
42 TradeData* GetTraderData() const;
43
44 Item* GetItem(TradeSlots slot) const;
45 bool HasItem(ObjectGuid itemGuid) const;
46 TradeSlots GetTradeSlotForItem(ObjectGuid itemGuid) const;
47 void SetItem(TradeSlots slot, Item* item, bool update = false);
48
49 uint32 GetSpell() const { return _spell; }
50 void SetSpell(uint32 spell_id, Item* castItem = nullptr);
51
52 Item* GetSpellCastItem() const;
53 bool HasSpellCastItem() const { return !_spellCastItem.IsEmpty(); }
54
55 uint32 GetMoney() const { return _money; }
56 void SetMoney(uint32 money);
57
58 bool IsAccepted() const { return _accepted; }
59 void SetAccepted(bool state, bool forTrader = false);
60
61 bool IsInAcceptProcess() const { return _acceptProccess; }
62 void SetInAcceptProcess(bool state) { _acceptProccess = state; }
63
64private:
65 void Update(bool for_trader = true) const;
66
67 Player* _player; // Player who own of this TradeData
68 Player* _trader; // Player who trade with _player
69
70 bool _accepted; // _player press accept for trade list
71 bool _acceptProccess; // one from player/trader press accept and this processed
72
73 uint32 _money; // _player place money to trade
74
75 uint32 _spell; // _player apply spell to non-traded slot item
76 ObjectGuid _spellCastItem; // applied spell cast by item use
77
78 ObjectGuid _items[TRADE_SLOT_COUNT]; // traded items from _player side including non-traded slot
79};
80
81#endif // TradeData_h__
#define TC_GAME_API
Definition Define.h:114
uint32_t uint32
Definition Define.h:133
TradeSlots
Definition TradeData.h:24
@ TRADE_SLOT_COUNT
Definition TradeData.h:25
@ TRADE_SLOT_TRADED_COUNT
Definition TradeData.h:26
@ TRADE_SLOT_INVALID
Definition TradeData.h:28
@ TRADE_SLOT_NONTRADED
Definition TradeData.h:27
Definition Item.h:62
bool HasSpellCastItem() const
Definition TradeData.h:53
bool _acceptProccess
Definition TradeData.h:71
Player * GetTrader() const
Definition TradeData.h:41
void SetInAcceptProcess(bool state)
Definition TradeData.h:62
Player * _player
Definition TradeData.h:67
uint32 GetMoney() const
Definition TradeData.h:55
bool IsAccepted() const
Definition TradeData.h:58
bool _accepted
Definition TradeData.h:70
uint32 GetSpell() const
Definition TradeData.h:49
uint32 _money
Definition TradeData.h:73
ObjectGuid _spellCastItem
Definition TradeData.h:76
bool IsInAcceptProcess() const
Definition TradeData.h:61
TradeData(Player *player, Player *trader)
Definition TradeData.h:37
uint32 _spell
Definition TradeData.h:75
Player * _trader
Definition TradeData.h:68