2022-02-18 17:45:28 +00:00
|
|
|
namespace MultiversalDiplomacy.Model;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a single province as it exists across all timelines.
|
|
|
|
/// </summary>
|
|
|
|
public class Province
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The province's full human-readable name.
|
|
|
|
/// </summary>
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The province's shorthand abbreviation.
|
|
|
|
/// </summary>
|
|
|
|
public string[] Abbreviations { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether the province contains a supply center.
|
|
|
|
/// </summary>
|
|
|
|
public bool IsSupplyCenter { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether the province contains a time center.
|
|
|
|
/// </summary>
|
|
|
|
public bool IsTimeCenter { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The occupiable locations in this province. Only one location can be occupied at a time.
|
|
|
|
/// </summary>
|
|
|
|
public IEnumerable<Location> Locations => LocationList;
|
|
|
|
private List<Location> LocationList { get; set; }
|
|
|
|
|
2024-08-25 03:50:08 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The province's name and abbreviations as a single enumeration.
|
|
|
|
/// </summary>
|
|
|
|
public IEnumerable<string> AllNames => Abbreviations.Append(Name);
|
|
|
|
|
2022-02-18 17:45:28 +00:00
|
|
|
public Province(string name, string[] abbreviations, bool isSupply, bool isTime)
|
|
|
|
{
|
|
|
|
this.Name = name;
|
|
|
|
this.Abbreviations = abbreviations;
|
|
|
|
this.IsSupplyCenter = isSupply;
|
|
|
|
this.IsTimeCenter = isTime;
|
2024-08-14 13:55:40 +00:00
|
|
|
this.LocationList = [];
|
2022-02-18 17:45:28 +00:00
|
|
|
}
|
|
|
|
|
2022-03-16 00:36:47 +00:00
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return this.Name;
|
|
|
|
}
|
|
|
|
|
2024-08-27 02:43:12 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether a name is the name or abbreviation of this province.
|
|
|
|
/// </summary>
|
|
|
|
public bool Is(string name)
|
|
|
|
=> name.EqualsAnyCase(Name) || Abbreviations.Any(name.EqualsAnyCase);
|
|
|
|
|
2022-02-18 17:45:28 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Create a new province with no supply center.
|
|
|
|
/// </summary>
|
|
|
|
public static Province Empty(string name, params string[] abbreviations)
|
2024-08-14 13:55:40 +00:00
|
|
|
=> new(name, abbreviations, isSupply: false, isTime: false);
|
2022-02-18 17:45:28 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a new province with a supply center.
|
|
|
|
/// </summary>
|
|
|
|
public static Province Supply(string name, params string[] abbreviations)
|
2024-08-14 13:55:40 +00:00
|
|
|
=> new(name, abbreviations, isSupply: true, isTime: false);
|
2022-02-18 17:45:28 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a new province with a time center.
|
|
|
|
/// </summary>
|
|
|
|
public static Province Time(string name, params string[] abbreviations)
|
2024-08-14 13:55:40 +00:00
|
|
|
=> new(name, abbreviations, isSupply: true, isTime: true);
|
2022-02-18 17:45:28 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a new land location in this province.
|
|
|
|
/// </summary>
|
|
|
|
public Province AddLandLocation()
|
|
|
|
{
|
2024-08-14 13:55:40 +00:00
|
|
|
Location location = new(this, "land", "l", LocationType.Land);
|
2022-02-18 17:45:28 +00:00
|
|
|
this.LocationList.Add(location);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a new ocean location.
|
|
|
|
/// </summary>
|
|
|
|
public Province AddOceanLocation()
|
|
|
|
{
|
2024-08-14 13:55:40 +00:00
|
|
|
Location location = new(this, "water", "w", LocationType.Water);
|
2022-02-18 17:45:28 +00:00
|
|
|
this.LocationList.Add(location);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a new coastal location. Coastal locations must have names to disambiguate them
|
|
|
|
/// from the single land location in coastal provinces.
|
|
|
|
/// </summary>
|
|
|
|
public Province AddCoastLocation(string name, string abbreviation)
|
|
|
|
{
|
2024-08-14 13:55:40 +00:00
|
|
|
Location location = new(this, name, abbreviation, LocationType.Water);
|
2022-02-18 17:45:28 +00:00
|
|
|
this.LocationList.Add(location);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|