TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AuctionHouseBot.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
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 AUCTION_HOUSE_BOT_H
19 #define AUCTION_HOUSE_BOT_H
20 
21 #include "Define.h"
22 
23 class AuctionBotSeller;
24 class AuctionBotBuyer;
25 
26 // shadow of ItemQualities with skipped ITEM_QUALITY_HEIRLOOM, anything after ITEM_QUALITY_ARTIFACT(6) in fact
28 {
36 };
37 
38 #define MAX_AUCTION_QUALITY 7
39 
41 {
45 };
46 
47 #define MAX_AUCTION_HOUSE_TYPE 3
48 
50 {
156 };
157 
159 {
190 };
191 
193 {
196 };
197 
198 // All basic config data used by other AHBot classes for self-configure.
200 {
201 private:
202  AuctionBotConfig(): _itemsPerCycleBoost(1000), _itemsPerCycleNormal(20) {}
206 
207 public:
208  static AuctionBotConfig* instance();
209 
210  bool Initialize();
211  const std::string& GetAHBotIncludes() const { return _AHBotIncludes; }
212  const std::string& GetAHBotExcludes() const { return _AHBotExcludes; }
213 
214  uint32 GetConfig(AuctionBotConfigUInt32Values index) const { return _configUint32Values[index]; }
215  bool GetConfig(AuctionBotConfigBoolValues index) const { return _configBoolValues[index]; }
216  float GetConfig(AuctionBotConfigFloatValues index) const { return _configFloatValues[index]; }
217  void SetConfig(AuctionBotConfigBoolValues index, bool value) { _configBoolValues[index] = value; }
218  void SetConfig(AuctionBotConfigUInt32Values index, uint32 value) { _configUint32Values[index] = value; }
219  void SetConfig(AuctionBotConfigFloatValues index, float value) { _configFloatValues[index] = value; }
220 
221  uint32 GetConfigItemAmountRatio(AuctionHouseType houseType) const;
222  bool GetConfigBuyerEnabled(AuctionHouseType houseType) const;
223  uint32 GetConfigItemQualityAmount(AuctionQuality quality) const;
224 
225  uint32 GetItemPerCycleBoost() const { return _itemsPerCycleBoost; }
226  uint32 GetItemPerCycleNormal() const { return _itemsPerCycleNormal; }
227  void Reload() { GetConfigFromFile(); }
228 
229  static char const* GetHouseTypeName(AuctionHouseType houseType);
230 
231 private:
232  std::string _AHBotIncludes;
233  std::string _AHBotExcludes;
236 
238  bool _configBoolValues[CONFIG_UINT32_AHBOT_BOOL_COUNT];
239  float _configFloatValues[CONFIG_AHBOT_FLOAT_COUNT];
240 
241  void SetAHBotIncludes(const std::string& AHBotIncludes) { _AHBotIncludes = AHBotIncludes; }
242  void SetAHBotExcludes(const std::string& AHBotExcludes) { _AHBotExcludes = AHBotExcludes; }
243 
244  void SetConfig(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue);
245  void SetConfigMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 maxvalue);
246  void SetConfigMinMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue);
247  void SetConfig(AuctionBotConfigBoolValues index, char const* fieldname, bool defvalue);
248  void SetConfig(AuctionBotConfigFloatValues index, char const* fieldname, float defvalue);
249  void GetConfigFromFile();
250 };
251 
252 #define sAuctionBotConfig AuctionBotConfig::instance()
253 
255 {
256 public:
258  virtual ~AuctionBotAgent() {}
259  virtual bool Initialize() = 0;
260  virtual bool Update(AuctionHouseType houseType) = 0;
261 };
262 
264 {
267 };
268 
270 
271 // This class handle both Selling and Buying method
272 // (holder of AuctionBotBuyer and AuctionBotSeller objects)
274 {
275 private:
276  AuctionHouseBot();
277  ~AuctionHouseBot();
280 
281 public:
282  static AuctionHouseBot* instance();
283 
284  void Update();
285  void Initialize();
286 
287  // Followed method is mainly used by cs_ahbot.cpp for in-game/console command
288  void SetItemsRatio(uint32 al, uint32 ho, uint32 ne);
289  void SetItemsRatioForHouse(AuctionHouseType house, uint32 val);
290  void SetItemsAmount(uint32(&vals)[MAX_AUCTION_QUALITY]);
291  void SetItemsAmountForQuality(AuctionQuality quality, uint32 val);
292  void ReloadAllConfig();
293  void Rebuild(bool all);
294 
295  void PrepareStatusInfos(AuctionHouseBotStatusInfo& statusInfo);
296 private:
297  void InitializeAgents();
298 
301 
302  uint32 _operationSelector; // 0..2*MAX_AUCTION_HOUSE_TYPE-1
303 };
304 
305 #define sAuctionBot AuctionHouseBot::instance()
306 
307 #endif
AuctionQuality
Definition: AuctionHouseBot.h:27
Definition: AuctionHouseBot.h:143
AuctionBotAgent()
Definition: AuctionHouseBot.h:257
void SetConfig(AuctionBotConfigBoolValues index, bool value)
Definition: AuctionHouseBot.h:217
Definition: AuctionHouseBot.h:129
Definition: AuctionHouseBot.h:107
Definition: AuctionHouseBot.h:125
Definition: AuctionHouseBot.h:74
Definition: AuctionHouseBot.h:95
Definition: AuctionHouseBot.h:42
AuctionBotConfigBoolValues
Definition: AuctionHouseBot.h:158
Definition: AuctionHouseBot.h:151
Definition: AuctionHouseBot.h:80
Definition: AuctionHouseBot.h:52
Definition: AuctionHouseBot.h:75
AuctionHouseBotStatusInfoPerType AuctionHouseBotStatusInfo[MAX_AUCTION_HOUSE_TYPE]
Definition: AuctionHouseBot.h:269
std::string _AHBotExcludes
Definition: AuctionHouseBot.h:233
Definition: AuctionHouseBot.h:78
Definition: AuctionHouseBot.h:144
AuctionBotSeller * _seller
Definition: AuctionHouseBot.h:300
Definition: AuctionHouseBot.h:89
AuctionHouseType
Definition: AuctionHouseBot.h:40
Definition: AuctionHouseBot.h:103
Definition: AuctionHouseBot.h:90
Definition: AuctionHouseBot.h:184
Definition: AuctionHouseBot.h:172
Definition: AuctionHouseBot.h:34
Definition: AuctionHouseBot.h:101
uint32 GetItemPerCycleNormal() const
Definition: AuctionHouseBot.h:226
Definition: AuctionHouseBot.h:113
Definition: AuctionHouseBot.h:32
Definition: AuctionHouseBot.h:121
Definition: AuctionHouseBot.h:67
Definition: AuctionHouseBot.h:139
Definition: AuctionHouseBot.h:97
#define MAX_AUCTION_QUALITY
Definition: AuctionHouseBot.h:38
Definition: AuctionHouseBot.h:86
Definition: AuctionHouseBot.h:110
Definition: AuctionHouseBot.h:98
Definition: AuctionHouseBot.h:189
AuctionBotConfigUInt32Values
Definition: AuctionHouseBot.h:49
uint32 _itemsPerCycleNormal
Definition: AuctionHouseBot.h:235
Definition: AuctionHouseBot.h:149
AuctionBotBuyer * _buyer
Definition: AuctionHouseBot.h:299
Definition: AuctionHouseBot.h:140
Definition: AuctionHouseBot.h:59
Definition: AuctionHouseBot.h:99
Definition: AuctionHouseBot.h:171
Definition: AuctionHouseBot.h:117
Definition: AuctionHouseBot.h:33
Definition: AuctionHouseBot.h:76
Definition: AuctionHouseBot.h:55
Definition: AuctionHouseBot.h:195
Definition: AuctionHouseBot.h:176
Definition: AuctionHouseBot.h:72
Definition: AuctionHouseBot.h:177
Definition: AuctionHouseBot.h:168
~AuctionBotConfig()
Definition: AuctionHouseBot.h:203
void SetAHBotExcludes(const std::string &AHBotExcludes)
Definition: AuctionHouseBot.h:242
Definition: AuctionHouseBot.h:131
bool all(float x)
Definition: g3dmath.h:431
float GetConfig(AuctionBotConfigFloatValues index) const
Definition: AuctionHouseBot.h:216
Definition: AuctionHouseBot.h:83
Definition: AuctionHouseBot.h:88
Definition: AuctionHouseBot.h:183
AuctionBotConfigFloatValues
Definition: AuctionHouseBot.h:192
Definition: AuctionHouseBot.h:145
Definition: AuctionHouseBot.h:69
Definition: AuctionHouseBot.h:77
Definition: AuctionHouseBot.h:71
Definition: AuctionHouseBot.h:44
Definition: AuctionHouseBot.h:263
Definition: AuctionHouseBotSeller.h:118
Definition: AuctionHouseBot.h:133
Definition: AuctionHouseBot.h:118
Definition: AuctionHouseBot.h:130
Definition: AuctionHouseBot.h:169
uint32 QualityInfo[MAX_AUCTION_QUALITY]
Definition: AuctionHouseBot.h:266
Definition: AuctionHouseBot.h:136
const std::string & GetAHBotExcludes() const
Definition: AuctionHouseBot.h:212
bool GetConfig(AuctionBotConfigBoolValues index) const
Definition: AuctionHouseBot.h:215
Definition: AuctionHouseBot.h:102
#define MAX_AUCTION_HOUSE_TYPE
Definition: AuctionHouseBot.h:47
Definition: AuctionHouseBot.h:138
Definition: AuctionHouseBot.h:54
Definition: AuctionHouseBot.h:82
Definition: AuctionHouseBot.h:73
Definition: AuctionHouseBot.h:186
Definition: AuctionHouseBot.h:187
Definition: AuctionHouseBot.h:123
Definition: AuctionHouseBot.h:146
Definition: AuctionHouseBot.h:179
Definition: AuctionHouseBot.h:128
Definition: AuctionHouseBotBuyer.h:70
Definition: AuctionHouseBot.h:152
Definition: AuctionHouseBot.h:63
Definition: AuctionHouseBot.h:79
Definition: AuctionHouseBot.h:170
uint32 ItemsCount
Definition: AuctionHouseBot.h:265
virtual ~AuctionBotAgent()
Definition: AuctionHouseBot.h:258
virtual bool Update(AuctionHouseType houseType)=0
Vector2int16 & operator=(const Any &a)
Definition: AuctionHouseBot.h:112
Definition: AuctionHouseBot.h:120
Definition: AuctionHouseBot.h:154
uint32_t uint32
Definition: Define.h:150
Definition: AuctionHouseBot.h:96
static void Initialize(PCASC_SALSA20 pState, LPBYTE pbKey, DWORD cbKeyLength, LPBYTE pbVector)
Definition: CascDecrypt.cpp:81
Definition: AuctionHouseBot.h:194
Definition: AuctionHouseBot.h:153
Definition: AuctionHouseBot.h:185
Definition: SharedDefines.h:322
Definition: AuctionHouseBot.h:56
Definition: AuctionHouseBot.h:29
Definition: AuctionHouseBot.h:51
Definition: AuctionHouseBot.h:64
Definition: AuctionHouseBot.h:68
Definition: AuctionHouseBot.h:94
Definition: SharedDefines.h:326
virtual bool Initialize()=0
Definition: AuctionHouseBot.h:254
Definition: AuctionHouseBot.h:61
Definition: AuctionHouseBot.h:91
Definition: AuctionHouseBot.h:273
Definition: AuctionHouseBot.h:30
Definition: AuctionHouseBot.h:163
Definition: AuctionHouseBot.h:66
uint32 GetConfig(AuctionBotConfigUInt32Values index) const
Definition: AuctionHouseBot.h:214
Definition: AuctionHouseBot.h:167
Definition: AuctionHouseBot.h:165
uint32 _itemsPerCycleBoost
Definition: AuctionHouseBot.h:234
Definition: AuctionHouseBot.h:135
Definition: AuctionHouseBot.h:188
Definition: AuctionHouseBot.h:62
Definition: AuctionHouseBot.h:104
Definition: AuctionHouseBot.h:31
Definition: AuctionHouseBot.h:105
Definition: AuctionHouseBot.h:114
Definition: AuctionHouseBot.h:147
Definition: AuctionHouseBot.h:178
Definition: AuctionHouseBot.h:93
Definition: AuctionHouseBot.h:175
void SetConfig(AuctionBotConfigUInt32Values index, uint32 value)
Definition: AuctionHouseBot.h:218
Definition: AuctionHouseBot.h:148
Definition: SharedDefines.h:321
#define TC_GAME_API
Definition: Define.h:134
Definition: AuctionHouseBot.h:174
Definition: AuctionHouseBot.h:115
Definition: AuctionHouseBot.h:35
Definition: AuctionHouseBot.h:160
Definition: AuctionHouseBot.h:126
Definition: AuctionHouseBot.h:122
Definition: AuctionHouseBot.h:150
Definition: AuctionHouseBot.h:173
Definition: AuctionHouseBot.h:87
Definition: AuctionHouseBot.h:84
Definition: AuctionHouseBot.h:58
Definition: AuctionHouseBot.h:70
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: SharedDefines.h:323
Definition: SharedDefines.h:325
uint32 GetItemPerCycleBoost() const
Definition: AuctionHouseBot.h:225
std::string _AHBotIncludes
Definition: AuctionHouseBot.h:232
Definition: AuctionHouseBot.h:106
uint32 _operationSelector
Definition: AuctionHouseBot.h:302
const std::string & GetAHBotIncludes() const
Definition: AuctionHouseBot.h:211
uint32_t uint32
Definition: g3dmath.h:168
Definition: AuctionHouseBot.h:109
Definition: AuctionHouseBot.h:155
Definition: AuctionHouseBot.h:111
Definition: AuctionHouseBot.h:127
Definition: AuctionHouseBot.h:119
Definition: AuctionHouseBot.h:100
Definition: AuctionHouseBot.h:81
Definition: AuctionHouseBot.h:137
Definition: AuctionHouseBot.h:182
Definition: AuctionHouseBot.h:53
AuctionBotConfig()
Definition: AuctionHouseBot.h:202
void SetConfig(AuctionBotConfigFloatValues index, float value)
Definition: AuctionHouseBot.h:219
Definition: AuctionHouseBot.h:166
Definition: AuctionHouseBot.h:141
Definition: SharedDefines.h:324
Definition: SharedDefines.h:320
Definition: AuctionHouseBot.h:92
Definition: AuctionHouseBot.h:65
Definition: AuctionHouseBot.h:181
void SetAHBotIncludes(const std::string &AHBotIncludes)
Definition: AuctionHouseBot.h:241
Definition: AuctionHouseBot.h:164
Definition: AuctionHouseBot.h:124
Definition: AuctionHouseBot.h:134
Definition: AuctionHouseBot.h:161
Definition: AuctionHouseBot.h:199
Definition: AuctionHouseBot.h:180
Definition: AuctionHouseBot.h:43
Definition: AuctionHouseBot.h:57
Definition: AuctionHouseBot.h:162
Definition: AuctionHouseBot.h:142
Definition: AuctionHouseBot.h:85
Definition: AuctionHouseBot.h:116
void Update(uint32 diff)
Definition: WeatherMgr.cpp:150
void Reload()
Definition: AuctionHouseBot.h:227
Definition: AuctionHouseBot.h:108
Definition: AuctionHouseBot.h:132
Definition: AuctionHouseBot.h:60