More abilities, implemented support for form inheritance
All checks were successful
Build / Build (push) Successful in 49s
All checks were successful
Build / Build (push) Successful in 49s
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.Json.Serialization;
|
||||
@@ -111,11 +112,40 @@ public class SerializedForm
|
||||
/// </summary>
|
||||
public bool IsBattleOnly { get; set; }
|
||||
|
||||
public string? InheritFrom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Additional data that is not part of the standard form data.
|
||||
/// </summary>
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, JsonElement>? ExtensionData { get; set; }
|
||||
|
||||
[SuppressMessage("ReSharper", "ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract"),
|
||||
SuppressMessage("ReSharper", "NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract")]
|
||||
internal void MakeInheritFrom(SerializedForm other)
|
||||
{
|
||||
Abilities ??= other.Abilities.ToArray();
|
||||
HiddenAbilities ??= other.HiddenAbilities.ToArray();
|
||||
BaseStats ??= other.BaseStats.Copy();
|
||||
EVReward ??= other.EVReward.Copy();
|
||||
Types ??= other.Types.ToArray();
|
||||
if (Height == 0)
|
||||
Height = other.Height;
|
||||
if (Weight == 0)
|
||||
Weight = other.Weight;
|
||||
if (BaseExp == 0)
|
||||
BaseExp = other.BaseExp;
|
||||
Moves ??= new SerializedMoves();
|
||||
if (Moves.LevelMoves == null || Moves.LevelMoves.Length == 0)
|
||||
Moves.LevelMoves = other.Moves.LevelMoves?.ToArray();
|
||||
if (Moves.EggMoves == null || Moves.EggMoves.Length == 0)
|
||||
Moves.EggMoves = other.Moves.EggMoves?.ToArray();
|
||||
if (Moves.TutorMoves == null || Moves.TutorMoves.Length == 0)
|
||||
Moves.TutorMoves = other.Moves.TutorMoves?.ToArray();
|
||||
if (Moves.Machine == null || Moves.Machine.Length == 0)
|
||||
Moves.Machine = other.Moves.Machine?.ToArray();
|
||||
Flags ??= other.Flags.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -159,6 +189,17 @@ public record SerializedStats
|
||||
|
||||
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Speed"/>
|
||||
public ushort Speed { get; set; }
|
||||
|
||||
public SerializedStats Copy() =>
|
||||
new()
|
||||
{
|
||||
Hp = Hp,
|
||||
Attack = Attack,
|
||||
Defense = Defense,
|
||||
SpecialAttack = SpecialAttack,
|
||||
SpecialDefense = SpecialDefense,
|
||||
Speed = Speed,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user