public static JsonItem GetJsonItem(PlayerHeldItem item) { // TODO: Modifiers bool isCloudSynced = false; object[] transferUrl = { "", "", "", "" }; string uniqueIdentifier; if (item is PlayerItem pi) { transferUrl = new object[] { pi.BaseRecord, pi.PrefixRecord, pi.SuffixRecord, pi.MateriaRecord }; isCloudSynced = pi.IsCloudSynchronized; uniqueIdentifier = $"PI/{pi.Id}/{pi.CloudId}"; } else if (item is BuddyItem bi) { // TODO: Remove this, buddy items are never transferable. Gotta provide a better unique id. uniqueIdentifier = $"BI/{bi.BuddyId}/{bi.RemoteItemId}"; } else if (item is RecipeItem) { uniqueIdentifier = $"RI/{item.BaseRecord}"; } else if (item is AugmentationItem) { uniqueIdentifier = $"AI/{item.BaseRecord}"; } else { uniqueIdentifier = $"UK/{item.BaseRecord}"; } ItemTypeDto type; string extras = string.Empty; if (item.IsRecipe) { type = ItemTypeDto.Recipe; } else if (!string.IsNullOrEmpty(item.Stash)) { type = ItemTypeDto.Buddy; } else if (item is PlayerItem) { type = ItemTypeDto.Player; } else if (item is AugmentationItem augmentationItem) { type = ItemTypeDto.Augmentation; extras = ItemOperationsUtility.TranslateFaction( RuntimeSettings.Language, augmentationItem.Tags.FirstOrDefault(m => m.Stat == "factionSource")?.TextValue ?? string.Empty ); } else { type = ItemTypeDto.Unknown; } var json = new JsonItem { UniqueIdentifier = uniqueIdentifier, BaseRecord = item.BaseRecord ?? string.Empty, URL = transferUrl, Icon = item.Bitmap ?? string.Empty, Name = PureItemName(item.Name) ?? string.Empty, Quality = item.Rarity ?? string.Empty, Level = item.MinimumLevel, Socket = GetSocketFromItem(item?.Name) ?? string.Empty, NumItems = (uint)item.Count, InitialNumItems = (uint)item.Count, PetStats = item.PetStats.Select(ToJsonStat).ToHashSet().ToList(), BodyStats = item.BodyStats.Select(ToJsonStat).ToHashSet().ToList(), HeaderStats = item.HeaderStats.Select(ToJsonStat).ToHashSet().ToList(), Type = type, HasRecipe = item.HasRecipe, Buddies = item.Buddies.ToArray(), Skill = item.Skill != null?GetJsonSkill(item.Skill) : null, GreenRarity = (int)item.PrefixRarity, HasCloudBackup = isCloudSynced, Slot = SlotTranslator.Translate(RuntimeSettings.Language, item.Slot ?? ""), Extras = extras, IsMonsterInfrequent = item.ModifiedSkills.Any(s => s.IsMonsterInfrequent), }; var modifiedSkills = item.ModifiedSkills; foreach (var modifiedSkill in modifiedSkills) { var translated = modifiedSkill.Translated; foreach (var stat in translated.Select(ToJsonStat)) { json.BodyStats.Add(stat); } if (translated.Count == 0 && !(modifiedSkill.Class == null || modifiedSkill.Tier == null)) { string[] uri = json.URL.Select(o => o.ToString()).ToArray(); var error = $@"Could not translate skill-modifier on: '{item.Name}', {json.BaseRecord} - {string.Join(";", uri)}"; ExceptionReporter.ReportIssue(error); Logger.Debug($"Could not translate skill-modifier stats for \"{item.Name}\""); } } return(json); }
private static JsonItem GetJsonItem(PlayerHeldItem item) { // TODO: Modifiers bool isCloudSynced = false; object[] id = { item.Id, "", "", "", "" }; if (item is PlayerItem pi) { id = new object[] { pi.Id, pi.BaseRecord, pi.PrefixRecord, pi.SuffixRecord, pi.MateriaRecord }; isCloudSynced = !string.IsNullOrWhiteSpace(pi.AzureUuid); } ItemTypeDto type; string extras = string.Empty; if (item.IsRecipe) { type = ItemTypeDto.Recipe; } else if (!string.IsNullOrEmpty(item.Stash)) { type = ItemTypeDto.Buddy; } else if (item is PlayerItem) { type = ItemTypeDto.Player; } else if (item is AugmentationItem) { type = ItemTypeDto.Augmentation; extras = ItemOperationsUtility.TranslateFaction( GlobalSettings.Language, ((AugmentationItem)item).Tags.FirstOrDefault(m => m.Stat == "factionSource")?.TextValue ?? string.Empty ); } else { type = ItemTypeDto.Unknown; } var json = new JsonItem { BaseRecord = item.BaseRecord ?? string.Empty, URL = id, Icon = item.Bitmap ?? string.Empty, Name = PureItemName(item.Name) ?? string.Empty, Quality = item.Rarity ?? string.Empty, Level = item.MinimumLevel, Socket = GetSocketFromItem(item?.Name) ?? string.Empty, NumItems = item.Count, PetStats = item.PetStats.Select(m => new JsonStat { Label = m.ToString(), Extras = m.Extra?.ToString() }).ToList(), BodyStats = item.BodyStats.Select(m => new JsonStat { Label = m.ToString(), Extras = m.Extra?.ToString() }).ToList(), HeaderStats = item.HeaderStats.Select(m => new JsonStat { Label = m.ToString(), Extras = m.Extra?.ToString() }).ToList(), Type = type, HasRecipe = item.HasRecipe, Buddies = item.Buddies.ToArray(), Skill = item.Skill != null?GetJsonSkill(item.Skill) : null, GreenRarity = item.PrefixRarity, HasCloudBackup = isCloudSynced, Slot = SlotTranslator.Translate(GlobalSettings.Language, item.Slot ?? ""), Extras = extras }; var modifiedSkills = item.ModifiedSkills; foreach (var modifiedSkill in modifiedSkills) { var translated = modifiedSkill.Translated; foreach (var translatedStat in translated) { json.BodyStats.Add(new JsonStat { Label = translatedStat.ToString(), Extras = translatedStat.Extra?.ToString() }); } if (translated.Count == 0) { Logger.Debug($"Could not translate skill-modifier stats for \"{item.Name}\""); } } return(json); }
private static JsonItem GetJsonItem(PlayerHeldItem item) { // TODO: Modifiers bool isHardcore = false; bool isCloudSynced = false; object[] transferUrl = { "", "", "", "" }; string uniqueIdentifier = GetUniqueIdentifier(item); List <ItemStatInfo> replicaStats = null; var mergeIdentifier = item.BaseRecord ?? string.Empty; if (item is PlayerItem pi) { transferUrl = new object[] { pi.BaseRecord, pi.PrefixRecord, pi.SuffixRecord, pi.MateriaRecord, pi.Mod, pi.IsHardcore }; isCloudSynced = pi.IsCloudSynchronized; isHardcore = pi.IsHardcore; if (!string.IsNullOrEmpty(pi.ReplicaInfo)) { replicaStats = JsonConvert.DeserializeObject <List <ItemStatInfo> >(pi.ReplicaInfo); } mergeIdentifier += (pi.PrefixRecord ?? string.Empty) + (pi.SuffixRecord ?? string.Empty); } else if (item is BuddyItem bi) { mergeIdentifier += (bi.PrefixRecord ?? string.Empty) + (bi.SuffixRecord ?? string.Empty); if (!string.IsNullOrEmpty(bi.ReplicaInfo)) { replicaStats = JsonConvert.DeserializeObject <List <ItemStatInfo> >(bi.ReplicaInfo); } } ItemTypeDto type; string extras = item.Stash; if (item.IsRecipe) { type = ItemTypeDto.Recipe; } else if (!string.IsNullOrEmpty(item.Stash)) { type = ItemTypeDto.Buddy; } else if (item is PlayerItem) { type = ItemTypeDto.Player; } else if (item is AugmentationItem augmentationItem) { type = ItemTypeDto.Augmentation; extras = ItemOperationsUtility.TranslateFaction( RuntimeSettings.Language, augmentationItem.Tags.FirstOrDefault(m => m.Stat == "factionSource")?.TextValue ?? string.Empty ); } else { type = ItemTypeDto.Unknown; } bool skipStats = replicaStats != null; var replicaBodyStats = new List <JsonStat>(0); if (skipStats) { // Add skillz replicaBodyStats = item.BodyStats .Where(m => m.Extra != null) .Select(ToJsonStat) .ToHashSet() .ToList(); } var json = new JsonItem { UniqueIdentifier = uniqueIdentifier, MergeIdentifier = mergeIdentifier, BaseRecord = item.BaseRecord ?? string.Empty, URL = transferUrl, Icon = item.Bitmap ?? string.Empty, Name = PureItemName(item.Name) ?? string.Empty, Quality = item.Rarity ?? string.Empty, Level = item.MinimumLevel, Socket = GetSocketFromItem(item?.Name) ?? string.Empty, PetStats = skipStats ? new List <JsonStat>() : item.PetStats.Select(ToJsonStat).ToHashSet().ToList(), BodyStats = skipStats ? replicaBodyStats : item.BodyStats.Select(ToJsonStat).ToHashSet().ToList(), HeaderStats = skipStats ? new List <JsonStat>() : item.HeaderStats.Select(ToJsonStat).ToHashSet().ToList(), Type = type, HasRecipe = item.HasRecipe, Skill = (item.Skill != null && !skipStats) ? GetJsonSkill(item.Skill) : null, GreenRarity = (int)item.PrefixRarity, HasCloudBackup = isCloudSynced, Slot = SlotTranslator.Translate(RuntimeSettings.Language, item.Slot ?? ""), Extras = extras, IsMonsterInfrequent = item.ModifiedSkills.Any(s => s.IsMonsterInfrequent), IsHardcore = isHardcore, ReplicaStats = replicaStats, }; if (!skipStats) { var modifiedSkills = item.ModifiedSkills; foreach (var modifiedSkill in modifiedSkills) { var translated = modifiedSkill.Translated; foreach (var stat in translated.Select(ToJsonStat)) { json.BodyStats.Add(stat); } } } return(json); }