Heroes.Element 1.0.2

dotnet add package Heroes.Element --version 1.0.2
                    
NuGet\Install-Package Heroes.Element -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Heroes.Element" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Heroes.Element" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Heroes.Element" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Heroes.Element --version 1.0.2
                    
#r "nuget: Heroes.Element, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Heroes.Element@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Heroes.Element&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Heroes.Element&version=1.0.2
                    
Install as a Cake Tool

Heroes Element

Build Release NuGet

Heroes Element is a .NET library to read the JSON files from Heroes Data Parser and provides an API to access the data with multi-localization support.

This library only supports JSON files generated from Heroes Data Parser v5.0.0 or later.

The json files are also available in the Heroes Data repository.

Usage

There is a <data-file-name>DataDocument class for each json data file. Each provides a Load method that accepts a JsonDocument for the data file.

Example of loading the herodata file.

// load the data file
using FileStream dataFile = File.OpenRead("herodata_97039_enus.json");
using HeroDataDocument dataDocument = HeroDataDocument.Load(JsonDocument.Parse(dataFile));

// get the meta properties
MetaDataProperties metaDataProperties = dataDocument.Meta;

// get hero data for a specific hero
Hero heroData = dataDocument.GetElementById("Alarak");

// get some properties
string? attributeId = heroData.AttributeId;
GameStringText? name =  heroData.Name;
GameStringText? description = heroData.Description;
IDictionary<AbilityTier, IList<Ability>> abilities = heroData.Abilities;
IDictionary<TalentTier, IList<Talent>> talents = heroData.Talents;

Or if the data file's meta.localizedText property is set to Extracted, a gamestrings file may be loaded in.

using FileStream dataFile = File.OpenRead("herodata_97039_enus.json");
using FileStream gamestringsFile = File.OpenRead("gamestrings_97039_eses.json");
using GameStringsDocument gameStringsDocument = GameStringsDocument.Load(JsonDocument.Parse(gamestringsFile));

// pass in the gameStringsDocument as the second argument
using HeroDataDocument dataDocument = HeroDataDocument.Load(JsonDocument.Parse(dataFile), gameStringsDocument);

Updating the GameStringsTexts

To update a data object's gamestrings to a different gamestrings file, such as a different locale, load the gamestrings file via the GameStringsDocument class.

// load a gamestrings file
using FileStream gamestringsFile = File.OpenRead("gamestrings_97039_frfr.json");
using GameStringsDocument gameStringsDocument = GameStringsDocument.Load(JsonDocument.Parse(gamestringsFile));

// get the meta properties
MetaGameStringProperties metaGameStringProperties = gameStringsDocument.Meta;

// update an existing heroData instance with the new gamestrings
gameStringsDocument.UpdateGameStringTexts(heroData);

// Or, use the extension method
heroData.UpdateGameStringTexts(gameStringsDocument);

Developing

To build and compile the code, it is recommended to use the latest version of Visual Studio 2026 or Visual Studio Code.

Another option is to use the dotnet CLI tools from the latest .NET SDK.

License

MIT license

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.