mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 16:23:58 +00:00
Implement Weapon_Upgrade
This commit is contained in:
52
Common/Data/Excel/SuppliesExcel.cs
Normal file
52
Common/Data/Excel/SuppliesExcel.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("suplies.json")]
|
||||
public class SuppliesExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
public uint Detail { get; set; }
|
||||
public uint Particular { get; set; }
|
||||
public uint Level { get; set; }
|
||||
[JsonProperty("Color")] public JToken? ColorRaw { get; set; }
|
||||
[JsonProperty("ProvideExp")] public JToken? ProvideExpRaw { get; set; }
|
||||
[JsonProperty("ConsumeGold")] public JToken? ConsumeGoldRaw { get; set; }
|
||||
|
||||
[JsonIgnore] public int Color => ReadInt(ColorRaw);
|
||||
[JsonIgnore] public uint ProvideExp => ReadUInt(ProvideExpRaw);
|
||||
[JsonIgnore] public uint ConsumeGold => ReadUInt(ConsumeGoldRaw);
|
||||
|
||||
public override uint GetId()
|
||||
{
|
||||
return (uint)GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.SuppliesData[GetId()] = this;
|
||||
}
|
||||
|
||||
private static int ReadInt(JToken? token)
|
||||
{
|
||||
if (token == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return token.Type switch
|
||||
{
|
||||
JTokenType.Integer => token.Value<int>(),
|
||||
JTokenType.Float => (int)token.Value<decimal>(),
|
||||
JTokenType.String when int.TryParse(token.Value<string>(), out var value) => value,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
private static uint ReadUInt(JToken? token)
|
||||
{
|
||||
var value = ReadInt(token);
|
||||
return value > 0 ? (uint)value : 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user