diff --git a/Stars Assistant/Model/Planet.cs b/Stars Assistant/Model/Planet.cs
index 1eaeb19..34d43ec 100644
--- a/Stars Assistant/Model/Planet.cs
+++ b/Stars Assistant/Model/Planet.cs
@@ -5,6 +5,8 @@ namespace StarsAssistant.Model;
public class Planet
{
+ public const int MinEffectiveValue = 5;
+
[Key]
public required string Name { get; set; }
diff --git a/Stars Assistant/Model/Race.cs b/Stars Assistant/Model/Race.cs
new file mode 100644
index 0000000..4f7fabd
--- /dev/null
+++ b/Stars Assistant/Model/Race.cs
@@ -0,0 +1,90 @@
+using System.ComponentModel.DataAnnotations;
+using System;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace StarsAssistant.Model;
+
+///
+/// Primary Racial Trait, only PRTs with relevant rules are currently listed.
+///
+public enum PRT {
+ Other = 0,
+ HE = 1,
+ JOAT = 2
+}
+
+public class Race
+{
+ [Key]
+ public required string Name { get; set; }
+
+ public int ColonistsPerResource { get; set; }
+
+ public int GrowthRatePercent { get; set; }
+
+ private PRT _PRT;
+ public PRT PRT {
+ get => _PRT;
+ set {
+ _PRT = value;
+ UpdatePopDerivedValues();
+ }
+ }
+
+ private bool _hasOBRM;
+ public bool HasOBRM {
+ get => _hasOBRM;
+ set {
+ _hasOBRM = value;
+ UpdatePopDerivedValues();
+ }
+ }
+
+ [NotMapped]
+ public int MaxPopOnPlanet { get; private set; } = 1_000_000;
+
+ [NotMapped]
+ public int MaxEffectivePopOnRed { get; private set; }
+
+ [NotMapped]
+ public int MaxEffectivePopOnGreen { get; private set; }
+
+ private bool _factoryCost3;
+ public bool FactoryCost3 {
+ get => _factoryCost3;
+ set {
+ _factoryCost3 = value;
+ FactoryGerCost = _factoryCost3 ? 3 : 4;
+ }
+ }
+
+ [NotMapped]
+ public int FactoryGerCost { get; private set; }
+
+ public int FactoryNumberPer10k { get; set; }
+
+ public int FactoryResCost { get; set; }
+
+ public int FactoryResPer10 { get; set; }
+
+ public int MineResCost { get; set; }
+
+ public int MineNumberPer10k { get; set; }
+
+ public int MineMineralsPer10 { get; set; }
+
+ private void UpdatePopDerivedValues() {
+ const int basePop = 1_000_000;
+ var prtMod = PRT switch
+ {
+ PRT.HE => 0.5,
+ PRT.JOAT => 1.2,
+ _ => 1,
+ };
+ double obrmMod = HasOBRM ? 1.1 : 1.0;
+ MaxPopOnPlanet = Convert.ToInt32(basePop * prtMod * obrmMod);
+ MaxEffectivePopOnRed = MaxPopOnPlanet * Planet.MinEffectiveValue / 100 * 3;
+ MaxEffectivePopOnGreen = MaxPopOnPlanet * 3;
+ }
+
+}
diff --git a/Stars Assistant/Model/StarsDatabase.cs b/Stars Assistant/Model/StarsDatabase.cs
index ce5729c..1894810 100644
--- a/Stars Assistant/Model/StarsDatabase.cs
+++ b/Stars Assistant/Model/StarsDatabase.cs
@@ -27,5 +27,10 @@ public class StarsDatabase(string DbPath) : DbContext
///
public DbSet Planets { get; set; }
+ ///
+ /// Lists of all defined races.
+ ///
+ public DbSet Races { get; set; }
+
#endregion
}
\ No newline at end of file
diff --git a/Stars Assistant/Program.cs b/Stars Assistant/Program.cs
index 6c5980a..0ca711c 100644
--- a/Stars Assistant/Program.cs
+++ b/Stars Assistant/Program.cs
@@ -18,7 +18,7 @@ sealed class Program
[STAThread]
public static void Main(string[] args)
{
- // __createTestData();
+ __createTestData();
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
@@ -42,6 +42,23 @@ sealed class Program
// Note: This sample requires the database to be created before running.
Console.WriteLine($"Database path: {db.DbPath}.");
+ Race r = new()
+ {
+ Name = "Atlantis",
+ ColonistsPerResource = 1000,
+ GrowthRatePercent = 19,
+ PRT = PRT.Other,
+ HasOBRM = true,
+ FactoryCost3 = false,
+ FactoryNumberPer10k = 8,
+ FactoryResCost = 8,
+ FactoryResPer10 = 15,
+ MineResCost = 3,
+ MineMineralsPer10 = 10,
+ MineNumberPer10k = 10
+ };
+ db.Add(r);
+
var config = CsvConfiguration.FromAttributes(CultureInfo.InvariantCulture);
config.Delimiter = "\t";
config.Escape = '\0';