namespace MultiversalDiplomacy.Model; /// /// Represents a unit at a particular point in time. /// public class Unit { /// /// The previous iteration of a unit. This is null if the unit was just built. /// public Unit? Past { get; } /// /// The location on the map where the unit is. /// public Location Location { get; } /// /// The province where the unit is. /// public Province Province => this.Location.Province; /// /// The season in time when the unit is. /// public Season Season { get; } /// /// The allegiance of the unit. /// public Power Power { get; } /// /// The type of unit. /// public UnitType Type { get; } /// /// The unit's spatiotemporal location as a province-season tuple. /// public (Province province, Season season) Point => (this.Province, this.Season); private Unit(Unit? past, Location location, Season season, Power power, UnitType type) { this.Past = past; this.Location = location; this.Season = season; this.Power = power; this.Type = type; } public override string ToString() { return $"{this.Power.Name[0]} {this.Type.ToShort()} {(this.Province, this.Season).ToShort()}"; } /// /// Create a new unit. No validation is performed; the adjudicator should only call this /// method after accepting a build order. /// public static Unit Build(Location location, Season season, Power power, UnitType type) => new Unit(past: null, location, season, power, type); /// /// Advance this unit's timeline to a new location and season. /// public Unit Next(Location location, Season season) => new Unit(past: this, location, season, this.Power, this.Type); }