Skip to content

Commit 36c2e71

Browse files
author
Justin
committed
Added support for parsing game item neutral drops and cosmetic item static attributes.
1 parent 049a232 commit 36c2e71

File tree

5 files changed

+65
-2
lines changed

5 files changed

+65
-2
lines changed

src/SourceSchemaParser/DOTA2/DotaItemAbilitySchemaItem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,9 @@ public DotaItemAbilitySchemaItem()
138138

139139
[JsonProperty("ItemDisassembleRule")]
140140
public string ItemDisassembleRule { get; set; }
141+
142+
[JsonProperty("ItemIsNeutralDrop")]
143+
[JsonConverter(typeof(StringToNullableBoolJsonConverter))]
144+
public bool? ItemIsNeutralDrop { get; set; }
141145
}
142146
}

src/SourceSchemaParser/DOTA2/DotaSchemaItem.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ internal class DotaSchemaItem : SchemaItem
3434
[JsonConverter(typeof(DotaSchemaItemBundleJsonConverter))]
3535
[JsonProperty("bundle")]
3636
public IList<string> BundledItems { get; set; }
37+
38+
[JsonConverter(typeof(DotaSchemaItemStaticAttributeJsonConverter))]
39+
[JsonProperty("static_attributes")]
40+
public IList<DotaSchemaItemStaticAttribute> StaticAttributes { get; set; }
41+
}
42+
43+
public class DotaSchemaItemStaticAttribute
44+
{
45+
[JsonProperty("attribute_class")]
46+
public string Class { get; set; }
47+
48+
[JsonProperty("value")]
49+
public string Value { get; set; }
3750
}
3851

3952
public class DotaSchemaItemPriceInfo

src/SourceSchemaParser/DotaSchemaMapperProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public DotaSchemaMapperProfile()
2323
CreateMap<DotaSchemaItemTool, SchemaItemToolModel>();
2424
CreateMap<DotaSchemaItemToolUsage, SchemaItemToolUsageModel>();
2525
CreateMap<DotaSchemaItemPriceInfo, SchemaItemPriceInfoModel>();
26+
CreateMap<DotaSchemaItemStaticAttribute, SchemaItemStaticAttributeModel>();
2627
CreateMap<DotaItemAbilitySchemaItem, ItemAbilitySchemaItemModel>();
2728
CreateMap<DotaAbilitySpecialSchemaItem, AbilitySpecialSchemaItemModel>();
2829
CreateMap<DotaAbilitySchemaItem, AbilitySchemaItemModel>();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
using Newtonsoft.Json.Linq;
5+
using System.Reflection;
6+
using SourceSchemaParser.DOTA2;
7+
8+
namespace SourceSchemaParser.JsonConverters
9+
{
10+
internal class DotaSchemaItemStaticAttributeJsonConverter : JsonConverter
11+
{
12+
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
13+
{
14+
throw new NotImplementedException();
15+
}
16+
17+
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
18+
{
19+
if (reader.TokenType == JsonToken.Null)
20+
{
21+
return null;
22+
}
23+
24+
JToken t = JToken.Load(reader);
25+
26+
List<DotaSchemaItemStaticAttribute> attributes = new List<DotaSchemaItemStaticAttribute>();
27+
28+
var attributeProperties = t.Children<JProperty>();
29+
foreach (var attributesProperty in attributeProperties)
30+
{
31+
var attribute = attributesProperty.Value.ToObject<DotaSchemaItemStaticAttribute>();
32+
attributes.Add(attribute);
33+
}
34+
35+
return attributes;
36+
}
37+
38+
public override bool CanWrite { get { return false; } }
39+
40+
public override bool CanConvert(Type objectType)
41+
{
42+
return typeof(IList<DotaSchemaItemStaticAttribute>).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo());
43+
}
44+
}
45+
}

src/SourceSchemaParser/SourceSchemaParser.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>Parses Valve Source Engine game schema files into easy to use object oriented structures.</Description>
5-
<VersionPrefix>3.0.2</VersionPrefix>
5+
<VersionPrefix>3.0.3</VersionPrefix>
66
<Authors>Justin Skiles</Authors>
77
<AssemblyName>SourceSchemaParser</AssemblyName>
88
<PackageId>SourceSchemaParser</PackageId>
@@ -14,7 +14,7 @@
1414
<ItemGroup>
1515
<PackageReference Include="automapper" Version="9.0.0" />
1616
<PackageReference Include="newtonsoft.json" Version="12.0.3" />
17-
<PackageReference Include="SteamWebAPI2" Version="4.1.1" />
17+
<PackageReference Include="SteamWebAPI2" Version="4.1.3" />
1818
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
1919
</ItemGroup>
2020

0 commit comments

Comments
 (0)