Laying down the groundwork for data

This commit is contained in:
2025-11-29 23:22:04 -06:00
parent c749434d07
commit 7c98bc3a89
8 changed files with 97 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
namespace SessionZero.Data;
public class Datapack
{
public required DatapackMetadata Metadata { get; set; }
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace SessionZero.Data;
public class DatapackMetadata
{
public required string Name { get; set; }
public required string Id { get; set; }
public required string Description { get; set; }
public required string Version { get; set; }
public required string[] CompatibleSystems { get; set; }
public string Uuid { get; set; } = string.Empty;
}

View File

@@ -1,6 +1,35 @@
using System.Collections.Generic;
using SessionZero.Data.Sztl;
namespace SessionZero.Data;
public class Dataset
{
public required DatasetMetadata Metadata { get; set; }
public Dictionary<string, SztlField> Fields { get; set; } = [];
public Dictionary<string, SztlFieldGroup> Groups { get; set; } = [];
/// <summary>
/// Returns an SzfField from a string path (use dot notation, eg 'stats.damage')
/// </summary>
/// <param name="fieldPath"></param>
/// <returns></returns>
public SztlField? GetField(string fieldPath)
{
var split = fieldPath.Split('.');
var fieldName = split[0];
if (split.Length == 1)
{
return Fields.GetValueOrDefault(fieldName);
}
else
{
// Todo: Recurse into Groups.Fields to find the path
}
return null;
}
}

View File

@@ -0,0 +1,11 @@
namespace SessionZero.Data;
public class DatasetMetadata
{
public required string Name { get; set; }
public required string Id { get; set; }
public required string Description { get; set; }
public required string DatasetType { get; set; }
public required string Icon { get; set; }
public required string ObjectTemplate { get; set; }
}

View File

@@ -6,6 +6,17 @@ public class SztlField
{
public required string Id { get; set; }
public required SztlFieldType FieldType { get; set; }
public object? Value { get; set; } = null;
public bool TrySetValue()
{
throw new NotImplementedException();
}
public T TryGetValue<T>()
{
throw new NotImplementedException();
}
}
public enum SztlFieldType

View File

@@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace SessionZero.Data.Sztl;
public class SztlFieldGroup
{
public List<SztlField> Fields { get; set; } = [];
public List<SztlFieldGroup> SubGroups { get; set; } = [];
}

View File

@@ -0,0 +1,7 @@
namespace SessionZero.Data.Sztl;
public class SztlTemplate
{
}

View File

@@ -0,0 +1,9 @@
namespace SessionZero.Data.Sztl;
public class SztlTokenizer
{
enum TokenType
{
// TODO: Add token types
}
}