sa/Stars Assistant/CSV/Fleet.cs

150 lines
3.5 KiB
C#
Raw Normal View History

2024-10-01 18:19:19 +00:00
using System;
using CsvHelper.Configuration.Attributes;
namespace StarsAssistant.CSV;
public class Fleet
{
[Index(0)]
public string FleetName { get; set; } = String.Empty;
[Index(1)]
public int X { get; set; }
[Index(2)]
public int Y { get; set; }
[Index(3)]
public string Planet { get; set; } = String.Empty;
[Index(4)]
public string Destination { get; set; } = String.Empty;
[Index(5)]
public string BattlePlan { get; set; } = String.Empty;
[Index(6)]
public int ShipCount { get; set; }
[Index(7)]
public int Ironium { get; set; }
[Index(8)]
public int Boranium { get; set; }
[Index(9)]
public int Germanium { get; set; }
[Index(10)]
2024-10-01 18:19:19 +00:00
public int Colonists { get; set; }
[Index(11)]
2024-10-01 18:19:19 +00:00
public int Fuel { get; set; }
[Index(12)]
public int OwnerFileId { get; set; }
[Ignore()]
public int ETA { get; private set; }
[Index(13)]
public string CSVETA {
set {
if ( value.Length >= 2
&& int.TryParse(value[..^1], out int result))
{
ETA = result;
} else {
ETA = 0;
}
}
}
[Index(14)]
2024-10-01 18:19:19 +00:00
public int Warp { get; set; }
[Index(15)]
2024-10-01 18:19:19 +00:00
public int Mass { get; set; }
[Index(16)]
2024-10-01 18:19:19 +00:00
public int Cloak { get; set; }
[Index(17)]
2024-10-01 18:19:19 +00:00
public int Scan { get; set; }
[Index(18)]
2024-10-01 18:19:19 +00:00
public int PenScan { get; set; }
[Index(19)]
2024-10-01 18:19:19 +00:00
public string Task { get; set; } = String.Empty;
[Index(20)]
2024-10-01 18:19:19 +00:00
public int Mining { get; set; }
[Index(21)]
2024-10-01 18:19:19 +00:00
public int Sweep { get; set; }
[Index(22)]
2024-10-01 18:19:19 +00:00
public int Laying { get; set; }
[Index(23)]
2024-10-01 18:19:19 +00:00
public int Terraforming { get; set; }
[Index(24)]
2024-10-01 18:19:19 +00:00
public int Unarmed { get; set; }
[Index(25)]
2024-10-01 18:19:19 +00:00
public int Scout { get; set; }
[Index(26)]
2024-10-01 18:19:19 +00:00
public int Warship { get; set; }
[Index(27)]
2024-10-01 18:19:19 +00:00
public int Utility { get; set; }
[Index(28)]
2024-10-01 18:19:19 +00:00
public int Bomber { get; set; }
/// <summary>
/// This will update a DB Fleet recrod with this CSV Data. DB/EF Handling
/// has to be done by the caller, we'll take care of none PK properties
/// only.
/// </summary>
/// <param name="dbFleet">record to fill</param>
public void UpdateDbFleet(Model.Fleet dbFleet)
{
if (dbFleet == null)
throw new InvalidOperationException("Cannot update a null DB fleet instance");
dbFleet.FleetName = FleetName;
dbFleet.X = X;
dbFleet.Y = Y;
dbFleet.Planet = Planet;
dbFleet.Destination = Destination;
dbFleet.BattlePlan = BattlePlan;
dbFleet.ShipCount = ShipCount;
dbFleet.Ironium = Ironium;
dbFleet.Boranium = Boranium;
dbFleet.Germanium = Germanium;
dbFleet.Colonists = Colonists;
dbFleet.Fuel = Fuel;
dbFleet.OwnerFileId = OwnerFileId;
dbFleet.ETA = ETA;
dbFleet.Warp = Warp;
dbFleet.Mass = Mass;
dbFleet.Cloak = Cloak;
dbFleet.Scan = Scan;
dbFleet.PenScan = PenScan;
dbFleet.Task = Task;
dbFleet.Mining = Mining;
dbFleet.Sweep = Sweep;
dbFleet.Laying = Laying;
dbFleet.Terraforming = Terraforming;
dbFleet.Unarmed = Unarmed;
dbFleet.Scout = Scout;
dbFleet.Warship = Warship;
dbFleet.Utility = Utility;
}
2024-10-01 18:19:19 +00:00
}