From 442015b94273c62925f23f02da02f573f0b4c06b Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 14 Aug 2024 06:55:40 -0700 Subject: [PATCH] Always name locations --- MultiversalDiplomacy/Model/Location.cs | 8 +-- MultiversalDiplomacy/Model/Map.cs | 80 +++++++++++++------------- MultiversalDiplomacy/Model/Province.cs | 26 +++------ 3 files changed, 51 insertions(+), 63 deletions(-) diff --git a/MultiversalDiplomacy/Model/Location.cs b/MultiversalDiplomacy/Model/Location.cs index ff4d365..10d0eee 100644 --- a/MultiversalDiplomacy/Model/Location.cs +++ b/MultiversalDiplomacy/Model/Location.cs @@ -20,12 +20,12 @@ public class Location /// /// The location's full human-readable name. /// - public string? Name { get; } + public string Name { get; } /// /// The location's shorthand abbreviation. /// - public string? Abbreviation { get; } + public string Abbreviation { get; } /// /// The location's type. @@ -39,7 +39,7 @@ public class Location public IEnumerable Adjacents => this.AdjacentList; private List AdjacentList { get; set; } - public Location(Province province, string? name, string? abbreviation, LocationType type) + public Location(Province province, string name, string abbreviation, LocationType type) { this.Province = province; this.Name = name; @@ -50,7 +50,7 @@ public class Location public override string ToString() { - return this.Name == null + return this.Name == "land" || this.Name == "water" ? $"{this.Province.Name} ({this.Type})" : $"{this.Province.Name} ({this.Type}:{this.Name}]"; } diff --git a/MultiversalDiplomacy/Model/Map.cs b/MultiversalDiplomacy/Model/Map.cs index 36a4914..ab98092 100644 --- a/MultiversalDiplomacy/Model/Map.cs +++ b/MultiversalDiplomacy/Model/Map.cs @@ -121,10 +121,10 @@ public class Map #region Provinces Province.Empty("North Africa", "NAF") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Tunis", "TUN") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Bohemia", "BOH") .AddLandLocation(), Province.Supply("Budapest", "BUD") @@ -133,71 +133,71 @@ public class Map .AddLandLocation(), Province.Supply("Trieste", "TRI") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Tyrolia", "TYR") .AddLandLocation(), Province.Time("Vienna", "VIE") .AddLandLocation(), Province.Empty("Albania", "ALB") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Bulgaria", "BUL") .AddLandLocation() .AddCoastLocation("east coast", "ec") .AddCoastLocation("south coast", "sc"), Province.Supply("Greece", "GRE") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Rumania", "RUM", "RMA") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Serbia", "SER") .AddLandLocation(), Province.Empty("Clyde", "CLY") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Edinburgh", "EDI") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Liverpool", "LVP", "LPL") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Time("London", "LON") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Wales", "WAL") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Yorkshire", "YOR") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Brest", "BRE") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Burgundy", "BUR") .AddLandLocation(), Province.Empty("Gascony", "GAS") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Marseilles", "MAR") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Time("Paris", "PAR") .AddLandLocation(), Province.Empty("Picardy", "PIC") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Time("Berlin", "BER") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Kiel", "KIE") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Munich", "MUN") .AddLandLocation(), Province.Empty("Prussia", "PRU") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Ruhr", "RUH", "RHR") .AddLandLocation(), Province.Empty("Silesia", "SIL") @@ -208,43 +208,43 @@ public class Map .AddCoastLocation("south coast", "sc"), Province.Supply("Portugal", "POR") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Apulia", "APU") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Naples", "NAP") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Piedmont", "PIE") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Time("Rome", "ROM", "RME") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Tuscany", "TUS") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Venice", "VEN") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Belgium", "BEL") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Holland", "HOL") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Finland", "FIN") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Livonia", "LVN", "LVA") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Time("Moscow", "MOS") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Sevastopol", "SEV") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Saint Petersburg", "STP") .AddLandLocation() .AddCoastLocation("north coast", "nc") @@ -255,28 +255,28 @@ public class Map .AddLandLocation(), Province.Supply("Denmark", "DEN") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Norway", "NWY") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Sweden", "SWE") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Ankara", "ANK") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Armenia", "ARM") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Time("Constantinople", "CON") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Supply("Smyrna", "SMY") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Syria", "SYR") .AddLandLocation() - .AddCoastLocation(), + .AddOceanLocation(), Province.Empty("Barents Sea", "BAR") .AddOceanLocation(), Province.Empty("English Channel", "ENC", "ECH") diff --git a/MultiversalDiplomacy/Model/Province.cs b/MultiversalDiplomacy/Model/Province.cs index b53d7ae..ec2da17 100644 --- a/MultiversalDiplomacy/Model/Province.cs +++ b/MultiversalDiplomacy/Model/Province.cs @@ -37,7 +37,7 @@ public class Province this.Abbreviations = abbreviations; this.IsSupplyCenter = isSupply; this.IsTimeCenter = isTime; - this.LocationList = new List(); + this.LocationList = []; } public override string ToString() @@ -49,26 +49,26 @@ public class Province /// Create a new province with no supply center. /// public static Province Empty(string name, params string[] abbreviations) - => new Province(name, abbreviations, isSupply: false, isTime: false); + => new(name, abbreviations, isSupply: false, isTime: false); /// /// Create a new province with a supply center. /// public static Province Supply(string name, params string[] abbreviations) - => new Province(name, abbreviations, isSupply: true, isTime: false); + => new(name, abbreviations, isSupply: true, isTime: false); /// /// Create a new province with a time center. /// public static Province Time(string name, params string[] abbreviations) - => new Province(name, abbreviations, isSupply: true, isTime: true); + => new(name, abbreviations, isSupply: true, isTime: true); /// /// Create a new land location in this province. /// public Province AddLandLocation() { - Location location = new Location(this, name: null, abbreviation: null, LocationType.Land); + Location location = new(this, "land", "l", LocationType.Land); this.LocationList.Add(location); return this; } @@ -78,19 +78,7 @@ public class Province /// public Province AddOceanLocation() { - Location location = new Location(this, name: null, abbreviation: null, LocationType.Water); - this.LocationList.Add(location); - return this; - } - - /// - /// Create a new coastal location. Coastal locations must have names to disambiguate them - /// from the single land location in coastal provinces. - /// - public Province AddCoastLocation() - { - // Use a default name for provinces with only one coastal location - Location location = new Location(this, "coast", "c", LocationType.Water); + Location location = new(this, "water", "w", LocationType.Water); this.LocationList.Add(location); return this; } @@ -101,7 +89,7 @@ public class Province /// public Province AddCoastLocation(string name, string abbreviation) { - Location location = new Location(this, name, abbreviation, LocationType.Water); + Location location = new(this, name, abbreviation, LocationType.Water); this.LocationList.Add(location); return this; }