2024-08-17 14:52:31 +00:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
|
|
|
namespace StarsAssistant.Model;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Primary Racial Trait, only PRTs with relevant rules are currently listed.
|
|
|
|
/// </summary>
|
|
|
|
public enum PRT {
|
|
|
|
Other = 0,
|
|
|
|
HE = 1,
|
|
|
|
JOAT = 2
|
|
|
|
}
|
|
|
|
|
|
|
|
public class Race
|
|
|
|
{
|
2024-08-18 17:21:18 +00:00
|
|
|
#region Persistant and derived properties
|
|
|
|
|
2024-08-17 14:52:31 +00:00
|
|
|
[Key]
|
|
|
|
public required string Name { get; set; }
|
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
public bool PlayerRace { get; set; } = false;
|
|
|
|
|
2024-09-17 18:20:42 +00:00
|
|
|
public int? PlayerFileId { get; set; }
|
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
public int? ColonistsPerResource { get; set; }
|
2024-08-17 14:52:31 +00:00
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
public int? GrowthRatePercent { get; set; }
|
2024-08-17 14:52:31 +00:00
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
private PRT _PRT = PRT.Other;
|
2024-08-17 14:52:31 +00:00
|
|
|
public PRT PRT {
|
|
|
|
get => _PRT;
|
|
|
|
set {
|
|
|
|
_PRT = value;
|
|
|
|
UpdatePopDerivedValues();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
private bool? _hasOBRM;
|
|
|
|
public bool? HasOBRM {
|
2024-08-17 14:52:31 +00:00
|
|
|
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; }
|
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
private bool? _factoryCost3;
|
|
|
|
public bool? FactoryCost3 {
|
2024-08-17 14:52:31 +00:00
|
|
|
get => _factoryCost3;
|
|
|
|
set {
|
|
|
|
_factoryCost3 = value;
|
2024-08-18 17:21:18 +00:00
|
|
|
FactoryGerCost = (_factoryCost3 ?? false) ? 3 : 4;
|
2024-08-17 14:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[NotMapped]
|
|
|
|
public int FactoryGerCost { get; private set; }
|
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
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; }
|
2024-08-17 14:52:31 +00:00
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
public int? MineMineralsPer10 { get; set; }
|
2024-08-17 14:52:31 +00:00
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
#endregion
|
2024-08-17 14:52:31 +00:00
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
#region Relationships
|
2024-08-17 14:52:31 +00:00
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
public ICollection<Planet> Planets { get; } = new List<Planet>();
|
2024-08-17 14:52:31 +00:00
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Public Helpers
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Internal Helpers
|
2024-08-17 14:52:31 +00:00
|
|
|
|
|
|
|
private void UpdatePopDerivedValues() {
|
|
|
|
const int basePop = 1_000_000;
|
|
|
|
var prtMod = PRT switch
|
|
|
|
{
|
|
|
|
PRT.HE => 0.5,
|
|
|
|
PRT.JOAT => 1.2,
|
|
|
|
_ => 1,
|
|
|
|
};
|
2024-08-18 17:21:18 +00:00
|
|
|
double obrmMod = (HasOBRM ?? false) ? 1.1 : 1.0;
|
2024-08-17 14:52:31 +00:00
|
|
|
MaxPopOnPlanet = Convert.ToInt32(basePop * prtMod * obrmMod);
|
|
|
|
MaxEffectivePopOnRed = MaxPopOnPlanet * Planet.MinEffectiveValue / 100 * 3;
|
|
|
|
MaxEffectivePopOnGreen = MaxPopOnPlanet * 3;
|
|
|
|
}
|
|
|
|
|
2024-08-18 17:21:18 +00:00
|
|
|
#endregion
|
|
|
|
}
|