internal static void DumpReferenceItems(TrinityLogLevel level = TrinityLogLevel.Debug) { var path = Path.Combine(FileManager.DemonBuddyPath, "Resources\\JS Class Generator\\ItemReference.js"); if (File.Exists(path)) { File.Delete(path); } using (StreamWriter w = File.AppendText(path)) { w.WriteLine("var itemLookup = {"); foreach (var item in Legendary.ToList()) { if (item.Id != 0) { w.WriteLine(string.Format(" \"{0}\": [\"{1}\", {2}, \"{3}\"],", item.Slug, item.Name, item.Id, item.InternalName)); } } w.WriteLine("}"); } Logger.Log("Dumped Reference Items to: {0}", path); }
/// <summary> /// Convert Legendary items to SettingsItem objects only once to a static collection. /// </summary> public static void CacheReferenceItems() { if (_cachedItems == null) { _cachedItems = Legendary.ToList().Where(i => !i.IsCrafted && i.Id != 0).Select(i => new LItem(i)).ToList(); } }
internal static void DumpReferenceItems(TrinityLogLevel level = TrinityLogLevel.Debug) { var path = Path.Combine(FileManager.DemonBuddyPath, "Plugins\\Trinity\\Resources\\JS Class Generator\\ItemReference.js"); if (File.Exists(path)) { File.Delete(path); } using (StreamWriter w = File.AppendText(path)) { w.WriteLine("var itemLookup = {"); foreach (var item in Legendary.ToList()) { var key = !string.IsNullOrEmpty(item.Slug) ? item.Slug : RemoveApostophes(item.Name).ToLower(); if (item.Id != 0) { w.WriteLine($" \"{key}\": [\"{item.Name}\", {item.Id}, \"{item.InternalName}\"],"); } } w.WriteLine("}"); } Core.Logger.Log("Dumped Reference Items to: {0}", path); }
public void Merge(LootTracking other) { Magical.Merge(other.Magical); Rare.Merge(other.Rare); Legendary.Merge(other.Legendary); Gems.Merge(other.Gems); Crafting.Merge(other.Crafting); Keys.Merge(other.Keys); }
public void UpdateQuality_QualityStartsAtMax_NoChange() { // Arrange Item i = new Legendary("Sulfuras", 10, 50); // Act i.UpdateQuality(); //Assert Assert.Equal(50, i.Quality); }
public void UpdateQuality_PositiveDaysToSell_NoChange() { // Arrange Item i = new Legendary("Sulfuras", 10, 10); // Act i.UpdateQuality(); //Assert Assert.Equal(10, i.Quality); }
public void Merge(LootTracking other) { Magical.Merge(other.Magical); Rare.Merge(other.Rare); Legendary.Merge(other.Legendary); Gems.Merge(other.Gems); Crafting.Merge(other.Crafting); Keys.Merge(other.Keys); KeyStoneFragments.Merge(other.KeyStoneFragments); HoradricCache.Merge(other.HoradricCache); }
public void UpdateQuality_Expired_NoChange() { // Arrange Item i = new Legendary("Sulfuras", -1, 10); // Act i.UpdateQuality(); //Assert Assert.Equal(10, i.Quality); }
public void ShouldValidateLegendaryIsBoring() { // arrange Legendary item = new Legendary(10); // act item.AdjustQuality(); //assert item.CurrentQuality().Should().Be(10); }
public void Test_ItemFactory_Create_Legendary_ReturnOk() { // Arrange Legendary legendary = new Legendary("Sulfuras", 0); //Act var itemCreated = ItemFactory.Create("Sulfuras", 0); //Assert Assert.Equal(itemCreated.GetType(), legendary.GetType()); }
public void Test_Legendary_Update_NeverSaleOrDecreasesQuality_ReturnOk() { // Arrange Legendary legendary = new Legendary("Sulfuras", 12); //Act legendary.Update(); //Assert Assert.Equal(80, legendary.Quality); Assert.Equal(12, legendary.SellIn); }
internal static bool ShouldStashItem(CachedACDItem cItem, bool test = false) { if (cItem.AcdItem != null && cItem.AcdItem.IsValid) { var item = Legendary.GetItemByACD(cItem.AcdItem); if (item == null) { Logger.Log(TrinityLogLevel.Info, " >> Unknown Item {0} {1} - Auto-keeping", cItem.RealName, cItem.ActorSNO); return(true); } return(ShouldStashItem(item, cItem, test));; } return(false); }
internal static bool ShouldStashItem(ACDItem cItem, bool test = false) { if (ShouldStashItemType(cItem, test)) { return(true); } var item = Legendary.GetItem(cItem); if (item == null) { Core.Logger.Verbose(" >> Unknown Item {0} {1} - Auto-keeping", cItem.Name, cItem.ActorSnoId); return(true); } return(ShouldStashItem(item, cItem, test)); }
internal static void LogInvalidItems(TrinityLogLevel level = TrinityLogLevel.Debug) { var dropItems = Legendary.ToList().Where(i => !i.IsCrafted && i.Id == 0).OrderBy(i => i.TrinityItemType).ToList(); var craftedItems = Legendary.ToList().Where(i => i.IsCrafted && i.Id == 0).OrderBy(i => i.TrinityItemType).ToList(); Core.Logger.Log("Dropped Items: {0}", dropItems.Count); foreach (var item in dropItems) { Core.Logger.Log("{0} - {1} = 0", item.TrinityItemType, item.Name); } Core.Logger.Log(" "); Core.Logger.Log("Crafted Items: {0}", craftedItems.Count); foreach (var item in craftedItems) { Core.Logger.Log("{0} - {1} = 0", item.TrinityItemType, item.Name); } }
/// <summary> /// Convert rares into legendaries with Kanai's cube /// </summary> /// <param name="types">restrict the rares that can be selected by ItemType</param> public static async Task <bool> Execute(List <ItemSelectionType> types = null) { while (CanRun(types)) { if (!ZetaDia.IsInTown) { break; } Logger.Log("[CubeRaresToLegendary] CubeRaresToLegendary Started! Wooo!"); var backpackGuids = new HashSet <int>(ZetaDia.Me.Inventory.Backpack.Select(i => i.ACDGuid)); if (BackpackHasMaterials) { if (Town.Locations.KanaisCube.Distance(ZetaDia.Me.Position) > 10f || !GameUI.KanaisCubeWindow.IsVisible) { if (!await MoveToAndInteract.Execute(Town.Locations.KanaisCube, Town.ActorIds.KanaisCube, 3f)) { Logger.Log("Failed to move to the cube, quite unfortunate."); break; } continue; } Logger.Log("[CubeRaresToLegendary] Ready to go, Lets transmute!"); var item = GetBackPackRares(types).First(); var itemName = item.Name; var itemDynamicId = item.DynamicId; var itemInternalName = item.InternalName; var transmuteGroup = new List <ACDItem> { item, }; transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.ArcaneDust, 50)); transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.VeiledCrystals, 50)); transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.ReusableParts, 50)); transmuteGroup.AddRange(Inventory.GetStacksUpToQuantity(Inventory.Backpack.DeathsBreath, 25)); await Transmute.Execute(transmuteGroup); await Coroutine.Sleep(1500); var newItem = ZetaDia.Me.Inventory.Backpack.FirstOrDefault(i => !backpackGuids.Contains(i.ACDGuid)); if (newItem != null) { var newLegendaryItem = Legendary.GetItemByACD(newItem); Logger.Log("[CubeRaresToLegendary] Upgraded Rare '{0}' ---> '{1}' ({2})", itemName, newLegendaryItem.Name, newItem.ActorSNO); } else { Logger.Log("[CubeRaresToLegendary] Failed to upgrade Item '{0}' {1} DynId={2} HasBackpackMaterials={3}", itemName, itemInternalName, itemDynamicId, BackpackHasMaterials); } Inventory.InvalidItemDynamicIds.Add(itemDynamicId); } else if (StashHasMaterials) { Logger.Log("[CubeRaresToLegendary] Getting Materials from Stash"); if (!await TakeItemsFromStash.Execute(Inventory.RareUpgradeIds, 5000)) { return(true); } } else { Logger.Log("[CubeRaresToLegendary] Oh no! Out of materials!"); return(true); } await Coroutine.Sleep(500); await Coroutine.Yield(); } return(true); }
private static IEnumerable <TrinityItem> GetLegendaryExtractionCandidates(InventorySlot slot) { var alreadyCubedIds = new HashSet <int>(ZetaDia.Storage.PlayerDataManager.ActivePlayerData.KanaisPowersExtractedActorSnoIds); var usedIds = new HashSet <int>(); foreach (var item in Core.Inventory.Where(i => i.InventorySlot == slot)) { if (!item.IsValid) { continue; } if (item.TrinityItemType == TrinityItemType.HealthPotion) { continue; } if (item.FollowerType != FollowerType.None) { continue; } if (usedIds.Contains(item.ActorSnoId)) { continue; } if (DoNotExtractRawItemTypes.Contains(item.RawItemType)) { continue; } if (DoNotExtractItemIds.Contains(item.ActorSnoId)) { continue; } if (alreadyCubedIds.Contains(item.ActorSnoId)) { continue; } if (_blacklistedActorSnoIds.Contains(item.ActorSnoId)) { continue; } if (Core.Settings.KanaisCube.ExtractLegendaryPowers == CubeExtractOption.OnlyTrashed && Combat.TrinityCombat.Loot.ShouldStash(item)) { continue; } if (Core.Settings.KanaisCube.ExtractLegendaryPowers == CubeExtractOption.OnlyNonAncient && !item.IsAncient) { continue; } if (string.IsNullOrEmpty(Legendary.GetItem(item)?.LegendaryAffix)) { continue; } usedIds.Add(item.ActorSnoId); yield return(item); } }
/// <summary> /// Convert rares into legendaries with Kanai's cube /// </summary> /// <param name="types">restrict the rares that can be selected by ItemType</param> public static async Task <bool> Execute(List <ItemSelectionType> types = null) { while (CanRun(types)) { if (!ZetaDia.IsInTown) { break; } //Core.Logger.Log("[CubeRaresToLegendary] CubeRaresToLegendary Started! Wooo!"); var backpackGuids = new HashSet <int>(InventoryManager.Backpack.Select(i => i.ACDId)); if (HasMaterialsRequired) { if (TownInfo.KanaisCube.Distance > 10f || !GameUI.KanaisCubeWindow.IsVisible) { if (!await MoveToAndInteract.Execute(TownInfo.KanaisCube)) { Core.Logger.Log("Failed to move to the cube, quite unfortunate."); break; } continue; } //Core.Logger.Log("[CubeRaresToLegendary] Ready to go, Lets transmute!"); var item = GetBackPackRares(types).First(); var itemName = item.Name; var itemAnnId = item.AnnId; var itemInternalName = item.InternalName; await Transmute.Execute(item, TransmuteRecipe.UpgradeRareItem); await Coroutine.Sleep(1500); var newItem = InventoryManager.Backpack.FirstOrDefault(i => !backpackGuids.Contains(i.ACDId)); if (newItem != null) { var newLegendaryItem = Legendary.GetItemByACD(newItem); var newTrinityItem = Core.Actors.ItemByAnnId(newItem.AnnId); ItemEvents.FireItemCubed(newTrinityItem); if (newTrinityItem.IsPrimalAncient) { Core.Logger.Warn($"[CubeRaresToLegendary] Upgraded Rare '{itemName}' ---> '{newLegendaryItem.Name}' ({newItem.ActorSnoId}) PRIMAL!~"); } else { Core.Logger.Log($"[CubeRaresToLegendary] Upgraded Rare '{itemName}' ---> '{newLegendaryItem.Name}' ({newItem.ActorSnoId})"); } } else { Core.Logger.Log("[CubeRaresToLegendary] Failed to upgrade Item '{0}' {1} DynId={2} HasBackpackMaterials={3}", itemName, itemInternalName, itemAnnId, HasMaterialsRequired); } Core.Inventory.InvalidAnnIds.Add(itemAnnId); } else { Core.Logger.Log("[CubeRaresToLegendary] Oh no! Out of materials!"); return(true); } await Coroutine.Sleep(500); await Coroutine.Yield(); } return(true); }