personaforge/Archetypes.cs
2025-04-28 13:56:46 -04:00

102 lines
3 KiB
C#

namespace PersonaForge;
public class Archetypes
{
public string Name { get; set; }
public Dictionary<string, double> TraitBiases { get; set; } = new();
public static Dictionary<string, double> LoadFromJson(string json)
{
var opt = new JsonSerializerOptions()
{
PropertyNameCaseInsensitive = false
};
var definitions = JsonSerializer.Deserialize<List<Archetypes>>(json, opt);
if (definitions is null)
throw new InvalidOperationException("Failed to deserialize Archetype JSON.");
var traitBiases = new Dictionary<string, double>();
foreach (var def in definitions)
{
foreach (var traitBias in def.TraitBiases)
{
traitBiases[traitBias.Key] = traitBias.Value;
}
}
return traitBiases;
}
// TODO: Load default archetypes from a file or database
public static List<Archetypes> DefaultArchetypes() => new()
{
new Archetypes
{
Name = "Grumpy",
TraitBiases = new Dictionary<string, double>
{
{ "Nice", 0.2 },
{ "Playful", 0.4 },
{ "Outgoing", 0.6 },
{ "Neat", 0.7 },
{ "Active", 0.5 }
}
},
new Archetypes
{
Name = "Party Animal",
TraitBiases = new Dictionary<string, double>
{
{ "Outgoing", 0.9 },
{ "Playful", 0.8 },
{ "Active", 0.7 },
{ "Nice", 0.5 },
{ "Neat", 0.3 }
}
},
new Archetypes
{
Name = "Lazy",
TraitBiases = new Dictionary<string, double>
{
{ "Nice", 0.8 },
{ "Playful", 0.6 },
{ "Outgoing", 0.4 },
{ "Neat", 0.2 },
{ "Active", 0.1 }
}
},
new Archetypes
{
Name = "Shy",
TraitBiases = new Dictionary<string, double>
{
{ "Nice", 0.9 },
{ "Playful", 0.7 },
{ "Outgoing", 0.3 },
{ "Neat", 0.5 },
{ "Active", 0.2 }
}
},
new Archetypes
{
Name = "Energetic",
TraitBiases = new Dictionary<string, double>
{
{ "Nice", 0.7 },
{ "Playful", 0.6 },
{ "Outgoing", 0.5 },
{ "Neat", 0.4 },
{ "Active", 0.3 }
}
},
new Archetypes
{
Name = "Random",
TraitBiases = new()
}
};
}