Ejemplo n.º 1
0
        private bool TakeCurrency(CustomerInfo customer)
        {
            ClientManager.Instance.ActivateTab("currency_tab");

            // Get Currency Position
            int            clientResolution = Convert.ToInt32(ClientManager.Instance.ResolutionEnum.GetDescription());
            string         requestedNormal  = customer.Product.Replace(" ", "").Replace("'", "");
            Position       currencySlot     = ClientManager.Instance.GetAbsoluteAssetPosition(StaticUtils.GetCurrencyPath(requestedNormal));
            ItemInfoParser itemInfo         = ClientManager.Instance.GetItemInfo(currencySlot, false);

            // Do I have enough to fulfill the order?
            if (itemInfo.Item.SizeInStack < customer.NumberProducts)
            {
                return(false);
            }

            // Ok, we have enough so lets move it to Inventory
            // First we need to figure out the off stack and full stacks
            int offStack   = customer.NumberProducts % itemInfo.Item.StackSize;
            int fullStacks = customer.NumberProducts / itemInfo.Item.StackSize;

            // Now get the off stack to Invendory slot 1
            ClientManager.Instance.GetPartialStackToCusor(currencySlot, offStack);
            Position invSlot1 = ClientManager.Instance.TranslatePosition(InventoryPositions.GetInvenoryPositions(ClientManager.Instance.ResolutionEnum)[0]);

            ClientManager.Instance.ClickPosition(invSlot1);
            for (int i = 0; i < fullStacks; i++)
            {
                ClientManager.Instance.CtrlClickPosition(currencySlot);
            }

            // Now we should have the correct items in the Inventory
            return(true);
        }
Ejemplo n.º 2
0
        public Tab GetTabData(string tabName = "trade_tab")
        {
            Logger.Console.Debug($"Tab Scan of {tabName}.");

            Tab returnTab = new Tab();

            if (!ActivateTab(tabName))
            {
                return(returnTab);
            }

            foreach (Position stashData in StashPositions.GetStashPositions(ResolutionEnum))
            {
                if (stashData == null)
                {
                    continue;
                }
                ItemInfoParser itemParser = GetItemInfo(stashData);
                if (itemParser.Item.Name == "Not For Sell")
                {
                    continue;
                }
                itemParser.AddPlace(stashData.ClickTargetX, stashData.ClickTargetY);
                returnTab.AddItem(itemParser.Item);
            }

            Logger.Console.Debug("Tab Scan completed.");
            return(returnTab);
        }
Ejemplo n.º 3
0
        private bool CheckCurrency(CustomerInfo customer, double margin = 0.1)
        {
            // Give the customer a little time to move currency to trade window.
            Thread.Sleep(5000);

            double chaosValueInTrade  = 0.0;
            double chaosValueExpected = customer.CurrencyType.ChaosEquivalent * customer.Cost;
            int    amountInTrade      = 0;

            // Count Currency in trade window
            while (ClientManager.Instance.GetAbsoluteAssetPosition(StaticUtils.GetUIFragmentPath("trade_window_title")).IsVisible)
            {
                customer.TradeStatus = CustomerInfo.TradeStatuses.STARTED;
                foreach (Position offerSlot in TradePositions.GetPositions(ClientManager.Instance.ResolutionEnum))
                {
                    if (customer.TradeStatus != CustomerInfo.TradeStatuses.STARTED)
                    {
                        return(false);
                    }
                    ClientManager.Instance.HoverPosition(ClientManager.Instance.TranslatePosition(offerSlot));
                    Thread.Sleep(100);
                }

                foreach (Position offerSlot in TradePositions.GetPositions(ClientManager.Instance.ResolutionEnum))
                {
                    if (customer.TradeStatus != CustomerInfo.TradeStatuses.STARTED)
                    {
                        break;
                    }

                    ItemInfoParser itemInfo = ClientManager.Instance.GetItemInfo(offerSlot);
                    if (itemInfo.Item.ChaosValue != 0)
                    {
                        chaosValueInTrade += itemInfo.Item.ChaosValue;
                    }
                    if (itemInfo.Item.SizeInStack != 0)
                    {
                        amountInTrade += itemInfo.Item.SizeInStack;
                    }
                    if (chaosValueInTrade >= chaosValueExpected - (chaosValueExpected * margin) ||
                        amountInTrade >= customer.Cost)
                    {
                        break; // No need to keep checking
                    }
                }
                if (chaosValueInTrade >= chaosValueExpected - (chaosValueExpected * margin) ||
                    amountInTrade >= customer.Cost)
                {
                    break; // we are ready to accept the trade
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        private bool OfferSingleProduct(CustomerInfo customer)
        {
            foreach (Position invData in InventoryPositions.GetInvenoryPositions(ClientManager.Instance.ResolutionEnum))
            {
                ItemInfoParser itemInfo = ClientManager.Instance.GetItemInfo(invData);
                if (!customer.Product.Contains(itemInfo.Item.RealName))
                {
                    continue;
                }

                ClientManager.Instance.CtrlClickPosition(ClientManager.Instance.TranslatePosition(invData));
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        private bool OfferCurrency(CustomerInfo customer)
        {
            Thread.Sleep(1000);
            int amountOffered = 0;

            foreach (Position invData in InventoryPositions.GetInvenoryPositions(ClientManager.Instance.ResolutionEnum))
            {
                ItemInfoParser itemInfo = ClientManager.Instance.GetItemInfo(invData);
                if (!customer.Product.Contains(itemInfo.Item.RealName))
                {
                    continue;
                }

                ClientManager.Instance.CtrlClickPosition(ClientManager.Instance.TranslatePosition(invData));
                amountOffered += itemInfo.Item.SizeInStack;
                if (amountOffered >= customer.NumberProducts)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 6
0
        private bool TakeProduct(CustomerInfo customer)
        {
            ClientManager.Instance.ActivateTab("trade_tab");

            // Get item position
            int            clientResolution = Convert.ToInt32(ClientManager.Instance.ResolutionEnum.GetDescription());
            Position       itemPosition     = StashPositions.StashPositionData[clientResolution][customer.Left, customer.Top];
            ItemInfoParser itemInfo         = ClientManager.Instance.GetItemInfo(itemPosition);

            // Verify Item Data
            if (string.IsNullOrWhiteSpace(itemInfo.Item.Name) ||                     // Did we find an item in that slot?
                itemInfo.Item.Name == "Not For Sell" ||                              // Is the Item Listed?
                !customer.Product.Contains(itemInfo.Item.Name) ||                    // Is this the item the customer wants?
                itemInfo.Item.Price.Cost > customer.Cost ||                          // Did he offer the asking price?
                itemInfo.Item.Price.CurrencyType.Name != customer.CurrencyType.Name) // And in the right currency?
            {
                return(false);
            }

            // Everything is good at this point. Move the item to Inventory
            return(ClientManager.Instance.GetItemFromStash(itemPosition, customer.StashTabNormal));
        }
Ejemplo n.º 7
0
        private bool ApiTakeCurrency(CustomerInfo customer)
        {
            ClientManager.Instance.ActivateTab("currency_tab");
            Thread.Sleep(500);

            // Get Currency Position
            int      clientResolution = Convert.ToInt32(ClientManager.Instance.ResolutionEnum.GetDescription());
            string   requestedNormal  = customer.Product.Replace(" ", "").Replace("'", "");
            Position currencySlot     = ClientManager.Instance.GetAbsoluteAssetPosition(StaticUtils.GetCurrencyPath(requestedNormal), 0.90);

            if (!currencySlot.IsVisible)
            {
                return(false);
            }

            ItemInfoParser itemInfo   = ClientManager.Instance.GetItemInfo(currencySlot, false);
            int            fullStacks = (itemInfo.Item.SizeInStack / itemInfo.Item.StackSize) + 1;

            for (int i = 0; i < fullStacks; i++)
            {
                ClientManager.Instance.CtrlClickPosition(currencySlot);
            }
            return(true);
        }