public void StartTradingGrind() { _loginController.AuthenticateLogin(); SetAllControllerCookies(_loginController._authResponse.data.session); _profileController.SelectPMCProfile(); PlayerProfile profile = _profileController.GetLatestPlayerProfile(); LinkManager.CurrentRoubles = _profileController.GetCurrentRoubles(); _profileController.GetSellableFromInventory(); long currentRoubles = LinkManager.CurrentRoubles; while (true) { Log("Running main loop!"); CheckBotTime(); LinkManager.AllBoughtItems.Clear(); //TODO: Handle error 201 (Need to login again) //TODO: Maybe a check to exit the bot once we've filled all of our slots? Otherwise we're just spamming their API for no reason - too obvious foreach (var itemsToBuy in _marketController.GetBuyableItems(profile)) { profile = _profileController.GetLatestPlayerProfile(); currentRoubles = (LinkManager.CurrentRoubles = _profileController.GetCurrentRoubles()); bool haveBoughtItems = _marketController.BuyBulk(itemsToBuy); Thread.Sleep(LinkManager.Timer); //TODO: After buying items, update the inventory on our end without calling server. Saves requests too. profile = _profileController.GetLatestPlayerProfile(); if (!haveBoughtItems) { continue; } var sellableItems = _profileController.GetSellableFromInventory(); //foreach (var sellableItem in sellableItems) //{ // var matchingBuyOffer = itemToBuy.First(itb => itb.Offer.items[0]._id == sellableItem.Item.Id); // sellableItem.ExpectedProfit = matchingBuyOffer.ExpectedProfit; //} //TODO: Update inventory situation based on the updates from buying/selling (delete/change properties). Cheaper than two profile lookups each time we buy a set. bool sellSuccessful = _traderController.SellBulk(sellableItems); if (sellSuccessful) { profile = _profileController.GetLatestPlayerProfile(); long amountAfterSelling = (LinkManager.CurrentRoubles = _profileController.GetCurrentRoubles()); long profitMade = amountAfterSelling - currentRoubles; Log($"Profit made: {profitMade}"); Console.Title = $"Current Roubles: {amountAfterSelling:C}"; } else { Log($"Failed to sell items. Not calculating profit as there is none (pending items to sell)"); } Thread.Sleep(LinkManager.Timer); } GetLastHourProfit(); Thread.Sleep(LinkManager.Timer); } }