当前位置: 首页>>代码示例>>C++>>正文


C++ AuctionHouseObject::GetAuctionsEnd方法代码示例

本文整理汇总了C++中AuctionHouseObject::GetAuctionsEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ AuctionHouseObject::GetAuctionsEnd方法的具体用法?C++ AuctionHouseObject::GetAuctionsEnd怎么用?C++ AuctionHouseObject::GetAuctionsEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AuctionHouseObject的用法示例。


在下文中一共展示了AuctionHouseObject::GetAuctionsEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetItemInformation

// Collects information about item counts and minimum prices to SameItemInfo and updates EligibleItems - a list with new items eligible for bot to buy and bid
// Returns count of items in AH that were eligible for being bought or bidded on by ahbot buyer (EligibleItems size)
uint32 AuctionBotBuyer::GetItemInformation(BuyerConfiguration& config)
{
    config.SameItemInfo.clear();
    time_t now = time(nullptr);
    uint32 count = 0;

    AuctionHouseObject* house = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
    for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = house->GetAuctionsBegin(); itr != house->GetAuctionsEnd(); ++itr)
    {
        AuctionEntry* entry = itr->second;

        if (!entry->owner)
            continue; // Skip auctions owned by AHBot

        Item* item = sAuctionMgr->GetAItem(entry->itemGUIDLow);
        if (!item)
            continue;

        BuyerItemInfo& itemInfo = config.SameItemInfo[item->GetEntry()];

        // Update item entry's count and total bid prices
        // This can be used later to determine the prices and chances to bid
        uint32 itemBidPrice = entry->startbid / item->GetCount();
        itemInfo.TotalBidPrice = itemInfo.TotalBidPrice + itemBidPrice;
        itemInfo.BidItemCount++;

        // Set minimum bid price
        if (!itemInfo.MinBidPrice)
            itemInfo.MinBidPrice = itemBidPrice;
        else
            itemBidPrice = std::min(itemInfo.MinBidPrice, itemBidPrice);

        // Set minimum buyout price if item has buyout
        if (entry->buyout)
        {
            // Update item entry's count and total buyout prices
            // This can be used later to determine the prices and chances to buyout
            uint32 itemBuyPrice = entry->buyout / item->GetCount();
            itemInfo.TotalBuyPrice = itemInfo.TotalBuyPrice + itemBuyPrice;
            itemInfo.BuyItemCount++;

            if (!itemInfo.MinBuyPrice)
                itemInfo.MinBuyPrice = itemBuyPrice;
            else
                itemInfo.MinBuyPrice = std::min(itemInfo.MinBuyPrice, itemBuyPrice);
        }

        // Add/update EligibleItems if:
        // * no bid
        // * bid from player
        if (!entry->bid || entry->bidder)
        {
            config.EligibleItems[entry->Id].LastExist = now;
            config.EligibleItems[entry->Id].AuctionId = entry->Id;
            ++count;
        }
    }

    TC_LOG_DEBUG("ahbot", "AHBot: %u items added to buyable/biddable vector for ah type: %u", count, config.GetHouseType());
    TC_LOG_DEBUG("ahbot", "AHBot: SameItemInfo size = %u", (uint32)config.SameItemInfo.size());
    return count;
}
开发者ID:DanielBallaSZTE,项目名称:TrinityCorePreWOTLK,代码行数:64,代码来源:AuctionHouseBotBuyer.cpp

示例2: Load

void InAuctionItemsBag::Load()
{
    AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(auctionId);
    for (AuctionHouseObject::AuctionEntryMap::iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
    {
        ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itr->second->itemEntry);
        if (!proto)
            continue;

        Add(proto);
    }
}
开发者ID:Cyph3r,项目名称:LordPsyanBots,代码行数:12,代码来源:ItemBag.cpp

示例3: AuctionHouseBotCommands

void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* args)
{
	AHBConfig *config;
	switch (ahMapID)
	{
	case 2:
		config = &AllianceConfig;
		break;
	case 6:
		config = &HordeConfig;
		break;
	case 7:
		config = &NeutralConfig;
		break;
	}
	std::string color;
	switch (col)
	{
	case AHB_GREY:
		color = "grey";
		break;
	case AHB_WHITE:
		color = "white";
		break;
	case AHB_GREEN:
		color = "green";
		break;
	case AHB_BLUE:
		color = "blue";
		break;
	case AHB_PURPLE:
		color = "purple";
		break;
	default:
		break;
	}
	switch (command)
	{
	case 0:		//ahexpire
		{
			AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);

			AuctionHouseObject::AuctionEntryMap::iterator itr;
			itr = auctionHouse->GetAuctionsBegin();

			while (itr != auctionHouse->GetAuctionsEnd())
			{
			  if (itr->second->owner == AHBplayerGUID)
				 itr->second->time = sWorld.GetGameTime();

			  ++itr;
			}
		}break;
	case 1:		//min items
		{
			char * param1 = strtok(args, " ");
			uint32 minItems = (uint32) strtoul(param1, NULL, 0);
			CharacterDatabase.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems, ahMapID);
			config->SetMinItems(minItems);
		}break;
	case 2:		//max items
		{
			char * param1 = strtok(args, " ");
			uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
			CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID);
			config->SetMaxItems(maxItems);
		}break;
	case 3:		//min time
		{
			char * param1 = strtok(args, " ");
			uint32 minTime = (uint32) strtoul(param1, NULL, 0);
			CharacterDatabase.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime, ahMapID);
			config->SetMinTime(minTime);
		}break;
	case 4:		//max time
		{
			char * param1 = strtok(args, " ");
			uint32 maxTime = (uint32) strtoul(param1, NULL, 0);
			CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime, ahMapID);
			config->SetMaxTime(maxTime);
		}break;
	case 5:		//percentages
		{
			char * param1 = strtok(args, " ");
			char * param2 = strtok(NULL, " ");
			char * param3 = strtok(NULL, " ");
			char * param4 = strtok(NULL, " ");
			char * param5 = strtok(NULL, " ");
			char * param6 = strtok(NULL, " ");
			char * param7 = strtok(NULL, " ");
			char * param8 = strtok(NULL, " ");
			uint32 wtg = (uint32) strtoul(param1, NULL, 0);
			uint32 gtg = (uint32) strtoul(param2, NULL, 0);
			uint32 btg = (uint32) strtoul(param3, NULL, 0);
			uint32 ptg = (uint32) strtoul(param4, NULL, 0);
			uint32 wi = (uint32) strtoul(param5, NULL, 0);
			uint32 gi = (uint32) strtoul(param6, NULL, 0);
			uint32 bi = (uint32) strtoul(param7, NULL, 0);
			uint32 pi = (uint32) strtoul(param8, NULL, 0);

//.........这里部分代码省略.........
开发者ID:Hereticbeast,项目名称:mangos,代码行数:101,代码来源:AuctionHouseBot.cpp

示例4: addNewAuctions

static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
{
	if (!AHBSeller)
		return;
	AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID());
	uint32 items = 0;
	uint32 minItems = config->GetMinItems();
	uint32 maxItems = config->GetMaxItems();
	uint32 auctions = auctionHouse->Getcount();

	if (auctions >= minItems)
	  return;
	if (auctions <= maxItems)
	{
		if ((maxItems - auctions) > ItemsPerCycle)
			items = ItemsPerCycle;
		else
			items = (maxItems - auctions);
	}
	uint32 wtgbin = config->GetPercents(AHB_WHITE_TG);
	uint32 gtgbin = config->GetPercents(AHB_GREEN_TG);
	uint32 btgbin = config->GetPercents(AHB_BLUE_TG);
	uint32 ptgbin = config->GetPercents(AHB_PURPLE_TG);
	uint32 wibin = config->GetPercents(AHB_WHITE_I);
	uint32 gibin = config->GetPercents(AHB_GREEN_I);
	uint32 bibin = config->GetPercents(AHB_BLUE_I);
	uint32 pibin = config->GetPercents(AHB_PURPLE_I);
	uint32 total = wtgbin + gtgbin + btgbin + ptgbin + wibin + gibin + bibin + pibin;

	uint32 pItems = 0;
	uint32 bItems = 0;
	uint32 gItems = 0;
	uint32 wItems = 0;
	uint32 pTGoods = 0;
	uint32 bTGoods = 0;
	uint32 gTGoods = 0;
	uint32 wTGoods = 0;
	for (AuctionHouseObject::AuctionEntryMap::iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr)
	{
		AuctionEntry *Aentry = itr->second;
		Item *item = objmgr.GetAItem(Aentry->item_guidlow);
		if( item )
		{
			ItemPrototype const *prototype = item->GetProto();
			if( prototype )
			{
				switch (prototype->Quality)
				{
				 case 0:
					if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
					   wTGoods = wTGoods + 1;
					else
					   wItems = wItems + 1;
					break;

				 case 1:
					if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
					   wTGoods = wTGoods + 1;
					else
					   wItems = wItems + 1;
					break;

				 case 2:
					if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
					   gTGoods = gTGoods + 1;
					else
					   gItems = gItems + 1;
					break;

				 case 3:
					if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
					   bTGoods = bTGoods + 1;
					else
					   bItems = bItems + 1;
					break;

				 case 4:
					if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
					   pTGoods = pTGoods + 1;
					else
					   pItems = pItems + 1;
					break;
				}
			}
		}
	}
	// only insert a few at a time, so as not to peg the processor
	for (uint32 cnt = 1;cnt <= items;cnt++)
	{
		uint32 itemID = 0;
		while (itemID == 0)
		{
			uint32 choice = urand(1, 8);
			switch (choice)
			{
			case 1:
				{
					if ((purpleItems.size() > 0) && (pItems < pibin))
					{
						itemID = purpleItems[urand(0, purpleItems.size() - 1)];
//.........这里部分代码省略.........
开发者ID:Hereticbeast,项目名称:mangos,代码行数:101,代码来源:AuctionHouseBot.cpp

示例5: addNewAuctionBuyerBotBid

static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session)
{
	if (!AHBBuyer)
		return;

        // Fetches content of selected AH
   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID());
   AuctionHouseObject::AuctionEntryMap::iterator itr;

   itr = auctionHouse->GetAuctionsBegin();
   vector<uint32> possibleBids;

   while (itr != auctionHouse->GetAuctionsEnd())
   {
      AuctionHouseObject::AuctionEntryMap::iterator tmp = itr;
      ++itr;
         // Check if the auction is ours
         // if it is, we skip this iteration.
      if(tmp->second->owner == AHBplayerGUID)
      {
         continue;
      }
         // Check that we haven't bidded in this auction already.
      if(tmp->second->bidder != AHBplayerGUID)
      {
         uint32 tmpdata = tmp->second->Id;
         possibleBids.push_back(tmpdata);
      }
   }

      // Do we have anything to bid? If not, stop here.
   if(possibleBids.empty())
   {
      return;
   }

      // Choose random auction from possible auctions
   uint32 auctionID = possibleBids[urand(0, possibleBids.size() - 1)];

      // from auctionhouse.cpp, creates auction pointer & player pointer
   AuctionEntry* auction = auctionHouse->GetAuction(auctionID);

        // get exact item information
   Item *pItem = objmgr.GetAItem(auction->item_guidlow);
   if (!pItem)
   {
      sLog.outError("Item doesn't exists, perhaps bought already?");
      return;
   }

        // get item prototype
   ItemPrototype const* prototype = objmgr.GetItemPrototype(auction->item_template);

        // check which price we have to use, startbid or if it is bidded already
	if(debug_Out)
	{sLog.outError("Auction Number: %u", auction->Id);}
	if(debug_Out)
	{sLog.outError("Item Template: %u", auction->item_template);}
	if(debug_Out)
	{sLog.outError("Buy Price: %u", prototype->BuyPrice);}
	if(debug_Out)
	{sLog.outError("Sell Price: %u", prototype->SellPrice);}
	if(debug_Out)
	{sLog.outError("Quality: %u", prototype->Quality);}
   uint32 currentprice;
   if(auction->bid)
   {
      currentprice = auction->bid;
		if(debug_Out)
		{sLog.outError("Current Price: %u", auction->bid);}
   }
   else
   {
      currentprice = auction->startbid;
		if(debug_Out)
		{sLog.outError("Current Price: %u", auction->startbid);}
   }
   uint32 bidprice;

      // Prepare portion from maximum bid
   uint32 tmprate2 = urand(0, 100);
   double tmprate = static_cast<double>(tmprate2);
	if(debug_Out)
	{sLog.outError("tmprate: %f", tmprate);}
   double bidrate = tmprate / 100;
	if(debug_Out)
	{sLog.outError("bidrate: %f", bidrate);}
   long double bidMax = 0;

      // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
   switch (BuyMethod)
   {
   case 0:
	   switch (prototype->Quality)
	   {
	   case 0:
		  if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY))
		  {
			 bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY);
		  }
//.........这里部分代码省略.........
开发者ID:Hereticbeast,项目名称:mangos,代码行数:101,代码来源:AuctionHouseBot.cpp

示例6: GetBuyableEntry

uint32 AuctionBotBuyer::GetBuyableEntry(BuyerConfiguration& config)
{
    config.SameItemInfo.clear();
    uint32 count = 0;
    time_t now = time(nullptr);

    AuctionHouseObject* house = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
    for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = house->GetAuctionsBegin(); itr != house->GetAuctionsEnd(); ++itr)
    {
        AuctionEntry* entry = itr->second;
        Item* item = sAuctionMgr->GetAItem(entry->itemGUIDLow);
        if (item)
        {
            ItemTemplate const * prototype = item->GetTemplate();
            if (prototype)
            {
                ++config.SameItemInfo[item->GetEntry()].ItemCount;    // Structure constructor will make sure Element are correctly initialized if entry is created here.
                config.SameItemInfo[item->GetEntry()].BuyPrice = config.SameItemInfo[item->GetEntry()].BuyPrice + (itr->second->buyout / item->GetCount());
                config.SameItemInfo[item->GetEntry()].BidPrice = config.SameItemInfo[item->GetEntry()].BidPrice + (itr->second->startbid / item->GetCount());
                if (itr->second->buyout != 0)
                {
                    if (itr->second->buyout / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBuyPrice)
                        config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount();
                    else if (config.SameItemInfo[item->GetEntry()].MinBuyPrice == 0)
                        config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount();
                }
                if (itr->second->startbid / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBidPrice)
                    config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount();
                else if (config.SameItemInfo[item->GetEntry()].MinBidPrice == 0)
                    config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount();

                if (!entry->owner)
                {

                    if (entry->bid != 0 && entry->bidder) // Add bid by player
                    {
                        config.CheckedEntry[entry->Id].LastExist = now;
                        config.CheckedEntry[entry->Id].AuctionId = entry->Id;
                        ++count;
                    }
                }
                else
                {
                    if (entry->bid != 0)
                    {
                        if (entry->bidder)
                        {
                            config.CheckedEntry[entry->Id].LastExist = now;
                            config.CheckedEntry[entry->Id].AuctionId = entry->Id;
                            ++count;
                        }
                    }
                    else
                    {
                        config.CheckedEntry[entry->Id].LastExist = now;
                        config.CheckedEntry[entry->Id].AuctionId = entry->Id;
                        ++count;
                    }
                }
            }
        }
    }

    TC_LOG_DEBUG("ahbot", "AHBot: %u items added to buyable vector for ah type: %u", count, config.GetHouseType());
    TC_LOG_DEBUG("ahbot", "AHBot: SameItemInfo size = %u", (uint32)config.SameItemInfo.size());
    return count;
}
开发者ID:AllThing,项目名称:TrinityCore,代码行数:67,代码来源:AuctionHouseBotBuyer.cpp


注:本文中的AuctionHouseObject::GetAuctionsEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。