2018-05-19 19:07:50 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Generation 6 Evolution Branch Entries
|
|
|
|
/// </summary>
|
2019-03-23 17:36:28 +00:00
|
|
|
public static class EvolutionSet6
|
2018-05-19 19:07:50 +00:00
|
|
|
{
|
2020-12-22 01:17:56 +00:00
|
|
|
internal static readonly HashSet<int> EvosWithArg = new() {6, 8, 16, 17, 18, 19, 20, 21, 22, 29};
|
2018-05-19 19:07:50 +00:00
|
|
|
private const int SIZE = 6;
|
2018-09-15 05:37:47 +00:00
|
|
|
|
2019-03-23 17:36:28 +00:00
|
|
|
private static EvolutionMethod[] GetMethods(byte[] data)
|
2018-05-19 19:07:50 +00:00
|
|
|
{
|
2019-03-23 17:36:28 +00:00
|
|
|
var evos = new EvolutionMethod[data.Length / SIZE];
|
2018-05-19 19:07:50 +00:00
|
|
|
for (int i = 0; i < data.Length; i += SIZE)
|
|
|
|
{
|
2020-01-25 23:42:17 +00:00
|
|
|
var method = BitConverter.ToUInt16(data, i + 0);
|
|
|
|
var arg = BitConverter.ToUInt16(data, i + 2);
|
2020-12-29 06:22:52 +00:00
|
|
|
var species = BitConverter.ToUInt16(data, i + 4);
|
2018-05-19 19:07:50 +00:00
|
|
|
|
|
|
|
// Argument is used by both Level argument and Item/Move/etc. Clear if appropriate.
|
2020-01-25 23:42:17 +00:00
|
|
|
var lvl = EvosWithArg.Contains(method) ? 0 : arg;
|
2018-05-19 19:07:50 +00:00
|
|
|
|
2020-12-29 06:22:52 +00:00
|
|
|
evos[i/SIZE] = new EvolutionMethod(method, species, argument: arg, level: lvl);
|
2018-05-19 19:07:50 +00:00
|
|
|
}
|
2019-03-23 17:36:28 +00:00
|
|
|
return evos;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IReadOnlyList<EvolutionMethod[]> GetArray(IReadOnlyList<byte[]> data)
|
|
|
|
{
|
|
|
|
var evos = new EvolutionMethod[data.Count][];
|
|
|
|
for (int i = 0; i < evos.Length; i++)
|
|
|
|
evos[i] = GetMethods(data[i]);
|
|
|
|
return evos;
|
2018-05-19 19:07:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|