2020-09-01 11:34:52 -07:00
|
|
|
|
using System.Collections.Generic;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
2020-12-08 13:23:59 -08:00
|
|
|
|
using SabreTools.Core;
|
2020-09-01 11:34:52 -07:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-01 11:34:52 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents which Adjuster(s) is associated with a set
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("adjuster"), XmlRoot("adjuster")]
|
2020-09-01 11:34:52 -07:00
|
|
|
|
public class Adjuster : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
2020-09-02 12:19:12 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Name of the item
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[JsonProperty("name")]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[XmlElement("name")]
|
2020-09-02 12:19:12 -07:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determine whether the value is default
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[XmlElement("default")]
|
2020-09-01 11:34:52 -07:00
|
|
|
|
public bool? Default { get; set; }
|
|
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool DefaultSpecified { get { return Default != null; } }
|
|
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Conditions associated with the adjustment
|
|
|
|
|
|
/// </summary>
|
2020-09-02 14:32:16 -07:00
|
|
|
|
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[XmlElement("conditions")]
|
2020-09-01 16:21:55 -07:00
|
|
|
|
public List<Condition> Conditions { get; set; }
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ConditionsSpecified { get { return Conditions != null && Conditions.Count > 0; } }
|
|
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2020-12-14 10:15:28 -08:00
|
|
|
|
public override string GetName() => Name;
|
2020-09-02 12:19:12 -07:00
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2020-12-14 10:15:28 -08:00
|
|
|
|
public override void SetName(string name) => Name = name;
|
2020-12-13 14:01:16 -08:00
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Adjuster object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Adjuster()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = string.Empty;
|
|
|
|
|
|
ItemType = ItemType.Adjuster;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
|
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Adjuster()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
|
|
|
|
|
Machine = this.Machine.Clone() as Machine,
|
|
|
|
|
|
Source = this.Source.Clone() as Source,
|
|
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2020-09-03 13:01:33 -07:00
|
|
|
|
Name = this.Name,
|
2020-09-01 11:34:52 -07:00
|
|
|
|
Default = this.Default,
|
|
|
|
|
|
Conditions = this.Conditions,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Comparision Methods
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(DatItem other)
|
|
|
|
|
|
{
|
2020-09-01 11:55:11 -07:00
|
|
|
|
// If we don't have a Adjuster, return false
|
2020-09-01 11:34:52 -07:00
|
|
|
|
if (ItemType != other.ItemType)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, treat it as a Adjuster
|
|
|
|
|
|
Adjuster newOther = other as Adjuster;
|
|
|
|
|
|
|
|
|
|
|
|
// If the Adjuster information matches
|
2020-09-02 22:14:00 -07:00
|
|
|
|
bool match = (Name == newOther.Name && Default == newOther.Default);
|
|
|
|
|
|
if (!match)
|
|
|
|
|
|
return match;
|
|
|
|
|
|
|
|
|
|
|
|
// If the conditions match
|
2020-09-30 13:25:40 -07:00
|
|
|
|
if (ConditionsSpecified)
|
2020-09-02 22:14:00 -07:00
|
|
|
|
{
|
|
|
|
|
|
foreach (Condition condition in Conditions)
|
|
|
|
|
|
{
|
|
|
|
|
|
match &= newOther.Conditions.Contains(condition);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return match;
|
2020-09-01 11:34:52 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|