Skip to content

Commit

Permalink
Updated Maxroll imports to work with new format.
Browse files Browse the repository at this point in the history
  • Loading branch information
josdemmers committed Jan 30, 2024
1 parent 1af1802 commit 442da7c
Show file tree
Hide file tree
Showing 15 changed files with 593 additions and 149 deletions.
20 changes: 20 additions & 0 deletions D4Companion.Entities/MaxrollBuild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace D4Companion.Entities
{
public class MaxrollBuild
{
public MaxrollBuildDataJson Data { get; set; } = new();

public string Date { get; set; } = string.Empty;

public string Id { get; set; } = string.Empty;

public string Name { get; set; } = string.Empty;
}
}
20 changes: 0 additions & 20 deletions D4Companion.Entities/MaxrollBuildDescription.cs

This file was deleted.

66 changes: 66 additions & 0 deletions D4Companion.Entities/MaxrollBuildJson.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace D4Companion.Entities
{
public class MaxrollBuildJson
{
[JsonPropertyName("data")]
public string Data { get; set; } = string.Empty;

[JsonPropertyName("date")]
public string Date { get; set; } = string.Empty;

[JsonPropertyName("id")]
public string Id { get; set; } = string.Empty;

[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
}

public class MaxrollBuildDataJson
{
[JsonPropertyName("profiles")]
public List<MaxrollBuildDataProfileJson> Profiles { get; set; } = new();

[JsonPropertyName("items")]
public Dictionary<int, MaxrollBuildDataItemJson> Items { get; set; } = new();
}

public class MaxrollBuildDataProfileJson
{
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;

[JsonPropertyName("items")]
public Dictionary<int, int> Items { get; set; } = new(); // <itemslot, item>
}

public class MaxrollBuildDataItemJson
{
[JsonPropertyName("id")]
public string Id { get; set; } = string.Empty;

[JsonPropertyName("explicits")]
public List<MaxrollBuildDataItemExplicitJson> Explicits { get; set; } = new();

[JsonPropertyName("legendaryPower")]
public MaxrollBuildDataItemLegendaryPowerJson LegendaryPower { get; set; } = new();
}

public class MaxrollBuildDataItemExplicitJson
{
[JsonPropertyName("nid")]
public int Nid { get; set; }
}

public class MaxrollBuildDataItemLegendaryPowerJson
{
[JsonPropertyName("nid")]
public int Nid { get; set; }
}
}
14 changes: 14 additions & 0 deletions D4Companion.Events/BuildsManagerEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D4Companion.Events
{
public class MaxrollBuildsLoadedEvent : PubSubEvent
{

}
}
2 changes: 2 additions & 0 deletions D4Companion.Interfaces/IAffixManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public interface IAffixManager
void AddAspect(AspectInfo aspectInfo, string itemType);
void AddSigil(SigilInfo sigilInfo, string itemType);
string GetAffixDescription(string affixId);
string GetAffixId(int affixSno);
string GetAspectDescription(string aspectId);
string GetAspectId(int aspectSno);
string GetAspectName(string aspectId);
string GetSigilDescription(string sigilId);
string GetSigilName(string sigilId);
Expand Down
4 changes: 3 additions & 1 deletion D4Companion.Interfaces/IBuildsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ namespace D4Companion.Interfaces
{
public interface IBuildsManager
{
List<Dictionary<string, string>> MaxrollBuilds { get; }
List<MaxrollBuild> MaxrollBuilds { get; }

void CreatePresetFromMaxrollBuild(MaxrollBuild maxrollBuild, string profile);
void DownloadMaxrollBuild(string name);
void RemoveMaxrollBuild(string buildId);
}
}
45 changes: 45 additions & 0 deletions D4Companion.Localization/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions D4Companion.Localization/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,19 @@
<data name="rsCapClearLog" xml:space="preserve">
<value>Clear log</value>
</data>
<data name="rsTooltipAddMaxrollBuild" xml:space="preserve">
<value>Add Maxroll Build</value>
</data>
<data name="rsTooltipAdd" xml:space="preserve">
<value>Add</value>
</data>
<data name="rsTooltipRemove" xml:space="preserve">
<value>Remove</value>
</data>
<data name="rsTooltipMaxrollWeb" xml:space="preserve">
<value>Visit Maxroll.com</value>
</data>
<data name="rsTooltipUpdate" xml:space="preserve">
<value>Update</value>
</data>
</root>
26 changes: 26 additions & 0 deletions D4Companion.Services/AffixManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,19 @@ public string GetAffixDescription(string affixId)
}
}

public string GetAffixId(int affixSno)
{
var affixInfo = _affixes.FirstOrDefault(a => a.IdSno == affixSno);
if (affixInfo != null)
{
return affixInfo.IdName;
}
else
{
return string.Empty;
}
}

public string GetAspectDescription(string aspectId)
{
var aspectInfo = _aspects.FirstOrDefault(a => a.IdName.Equals(aspectId));
Expand All @@ -328,6 +341,19 @@ public string GetAspectDescription(string aspectId)
}
}

public string GetAspectId(int aspectSno)
{
var aspectInfo = _aspects.FirstOrDefault(a => a.IdSno == aspectSno);
if (aspectInfo != null)
{
return aspectInfo.IdName;
}
else
{
return string.Empty;
}
}

public string GetAspectName(string aspectId)
{
var aspectInfo = _aspects.FirstOrDefault(a => a.IdName.Equals(aspectId));
Expand Down
Loading

0 comments on commit 442da7c

Please sign in to comment.