Misc updates

Add more enums, expand on information types
This commit is contained in:
Kurt
2018-11-20 16:31:05 -08:00
parent 0ed465913f
commit 8341dd8f95
8 changed files with 155 additions and 70 deletions

View File

@@ -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,
}
}

View File

@@ -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<EvolutionType, EvolutionTypeArgumentType> ArgType = new Dictionary<EvolutionType, EvolutionTypeArgumentType>
{
[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];
}
}

View File

@@ -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;
}
}
}

View File

@@ -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()

View File

@@ -1,67 +0,0 @@
using System.Collections.Generic;
namespace pkNX.Structures
{
/// <summary>
/// Represents all possible Mega Evolutions for all <see cref="PersonalInfo"/> entries in the <see cref="PersonalTable"/>.
/// </summary>
public sealed class MegaEvolutionTable
{
private readonly MegaEvolutionSet[][] Table;
public MegaEvolutionTable(IList<byte[]> 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<MegaEvolutionSet> 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;
}
/// <summary>
/// Removes any restriction for Mega Evolution
/// </summary>
/// <remarks>
/// <see cref="GameVersion.GG"/> uses <see cref="MegaEvolutionMethod.NoRequirement"/>; not supported in prior games and maybe not future games.
/// This might not be useful in the long run.
/// </remarks>
public void RemoveRestrictions()
{
foreach (var t in Table)
{
foreach (var s in t)
s.RemoveRestrictions();
}
}
/// <summary>
/// Writes the entire <see cref="MegaEvolutionTable"/> to its component files.
/// </summary>
/// <returns>Pack-ready array of files.</returns>
public byte[][] Write()
{
byte[][] data = new byte[Table.Length][];
for (int i = 0; i < data.Length; i++)
data[i] = Write(Table[i]);
return data;
}
}
}

View File

@@ -0,0 +1,12 @@
namespace pkNX.Structures
{
public enum EXPGroup
{
MediumFast,
Erratic,
Fluctuating,
MediumSlow,
Fast,
Slow,
}
}

View File

@@ -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,
}
}

View File

@@ -0,0 +1,16 @@
namespace pkNX.Structures
{
public enum PokeColor
{
Red,
Blue,
Yellow,
Green,
Black,
Brown,
Purple,
Gray,
White,
Pink,
}
}