using System.Text.Json.Serialization;
namespace MultiversalDiplomacy.Model;
///
/// Represents a unit at a particular point in time.
///
public class Unit
{
///
/// The location on the map where the unit is.
///
public string Location { get; }
///
/// The season in time when the unit is.
///
public Season Season { get; }
///
/// The allegiance of the unit.
///
public string Power { get; }
///
/// The type of unit.
///
public UnitType Type { get; }
///
/// A unique designation for this unit.
///
[JsonIgnore]
public string Key => $"{Type.ToShort()} {Season.Timeline}-{Location}@{Season.Turn}";
public Unit(string location, Season season, string power, UnitType type)
{
this.Location = location;
this.Season = season;
this.Power = power;
this.Type = type;
}
public override string ToString()
=> $"{Power[0]} {Type.ToShort()} {Season.Timeline}-{Location}@{Season.Turn}";
///
/// Create a new unit. No validation is performed; the adjudicator should only call this
/// method after accepting a build order.
///
public static Unit Build(string location, Season season, string power, UnitType type)
=> new(location, season, power, type);
///
/// Advance this unit's timeline to a new location and season.
///
public Unit Next(string location, Season season)
=> new(location, season, this.Power, this.Type);
public Location GetLocation(World world) => world.Map.GetLocation(Location);
public Province GetProvince(World world) => GetLocation(world).Province;
}