Пример #1
0
        public override void OnStashing(CachedItem item)
        {
            if (_tabWithGcpSet != null || item.Type.ItemType != ItemTypes.Gem || item.Quality < 1)
            {
                return;
            }

            var qualities = GemQualitiesInCurrentTab;

            if (qualities.Count == 0)
            {
                return;
            }

            var finder = new GemSetFinder(qualities);

            _gcpSet = finder.BestSet;

            if (_gcpSet != null)
            {
                GlobalLog.Info($"[OnQGemStash] Found gem set for gcp recipe {_gcpSet}");
                _tabWithGcpSet = LokiPoe.InGameState.StashUi.TabControl.CurrentTabName;
            }
            else
            {
                GlobalLog.Info("[OnQGemStash] Gem set for gcp recipe was not found.");
            }
        }
Пример #2
0
            // http://algorithms.tutorialhorizon.com/dynamic-programming-subset-sum-problem/
            private void FindSets(bool[] solution, int currentSum, int index)
            {
                if (currentSum == 40)
                {
                    _perfectSet = CreateGemSet(solution, currentSum);
                    return;
                }
                if (currentSum > 40)
                {
                    if (currentSum <= 45)
                    {
                        _sets.Add(CreateGemSet(solution, currentSum));
                    }
                    return;
                }

                if (_perfectSet != null || index == _numbers.Count)
                {
                    return;
                }

                solution[index] = true;
                currentSum     += _numbers[index];
                FindSets(solution, currentSum, index + 1);

                solution[index] = false;
                currentSum     -= _numbers[index];
                FindSets(solution, currentSum, index + 1);
            }
Пример #3
0
        private static async Task <bool> TakeGcpSets()
        {
            if (!await Inventories.OpenStashTab(_tabWithGcpSet))
            {
                return(false);
            }

            while (true)
            {
                if (_gcpSet == null)
                {
                    var qualities = GemQualitiesInCurrentTab;
                    if (qualities.Count == 0)
                    {
                        GlobalLog.Info($"[TakeGcpSets] No quality gems were found in \"{_tabWithGcpSet}\" tab.");
                        _tabWithGcpSet = null;
                        return(true);
                    }

                    var finder = new GemSetFinder(qualities);
                    _gcpSet = finder.BestSet;

                    if (_gcpSet == null)
                    {
                        GlobalLog.Info($"[TakeGcpSets] No more gem sets for gcp recipe were found in \"{_tabWithGcpSet}\" tab.");
                        _tabWithGcpSet = null;
                        return(true);
                    }
                }

                if (!_gcpSet.CanFit)
                {
                    GlobalLog.Warn("[TakeGcpSets] Not enough inventory space for current gcp set.");
                    _gcpSet = null;
                    return(true);
                }

                GlobalLog.Warn($"[TakeGcpSets] Now taking gcp set {_gcpSet}");

                foreach (int q in _gcpSet.Qualities)
                {
                    var gem = StashGems.FirstOrDefault(g => QGemFitsForSelling(g) && g.Quality == q);
                    if (gem == null)
                    {
                        GlobalLog.Error($"[TakeGcpSets] Unexpected error. Fail to find gem with quality {q} as a part of {_gcpSet} gcp set.");
                        _tabWithGcpSet = null;
                        _gcpSet        = null;
                        return(false);
                    }

                    if (!await Inventories.FastMoveFromStashTab(gem.LocationTopLeft))
                    {
                        return(false);
                    }
                }
                _gcpSet = null;
            }
        }
Пример #4
0
 public override void ResetData()
 {
     _tabWithGcpSet = null;
     _gcpSet        = null;
 }