Merge branch 'main' of https://github.com/sp-tarkov/server-csharp
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Core.Models.Eft.Common.Tables;
|
using Core.Models.Eft.Common.Tables;
|
||||||
|
using Core.Utils.Json.Converters;
|
||||||
|
|
||||||
namespace Core.Models.Eft.Common;
|
namespace Core.Models.Eft.Common;
|
||||||
|
|
||||||
public class PmcData : BotBase
|
public class PmcData : BotBase
|
||||||
{
|
{
|
||||||
[JsonPropertyName("Prestige")]
|
[JsonPropertyName("Prestige")]
|
||||||
|
[JsonConverter(typeof(ArrayToObjectFactoryConverter))]
|
||||||
public Tables.Prestige Prestige { get; set; }
|
public Tables.Prestige Prestige { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ public class Info
|
|||||||
public string? Voice { get; set; }
|
public string? Voice { get; set; }
|
||||||
public double? Level { get; set; }
|
public double? Level { get; set; }
|
||||||
public double? Experience { get; set; }
|
public double? Experience { get; set; }
|
||||||
|
[JsonConverter(typeof(StringToNumberFactoryConverter))]
|
||||||
public long? RegistrationDate { get; set; }
|
public long? RegistrationDate { get; set; }
|
||||||
public string? GameVersion { get; set; }
|
public string? GameVersion { get; set; }
|
||||||
public double? AccountType { get; set; }
|
public double? AccountType { get; set; }
|
||||||
@@ -181,6 +182,7 @@ public class Info
|
|||||||
|
|
||||||
[JsonPropertyName("isMigratedSkills")]
|
[JsonPropertyName("isMigratedSkills")]
|
||||||
public bool? IsMigratedSkills { get; set; }
|
public bool? IsMigratedSkills { get; set; }
|
||||||
|
public double? PrestigeLevel { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BotInfoSettings
|
public class BotInfoSettings
|
||||||
@@ -219,6 +221,7 @@ public class Customization
|
|||||||
public string? Body { get; set; }
|
public string? Body { get; set; }
|
||||||
public string? Feet { get; set; }
|
public string? Feet { get; set; }
|
||||||
public string? Hands { get; set; }
|
public string? Hands { get; set; }
|
||||||
|
public string? DogTag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BotBaseHealth
|
public class BotBaseHealth
|
||||||
@@ -518,6 +521,7 @@ public class Hideout
|
|||||||
|
|
||||||
[JsonPropertyName("sptUpdateLastRunTimestamp")]
|
[JsonPropertyName("sptUpdateLastRunTimestamp")]
|
||||||
public long? SptUpdateLastRunTimestamp { get; set; }
|
public long? SptUpdateLastRunTimestamp { get; set; }
|
||||||
|
public Dictionary<string, string>? Customization { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HideoutCounters
|
public class HideoutCounters
|
||||||
@@ -751,6 +755,7 @@ public class Bonus
|
|||||||
public string? Id { get; set; }
|
public string? Id { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("type")]
|
[JsonPropertyName("type")]
|
||||||
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
public BonusType? Type { get; set; }
|
public BonusType? Type { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("templateId")]
|
[JsonPropertyName("templateId")]
|
||||||
|
|||||||
@@ -197,6 +197,10 @@ public class TraderRepair
|
|||||||
[JsonPropertyName("quality")]
|
[JsonPropertyName("quality")]
|
||||||
[JsonConverter(typeof(StringToNumberFactoryConverter))]
|
[JsonConverter(typeof(StringToNumberFactoryConverter))]
|
||||||
public double? Quality { get; set; }
|
public double? Quality { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("price_rate")]
|
||||||
|
public double? PriceRate { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TraderAssort
|
public class TraderAssort
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace Core.Models.Spt.Services;
|
|||||||
public class TraderServiceModel
|
public class TraderServiceModel
|
||||||
{
|
{
|
||||||
[JsonPropertyName("serviceType")]
|
[JsonPropertyName("serviceType")]
|
||||||
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
public TraderServiceType? ServiceType { get; set; }
|
public TraderServiceType? ServiceType { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("itemsToPay")]
|
[JsonPropertyName("itemsToPay")]
|
||||||
@@ -27,5 +28,5 @@ public class TraderServiceRequirementsModel
|
|||||||
public List<string>? CompletedQuests { get; set; }
|
public List<string>? CompletedQuests { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("standings")]
|
[JsonPropertyName("standings")]
|
||||||
public Dictionary<string, int>? Standings { get; set; }
|
public Dictionary<string, double>? Standings { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Core.Annotations;
|
using Core.Annotations;
|
||||||
@@ -11,6 +10,8 @@ public class ImporterUtil
|
|||||||
{
|
{
|
||||||
private readonly FileUtil _fileUtil;
|
private readonly FileUtil _fileUtil;
|
||||||
|
|
||||||
|
private readonly HashSet<string> filesToIgnore = ["bearsuits.json", "usecsuits.json", "archivedquests.json"];
|
||||||
|
|
||||||
public ImporterUtil(FileUtil fileUtil)
|
public ImporterUtil(FileUtil fileUtil)
|
||||||
{
|
{
|
||||||
_fileUtil = fileUtil;
|
_fileUtil = fileUtil;
|
||||||
@@ -39,8 +40,7 @@ public class ImporterUtil
|
|||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
if (_fileUtil.GetFileExtension(file) != "json") continue;
|
if (_fileUtil.GetFileExtension(file) != "json") continue;
|
||||||
// to skip ArchivedQuests.json
|
if (filesToIgnore.Contains(Path.GetFileName(file).ToLower())) continue;
|
||||||
if (file.ToLower().Contains("archived")) continue;
|
|
||||||
tasks.Add(
|
tasks.Add(
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,24 @@ public class StringToNumberFactoryConverter : JsonConverterFactory
|
|||||||
var value = reader.GetString();
|
var value = reader.GetString();
|
||||||
if (string.IsNullOrWhiteSpace(value))
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
return default;
|
return default;
|
||||||
goto case JsonTokenType.Number;
|
var type = typeToConvert;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (typeToConvert.IsGenericType &&
|
||||||
|
typeToConvert.GetGenericTypeDefinition() == typeof(Nullable<>))
|
||||||
|
{
|
||||||
|
type = typeToConvert.GenericTypeArguments[0];
|
||||||
|
}
|
||||||
|
return (T) type.GetMethods().First(m =>
|
||||||
|
m.Name == "Parse" && m.GetParameters().Length == 1 &&
|
||||||
|
m.GetParameters().First().ParameterType == typeof(string)).Invoke(null, [value]);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Tried to convert {value} into {type.Name} but failed to parse it, null value will be used instead.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
case JsonTokenType.Number:
|
case JsonTokenType.Number:
|
||||||
using (var jsonDocument = JsonDocument.ParseValue(ref reader))
|
using (var jsonDocument = JsonDocument.ParseValue(ref reader))
|
||||||
{
|
{
|
||||||
@@ -46,4 +63,4 @@ public class StringToNumberFactoryConverter : JsonConverterFactory
|
|||||||
JsonSerializer.Serialize(writer, value, options);
|
JsonSerializer.Serialize(writer, value, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user