TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AuctionHouseBotSeller.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_SELLER_H
19 #define AUCTION_HOUSE_BOT_SELLER_H
20 
21 #include "Define.h"
22 #include "ItemTemplate.h"
23 #include "AuctionHouseBot.h"
24 
25 struct ItemToSell
26 {
29 };
30 
31 typedef std::vector<ItemToSell> ItemsToSellArray;
32 typedef std::vector<std::vector<uint32>> AllItemsArray;
33 
35 {
37 
43 };
44 
46 {
48 
52 
54 };
55 
57 {
58 public:
60  {
61  }
62 
64 
65  void Initialize(AuctionHouseType houseType)
66  {
67  _houseType = houseType;
68  }
69 
71 
73 
75  {
76  _minTime = value;
77  }
79  {
80  return std::min(1u, std::min(_minTime, _maxTime));
81  }
82 
84  uint32 GetMaxTime() const { return _maxTime; }
85  // Data access classified by item class and item quality
86  void SetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass, uint32 amount) { _ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems = amount * _ItemInfo[quality].ItemClassInfos[itemclass].Quantity; }
87  uint32 GetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass) const { return _ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems; }
88  void SetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass, uint32 qty) { _ItemInfo[quality].ItemClassInfos[itemclass].Quantity = qty; }
89  uint32 GetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass) const { return _ItemInfo[quality].ItemClassInfos[itemclass].Quantity; }
90  void SetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass, uint32 found)
91  {
92  if (_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems > found)
93  _ItemInfo[quality].ItemClassInfos[itemclass].MissItems = _ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems - found;
94  else
95  _ItemInfo[quality].ItemClassInfos[itemclass].MissItems = 0;
96  }
97  uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass) const { return _ItemInfo[quality].ItemClassInfos[itemclass].MissItems; }
98 
99  // Data for every quality of item
108 
109 private:
114 };
115 
116 // This class handle all Selling method
117 // (holder of AHB_Seller_Config data for each auction house type)
119 {
120 public:
121  typedef std::vector<uint32> ItemPool;
122 
124  ~AuctionBotSeller();
125 
126  bool Initialize() override;
127  bool Update(AuctionHouseType houseType) override;
128 
129  void AddNewAuctions(SellerConfiguration& config);
130  void SetItemsRatio(uint32 al, uint32 ho, uint32 ne);
131  void SetItemsRatioForHouse(AuctionHouseType house, uint32 val);
132  void SetItemsAmount(uint32(&vals)[MAX_AUCTION_QUALITY]);
133  void SetItemsAmountForQuality(AuctionQuality quality, uint32 val);
134  void LoadConfig();
135 
136 private:
138 
139  ItemPool _itemPool[MAX_AUCTION_QUALITY][MAX_ITEM_CLASS];
140 
141  void LoadSellerValues(SellerConfiguration& config);
142  uint32 SetStat(SellerConfiguration& config);
143  bool GetItemsToSell(SellerConfiguration& config, ItemsToSellArray& itemsToSellArray, AllItemsArray const& addedItem);
144  void SetPricesOfItem(ItemTemplate const* itemProto, SellerConfiguration& config, uint32& buyp, uint32& bidp, uint32 stackcnt);
145  uint32 GetStackSizeForItem(ItemTemplate const* itemProto, SellerConfiguration& config) const;
146  void LoadItemsQuantity(SellerConfiguration& config);
147  static uint32 GetBuyModifier(ItemTemplate const* prototype);
148  static uint32 GetSellModifier(ItemTemplate const* itemProto);
149 };
150 
151 #endif
uint32 LastMissedItem
Definition: AuctionHouseBotSeller.h:72
AuctionQuality
Definition: AuctionHouseBot.h:27
uint32 MissItems
Definition: AuctionHouseBotSeller.h:50
Definition: AuctionHouseBot.h:42
std::vector< ItemToSell > ItemsToSellArray
Definition: AuctionHouseBotSeller.h:31
uint32 AmountOfItems
Definition: AuctionHouseBotSeller.h:38
Definition: AuctionHouseBotSeller.h:56
AuctionHouseType
Definition: AuctionHouseBot.h:40
AuctionHouseType GetHouseType() const
Definition: AuctionHouseBotSeller.h:70
AuctionHouseType _houseType
Definition: AuctionHouseBotSeller.h:110
uint32 PriceRatio
Definition: AuctionHouseBotSeller.h:41
uint32 GetItemsAmountPerQuality(AuctionQuality quality) const
Definition: AuctionHouseBotSeller.h:101
#define MAX_AUCTION_QUALITY
Definition: AuctionHouseBot.h:38
SellerItemClassInfo()
Definition: AuctionHouseBotSeller.h:36
std::vector< uint32 > ItemPool
Definition: AuctionHouseBotSeller.h:121
void SetMinTime(uint32 value)
Definition: AuctionHouseBotSeller.h:74
#define MAX_ITEM_CLASS
Definition: ItemTemplate.h:386
~SellerConfiguration()
Definition: AuctionHouseBotSeller.h:63
uint32 _maxTime
Definition: AuctionHouseBotSeller.h:112
uint32 Color
Definition: AuctionHouseBotSeller.h:27
void SetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass, uint32 found)
Definition: AuctionHouseBotSeller.h:90
uint32 AmountOfItems
Definition: AuctionHouseBotSeller.h:49
Definition: AuctionHouseBotSeller.h:118
uint32 RandomStackRatio
Definition: AuctionHouseBotSeller.h:42
std::vector< std::vector< uint32 > > AllItemsArray
Definition: AuctionHouseBotSeller.h:32
void SetPriceRatioPerQuality(AuctionQuality quality, uint32 value)
Definition: AuctionHouseBotSeller.h:102
uint32 GetPriceRatioPerClass(ItemClass item) const
Definition: AuctionHouseBotSeller.h:105
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define MAX_AUCTION_HOUSE_TYPE
Definition: AuctionHouseBot.h:47
uint32 GetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass) const
Definition: AuctionHouseBotSeller.h:87
uint32 GetMinTime() const
Definition: AuctionHouseBotSeller.h:78
Definition: AuctionHouseBotSeller.h:34
uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass) const
Definition: AuctionHouseBotSeller.h:97
void SetPriceRatioPerClass(ItemClass item, uint32 value)
Definition: AuctionHouseBotSeller.h:104
SellerItemInfo _ItemInfo[MAX_AUCTION_QUALITY]
Definition: AuctionHouseBotSeller.h:113
virtual bool Update(AuctionHouseType houseType)=0
uint32 Quantity
Definition: AuctionHouseBotSeller.h:40
uint32_t uint32
Definition: Define.h:150
SellerItemInfo()
Definition: AuctionHouseBotSeller.h:47
void SetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass, uint32 amount)
Definition: AuctionHouseBotSeller.h:86
Definition: AuctionHouseBotSeller.h:45
virtual bool Initialize()=0
Definition: AuctionHouseBot.h:254
ItemClass
Definition: ItemTemplate.h:365
uint32 GetRandomStackRatioPerClass(ItemClass item) const
Definition: AuctionHouseBotSeller.h:107
uint32 _minTime
Definition: AuctionHouseBotSeller.h:111
void SetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass, uint32 qty)
Definition: AuctionHouseBotSeller.h:88
uint32 PriceRatio
Definition: AuctionHouseBotSeller.h:51
Definition: ItemTemplate.h:647
uint32 MissItems
Definition: AuctionHouseBotSeller.h:39
Definition: AuctionHouseBotSeller.h:25
void SetRandomStackRatioPerClass(ItemClass item, uint32 value)
Definition: AuctionHouseBotSeller.h:106
#define TC_GAME_API
Definition: Define.h:134
SellerConfiguration()
Definition: AuctionHouseBotSeller.h:59
void Initialize(AuctionHouseType houseType)
Definition: AuctionHouseBotSeller.h:65
const FieldDescriptor value
Definition: descriptor.h:1522
uint32 Itemclass
Definition: AuctionHouseBotSeller.h:28
uint32_t uint32
Definition: g3dmath.h:168
uint32 GetMaxTime() const
Definition: AuctionHouseBotSeller.h:84
uint32 GetPriceRatioPerQuality(AuctionQuality quality) const
Definition: AuctionHouseBotSeller.h:103
void SetItemsAmountPerQuality(AuctionQuality quality, uint32 cnt)
Definition: AuctionHouseBotSeller.h:100
SellerItemClassInfo ItemClassInfos[MAX_ITEM_CLASS]
Definition: AuctionHouseBotSeller.h:53
uint32 GetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass) const
Definition: AuctionHouseBotSeller.h:89
void SetMaxTime(uint32 value)
Definition: AuctionHouseBotSeller.h:83