public ItemInfo( Item item, D2Unit owner, UnitReader unitReader, IStringReader stringReader, IInventoryReader inventoryReader ) { Class = item.Unit.eClass; ItemName = unitReader.GetFullItemName(item); ItemBaseName = BaseItemName(item, unitReader); QualityColor = QualityColorDefault(item); Properties = unitReader.GetMagicalStrings(item, owner, inventoryReader); Location = item.ItemData.BodyLoc; // Backward compatibility for D2ID: // TODO: add Slug/Image/EnglishBaseName or something like that, D2ID currently uses ItemName/BaseItem for // displaying images, which doesnt work for languages other than english, so BaseItem will be // the english version, to show at least some item. also Quality is set to "YELLOW" in case of // unique and set, if game is not english, so that D2ID falls back to the // BaseItem img and shows the "unique" / "set" name above the BaseItem if (stringReader.Language == Language.English) { BaseItem = ItemBaseName; Quality = QualityColor; } else { BaseItem = BaseItemNameFallback(item, unitReader); Quality = QualityColorFallback(item); } }
void CleanUpDataReaders() { reader?.Dispose(); reader = null; memory = null; inventoryReader = null; unitReader = null; skillReader = null; }
void CreateReaders() { stringReader = new StringReader(reader, memory); skillReader = new SkillReader(reader, memory); // note: readers need to be recreated everytime before read.. at least unitReader // unitReader fails sometimes... if this is not done .. why? not sure yet ~_~ unitReader = new UnitReader(reader, memory, stringReader, skillReader); inventoryReader = new InventoryReader(reader, unitReader); }
private static bool MatchesStartingItems(D2Unit p, IInventoryReader inventoryReader) { int[] list = ( from item in inventoryReader.EnumerateInventoryForward(p) select item.Unit.eClass ).ToArray(); return(list.SequenceEqual(StartingItems[(CharacterClass)p.eClass])); }
public static bool IsNewChar( D2Unit unit, UnitReader unitReader, IInventoryReader inventoryReader, ISkillReader skillReader ) { return(MatchesStartingProps(unit, unitReader) && MatchesStartingItems(unit, inventoryReader) && MatchesStartingSkills(unit, skillReader)); }
public List <string> GetMagicalStrings(Item item, D2Unit owner, IInventoryReader inventoryReader) { List <D2Stat> magicalStats = GetMagicalStats(item, inventoryReader); if (magicalStats.Count == 0) { return(new List <string>(0)); } // Perform special handling for some stats such as damage ranges. // Example: "1-80 lightning damage" comes from 2 stats. var rangeData = new RangeStatData(stringReader, magicalStats); string getDescription(D2Stat stat) { if (rangeData.TryHandleStat(stat, out string description)) { return(description); } // If not handled specially, do default handling. return(GetStatPropertyDescription(magicalStats, stat, owner)); } // Only get stat descriptions for stat identifiers contained in the opNestings array. // This also orders stats into the same order that the game displays the stats. var properties = (from op in opNestings from stat in magicalStats where stat.LoStatID == op let description = getDescription(stat) where description != null // Get the property list in reverse (d2 builds them backwards). select description).Reverse().ToList(); // Check for sockets. int?socketCount = GetStatValue(item.Unit, StatIdentifier.SocketCount); if (socketCount.HasValue) { // TODO: use correct language (from the game) instead of hardcoded "Socketed" string sockets = string.Format("Socketed ({0})", socketCount.Value); properties.Add(sockets); } return(properties); }
public static bool DetermineIfNewChar( D2Unit unit, UnitReader unitReader, IInventoryReader inventoryReader, List <SkillInfo> skills ) { if (!MatchesStartingProps(unit, unitReader)) { Logger.Info("Starting Props don't match"); return(false); } if (!MatchesStartingItems(unit, inventoryReader)) { Logger.Info("Starting Items don't match"); return(false); } if (!MatchesStartingSkills(unit, skills)) { Logger.Info("Starting Skills don't match"); return(false); } return(true); }
private List <D2Stat> GetMagicalStats(Item item, IInventoryReader inventoryReader) { // check if item has any stats, otherwise the other stuff doesnt work List <D2Stat> itemStats = GetStats(item.Unit); if (itemStats.Count == 0) { return(itemStats); } // Combine stats in different states. // TODO: why find out why 16 is hardcoded here List <D2Stat> stats = new List <D2Stat>(16); CombineNodeStats(stats, FindStatListNode(item.Unit, 0x00)); CombineNodeStats(stats, FindStatListNode(item.Unit, 0xAB)); foreach (Item socketedItem in GetSocketedItems(item, inventoryReader)) { CombineNodeStats(stats, FindStatListNode(socketedItem.Unit, 0x00)); } return(stats); }
public IEnumerable <Item> GetSocketedItems(Item item, IInventoryReader inventoryReader) { return(inventoryReader.EnumerateInventoryForward(item.Unit)); }
public InventoryController(IInventoryReader inventoryReader) { this.inventoryReader = inventoryReader; }