diff --git a/pkNX.Structures/Evolution/EvolutionType.cs b/pkNX.Structures/Evolution/EvolutionType.cs index e72f6590..9b940346 100644 --- a/pkNX.Structures/Evolution/EvolutionType.cs +++ b/pkNX.Structures/Evolution/EvolutionType.cs @@ -18,7 +18,7 @@ public enum EvolutionType : byte LevelUpECgeq5, LevelUpNinjask, LevelUpShedinja, - LevelUpBauty, + LevelUpBeauty, UseItemMale, UseItemFemale, LevelUpHeldItemDay, @@ -32,7 +32,7 @@ public enum EvolutionType : byte LevelUpCold, LevelUpInverted, LevelUpAffection50MoveType, - LevelUpFairy, + LevelUpMoveType, LevelUpWeather, LevelUpMorning, LevelUpNight, @@ -42,5 +42,20 @@ public enum EvolutionType : byte LevelUpVersionDay, LevelUpVersionNight, LevelUpSummit, + LevelUpDusk, + LevelUpWormhole, + UseItemWormhole, + } + + public enum EvolutionTypeArgumentType + { + NoArg, + Level, + Items, + Moves, + Species, + Stat, + Type, + Version, } } diff --git a/pkNX.Structures/Evolution/Extensions.cs b/pkNX.Structures/Evolution/Extensions.cs new file mode 100644 index 00000000..7db503cb --- /dev/null +++ b/pkNX.Structures/Evolution/Extensions.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; + +using static pkNX.Structures.EvolutionType; +using static pkNX.Structures.EvolutionTypeArgumentType; + +namespace pkNX.Structures +{ + public static partial class Extensions + { + private static readonly Dictionary ArgType = new Dictionary + { + [None] = NoArg, + [LevelUpFriendship] = NoArg, + [LevelUpFriendshipMorning] = NoArg, + [LevelUpFriendshipNight] = NoArg, + [LevelUp] = Level, + [Trade] = NoArg, + [TradeHeldItem] = Items, + [TradeSpecies] = Species, + [UseItem] = Items, + + [LevelUpATK] = Level, + [LevelUpDEF] = Level, + [LevelUpAeqD] = Level, + [LevelUpECl5] = Level, + [LevelUpECgeq5] = Level, + [LevelUpNinjask] = Level, + [LevelUpShedinja] = Level, + [LevelUpBeauty] = Stat, + + [UseItemMale] = Items, + [UseItemFemale] = Items, + [LevelUpHeldItemDay] = Items, + [LevelUpHeldItemNight] = Items, + [LevelUpKnowMove] = Moves, + [LevelUpWithTeammate] = Species, + [LevelUpMale] = Level, + [LevelUpFemale] = Level, + [LevelUpElectric] = NoArg, + [LevelUpForest] = NoArg, + [LevelUpCold] = NoArg, + [LevelUpInverted] = NoArg, + [LevelUpAffection50MoveType] = NoArg, + + [LevelUpMoveType] = Type, + [LevelUpWeather] = Level, + [LevelUpMorning] = Level, + [LevelUpNight] = Level, + [LevelUpFormFemale1] = Level, + [UNUSED] = NoArg, + [LevelUpVersion] = Version, + [LevelUpVersionDay] = Version, + [LevelUpVersionNight] = Version, + [LevelUpSummit] = Level, + [LevelUpDusk] = Level, + [LevelUpWormhole] = Level, + [UseItemWormhole] = Items + }; + + public static EvolutionTypeArgumentType GetArgType(this EvolutionType t) => ArgType[t]; + } +} \ No newline at end of file diff --git a/pkNX.Structures/Learnset/Learnset.cs b/pkNX.Structures/Learnset/Learnset.cs index a4d12762..188953e8 100644 --- a/pkNX.Structures/Learnset/Learnset.cs +++ b/pkNX.Structures/Learnset/Learnset.cs @@ -78,5 +78,12 @@ public int GetLevelLearnMove(int move) int index = Array.IndexOf(Moves, move); return index < 0 ? index : Levels[index]; } + + public void Update(int[] moves, int[] levels) + { + Moves = moves; + Levels = levels; + Count = Moves.Length; + } } } diff --git a/pkNX.Structures/MegaEvolution/MegaEvolutionSet.cs b/pkNX.Structures/MegaEvolution/MegaEvolutionSet.cs index c7cf0c2d..ef535934 100644 --- a/pkNX.Structures/MegaEvolution/MegaEvolutionSet.cs +++ b/pkNX.Structures/MegaEvolution/MegaEvolutionSet.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Linq; namespace pkNX.Structures { @@ -9,7 +10,7 @@ public class MegaEvolutionSet private const int OFS_FORM = 0; private const int OFS_METHOD = 2; private const int OFS_ARGUMENT = 4; - internal const int SIZE = 8; + public const int SIZE = 8; public MegaEvolutionSet(byte[] data, int index) { @@ -18,6 +19,21 @@ public MegaEvolutionSet(byte[] data, int index) Array.Copy(data, index*SIZE, Data, 0, SIZE); } + public static MegaEvolutionSet[] ReadArray(byte[] data) + { + var count = data.Length / SIZE; + var result = new MegaEvolutionSet[count]; + for (int i = 0; i < count; i++) + result[i] = new MegaEvolutionSet(data, i); + return result; + } + + + public static byte[] WriteArray(MegaEvolutionSet[] data) + { + return data.SelectMany(z => z.Write()).ToArray(); + } + public int ToForm { get => BitConverter.ToUInt16(Data, OFS_FORM); @@ -42,6 +58,8 @@ public void Clear() Data[i] = 0; } + public byte[] Write() => (byte[])Data.Clone(); + public void Write(byte[] data, int index) => Data.CopyTo(data, index * SIZE); public void RemoveRestrictions() diff --git a/pkNX.Structures/MegaEvolution/MegaEvolutionTable.cs b/pkNX.Structures/MegaEvolution/MegaEvolutionTable.cs deleted file mode 100644 index 1ff48fab..00000000 --- a/pkNX.Structures/MegaEvolution/MegaEvolutionTable.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Collections.Generic; - -namespace pkNX.Structures -{ - /// - /// Represents all possible Mega Evolutions for all entries in the . - /// - public sealed class MegaEvolutionTable - { - private readonly MegaEvolutionSet[][] Table; - - public MegaEvolutionTable(IList data) - { - Table = new MegaEvolutionSet[data.Count][]; - for (int i = 0; i < data.Count; i++) - { - int count = data[i].Length / MegaEvolutionSet.SIZE; - Table[i] = new MegaEvolutionSet[count]; - for (int j = 0; j < count; j++) - Table[i][j] = new MegaEvolutionSet(data[i], j); - } - } - - private static byte[] Write(IList entry) - { - int count = entry.Count; - byte[] data = new byte[MegaEvolutionSet.SIZE]; - for (int i = 0; i < count; i++) - entry[i].Write(data, i); - return data; - } - - public MegaEvolutionSet[] this[int index] - { - get => Table[index]; - set => Table[index] = value; - } - - /// - /// Removes any restriction for Mega Evolution - /// - /// - /// uses ; not supported in prior games and maybe not future games. - /// This might not be useful in the long run. - /// - public void RemoveRestrictions() - { - foreach (var t in Table) - { - foreach (var s in t) - s.RemoveRestrictions(); - } - } - - /// - /// Writes the entire to its component files. - /// - /// Pack-ready array of files. - public byte[][] Write() - { - byte[][] data = new byte[Table.Length][]; - for (int i = 0; i < data.Length; i++) - data[i] = Write(Table[i]); - return data; - } - } -} diff --git a/pkNX.Structures/Personal/EXPGroup.cs b/pkNX.Structures/Personal/EXPGroup.cs new file mode 100644 index 00000000..a6245f72 --- /dev/null +++ b/pkNX.Structures/Personal/EXPGroup.cs @@ -0,0 +1,12 @@ +namespace pkNX.Structures +{ + public enum EXPGroup + { + MediumFast, + Erratic, + Fluctuating, + MediumSlow, + Fast, + Slow, + } +} \ No newline at end of file diff --git a/pkNX.Structures/Personal/EggGroup.cs b/pkNX.Structures/Personal/EggGroup.cs new file mode 100644 index 00000000..0ae5e628 --- /dev/null +++ b/pkNX.Structures/Personal/EggGroup.cs @@ -0,0 +1,22 @@ +namespace pkNX.Structures +{ + public enum EggGroup + { + None, + Monster, + Water1, + Bug, + Flying, + Field, + Fairy, + Grass, + HumanLike, + Water3, + Mineral, + Amorphous, + Water2, + Ditto, + Dragon, + Undiscovered, + } +} \ No newline at end of file diff --git a/pkNX.Structures/Personal/PokeColor.cs b/pkNX.Structures/Personal/PokeColor.cs new file mode 100644 index 00000000..b4d22274 --- /dev/null +++ b/pkNX.Structures/Personal/PokeColor.cs @@ -0,0 +1,16 @@ +namespace pkNX.Structures +{ + public enum PokeColor + { + Red, + Blue, + Yellow, + Green, + Black, + Brown, + Purple, + Gray, + White, + Pink, + } +}