⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aucbidmanager.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
	-- Blizzard never updates all the owner information. We give it 20	-- seconds, then give up and try again.	if (CurrentSearchParams.queryResponse == true and		CurrentSearchParams.queryComplete == false and		CurrentSearchParams.queryTime and		time() - CurrentSearchParams.queryTime >= 20) then		-- Discard the results of the search and try again.		CurrentSearchParams.name = nil;		CurrentSearchParams.minLevel = nil;		CurrentSearchParams.maxLevel = nil;		CurrentSearchParams.invTypeIndex = nil;		CurrentSearchParams.classIndex = nil;		CurrentSearchParams.subclassIndex = nil;		CurrentSearchParams.page = nil;		CurrentSearchParams.isUsable = nil;		CurrentSearchParams.qualityIndex = nil;		CurrentSearchParams.queryTime = nil;		CurrentSearchParams.queryResponse = true;		CurrentSearchParams.queryComplete = true;		CurrentSearchParams.targetCountForPage = nil;		Auctioneer.Util.ChatPrint(string.format(_AUCT('AuctionScanRedo'), 20));	end	-- Process the bid queue!	if (beginProcessingRequestQueue()) then		while (table.getn(RequestQueue) > 0 and not isQueryInProgress() and not isBidInProgress()) do			local request = RequestQueue[1];			--debugPrint("Processing bid queue: "..request.name..", "..request.count..", "..nilSafe(request.owner)..", "..nilSafe(request.bid)..", "..nilSafe(request.buyout));			--debugPrint("CurrentSearchParams: ");			--debugPrint("    name: "..nilSafe(CurrentSearchParams.name));			--debugPrint("    minLevel: "..nilSafe(CurrentSearchParams.minLevel));			--debugPrint("    maxLevel: "..nilSafe(CurrentSearchParams.maxLevel));			if (CurrentSearchParams.name and				CurrentSearchParams.name == request.name and				CurrentSearchParams.minLevel == "" and				CurrentSearchParams.maxLevel == "" and				CurrentSearchParams.invTypeIndex == nil and				CurrentSearchParams.classIndex == nil and				CurrentSearchParams.page == request.currentPage and				CurrentSearchParams.isUsable == nil and				CurrentSearchParams.qualityIndex == nil) then				processPage();			elseif (canSendAuctionQuery()) then				QueryAuctionItems(request.name, "", "", nil, nil, nil, request.currentPage, nil, nil);			else				-- We gotta wait to be able to send a query.				break;			end		end		-- If we've emptied the RequestQueue, then end the processing		if (table.getn(RequestQueue) == 0) then			endProcessingRequestQueue();		end	endend--------------------------------------------------------------------------------- Searches the current page for an auction matching the first request in-- the request queue. If it finds the auction, it carries out the specified-- action (bid/buyout).-------------------------------------------------------------------------------function processPage()	local request = RequestQueue[1];	-- Iterate through each item on the page, searching for a match	local lastIndexOnPage, totalAuctions = GetNumAuctionItems("list");	debugPrint("Processing page "..request.currentPage.." starting at index "..request.currentIndex.." ("..lastIndexOnPage.." on page; "..totalAuctions.." in total)");	debugPrint("Searching for item: "..request.id..", "..request.rprop..", "..request.enchant..", "..request.name..", "..request.count..", "..request.min..", "..request.buyout..", "..request.unique..", "..request.bid);	local foundMatchingAuction = false;	for indexOnPage = request.currentIndex, lastIndexOnPage do		-- Check if this item matches		local name, texture, count, quality, canUse, level, minBid, minIncrement, buyoutPrice, bidAmount, highBidder, owner = GetAuctionItemInfo("list", indexOnPage);		local link = GetAuctionItemLink("list", indexOnPage);		local id, rprop, enchant, unique = EnhTooltip.BreakLink(link);		debugPrint("Processing item "..indexOnPage..": "..id..", "..rprop..", "..enchant..", "..name..", "..count..", "..minBid..", "..buyoutPrice..", "..unique..", "..bidAmount);		if ((request.id == id) and			(request.rprop == rprop) and			(request.enchant == enchant) and			(request.name == name) and			(request.count == count) and			(request.min == minBid) and			(request.buyout == buyoutPrice) and			(request.unique == unique)) then			local bid = nil;			-- Check if the auction is owned by the player.			if (isPlayerOnAccount(owner)) then				table.insert(request.results, BidResultCodes["OwnAuction"]);				local output = string.format(_AUCT('FrmtSkippedBiddingOnOwnAuction'), request.name, request.count);				chatPrint(output);			-- Check for a buyout request			elseif (request.buyout == request.bid) then				bid = request.buyout;			-- Otherwise it must be a bid request			else				-- Check if we are already the high bidder				if (highBidder) then					table.insert(request.results, BidResultCodes["AlreadyHighBidder"]);					local output = string.format(_AUCT('FrmtAlreadyHighBidder'), request.name, request.count);					chatPrint(output);				-- Check if the item has been bid on				elseif (bidAmount ~= 0) then					-- Check the bid matches what we are looking for					if (bidAmount == request.bid) then						bid = bidAmount + minIncrement;					-- Check if there is already a higher bidder					elseif (bidAmount > request.bid) then						table.insert(request.results, BidResultCodes["AlreadyHigherBid"]);						local output = string.format(_AUCT('FrmtSkippedAuctionWithHigherBid'), request.name, request.count);						chatPrint(output);					-- Otherwise the bid must be lower...					else						table.insert(request.results, BidResultCodes["CurrentBidLower"]);						local output = string.format(_AUCT('FrmtSkippedAuctionWithLowerBid'), request.name, request.count);						chatPrint(output);					end				-- Otherwise the item hasn't been bid on				else					-- Check the bid matches what we are looking for					if (minBid == request.bid) then						bid = minBid;					-- Otherwise the min bid is lower...					else						table.insert(request.results, BidResultCodes["CurrentBidLower"]);						local output = string.format(_AUCT('FrmtSkippedAuctionWithLowerBid'), request.name, request.count);						chatPrint(output);					end				end			end			-- If we've settled on a bid, do it now!			if (bid) then				foundMatchingAuction = true;								-- Check if we've reached the bid limit on this request.				if (request.bidCount == request.maxBids) then					-- Report that the maximum number of bids has been reached.					local output = string.format(_AUCT('FrmtMaxBidsReached'), request.name, request.count, request.maxBids);					chatPrint(output);					debugPrint("Reached max bids!");										-- Add the bid result to the request.					table.insert(request.results, BidResultCodes["MaxBidsReached"]);					-- Since this request didn't fully completed due to bid					-- limits, update the currentIndex and save it as the					-- last request. If the next request is for the same item,					-- it will pickup where this request left off.					LastRequest = request;					request.currentIndex = indexOnPage;					removeRequestFromQueue();				else					-- Successful bid/buyouts result in the query results being					-- updated. To prevent additional queries from being sent					-- until the list is updated, we flip the complete flag					-- back to false. If the bid fails we'll manually flip					-- the flag back to true again.					CurrentSearchParams.queryTime = time();					CurrentSearchParams.queryResponse = false;					CurrentSearchParams.queryComplete = false;					if (bid == buyoutPrice) then						CurrentSearchParams.targetCountForPage = lastIndexOnPage - 1;					end					-- Update the starting point for this page					request.currentIndex = indexOnPage;					request.bidAttempts = request.bidAttempts + 1;					-- Place the bid! This MUST be done last since the response					-- can be received during the call to PlaceAuctionBid.					debugPrint("Placing bid on "..name.. " at "..bid.." (index "..indexOnPage..")");					PlaceAuctionBid("list", indexOnPage, bid, request);				end				break;			end		end	end	-- If an item was not found to bid on...	if (not foundMatchingAuction) then		-- When an item is bought out on the page, the item is not replaced		-- with an item from a subsequent page. Nor is the item removed from		-- the total count. Thus if there were 7 items total before the buyout,		-- GetNumAuctionItems() will report 6 items on the page and but still		-- 7 total after the buyout.		if (lastIndexOnPage == 0 or			request.currentPage * NUM_AUCTION_ITEMS_PER_PAGE + lastIndexOnPage == totalAuctions) then			-- Reached the end of the line for this item, remove it from the queue			request.currentIndex = lastIndexOnPage + 1;			removeRequestFromQueue();		else			-- Continue looking for items on the next page.			request.currentPage = request.currentPage + 1;			request.currentIndex = 1;		end	endend--------------------------------------------------------------------------------- Adds a bid request to the queue. For bids, the bid parameter should be the-- current bid (or minimum bid in the case the item isn't bid on). For buyouts,-- the bid parameter should be the buyout price.-------------------------------------------------------------------------------function bidAuction(bid, signature, maxBids, callbackFunc, callbackParam)	debugPrint("BidAuction("..bid..", "..signature..")");	local id,rprop,enchant,name,count,min,buyout,unique = Auctioneer.Core.GetItemSignature(signature);	if (bid and id and rprop and enchant and name and count and min and buyout and unique) then		-- Make sure we have a valid maxBids		if (maxBids == nil or maxBids < 1) then			maxBids = 25;		end			-- Create a bid request.		local request = {};		request.id = id;		request.rprop = rprop;		request.enchant = enchant;		request.name = name;		request.count = count;		request.min = min;		request.buyout = buyout;		request.unique = unique;		request.bid = bid;		request.maxBids = maxBids;		request.callback = { func = callbackFunc, param = callbackParam };				-- Queue the bid request and kick off request processing!		addRequestToQueue(request);		processRequestQueue();	endend--------------------------------------------------------------------------------- Dumps the state of the BidManager to the chat window.-------------------------------------------------------------------------------function dumpState()	chatPrint("BidManager State:");	chatPrint("    IsBidInProgress: "..boolString(isBidInProgress()));	chatPrint("    IsQueryInProgress: "..boolString(isQueryInProgress()));	chatPrint("    RequestQueue ("..table.getn(RequestQueue).."):");	chatPrint("    PendingBids ("..table.getn(PendingBids).."):");	chatPrint("    CurrentSearchParams:");	chatPrint("        name: "..nilSafe(CurrentSearchParams.name));	chatPrint("        minLevel: "..nilSafe(CurrentSearchParams.minLevel));	chatPrint("        maxLevel: "..nilSafe(CurrentSearchParams.maxLevel));	chatPrint("        invTypeIndex: "..nilSafe(CurrentSearchParams.invTypeIndex));	chatPrint("        classIndex: "..nilSafe(CurrentSearchParams.classIndex));	chatPrint("        subclassIndex: "..nilSafe(CurrentSearchParams.subclassIndex));	chatPrint("        page: "..nilSafe(CurrentSearchParams.page));	chatPrint("        isUsable: "..boolString(CurrentSearchParams.isUsable));	chatPrint("        qualityIndex: "..nilSafe(CurrentSearchParams.qualityIndex));	chatPrint("        queryResponse: "..boolString(CurrentSearchParams.queryResponse));	chatPrint("        queryComplete: "..boolString(CurrentSearchParams.queryComplete));	chatPrint("        targetCountForPage: "..nilSafe(CurrentSearchParams.targetCountForPage));end--------------------------------------------------------------------------------------------------------------------------------------------------------------function nilSafe(string)	if (string) then		return string;	end	return "<nil>";end--------------------------------------------------------------------------------------------------------------------------------------------------------------function boolString(value)	if (value) then		return "true";	end	return "false";end--------------------------------------------------------------------------------------------------------------------------------------------------------------chatPrint = Auctioneer.Util.ChatPrint;--------------------------------------------------------------------------------------------------------------------------------------------------------------debugPrint = EnhTooltip.DebugPrint;--------------------------------------------------------------------------------- Public API-------------------------------------------------------------------------------AucBidManager ={	-- Exported functions	BidAuction = bidAuction;	IsProcessingRequest = isProcessingRequest;	GetRequestCount = getRequestCount;	DumpState = dumpState;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -