Esempio n. 1
0
 internal static void ResetTownRun()
 {
     ItemValuation.ResetValuationStatStrings();
     TownRun.TownRunCheckTimer.Reset();
     Trinity.ForceVendorRunASAP = false;
     Trinity.WantToTownRun      = false;
 }
Esempio n. 2
0
 private static void ResetTownRun()
 {
     ItemValuation.ResetValuationStatStrings();
     TownRun.TownRunCheckTimer.Reset();
     ForceVendorRunASAP = false;
     IsReadyToTownRun   = false;
 }
        public bool ShouldStashItem(ACDItem item, ItemEvaluationType evaluationType)
        {
            ItemEvents.ResetTownRun();

            if (Current.ItemIsProtected(item))
            {
                return(false);
            }

            // Vanity Items
            if (DataDictionary.VanityItems.Any(i => item.InternalName.StartsWith(i)))
            {
                return(false);
            }

            if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.DemonBuddy)
            {
                return(Current.ShouldStashItem(item));
            }

            CachedACDItem cItem = CachedACDItem.GetCachedItem(item);

            // Now look for Misc items we might want to keep
            GItemType     tItemType = cItem.TrinityItemType;     // DetermineItemType(cItem.InternalName, cItem.DBItemType, cItem.FollowerType);
            GItemBaseType tBaseType = cItem.TrinityItemBaseType; // DetermineBaseType(trinityItemType);

            bool isEquipment = (tBaseType == GItemBaseType.Armor ||
                                tBaseType == GItemBaseType.Jewelry ||
                                tBaseType == GItemBaseType.Offhand ||
                                tBaseType == GItemBaseType.WeaponOneHand ||
                                tBaseType == GItemBaseType.WeaponRange ||
                                tBaseType == GItemBaseType.WeaponTwoHand);

            if (cItem.TrinityItemType == GItemType.HoradricCache && Trinity.Settings.Loot.TownRun.OpenHoradricCaches)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] = (ignoring Horadric Cache)", cItem.RealName, cItem.InternalName);
                return(false);
            }

            // Stash all unidentified items - assume we want to keep them since we are using an identifier over-ride
            if (cItem.IsUnidentified)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] = (autokeep unidentified items)", cItem.RealName, cItem.InternalName);
                }
                return(true);
            }
            if (tItemType == GItemType.StaffOfHerding)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep staff of herding)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.CraftingMaterial)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep craft materials)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (tItemType == GItemType.Emerald || tItemType == GItemType.Amethyst || tItemType == GItemType.Topaz || tItemType == GItemType.Ruby || tItemType == GItemType.Diamond)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.CraftTome)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep tomes)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.InfernalKey)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep infernal key)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (tItemType == GItemType.HealthPotion)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (ignoring potions)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(false);
            }

            if (tItemType == GItemType.CraftingPlan && cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendary plans)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
            {
                Interpreter.InterpreterAction action = Trinity.StashRule.checkItem(item, evaluationType);

                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (" + action + ")", cItem.AcdItem.Name, cItem.AcdItem.InternalName, cItem.AcdItem.ItemType);
                }
                switch (action)
                {
                case Interpreter.InterpreterAction.KEEP:
                    return(true);

                case Interpreter.InterpreterAction.TRASH:
                    return(false);

                case Interpreter.InterpreterAction.SCORE:
                    break;
                }
            }

            if (tItemType == GItemType.CraftingPlan)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep plans)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            // Stashing Whites, auto-keep
            if (Trinity.Settings.Loot.TownRun.StashWhites && isEquipment && cItem.Quality <= ItemQuality.Superior)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (stashing whites)", cItem.RealName, cItem.InternalName, tItemType);
                return(true);
            }
            // Else auto-trash
            if (cItem.Quality <= ItemQuality.Superior && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (trash whites)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            // Stashing blues, auto-keep
            if (Trinity.Settings.Loot.TownRun.StashBlues && isEquipment && cItem.Quality >= ItemQuality.Magic1 && cItem.Quality <= ItemQuality.Magic3)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (stashing blues)", cItem.RealName, cItem.InternalName, tItemType);
                return(true);
            }
            // Else auto trash
            if (cItem.Quality >= ItemQuality.Magic1 && cItem.Quality <= ItemQuality.Magic3 && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (trashing blues)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            // Force salvage Rares
            if (Trinity.Settings.Loot.TownRun.ForceSalvageRares && cItem.Quality >= ItemQuality.Rare4 && cItem.Quality <= ItemQuality.Rare6 && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (force salvage rare)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            if (cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendaries)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            // Ok now try to do some decent item scoring based on item types
            double iNeedScore = Trinity.ScoreNeeded(item.ItemBaseType);
            double iMyScore   = ItemValuation.ValueThisItem(cItem, tItemType);

            if (evaluationType == ItemEvaluationType.Keep)
            {
                Logger.Log(TrinityLogLevel.Verbose, LogCategory.ItemValuation, "{0} [{1}] [{2}] = {3}", cItem.RealName, cItem.InternalName, tItemType, iMyScore);
            }
            if (iMyScore >= iNeedScore)
            {
                return(true);
            }

            // If we reached this point, then we found no reason to keep the item!
            return(false);
        }
Esempio n. 4
0
        public bool ShouldStashItem(ACDItem item, ItemEvaluationType evaluationType)
        {
            if (ItemManager.Current.ItemIsProtected(item))
            {
                return(false);
            }

            GilesCachedACDItem cItem = GilesCachedACDItem.GetCachedItem(item);

            // Now look for Misc items we might want to keep
            GItemType     trinityItemType = cItem.TrinityItemType;     // DetermineItemType(cItem.InternalName, cItem.DBItemType, cItem.FollowerType);
            GItemBaseType trinityBaseType = cItem.TrinityItemBaseType; // DetermineBaseType(trinityItemType);

            if (trinityItemType == GItemType.StaffOfHerding)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep staff of herding)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.CraftingMaterial)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep craft materials)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }

            if (trinityItemType == GItemType.Emerald)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.Amethyst)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.Topaz)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.Ruby)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.CraftTome)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep tomes)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.InfernalKey)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep infernal key)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.HealthPotion)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (ignoring potions)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(false);
            }

            // Stash all unidentified items - assume we want to keep them since we are using an identifier over-ride
            if (cItem.IsUnidentified)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] = (autokeep unidentified items)", cItem.RealName, cItem.InternalName);
                }
                return(true);
            }

            if (GilesTrinity.Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
            {
                Interpreter.InterpreterAction action = GilesTrinity.StashRule.checkItem(item, evaluationType);
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (" + action + ")", cItem.AcdItem.Name, cItem.AcdItem.InternalName, cItem.AcdItem.ItemType);
                }
                switch (action)
                {
                case Interpreter.InterpreterAction.KEEP:
                    return(true);

                case Interpreter.InterpreterAction.TRASH:
                    return(false);

                case Interpreter.InterpreterAction.SCORE:
                    break;
                }
            }

            // auto trash blue weapons/armor/jewlery
            if ((item.ItemBaseType == ItemBaseType.Armor ||
                 item.ItemBaseType == ItemBaseType.Weapon ||
                 item.ItemBaseType == ItemBaseType.Jewelry) &&
                item.ItemQualityLevel < ItemQuality.Rare4)
            {
                return(false);
            }

            if (cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendaries)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }

            if (trinityItemType == GItemType.CraftingPlan)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep plans)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }

            // Ok now try to do some decent item scoring based on item types
            double iNeedScore = GilesTrinity.ScoreNeeded(item.ItemBaseType);
            double iMyScore   = ItemValuation.ValueThisItem(cItem, trinityItemType);

            if (evaluationType == ItemEvaluationType.Keep)
            {
                DbHelper.Log(TrinityLogLevel.Verbose, LogCategory.ItemValuation, "{0} [{1}] [{2}] = {3}", cItem.RealName, cItem.InternalName, trinityItemType, iMyScore);
            }
            if (iMyScore >= iNeedScore)
            {
                return(true);
            }

            // If we reached this point, then we found no reason to keep the item!
            return(false);
        }
Esempio n. 5
0
        internal static void TrinityOnItemSold(object sender, ItemEventArgs e)
        {
            ResetTownRun();

            try
            {
                ACDItem i = e.Item;

                if (i == null || !i.IsValid || i.IsDisposed)
                {
                    return;
                }

                var cachedItem = CachedACDItem.GetCachedItem(i);
                switch (i.ItemBaseType)
                {
                case ItemBaseType.Gem:
                case ItemBaseType.Misc:
                    break;

                default:
                    TownRun.LogJunkItems(cachedItem, cachedItem.TrinityItemBaseType, cachedItem.TrinityItemType, ItemValuation.ValueThisItem(cachedItem, cachedItem.TrinityItemType));
                    break;
                }
            }
            catch (Exception ex)
            {
                if (ex is CoroutineStoppedException)
                {
                    throw;
                }
            }
        }
Esempio n. 6
0
        internal static void TrinityOnItemStashed(object sender, ItemEventArgs e)
        {
            ACDItem i = e.Item;

            if (!i.IsValid)
            {
                return;
            }

            var cachedItem = CachedACDItem.GetCachedItem(i);

            ResetTownRun();

            switch (i.ItemBaseType)
            {
            case ItemBaseType.Gem:
            case ItemBaseType.Misc:
                break;

            default:
                TownRun.LogGoodItems(cachedItem, cachedItem.TrinityItemBaseType, cachedItem.TrinityItemType, ItemValuation.ValueThisItem(cachedItem, cachedItem.TrinityItemType));
                break;
            }
        }
Esempio n. 7
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ConfigViewModel" /> class.
        /// </summary>
        /// <param name="model">The model.</param>
        public ConfigViewModel(TrinitySetting model)
        {
            try
            {
                _OriginalModel = model;
                _Model         = new TrinitySetting();
                _OriginalModel.CopyTo(_Model);
                InitializeResetCommand();

                SaveCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        if (Trinity.StashRule == null && _Model.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
                        {
                            // Load interpreter for the first time if needed
                            Trinity.StashRule = new Interpreter();
                        }

                        _Model.CopyTo(_OriginalModel);
                        _OriginalModel.Save();

                        if (_Model.Advanced.TPSEnabled != _OriginalModel.Advanced.TPSEnabled)
                        {
                            BotManager.SetBotTicksPerSecond();
                        }

                        if (_Model.Advanced.UnstuckerEnabled != _OriginalModel.Advanced.UnstuckerEnabled)
                        {
                            BotManager.SetUnstuckProvider();
                        }

                        if (_Model.Loot.ItemFilterMode != _OriginalModel.Loot.ItemFilterMode)
                        {
                            BotManager.SetItemManagerProvider();
                        }

                        CacheData.FullClear();
                        UsedProfileManager.SetProfileInWindowTitle();

                        UILoader.CloseWindow();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Exception in UI SaveCommand {0}", ex);
                    }
                });
                DumpBackpackCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Backpack Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Backpack);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Backpack: {0}", ex);
                    }
                });
                DumpQuickItemsCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nQuick Dumping Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpQuickItems();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception Quick Dumping: {0}", ex);
                    }
                });
                DumpAllItemsCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping ALL Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.All);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception Dumping ALL Items: {0}", ex);
                    }
                });
                DumpSkillsAndItemsCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        UILoader.CloseWindow();
                        DebugUtil.LogBuildAndItems(TrinityLogLevel.Info);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception Dumping Skill/Rune/Passive Items: {0}", ex);
                    }
                });
                DumpInvalidItemsCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        UILoader.CloseWindow();
                        DebugUtil.LogInvalidItems(TrinityLogLevel.Info);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception Dumping Invalid Items: {0}", ex);
                    }
                });
                DumpItemSNOReference = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        UILoader.CloseWindow();
                        DebugUtil.DumpItemSNOReference();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception in DumpItemSNOReference: {0}", ex);
                    }
                });
                DumpMerchantItemsCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Merchant Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Merchant);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Merchant: {0}", ex);
                    }
                });
                DumpEquippedCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Equipped Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Equipped);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Equipped: {0}", ex);
                    }
                });
                DumpGroundItemsCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Ground Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Ground);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Ground: {0}", ex);
                    }
                });
                DumpStashCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        Logger.Log(
                            "\n############################################\n"
                            + "\nDumping Stash Items. This will hang your client. Please wait....\n"
                            + "##########################");
                        UILoader.CloseWindow();
                        TrinityItemManager.DumpItems(TrinityItemManager.DumpItemLocation.Stash);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "Exception dumping Stash: {0}", ex);
                    }
                });
                TestScoreCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        ItemValuation.TestScoring();
                        //UILoader.CloseWindow();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogCategory.UserInformation, "{0}", ex);
                    }
                });
                HelpLinkCommand = new RelayCommand(
                    parameter =>
                {
                    var link = parameter as string;
                    if (!string.IsNullOrWhiteSpace(link))
                    {
                        Process.Start(link);
                    }
                });
                ConfigureLootToHunting = new RelayCommand(
                    parameter => ConfigHuntingLoot());
                ConfigureLootToQuesting = new RelayCommand(
                    parameter => ConfigQuestingLoot());
                LoadItemRuleSetCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        LoadItemRulesPath();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Exception in LoadItemRuleSetCommand: {0}", ex);
                    }
                });
                OpenTVarsCommand = new RelayCommand(
                    parameter =>
                {
                    try
                    {
                        V.ValidateLoad();
                        TVarsViewModel.CreateWindow().Show();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Exception in OpenTVarsCommand: {0}", ex);
                    }
                });
                UseGlobalConfigFileCommand = new RelayCommand(
                    parameter =>
                {
                    DialogResult rusure = MessageBox.Show("This will force all bots running under this Demonbuddy directory to use a shared configuration file.\n"
                                                          + "You can undo this by removing the Trinity.xml file under your Demonbuddy settings directory. \n"
                                                          + "Are you sure?",
                                                          "Confirm global settings",
                                                          MessageBoxButtons.OKCancel);

                    if (rusure == DialogResult.OK)
                    {
                        Trinity.Settings.Save(true);
                    }
                });
                DumpSkillsCommand = new RelayCommand(
                    parameter =>
                {
                    CacheData.Hotbar.Dump();
                    UILoader.CloseWindow();
                });
            }
            catch (Exception ex)
            {
                Logger.LogError("Error creating Trinity View Model {0}", ex);
            }
        }
Esempio n. 8
0
        /// <summary>
        ///     Log the nice items we found and stashed
        /// </summary>
        internal static void LogGoodItems(CachedACDItem acdItem, TrinityItemBaseType itemBaseType, TrinityItemType itemType, double itemValue)
        {
            FileStream logStream = null;

            try
            {
                string filePath = Path.Combine(FileManager.LoggingPath, "StashLog - " + Trinity.Player.ActorClass + ".log");
                logStream = File.Open(filePath, FileMode.Append, FileAccess.Write, FileShare.Read);

                //TODO : Change File Log writing
                using (var logWriter = new StreamWriter(logStream))
                {
                    if (!_loggedAnythingThisStash)
                    {
                        _loggedAnythingThisStash = true;
                        logWriter.WriteLine(DateTime.Now + ":");
                        logWriter.WriteLine("====================");
                    }
                    string sLegendaryString        = "";
                    bool   shouldSendNotifications = false;

                    if (acdItem.Quality >= ItemQuality.Legendary)
                    {
                        if (!Trinity.Settings.Notification.LegendaryScoring)
                        {
                            shouldSendNotifications = true;
                        }
                        else if (Trinity.Settings.Notification.LegendaryScoring && ItemValuation.CheckScoreForNotification(itemBaseType, itemValue))
                        {
                            shouldSendNotifications = true;
                        }
                        if (shouldSendNotifications)
                        {
                            NotificationManager.AddNotificationToQueue(acdItem.RealName + " [" + itemType +
                                                                       "] (Score=" + itemValue + ". " + acdItem.AcdItem.Stats + ")",
                                                                       ZetaDia.Service.Hero.Name + " new legendary!", ProwlNotificationPriority.Emergency);
                        }
                        sLegendaryString = " {legendary item}";

                        // Change made by bombastic
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+=+=+=+=+=+=+=+=+ LEGENDARY FOUND +=+=+=+=+=+=+=+=+");
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+  Name:       {0} ({1})", acdItem.RealName, itemType);
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+  Score:       {0:0}", itemValue);
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+  Attributes: {0}", acdItem.AcdItem.Stats.ToString());
                        Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+");
                    }
                    else
                    {
                        // Check for non-legendary notifications
                        shouldSendNotifications = ItemValuation.CheckScoreForNotification(itemBaseType, itemValue);
                        if (shouldSendNotifications)
                        {
                            NotificationManager.AddNotificationToQueue(acdItem.RealName + " [" + itemType + "] (Score=" + itemValue + ". " + acdItem.AcdItem.Stats + ")",
                                                                       ZetaDia.Service.Hero.BattleTagName + " new item!", ProwlNotificationPriority.Normal);
                        }
                    }
                    if (shouldSendNotifications)
                    {
                        NotificationManager.EmailMessage.AppendLine(itemBaseType + " - " + itemType + " '" + acdItem.RealName + "'. Score = " + Math.Round(itemValue) + sLegendaryString)
                        .AppendLine("  " + acdItem.AcdItem.Stats)
                        .AppendLine();
                    }
                    logWriter.WriteLine(itemBaseType + " - " + itemType + " '" + acdItem.RealName + "'. Score = " + Math.Round(itemValue) + sLegendaryString);
                    logWriter.WriteLine("  " + acdItem.AcdItem.Stats);
                    logWriter.WriteLine("");
                }
                logStream.Close();
            }
            catch (IOException)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Fatal Error: File access error for stash log file.");
                if (logStream != null)
                {
                    logStream.Close();
                }
            }
        }
Esempio n. 9
0
        private void TrinityOnItemSold(object sender, ItemEventArgs e)
        {
            ACDItem i = e.Item;

            var cachedItem = GilesCachedACDItem.GetCachedItem(i);

            ResetTownRun();

            switch (i.ItemBaseType)
            {
            case ItemBaseType.Gem:
            case ItemBaseType.Misc:
                break;

            default:
                TownRun.LogJunkItems(cachedItem, cachedItem.TrinityItemBaseType, cachedItem.TrinityItemType, ItemValuation.ValueThisItem(cachedItem, cachedItem.TrinityItemType));
                break;
            }
        }