Merge pull request #189 from hulkhan22/chore/objects
chore: Change 'object' types into specific types #148
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Utils.Json.Converters;
|
||||
|
||||
@@ -20,7 +21,10 @@ public record PmcData : BotBase
|
||||
set;
|
||||
}
|
||||
|
||||
public object CheckedChambers
|
||||
/// <summary>
|
||||
/// Returns the list of IDs of the weapons, which the player has checked the chamber of in the last raid.
|
||||
/// </summary>
|
||||
public List<string> CheckedChambers
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
||||
@@ -169,11 +169,11 @@ public record ItemLocation
|
||||
}
|
||||
|
||||
[JsonPropertyName("r")]
|
||||
public object? R
|
||||
public int R
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} // TODO: Can be string or number
|
||||
}
|
||||
|
||||
[JsonPropertyName("isSearched")]
|
||||
public bool? IsSearched
|
||||
@@ -186,11 +186,11 @@ public record ItemLocation
|
||||
/// SPT property?
|
||||
/// </summary>
|
||||
[JsonPropertyName("rotation")]
|
||||
public object? Rotation
|
||||
public bool? Rotation
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} // TODO: Can be string or boolean
|
||||
}
|
||||
}
|
||||
|
||||
public record Upd
|
||||
@@ -668,7 +668,8 @@ public record UpdDogtag
|
||||
}
|
||||
|
||||
[JsonPropertyName("Side")]
|
||||
public object? Side
|
||||
[JsonConverter(typeof(DogtagSideConverter))]
|
||||
public DogtagSide? Side
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
||||
@@ -179,11 +179,11 @@ public record Quest
|
||||
/// Becomes 'AppearStatus' inside client
|
||||
/// </summary>
|
||||
[JsonPropertyName("status")]
|
||||
public object? Status
|
||||
public int? Status
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} // TODO: string | number
|
||||
}
|
||||
|
||||
[JsonPropertyName("KeyQuest")]
|
||||
public bool? KeyQuest
|
||||
@@ -447,11 +447,11 @@ public record QuestCondition
|
||||
}
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
public object? Type
|
||||
public string? Type
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} // TODO: boolean | string
|
||||
}
|
||||
|
||||
[JsonPropertyName("status")]
|
||||
public List<QuestStatusEnum>? Status
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace SPTarkov.Server.Core.Models.Enums;
|
||||
|
||||
public enum DogtagSide
|
||||
{
|
||||
/// <summary>
|
||||
/// This is for the dogtag equipped by the player, which shows up as 0 (integer) on the profile json.
|
||||
/// </summary>
|
||||
NotApplicable,
|
||||
|
||||
Usec,
|
||||
Bear
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
|
||||
namespace SPTarkov.Server.Core.Utils.Json.Converters;
|
||||
|
||||
public class DogtagSideConverter : JsonConverter<DogtagSide>
|
||||
{
|
||||
public override DogtagSide Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
return DogtagSide.NotApplicable;
|
||||
}
|
||||
|
||||
var value = reader.GetString();
|
||||
return value != null ? Enum.Parse<DogtagSide>(value) : DogtagSide.NotApplicable;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, DogtagSide value, JsonSerializerOptions options)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case DogtagSide.NotApplicable:
|
||||
writer.WriteNumberValue(0);
|
||||
break;
|
||||
case DogtagSide.Usec:
|
||||
case DogtagSide.Bear:
|
||||
writer.WriteStringValue(value.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user