diff --git a/library/Structures/Pokemon4.cs b/library/Structures/Pokemon4.cs index d4f79023..7a0f94af 100644 --- a/library/Structures/Pokemon4.cs +++ b/library/Structures/Pokemon4.cs @@ -71,6 +71,8 @@ namespace PkmnFoundations.Structures blocks = blocks2; } + IsBadEgg = ComputeChecksum(blocks) != checksum; + int ribbons1, ribbons2, ribbons3; { diff --git a/library/Structures/PokemonPartyBase.cs b/library/Structures/PokemonPartyBase.cs index 80d2cfa3..1f0c1522 100644 --- a/library/Structures/PokemonPartyBase.cs +++ b/library/Structures/PokemonPartyBase.cs @@ -59,6 +59,7 @@ namespace PkmnFoundations.Structures public Markings Markings { get; set; } public ConditionValues ContestStats { get; set; } public bool IsEgg { get; set; } + public bool IsBadEgg { get; set; } /// /// this field decides whether or not its name gets reverted when it evolves. @@ -137,6 +138,12 @@ namespace PkmnFoundations.Structures } } + public virtual TrainerMemo TrainerMemo + { + get; + set; + } + public static bool HasRibbon(byte[] ribbons, int value) { if (value >= 96 || value < 0) throw new ArgumentOutOfRangeException(); @@ -145,10 +152,18 @@ namespace PkmnFoundations.Structures return (ribbons[offset] & mask) != 0; } - public virtual TrainerMemo TrainerMemo + public static ushort ComputeChecksum(byte[] data) { - get; - set; + ushort result = 0; + for (int x = 0; x < data.Length; x += 2) + result += BitConverter.ToUInt16(data, x); + + return result; + } + + public static ushort ComputeChecksum(byte[][] data) + { + return (ushort)data.Sum(inner => ComputeChecksum(inner)); } } }