pkNX/pkNX.Randomization/Randomizers/FormRandomizer.cs
2018-11-13 19:44:43 -08:00

48 lines
1.4 KiB
C#

using pkNX.Structures;
using System.Linq;
namespace pkNX.Randomization
{
public class FormRandomizer
{
private readonly PersonalTable Table;
public FormRandomizer(PersonalTable t)
{
Table = t;
}
public bool AllowMega { get; set; } = false;
public bool AllowAlolanForm { get; set; } = true;
public int GetRandomForme(int species, PersonalInfo[] stats = null)
{
if (stats == null)
stats = Table.Table;
if (stats[species].FormeCount <= 1)
return 0;
switch (species)
{
case 201: // Unown
case 586: // Sawsbuck
return 31; // Random
case 658 when !AllowMega:
return 0;
case 664:
case 665:
case 666: // Vivillon evo chain
return 30; // save file specific
case 774: // Minior
return Util.Random.Next(7);
}
if (AllowAlolanForm && Legal.EvolveToAlolanForms.Contains(species))
return Util.Random.Next(2);
if (!Legal.BattleExclusiveForms.Contains(species) || AllowMega)
return Util.Random.Next(stats[species].FormeCount); // Slot-Random
return 0;
}
}
}