TrinityCore
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
24{
29};
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(), _clientStateIndex(1), _serverStateIndex(1) { }
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 uint64 GetMoney() const { return _money; }
56 void SetMoney(uint64 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
64 uint32 GetClientStateIndex() const { return _clientStateIndex; }
65 void UpdateClientStateIndex() { ++_clientStateIndex; }
66
67 uint32 GetServerStateIndex() const { return _serverStateIndex; }
68 void UpdateServerStateIndex();
69
70private:
71 void Update(bool for_trader = true) const;
72
73 Player* _player; // Player who own of this TradeData
74 Player* _trader; // Player who trade with _player
75
76 bool _accepted; // _player press accept for trade list
77 bool _acceptProccess; // one from player/trader press accept and this processed
78
79 uint64 _money; // _player place money to trade
80
81 uint32 _spell; // _player apply spell to non-traded slot item
82 ObjectGuid _spellCastItem; // applied spell cast by item use
83
84 ObjectGuid _items[TRADE_SLOT_COUNT]; // traded items from _player side including non-traded slot
85
88};
89
90#endif // TradeData_h__
#define TC_GAME_API
Definition: Define.h:123
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
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:170
bool HasSpellCastItem() const
Definition: TradeData.h:53
bool _acceptProccess
Definition: TradeData.h:77
Player * GetTrader() const
Definition: TradeData.h:41
uint32 _serverStateIndex
Definition: TradeData.h:87
uint32 GetClientStateIndex() const
Definition: TradeData.h:64
void SetInAcceptProcess(bool state)
Definition: TradeData.h:62
Player * _player
Definition: TradeData.h:73
void UpdateClientStateIndex()
Definition: TradeData.h:65
uint32 _clientStateIndex
Definition: TradeData.h:86
bool IsAccepted() const
Definition: TradeData.h:58
uint64 GetMoney() const
Definition: TradeData.h:55
bool _accepted
Definition: TradeData.h:76
uint32 GetSpell() const
Definition: TradeData.h:49
ObjectGuid _spellCastItem
Definition: TradeData.h:82
bool IsInAcceptProcess() const
Definition: TradeData.h:61
TradeData(Player *player, Player *trader)
Definition: TradeData.h:37
uint32 GetServerStateIndex() const
Definition: TradeData.h:67
uint32 _spell
Definition: TradeData.h:81
uint64 _money
Definition: TradeData.h:79
Player * _trader
Definition: TradeData.h:74
void Update(VignetteData &vignette, WorldObject const *owner)
Definition: Vignette.cpp:90