Skip to content

Commit

Permalink
add spell components to character info
Browse files Browse the repository at this point in the history
  • Loading branch information
jkisor committed Oct 30, 2021
1 parent 0e0a2a4 commit 98f721e
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,34 @@ internal static void GetCharacterInfo()
req.Remove(req.Length - 1, 1);
req.Append("},");

// Components

string components_format = "\"{0}\":{{\"name\":\"{1}\",\"value\":{2}},";
req.Append("\"components\":{");

var componentNamesByKey = new Dictionary<string, string>
{
{ "lead", "Lead Scarab"},
{ "iron", "Iron Scarab"},
{ "copper", "Copper Scarab"},
{ "silver", "Silver Scarab"},
{ "gold", "Gold Scarab"},
{ "pyreal", "Pyreal Scarab"},
{ "platinum", "Platinum Scarab"},
{ "diamond", "Diamond Scarab"},
{ "mana", "Mana Scarab"},
{ "dark", "Dark Scarab"},
{ "prismatic", "Prismatic Taper"}
};

foreach (var (key, name) in componentNamesByKey)
{
int count = GetItemInventoryCount(name);
req.AppendFormat(components_format, key, name, count.ToString());
}
req.Remove(req.Length - 1, 1);
req.Append("},");


// Monarch & Patron Information
// We wrap in try/catch because AllegianceInfoWrapper behaves oddly (Is not null when it should be? Not sure on this.)
Expand Down Expand Up @@ -496,6 +524,54 @@ internal static void GetCharacterInfo()
}
}

internal static int GetItemInventoryCount(string itemName)
{
List<int> packList = new List<int>();
int tmpCount = 0;
foreach (WorldObject worldObject in MyCore.WorldFilter.GetByContainer(MyCore.CharacterFilter.Id))
{
if (itemName.Equals(worldObject.Name, StringComparison.Ordinal))
{
if (worldObject.Values(LongValueKey.StackCount) > 1)
{
tmpCount += worldObject.Values(LongValueKey.StackCount);
}
else
{
tmpCount = tmpCount + 1;
}
}
if (worldObject.Category == 512)
{
packList.Add(worldObject.Id);
}

}

if (packList.Count > 0)
{
foreach (int packID in packList)
{
foreach (WorldObject worldObject in MyCore.WorldFilter.GetByContainer(packID))
{
if (itemName.Equals(worldObject.Name, StringComparison.Ordinal))
{
if (worldObject.Values(LongValueKey.StackCount) > 1)
{
tmpCount += worldObject.Values(LongValueKey.StackCount);
}
else
{
tmpCount = tmpCount + 1;
}
}
}
}
}

return (tmpCount);
}

internal static void SendCharacterInfo(string message)
{
Uri sendUrl;
Expand Down

0 comments on commit 98f721e

Please sign in to comment.