2018-05-19 19:07:50 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Generation 5 Evolution Branch Entries
|
|
|
|
/// </summary>
|
2019-03-23 17:36:28 +00:00
|
|
|
public static class EvolutionSet5
|
2018-05-19 19:07:50 +00:00
|
|
|
{
|
|
|
|
private static EvolutionMethod GetMethod(byte[] data, int offset)
|
|
|
|
{
|
2019-03-23 08:01:04 +00:00
|
|
|
var method = data[offset]; // other byte unnecessary
|
2018-05-19 19:07:50 +00:00
|
|
|
int arg = BitConverter.ToUInt16(data, offset + 2);
|
|
|
|
int species = BitConverter.ToUInt16(data, offset + 4);
|
|
|
|
|
|
|
|
if (method == 0)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
var evo = new EvolutionMethod
|
|
|
|
{
|
|
|
|
Method = method,
|
|
|
|
Argument = arg,
|
|
|
|
Species = species,
|
|
|
|
Level = arg,
|
|
|
|
};
|
|
|
|
|
2019-03-23 08:01:04 +00:00
|
|
|
if (EvolutionSet6.EvosWithArg.Contains(method))
|
2018-05-19 19:07:50 +00:00
|
|
|
evo.Level = 0;
|
|
|
|
return evo;
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
2019-03-23 17:36:28 +00:00
|
|
|
public static IReadOnlyList<EvolutionMethod[]> GetArray(byte[] data)
|
2018-05-19 19:07:50 +00:00
|
|
|
{
|
2019-03-23 08:01:04 +00:00
|
|
|
const int bpe = 6; // bytes per evolution entry
|
|
|
|
const int entries = 7; // amount of entries per species
|
|
|
|
const int size = entries * bpe; // bytes per species entry
|
|
|
|
|
2019-03-23 17:36:28 +00:00
|
|
|
var evos = new EvolutionMethod[data.Length / size][];
|
2019-03-23 08:01:04 +00:00
|
|
|
for (int i = 0; i < evos.Length; i++)
|
2018-05-19 19:07:50 +00:00
|
|
|
{
|
2019-03-23 08:01:04 +00:00
|
|
|
int offset = i * size;
|
|
|
|
int count = 0;
|
|
|
|
for (; count < entries; count++)
|
2018-05-19 19:07:50 +00:00
|
|
|
{
|
2019-03-23 08:01:04 +00:00
|
|
|
var methodOffset = offset + (count * bpe);
|
|
|
|
var method = data[methodOffset];
|
|
|
|
if (method == 0)
|
2018-05-19 19:07:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-03-23 08:01:04 +00:00
|
|
|
if (count == 0)
|
|
|
|
{
|
2019-03-23 17:36:28 +00:00
|
|
|
evos[i] = Array.Empty<EvolutionMethod>();
|
2019-03-23 08:01:04 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var set = new EvolutionMethod[count];
|
|
|
|
for (int j = 0; j < set.Length; j++)
|
|
|
|
set[j] = GetMethod(data, offset + (j * bpe));
|
2019-03-23 17:36:28 +00:00
|
|
|
evos[i] = set;
|
2018-05-19 19:07:50 +00:00
|
|
|
}
|
|
|
|
return evos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|