mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Handle Adjuster conditions
This commit is contained in:
@@ -63,7 +63,14 @@ namespace SabreTools.Library.DatItems
|
|||||||
if (mappings.Keys.Contains(Field.DatItem_Default))
|
if (mappings.Keys.Contains(Field.DatItem_Default))
|
||||||
Default = mappings[Field.DatItem_Default].AsYesNo();
|
Default = mappings[Field.DatItem_Default].AsYesNo();
|
||||||
|
|
||||||
// TODO: Handle DatItem_Condition*
|
// Field.DatItem_Conditions does not apply here
|
||||||
|
if (Conditions != null)
|
||||||
|
{
|
||||||
|
foreach (Condition condition in Conditions)
|
||||||
|
{
|
||||||
|
condition.SetFields(mappings);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -132,7 +139,20 @@ namespace SabreTools.Library.DatItems
|
|||||||
Adjuster newOther = other as Adjuster;
|
Adjuster newOther = other as Adjuster;
|
||||||
|
|
||||||
// If the Adjuster information matches
|
// If the Adjuster information matches
|
||||||
return (Name == newOther.Name && Default == newOther.Default); // TODO: Handle DatItem_Condition*
|
bool match = (Name == newOther.Name && Default == newOther.Default);
|
||||||
|
if (!match)
|
||||||
|
return match;
|
||||||
|
|
||||||
|
// If the conditions match
|
||||||
|
if (Conditions != null)
|
||||||
|
{
|
||||||
|
foreach (Condition condition in Conditions)
|
||||||
|
{
|
||||||
|
match &= newOther.Conditions.Contains(condition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -187,7 +207,19 @@ namespace SabreTools.Library.DatItems
|
|||||||
if (filter.DatItem_Default.MatchesNeutral(null, Default) == false)
|
if (filter.DatItem_Default.MatchesNeutral(null, Default) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO: Handle DatItem_Condition*
|
// Filter on conditions
|
||||||
|
if (filter.DatItem_Conditions.MatchesNeutral(null, Conditions != null ? (bool?)(Conditions.Count > 0) : null) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Filter on individual conditions
|
||||||
|
if (Conditions != null)
|
||||||
|
{
|
||||||
|
foreach (Condition condition in Conditions)
|
||||||
|
{
|
||||||
|
if (!condition.PassesFilter(filter))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -211,7 +243,13 @@ namespace SabreTools.Library.DatItems
|
|||||||
if (fields.Contains(Field.DatItem_Conditions))
|
if (fields.Contains(Field.DatItem_Conditions))
|
||||||
Conditions = null;
|
Conditions = null;
|
||||||
|
|
||||||
// TODO: Handle DatItem_Condition*
|
if (Conditions != null)
|
||||||
|
{
|
||||||
|
foreach (Condition condition in Conditions)
|
||||||
|
{
|
||||||
|
condition.RemoveFields(fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -255,7 +293,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
if (fields.Contains(Field.DatItem_Conditions))
|
if (fields.Contains(Field.DatItem_Conditions))
|
||||||
Conditions = newItem.Conditions;
|
Conditions = newItem.Conditions;
|
||||||
|
|
||||||
// TODO: Handle DatItem_Condition*
|
// Field replacement doesn't make sense for DatItem_Condition*
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace SabreTools.Library.DatItems
|
|||||||
[JsonObject("condition")]
|
[JsonObject("condition")]
|
||||||
public class Condition : DatItem
|
public class Condition : DatItem
|
||||||
{
|
{
|
||||||
// TODO: Handle obscure field mappings due to this being used *under* other items as well
|
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -58,15 +57,23 @@ namespace SabreTools.Library.DatItems
|
|||||||
// Handle Condition-specific fields
|
// Handle Condition-specific fields
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||||
Tag = mappings[Field.DatItem_Tag];
|
Tag = mappings[Field.DatItem_Tag];
|
||||||
|
else if (mappings.Keys.Contains(Field.DatItem_Condition_Tag))
|
||||||
|
Tag = mappings[Field.DatItem_Condition_Tag];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||||
Mask = mappings[Field.DatItem_Mask];
|
Mask = mappings[Field.DatItem_Mask];
|
||||||
|
else if (mappings.Keys.Contains(Field.DatItem_Condition_Mask))
|
||||||
|
Mask = mappings[Field.DatItem_Condition_Mask];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Relation))
|
if (mappings.Keys.Contains(Field.DatItem_Relation))
|
||||||
Relation = mappings[Field.DatItem_Relation];
|
Relation = mappings[Field.DatItem_Relation];
|
||||||
|
else if (mappings.Keys.Contains(Field.DatItem_Condition_Relation))
|
||||||
|
Relation = mappings[Field.DatItem_Condition_Relation];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_ConditionValue))
|
if (mappings.Keys.Contains(Field.DatItem_ConditionValue))
|
||||||
ConditionValue = mappings[Field.DatItem_ConditionValue];
|
ConditionValue = mappings[Field.DatItem_ConditionValue];
|
||||||
|
else if (mappings.Keys.Contains(Field.DatItem_Condition_Value))
|
||||||
|
ConditionValue = mappings[Field.DatItem_Condition_Value];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -161,24 +168,40 @@ namespace SabreTools.Library.DatItems
|
|||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Tag.MatchesNegativeSet(Tag) == true)
|
if (filter.DatItem_Tag.MatchesNegativeSet(Tag) == true)
|
||||||
return false;
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Tag.MatchesPositiveSet(Tag) == false)
|
||||||
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Tag.MatchesNegativeSet(Tag) == true)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Filter on mask
|
// Filter on mask
|
||||||
if (filter.DatItem_Mask.MatchesPositiveSet(Mask) == false)
|
if (filter.DatItem_Mask.MatchesPositiveSet(Mask) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
||||||
return false;
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Mask.MatchesPositiveSet(Mask) == false)
|
||||||
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Mask.MatchesNegativeSet(Mask) == true)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Filter on mask
|
// Filter on mask
|
||||||
if (filter.DatItem_Relation.MatchesPositiveSet(Relation) == false)
|
if (filter.DatItem_Relation.MatchesPositiveSet(Relation) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Relation.MatchesNegativeSet(Relation) == true)
|
if (filter.DatItem_Relation.MatchesNegativeSet(Relation) == true)
|
||||||
return false;
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Relation.MatchesPositiveSet(Relation) == false)
|
||||||
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Relation.MatchesNegativeSet(Relation) == true)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Filter on value
|
// Filter on value
|
||||||
if (filter.DatItem_ConditionValue.MatchesPositiveSet(ConditionValue) == false)
|
if (filter.DatItem_ConditionValue.MatchesPositiveSet(ConditionValue) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_ConditionValue.MatchesNegativeSet(ConditionValue) == true)
|
if (filter.DatItem_ConditionValue.MatchesNegativeSet(ConditionValue) == true)
|
||||||
return false;
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Value.MatchesPositiveSet(ConditionValue) == false)
|
||||||
|
return false;
|
||||||
|
if (filter.DatItem_Condition_Value.MatchesNegativeSet(ConditionValue) == true)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -195,15 +218,23 @@ namespace SabreTools.Library.DatItems
|
|||||||
// Remove the fields
|
// Remove the fields
|
||||||
if (fields.Contains(Field.DatItem_Tag))
|
if (fields.Contains(Field.DatItem_Tag))
|
||||||
Tag = null;
|
Tag = null;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Tag))
|
||||||
|
Tag = null;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Mask))
|
if (fields.Contains(Field.DatItem_Mask))
|
||||||
Mask = null;
|
Mask = null;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Mask))
|
||||||
|
Mask = null;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Relation))
|
if (fields.Contains(Field.DatItem_Relation))
|
||||||
Relation = null;
|
Relation = null;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Relation))
|
||||||
|
Relation = null;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_ConditionValue))
|
if (fields.Contains(Field.DatItem_ConditionValue))
|
||||||
ConditionValue = null;
|
ConditionValue = null;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Value))
|
||||||
|
ConditionValue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -230,15 +261,23 @@ namespace SabreTools.Library.DatItems
|
|||||||
// Replace the fields
|
// Replace the fields
|
||||||
if (fields.Contains(Field.DatItem_Tag))
|
if (fields.Contains(Field.DatItem_Tag))
|
||||||
Tag = newItem.Tag;
|
Tag = newItem.Tag;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Tag))
|
||||||
|
Tag = newItem.Tag;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Mask))
|
if (fields.Contains(Field.DatItem_Mask))
|
||||||
Mask = newItem.Mask;
|
Mask = newItem.Mask;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Mask))
|
||||||
|
Mask = newItem.Mask;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Relation))
|
if (fields.Contains(Field.DatItem_Relation))
|
||||||
Relation = newItem.Relation;
|
Relation = newItem.Relation;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Relation))
|
||||||
|
Relation = newItem.Relation;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_ConditionValue))
|
if (fields.Contains(Field.DatItem_ConditionValue))
|
||||||
ConditionValue = newItem.ConditionValue;
|
ConditionValue = newItem.ConditionValue;
|
||||||
|
else if (fields.Contains(Field.DatItem_Condition_Value))
|
||||||
|
ConditionValue = newItem.ConditionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user