Merge branch 'sp-tarkov:main' into main
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Models.Eft.Common.Tables;
|
||||
|
||||
|
||||
public class Match
|
||||
{
|
||||
[JsonPropertyName("metrics")]
|
||||
public Metrics Metrics { get; set; }
|
||||
}
|
||||
|
||||
public class Metrics
|
||||
{
|
||||
[JsonPropertyName("Keys")]
|
||||
public List<int> Keys { get; set; }
|
||||
|
||||
[JsonPropertyName("NetProcessingBins")]
|
||||
public List<int> NetProcessingBins { get; set; }
|
||||
|
||||
[JsonPropertyName("RenderBins")]
|
||||
public List<int> RenderBins { get; set; }
|
||||
|
||||
[JsonPropertyName("GameUpdateBins")]
|
||||
public List<int> GameUpdateBins { get; set; }
|
||||
|
||||
[JsonPropertyName("MemoryMeasureInterval")]
|
||||
public int MemoryMeasureInterval { get; set; }
|
||||
|
||||
[JsonPropertyName("PauseReasons")]
|
||||
public List<int> PauseReasons { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Enums;
|
||||
using Core.Models.Spt.Services;
|
||||
|
||||
namespace Core.Models.Eft.Common.Tables;
|
||||
|
||||
public class Trader
|
||||
{
|
||||
[JsonPropertyName("assort")]
|
||||
public TraderAssort? Assort { get; set; }
|
||||
|
||||
[JsonPropertyName("base")]
|
||||
public TraderBase Base { get; set; }
|
||||
|
||||
[JsonPropertyName("dialogue")]
|
||||
public Dictionary<string, string[]>? Dialogue { get; set; }
|
||||
|
||||
[JsonPropertyName("questassort")]
|
||||
public Dictionary<string, Dictionary<string, string>>? QuestAssort { get; set; }
|
||||
|
||||
[JsonPropertyName("suits")]
|
||||
public List<Suit>? Suits { get; set; }
|
||||
|
||||
[JsonPropertyName("services")]
|
||||
public List<TraderServiceModel>? Services { get; set; }
|
||||
}
|
||||
|
||||
public class TraderBase
|
||||
{
|
||||
[JsonPropertyName("refreshTraderRagfairOffers")]
|
||||
public bool RefreshTraderRagfairOffers { get; set; }
|
||||
|
||||
[JsonPropertyName("_id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonPropertyName("availableInRaid")]
|
||||
public bool AvailableInRaid { get; set; }
|
||||
|
||||
[JsonPropertyName("avatar")]
|
||||
public string Avatar { get; set; }
|
||||
|
||||
[JsonPropertyName("balance_dol")]
|
||||
public decimal BalanceDollar { get; set; }
|
||||
|
||||
[JsonPropertyName("balance_eur")]
|
||||
public decimal BalanceEuro { get; set; }
|
||||
|
||||
[JsonPropertyName("balance_rub")]
|
||||
public decimal BalanceRub { get; set; }
|
||||
|
||||
[JsonPropertyName("buyer_up")]
|
||||
public bool BuyerUp { get; set; }
|
||||
|
||||
[JsonPropertyName("currency")]
|
||||
public string Currency { get; set; }
|
||||
|
||||
[JsonPropertyName("customization_seller")]
|
||||
public bool CustomizationSeller { get; set; }
|
||||
|
||||
[JsonPropertyName("discount")]
|
||||
public decimal Discount { get; set; }
|
||||
|
||||
[JsonPropertyName("discount_end")]
|
||||
public decimal DiscountEnd { get; set; }
|
||||
|
||||
[JsonPropertyName("gridHeight")]
|
||||
public int GridHeight { get; set; }
|
||||
|
||||
[JsonPropertyName("sell_modifier_for_prohibited_items")]
|
||||
public decimal? SellModifierForProhibitedItems { get; set; }
|
||||
|
||||
[JsonPropertyName("insurance")]
|
||||
public TraderInsurance Insurance { get; set; }
|
||||
|
||||
[JsonPropertyName("items_buy")]
|
||||
public ItemBuyData ItemsBuy { get; set; }
|
||||
|
||||
[JsonPropertyName("items_buy_prohibited")]
|
||||
public ItemBuyData ItemsBuyProhibited { get; set; }
|
||||
|
||||
[JsonPropertyName("isCanTransferItems")]
|
||||
public bool? IsCanTransferItems { get; set; }
|
||||
|
||||
[JsonPropertyName("transferableItems")]
|
||||
public ItemBuyData? TransferableItems { get; set; }
|
||||
|
||||
[JsonPropertyName("prohibitedTransferableItems")]
|
||||
public ItemBuyData? ProhibitedTransferableItems { get; set; }
|
||||
|
||||
[JsonPropertyName("location")]
|
||||
public string Location { get; set; }
|
||||
|
||||
[JsonPropertyName("loyaltyLevels")]
|
||||
public List<TraderLoyaltyLevel> LoyaltyLevels { get; set; }
|
||||
|
||||
[JsonPropertyName("medic")]
|
||||
public bool Medic { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("nextResupply")]
|
||||
public int NextResupply { get; set; }
|
||||
|
||||
[JsonPropertyName("nickname")]
|
||||
public string Nickname { get; set; }
|
||||
|
||||
[JsonPropertyName("repair")]
|
||||
public TraderRepair Repair { get; set; }
|
||||
|
||||
[JsonPropertyName("sell_category")]
|
||||
public List<string> SellCategory { get; set; }
|
||||
|
||||
[JsonPropertyName("surname")]
|
||||
public string Surname { get; set; }
|
||||
|
||||
[JsonPropertyName("unlockedByDefault")]
|
||||
public bool UnlockedByDefault { get; set; }
|
||||
}
|
||||
|
||||
public class ItemBuyData
|
||||
{
|
||||
[JsonPropertyName("category")]
|
||||
public List<string> Category { get; set; }
|
||||
|
||||
[JsonPropertyName("id_list")]
|
||||
public List<string> IdList { get; set; }
|
||||
}
|
||||
|
||||
public class TraderInsurance
|
||||
{
|
||||
[JsonPropertyName("availability")]
|
||||
public bool Availability { get; set; }
|
||||
|
||||
[JsonPropertyName("excluded_category")]
|
||||
public List<string> ExcludedCategory { get; set; }
|
||||
|
||||
[JsonPropertyName("max_return_hour")]
|
||||
public int MaxReturnHour { get; set; }
|
||||
|
||||
[JsonPropertyName("max_storage_time")]
|
||||
public int MaxStorageTime { get; set; }
|
||||
|
||||
[JsonPropertyName("min_payment")]
|
||||
public int MinPayment { get; set; }
|
||||
|
||||
[JsonPropertyName("min_return_hour")]
|
||||
public int MinReturnHour { get; set; }
|
||||
}
|
||||
|
||||
public class TraderLoyaltyLevel
|
||||
{
|
||||
[JsonPropertyName("buy_price_coef")]
|
||||
public int BuyPriceCoefficient { get; set; }
|
||||
|
||||
[JsonPropertyName("exchange_price_coef")]
|
||||
public int ExchangePriceCoefficient { get; set; }
|
||||
|
||||
[JsonPropertyName("heal_price_coef")]
|
||||
public int HealPriceCoefficient { get; set; }
|
||||
|
||||
[JsonPropertyName("insurance_price_coef")]
|
||||
public int InsurancePriceCoefficient { get; set; }
|
||||
|
||||
[JsonPropertyName("minLevel")]
|
||||
public int MinLevel { get; set; }
|
||||
|
||||
[JsonPropertyName("minSalesSum")]
|
||||
public int MinSalesSum { get; set; }
|
||||
|
||||
[JsonPropertyName("minStanding")]
|
||||
public int MinStanding { get; set; }
|
||||
|
||||
[JsonPropertyName("repair_price_coef")]
|
||||
public int RepairPriceCoefficient { get; set; }
|
||||
}
|
||||
|
||||
public class TraderRepair
|
||||
{
|
||||
[JsonPropertyName("availability")]
|
||||
public bool Availability { get; set; }
|
||||
|
||||
[JsonPropertyName("currency")]
|
||||
public string Currency { get; set; }
|
||||
|
||||
[JsonPropertyName("currency_coefficient")]
|
||||
public double CurrencyCoefficient { get; set; }
|
||||
|
||||
[JsonPropertyName("excluded_category")]
|
||||
public List<string> ExcludedCategory { get; set; }
|
||||
|
||||
[JsonPropertyName("excluded_id_list")]
|
||||
public List<string> ExcludedIdList { get; set; } // Doesn't exist in client object
|
||||
|
||||
[JsonPropertyName("quality")]
|
||||
public int Quality { get; set; }
|
||||
}
|
||||
|
||||
public class TraderAssort
|
||||
{
|
||||
[JsonPropertyName("nextResupply")]
|
||||
public int NextResupply { get; set; }
|
||||
|
||||
[JsonPropertyName("items")]
|
||||
public List<Item> Items { get; set; }
|
||||
|
||||
[JsonPropertyName("barter_scheme")]
|
||||
public Dictionary<string, List<List<BarterScheme>>> BarterScheme { get; set; }
|
||||
|
||||
[JsonPropertyName("loyal_level_items")]
|
||||
public Dictionary<string, int> LoyalLevelItems { get; set; }
|
||||
}
|
||||
|
||||
public class BarterScheme
|
||||
{
|
||||
[JsonPropertyName("count")]
|
||||
public int Count { get; set; }
|
||||
|
||||
[JsonPropertyName("_tpl")]
|
||||
public string Template { get; set; }
|
||||
|
||||
[JsonPropertyName("onlyFunctional")]
|
||||
public bool? OnlyFunctional { get; set; }
|
||||
|
||||
[JsonPropertyName("sptQuestLocked")]
|
||||
public bool? SptQuestLocked { get; set; }
|
||||
|
||||
[JsonPropertyName("level")]
|
||||
public int? Level { get; set; }
|
||||
|
||||
[JsonPropertyName("side")]
|
||||
public DogtagExchangeSide? Side { get; set; }
|
||||
}
|
||||
|
||||
public class Suit
|
||||
{
|
||||
[JsonPropertyName("_id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonPropertyName("externalObtain")]
|
||||
public bool ExternalObtain { get; set; }
|
||||
|
||||
[JsonPropertyName("internalObtain")]
|
||||
public bool InternalObtain { get; set; }
|
||||
|
||||
[JsonPropertyName("isHiddenInPVE")]
|
||||
public bool IsHiddenInPVE { get; set; }
|
||||
|
||||
[JsonPropertyName("tid")]
|
||||
public string Tid { get; set; }
|
||||
|
||||
[JsonPropertyName("suiteId")]
|
||||
public string SuiteId { get; set; }
|
||||
|
||||
[JsonPropertyName("isActive")]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
[JsonPropertyName("requirements")]
|
||||
public SuitRequirements Requirements { get; set; }
|
||||
}
|
||||
|
||||
public class SuitRequirements
|
||||
{
|
||||
[JsonPropertyName("achievementRequirements")]
|
||||
public List<string> AchievementRequirements { get; set; }
|
||||
|
||||
[JsonPropertyName("loyaltyLevel")]
|
||||
public int LoyaltyLevel { get; set; }
|
||||
|
||||
[JsonPropertyName("profileLevel")]
|
||||
public int ProfileLevel { get; set; }
|
||||
|
||||
[JsonPropertyName("standing")]
|
||||
public int Standing { get; set; }
|
||||
|
||||
[JsonPropertyName("skillRequirements")]
|
||||
public List<string> SkillRequirements { get; set; }
|
||||
|
||||
[JsonPropertyName("questRequirements")]
|
||||
public List<string> QuestRequirements { get; set; }
|
||||
|
||||
[JsonPropertyName("itemRequirements")]
|
||||
public List<ItemRequirement> ItemRequirements { get; set; }
|
||||
|
||||
[JsonPropertyName("requiredTid")]
|
||||
public string RequiredTid { get; set; }
|
||||
}
|
||||
|
||||
public class ItemRequirement
|
||||
{
|
||||
[JsonPropertyName("count")]
|
||||
public int Count { get; set; }
|
||||
|
||||
[JsonPropertyName("_tpl")]
|
||||
public string Tpl { get; set; }
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonPropertyName("onlyFunctional")]
|
||||
public bool OnlyFunctional { get; set; }
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Core.Models.Enums;
|
||||
|
||||
public enum TraderServiceType
|
||||
{
|
||||
ExUsecLoyalty,
|
||||
ZryachiyAid,
|
||||
CultistsAid,
|
||||
BtrItemsDelivery,
|
||||
PlayerTaxi,
|
||||
BtrBotCover,
|
||||
TransitItemsDelivery
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Core.Models.Eft.Common;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
|
||||
namespace Core.Models.Spt.Server;
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Enums;
|
||||
|
||||
namespace Core.Models.Spt.Services;
|
||||
|
||||
public class TraderServiceModel
|
||||
{
|
||||
[JsonPropertyName("serviceType")]
|
||||
public TraderServiceType ServiceType { get; set; }
|
||||
|
||||
[JsonPropertyName("itemsToPay")]
|
||||
public Dictionary<string, int>? ItemsToPay { get; set; }
|
||||
|
||||
[JsonPropertyName("itemsToReceive")]
|
||||
public List<string>? ItemsToReceive { get; set; }
|
||||
|
||||
[JsonPropertyName("subServices")]
|
||||
public Dictionary<string, int>? SubServices { get; set; }
|
||||
|
||||
[JsonPropertyName("requirements")]
|
||||
public TraderServiceRequirementsModel? Requirements { get; set; }
|
||||
}
|
||||
|
||||
public class TraderServiceRequirementsModel
|
||||
{
|
||||
[JsonPropertyName("completedQuests")]
|
||||
public List<string>? CompletedQuests { get; set; }
|
||||
|
||||
[JsonPropertyName("standings")]
|
||||
public Dictionary<string, int>? Standings { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,64 @@
|
||||
namespace Core.Services;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Core.Services;
|
||||
|
||||
public class I18nService
|
||||
{
|
||||
private string[] _locales;
|
||||
private Dictionary<string, string> _fallbacks;
|
||||
private string _defaultLocale;
|
||||
private string _directory;
|
||||
|
||||
private string _setLocale;
|
||||
|
||||
private Dictionary<string, Dictionary<string, string>> _loadedLocales = new();
|
||||
|
||||
public I18nService(string[] locales, Dictionary<string, string> fallbacks, string defaultLocale, string directory)
|
||||
{
|
||||
_locales = locales;
|
||||
_fallbacks = fallbacks;
|
||||
_defaultLocale = defaultLocale;
|
||||
_directory = directory;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
var files = Directory.GetFiles(_directory, "*.json");
|
||||
if (files.Length == 0)
|
||||
throw new Exception($"Localisation files in directory {_directory} not found.");
|
||||
foreach (var file in files)
|
||||
{
|
||||
_loadedLocales.Add(Path.GetFileName(file),
|
||||
JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(file)) ?? new Dictionary<string, string>());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLocale(string locale)
|
||||
{
|
||||
if (_loadedLocales.ContainsKey(locale))
|
||||
_setLocale = locale;
|
||||
else
|
||||
{
|
||||
var fallback = _fallbacks.Where(kv => locale.StartsWith(kv.Key.Replace("*", "")));
|
||||
if (fallback.Any())
|
||||
{
|
||||
var foundFallbackLocale = fallback.First().Value;
|
||||
if (!_loadedLocales.ContainsKey(foundFallbackLocale))
|
||||
throw new Exception($"Locale '{locale}' was not defined, and the found fallback locale did not match any of the loaded locales.");
|
||||
_setLocale = foundFallbackLocale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetLocalised(string key)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetLocalised(string key, params object[] args)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user