protected override RunStatus Run(object context) { if (!IsDone) { if (Lua.GetReturnVal <int>("if AuctionFrame and AuctionFrame:IsVisible() then return 1 else return 0 end ", 0) == 0) { MoveToAh(); } else { if (ToScanItemList == null) { ToScanItemList = BuildScanItemList(); ToSellItemList = new List <AuctionEntry>(); } if (ToScanItemList.Count == 0 && ToSellItemList.Count == 0) { ToScanItemList = null; IsDone = true; return(RunStatus.Failure); } if (ToScanItemList.Count > 0) { AuctionEntry ae = ToScanItemList[0]; bool scanDone = ScanAh(ref ae); ToScanItemList[0] = ae; // update if (scanDone) { uint lowestBo = ae.LowestBo; if (lowestBo > MaxBuyout.TotalCopper) { ae.Buyout = MaxBuyout.TotalCopper; } else if (lowestBo < MinBuyout.TotalCopper) { ae.Buyout = MinBuyout.TotalCopper; } else { ae.Buyout = lowestBo - (uint)Math.Ceiling(((double)(lowestBo * UndercutPrecent) / 100d)); } ae.Bid = (uint)((double)(ae.Buyout * BidPrecent) / 100d); bool enoughItemsPosted = AmountType == AmountBasedType.Amount && ae.myAuctions >= Amount; bool tooLowBuyout = !PostIfBelowMinBuyout && lowestBo < MinBuyout.TotalCopper; Professionbuddy.Debug("PB: PostIfBelowMinBuyout:{0} ", PostIfBelowMinBuyout, MinBuyout.TotalCopper); Professionbuddy.Debug("PB: lowestBo:{0} MinBuyout.TotalCopper: {1}", lowestBo, MinBuyout.TotalCopper); Professionbuddy.Debug("PB: tooLowBuyout:{0} enoughItemsPosted: {1}", enoughItemsPosted, enoughItemsPosted); if (!enoughItemsPosted && !tooLowBuyout) { ToSellItemList.Add(ae); } else { Professionbuddy.Log("Skipping {0} since {1}", ae.Name, tooLowBuyout ? string.Format("lowest buyout:{0} is below MinBuyout:{1}", AuctionEntry.GoldString(lowestBo), MinBuyout) : string.Format("{0} items from me are already posted. Max amount is {1}", ae.myAuctions, Amount)); } ToScanItemList.RemoveAt(0); } if (ToScanItemList.Count == 0) { Professionbuddy.Debug("Finished scanning for items"); } } if (ToSellItemList.Count > 0) { if (SellOnAh(ToSellItemList[0])) { Professionbuddy.Log("Selling {0}", ToSellItemList[0]); ToSellItemList.RemoveAt(0); } } } return(RunStatus.Running); } return(RunStatus.Failure); }