2022-02-19 00:58:16 +00:00
|
|
|
using MultiversalDiplomacy.Model;
|
|
|
|
|
|
|
|
namespace MultiversalDiplomacy.Orders;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// An order for a unit to move to another province.
|
|
|
|
/// </summary>
|
|
|
|
public class MoveOrder : UnitOrder
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The destination season to which the unit should move.
|
|
|
|
/// </summary>
|
|
|
|
public Season Season { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The destination location to which the unit should move.
|
|
|
|
/// </summary>
|
|
|
|
public Location Location { get; }
|
|
|
|
|
2022-03-30 19:52:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The destination province to which the unit should move.
|
|
|
|
/// </summary>
|
|
|
|
public Province Province => this.Location.Province;
|
|
|
|
|
2022-03-29 00:41:38 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The destination's spatiotemporal location as a province-season tuple.
|
|
|
|
/// </summary>
|
2022-03-30 19:52:57 +00:00
|
|
|
public (Province province, Season season) Point => (this.Province, this.Season);
|
2022-03-29 00:41:38 +00:00
|
|
|
|
2022-02-19 00:58:16 +00:00
|
|
|
public MoveOrder(Power power, Unit unit, Season season, Location location)
|
|
|
|
: base (power, unit)
|
|
|
|
{
|
|
|
|
this.Season = season;
|
|
|
|
this.Location = location;
|
|
|
|
}
|
2022-03-24 15:12:11 +00:00
|
|
|
|
2022-04-07 22:58:17 +00:00
|
|
|
public override string ToString()
|
|
|
|
{
|
2022-11-04 00:32:39 +00:00
|
|
|
return $"{this.Unit} -> {(this.Province, this.Season).ToShort()}";
|
2022-04-07 22:58:17 +00:00
|
|
|
}
|
|
|
|
|
2022-03-30 20:00:51 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Returns whether another move order has the same destination as this order.
|
|
|
|
/// </summary>
|
|
|
|
public bool IsCompeting(MoveOrder other)
|
|
|
|
=> this != other
|
|
|
|
&& this.Season == other.Season
|
|
|
|
&& this.Province == other.Province;
|
2022-02-19 00:58:16 +00:00
|
|
|
}
|