public void TestAddItem() { StashTab tab = new StashTab(); tab.AddItem(item01, "ItemRelic"); tab.Items.Should().Have.Count.EqualTo(1); tab.AddItem(new Item { BaseRecord = "stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0 }, "ItemRelic"); tab.Items.Should().Have.Count.EqualTo(2); tab.AddItem(new Item { BaseRecord = "stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0 }, "ItemRelic"); tab.Items.Should().Have.Count.EqualTo(2); tab.AddItem(new Item { BaseRecord = "stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0 }, "ItemRelic"); tab.Items.Should().Have.Count.EqualTo(2); tab.Items.Where(item => item.Seed == 1).FirstOrDefault().StackCount.Should().Be.EqualTo(3); }
public void TestAddItemCannotExeed100() { StashTab tab = new StashTab(); tab.AddItem(new Item { BaseRecord = "stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0, StackCount = 99 }, "ItemRelic"); tab.Items.Should().Have.Count.EqualTo(1); tab.AddItem(new Item { BaseRecord = "stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0, StackCount = 1 }, "ItemRelic"); tab.Items.Should().Have.Count.EqualTo(1); tab.AddItem(new Item { BaseRecord = "stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0, StackCount = 1 }, "ItemRelic"); tab.Items.Should().Have.Count.EqualTo(2); tab.Items.Sum(item => item.StackCount).Should().Be.EqualTo(101); }
public void UpdateStashTab(StashTab stashTab) { if (StashTabs.ContainsKey(stashTab.Index)) { StashTabs[stashTab.Index] = stashTab; } }
private ClassifiedItems Classify(StashTab tab) { var stacked = tab.Items.Where(item => item.StackCount > 1 || _cache.StackableRecords.Contains(item.BaseRecord) || _cache.SpecialRecords.Contains(item.BaseRecord) // Special "single seed" items. ).ToList(); var unknownItems = tab.Items.Where(item => !_cache.AllRecords.Contains(item.BaseRecord)).ToList(); var duplicates = tab.Items .Where(item => _playerItemDao.Exists(Arz.TransferStashService.Map(item, null, false))) // We don't care about mod/hardcore for dupe checking. .ToList(); var remaining = tab.Items .SkipWhile(item => duplicates.Contains(item)) .SkipWhile(item => stacked.Contains(item)) .SkipWhile(item => unknownItems.Contains(item)) .ToList(); return(new ClassifiedItems { Stacked = stacked, Duplicates = duplicates, Unknown = unknownItems, Remaining = remaining }); }
public void TestAddItemWhichIsNotStackable() { StashTab tab = new StashTab(); tab.AddItem(new Item { BaseRecord = "not-stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0, StackCount = 2 }, "something"); tab.Items.Should().Have.Count.EqualTo(1); tab.AddItem(new Item { BaseRecord = "not-stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0, StackCount = 2 }, "something"); tab.Items.Should().Have.Count.EqualTo(2); tab.AddItem(new Item { BaseRecord = "not-stackable", Seed = 1, RelicSeed = 0, EnchantmentSeed = 0, StackCount = 2 }, "something"); tab.Items.Should().Have.Count.EqualTo(3); }
private ItemClassificationService Classify(StashTab tab) { ItemClassificationService classifier = new ItemClassificationService(_cache, _playerItemDao); classifier.Add(tab.Items); return(classifier); }
public void AddStashTab(StashTab stashTab) { StashTabs.Add(stashTab.Index, stashTab); foreach (var item in stashTab.Items) { Items.Add(item.Id, item); ItemIdToTabIndex.Add(item.Id, stashTab.Index); } }
public void SetStashTab(StashTab stashTab, Dictionary <string, Price> prices) { this.Dispatcher.Invoke(() => { StashTab = stashTab; ClearStashTab(); PushToGrid(prices); }); }
private ChaosRecipeResult CalculateChaosRecipe(StashTab tab) { ChaosRecipeResult result = new ChaosRecipeResult(); string startStr = "https://web.poecdn.com/image/Art/2DItems/"; foreach (var item in tab.Items) { if (item.FrameType == 2 && item.ItemLevel >= 60 && item.ItemLevel < 75) { int startIndex = item.IconUrl.IndexOf(startStr); if (startIndex == -1) { continue; } startIndex += startStr.Length; int endIndex = item.IconUrl.IndexOf("/", startIndex); if (endIndex == -1) { continue; } string type = item.IconUrl.Substring(startIndex, endIndex - startIndex); if (type == "Weapons") { int nextIndex = item.IconUrl.IndexOf("/", endIndex + 1); if (nextIndex != -1) { type = item.IconUrl.Substring(startIndex, nextIndex - startIndex); } } if (type == "Armours") { int nextIndex = item.IconUrl.IndexOf("/", endIndex + 1); if (nextIndex != -1) { type = item.IconUrl.Substring(startIndex, nextIndex - startIndex); } } SetResult(type, ref result); } } return(result); }
static async Task Main(string[] args) { POEClient PoeClient = new POEClient(); StashTab stashtab = await PoeClient.GetPublicStashTabsASync(); List <League> GetLeagues = await PoeClient.GetLeaguesAsync(type : "event", id : "Standard"); Console.WriteLine(stashtab); Console.ReadLine(); }
private async Task GetChaosRecipeStashTab() { if (_authHttpService != null) { var config = AppService.Instance.GetConfig(); var response = await _authHttpService.Client.GetAsync($"/{POE_API_CHARS}?league={config.CurrentLeague}&tabs=0&tabIndex={config.ChaosRecipeTabIndex}&accountName={config.PlayerName}"); ChaosRecipeTab = await _authHttpService.ReadResponse <StashTab>(response); var result = CalculateChaosRecipe(ChaosRecipeTab); AppService.Instance.NewChaosRecipeResult(result); } }
private async void GetItems() { StashTab stashTab = await FetchStashItems(); foreach (Item item in stashTab.items) { item.NormalizeItemName(); item.NormalizeStackSize(); item.checkPrice(priceLists); } stashItemsCollection = new ListCollectionView(stashTab.items); RaiseEvents("Items"); }
private List <Item> ConvertToStashItems(IList <PlayerItem> playerItems, StashTab tab) { var result = new List <Item>(); var packer = new Packer(tab.Height, tab.Width); _itemSizeService.CacheItemSizes(playerItems); // Position existing items _itemSizeService.MapItemSizes(tab.Items); foreach (var item in tab.Items) { packer.Insert(new Shape { Height = item.Height, Width = item.Width }); } // Add and position any items that fits foreach (var playerItem in playerItems) { if (playerItem.StackCount == 0) { playerItem.StackCount = 1; } while (playerItem.StackCount > 0) { var stashItem = GetItem(playerItem); // Map item size and create a shape map if (!PositionItem(packer, stashItem)) { Logger.Info($"Could not fit all items in stash, stopping early. There are {tab.Items.Count} items in the tab."); playerItem.StackCount += stashItem.StackCount; return(result); } result.Add(stashItem); } } Logger.Debug("All items fit into stash"); return(result); }
public void GetSetTargetAmount(StashTab stash) { if (Properties.Settings.Default.Sets > 0) { this.SetTargetAmount = Properties.Settings.Default.Sets; } else { if (stash.Quad) { this.SetTargetAmount += 16; } else { this.SetTargetAmount += 4; } } }
private Item GetItem(PlayerItem item) { var stashItem = Map(item); // Calculate the final stack count (stored stack may be larger than max transfer size) if (StashTab.CanStack(item.Slot) || StashTab.HardcodedRecords.Contains(item.BaseRecord)) { var maxStack = Math.Min(item.StackCount, 100); stashItem.StackCount = (uint)Math.Max(1, Math.Min(stashItem.StackCount, maxStack)); } else { stashItem.StackCount = 1; } item.StackCount -= stashItem.StackCount; _itemSizeService.MapItemSize(stashItem); return(stashItem); }
// tries to add item, if item added returns private static bool AddItemToItemSet(ItemSet set, bool chaosItems = false, bool honorOrder = true) { string listName; switch (chaosItems) { case false: listName = "ItemList"; break; case true: listName = "ItemListChaos"; break; default: throw new Exception("How did you manage to provide a value neither true or false for a boolean?"); } Item minItem = null; double minDistance = double.PositiveInfinity; // TODO: crashes here after some time foreach (StashTab s in StashTabList.StashTabs) { foreach (Item i in ((List <Item>)Utility.GetPropertyValue(s, listName))) { if (set.GetNextItemClass() == i.ItemType || (!honorOrder && set.IsValidItem(i))) { if (set.GetItemDistance(i) < minDistance) { //Trace.WriteLine(minDistance, "minDistance"); minDistance = set.GetItemDistance(i); minItem = i; } } } } if (minItem != null) { set.AddItem(minItem); StashTab tab = GetStashTabFromItem(minItem); ((List <Item>)Utility.GetPropertyValue(tab, listName)).Remove(minItem); //tab.ItemListChaos.Remove(minItem); return(true); } else { // Looks ugly but in case we allow TwoHandWeapons we need to consider that adding a 1H fails but we might have a 2H (this only applies if we honor the order) if (honorOrder) { string nextItemType = set.GetNextItemClass(); if (nextItemType == "TwoHandWeapons") { nextItemType = "OneHandWeapons"; foreach (StashTab s in StashTabList.StashTabs) { foreach (Item i in ((List <Item>)Utility.GetPropertyValue(s, listName))) { if (nextItemType == i.ItemType) { if (set.GetItemDistance(i) < minDistance) { //Trace.WriteLine(minDistance, "minDistance"); minDistance = set.GetItemDistance(i); minItem = i; } } } } if (minItem != null) { set.AddItem(minItem); StashTab tab = GetStashTabFromItem(minItem); ((List <Item>)Utility.GetPropertyValue(tab, listName)).Remove(minItem); //tab.ItemListChaos.Remove(minItem); return(true); } } } } return(false); }
// public static void ActivateNextCell(bool active, Cell cell) { if (active) { if (Properties.Settings.Default.HighlightMode == 0) { //activate cell by cell foreach (StashTab s in StashTabList.StashTabs) { s.DeactivateItemCells(); s.TabHeaderColor = Brushes.Transparent; } // remove and sound if itemlist empty if (ItemSetListHighlight.Count > 0) { if (ItemSetListHighlight[0].ItemList.Count == 0) { ItemSetListHighlight.RemoveAt(0); PlayerSet.Dispatcher.Invoke(() => { PlayNotificationSoundSetPicked(); }); } } else { if (ItemSetListHighlight.Count > 0) { PlayerSet.Dispatcher.Invoke(() => { PlayNotificationSoundSetPicked(); }); } } // next item if itemlist not empty if (ItemSetListHighlight.Count > 0) { if (ItemSetListHighlight[0].ItemList.Count > 0 && ItemSetListHighlight[0].EmptyItemSlots.Count == 0) { Item highlightItem = ItemSetListHighlight[0].ItemList[0]; StashTab currentTab = GetStashTabFromItem(highlightItem); if (currentTab != null) { currentTab.ActivateItemCells(highlightItem); if (Properties.Settings.Default.ColorStash != "") { currentTab.TabHeaderColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(Properties.Settings.Default.ColorStash)); } else { currentTab.TabHeaderColor = Brushes.Red; } ItemSetListHighlight[0].ItemList.RemoveAt(0); } //check for full sets //if (ItemSetListHighlight[0].ItemList.Count <= 0) //{ //} } } } else if (Properties.Settings.Default.HighlightMode == 1) { // activate whole set if (ItemSetListHighlight.Count > 0) { Trace.WriteLine(ItemSetListHighlight[0].ItemList.Count, "item list count"); Trace.WriteLine(ItemSetListHighlight.Count, "itemset list ocunt"); // check for full sets if (ItemSetListHighlight[0].EmptyItemSlots.Count == 0) { if (cell != null) { Item highlightItem = cell.CellItem; StashTab currentTab = GetStashTabFromItem(highlightItem); if (currentTab != null) { currentTab.DeactivateSingleItemCells(cell.CellItem); currentTab.TabHeaderColor = Brushes.Transparent; ItemSetListHighlight[0].ItemList.Remove(highlightItem); } } //Trace.WriteLine("IS HERE IS HERE IS HERE"); foreach (Item i in ItemSetListHighlight[0].ItemList) { //currentTab.ActivateItemCells(i); StashTab currTab = GetStashTabFromItem(i); currTab.ActivateItemCells(i); //currTab.ShowNumbersOnActiveCells(); if (Properties.Settings.Default.ColorStash != "") { currTab.TabHeaderColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(Properties.Settings.Default.ColorStash)); } else { currTab.TabHeaderColor = Brushes.Red; } } // mark item order if (ItemSetListHighlight[0] != null) { if (ItemSetListHighlight[0].ItemList.Count > 0) { StashTab cTab = GetStashTabFromItem(ItemSetListHighlight[0].ItemList[0]); cTab.MarkNextItem(ItemSetListHighlight[0].ItemList[0]); } } if (ItemSetListHighlight[0].ItemList.Count == 0) { //Trace.WriteLine("itemsetlist gets removes0"); ItemSetListHighlight.RemoveAt(0); // activate next set ActivateNextCell(true, null); PlayerSet.Dispatcher.Invoke(() => { PlayNotificationSoundSetPicked(); }); } } } } else if (Properties.Settings.Default.HighlightMode == 2) { //activate all cells at once if (ItemSetListHighlight.Count > 0) { foreach (ItemSet set in ItemSetListHighlight) { if (set.EmptyItemSlots.Count == 0) { if (cell != null) { Item highlightItem = cell.CellItem; StashTab currentTab = GetStashTabFromItem(highlightItem); if (currentTab != null) { currentTab.DeactivateSingleItemCells(cell.CellItem); currentTab.TabHeaderColor = Brushes.Transparent; ItemSetListHighlight[0].ItemList.Remove(highlightItem); } } } } } } } }
public MainViewModel() { user = new User(); stashTab = new StashTab(); }
// TODO: rework tabitems, tabheaders public new virtual void Show() { if (ChaosRecipeEnhancer.FetchingActive) { ChaosRecipeEnhancer.aTimer.Enabled = false; } if (StashTabList.StashTabs.Count != 0) { IsOpen = true; OverlayStashTabList.Clear(); _tabHeaderGap.Right = Properties.Settings.Default.TabHeaderGap; _tabHeaderGap.Left = Properties.Settings.Default.TabHeaderGap; TabMargin = new Thickness(Properties.Settings.Default.TabMargin, 0, 0, 0); //TabHeaderWidth = new Thickness(Properties.Settings.Default.TabHeaderWidth, 2, Properties.Settings.Default.TabHeaderWidth, 2); foreach (StashTab i in StashTabList.StashTabs) { //i.PrepareOverlayList(); //i.ActivateNextCell(true); TabItem newStashTabItem; TextBlock tbk = new TextBlock() { Text = i.TabName }; //TextBlock tbk = new TextBlock() { Text = i.TabName}; //if (i.ItemOrderList.Count > 0) //{ // if (Properties.Settings.Default.ColorStash != "") // { // tbk.Background = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(Properties.Settings.Default.ColorStash)); // } // else // { // tbk.Background = Brushes.Red; // } //} //tbk.Background = i.TabHeaderColor; tbk.DataContext = i; tbk.SetBinding(TextBlock.BackgroundProperty, new System.Windows.Data.Binding("TabHeaderColor")); tbk.SetBinding(TextBlock.PaddingProperty, new System.Windows.Data.Binding("TabHeaderWidth")); //tbk.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("TabName")); //tbk.SetBinding(TextBlock.PaddingProperty, new System.Windows.Data.Binding("TabHeaderThickness")); tbk.FontSize = 16; //if(i..Co > 0) //{ // if (Properties.Settings.Default.ColorStash != "") // { // i.TabHeaderColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(Properties.Settings.Default.ColorStash)); // } // else // { // i.TabHeaderColor = Brushes.Red; // } //} i.TabHeader = tbk; //TextBlockList.Add(tbk, i.TabIndex); //string name = i.TabName + "GridControl"; if (i.Quad) { newStashTabItem = new TabItem { Header = tbk, Content = new UserControls.DynamicGridControlQuad { ItemsSource = i.OverlayCellsList, } }; } else { newStashTabItem = new TabItem { Header = tbk, Content = new UserControls.DynamicGridControl { ItemsSource = i.OverlayCellsList } }; } OverlayStashTabList.Add(newStashTabItem); } StashTabOverlayTabControl.SelectedIndex = 0; Data.PrepareSelling(); Data.ActivateNextCell(true, null); if (Properties.Settings.Default.HighlightMode == 2) { foreach (ItemSet set in Data.ItemSetListHighlight) { foreach (Item i in set.ItemList) { StashTab currTab = Data.GetStashTabFromItem(i); currTab.ActivateItemCells(i); } } } MainWindow.overlay.OpenStashOverlayButtonContent = "Hide"; MouseHook.Start(); base.Show(); } else { System.Windows.MessageBox.Show("No StashTabs Available! Fetch before opening Overlay.", "Stashtab Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public async Task RemoveStashtab(StashTab stashtab) { await _stashtabs.DeleteOneAsync(s => s.ClientId == stashtab.ClientId); }
private List <Item> ConvertToStashItems(IList <PlayerItem> playerItems, int itemsRemaining, StashTab tab) { List <Item> result = new List <Item>(); Packer packer = new Packer(tab.Height, tab.Width); _itemSizeService.CacheItemSizes(playerItems); // Position existing items _itemSizeService.MapItemSizes(tab.Items); foreach (var item in tab.Items) { packer.Insert(new Shape { Height = item.Height, Width = item.Width }); } // Add and position any items that fits for (int i = 0; i < playerItems.Count; i++) { if (playerItems[i].StackCount == 0) { playerItems[i].StackCount = 1; } while (playerItems[i].StackCount > 0 && itemsRemaining > 0) { Item stashItem = GetItem(playerItems[i], itemsRemaining); // Map item size and create a shape map if (!PositionItem(packer, stashItem)) { Logger.Info("Could not fit all items in stash, stopping early"); playerItems[i].StackCount += stashItem.StackCount; return(result); } result.Add(stashItem); itemsRemaining -= (int)stashItem.StackCount; } } Logger.Debug("All items fit into stash"); return(result); }