mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-11 06:05:04 -05:00
Add elemental tutors
Closes #2443 Capture some array references to avoid re-fetching array -- array reference is readonly so it probably won't matter
This commit is contained in:
parent
2292c7eb1d
commit
13adc38ee8
|
|
@ -100,19 +100,21 @@ private static GameVersion GetIsTutor4(int species, int form, int move)
|
|||
private static GameVersion GetIsTutor5(PKM pkm, int species, int form, bool specialTutors, int move)
|
||||
{
|
||||
var pi = PersonalTable.B2W2.GetFormeEntry(species, form);
|
||||
for (int i = 0; i < TypeTutor6.Length; i++)
|
||||
var arr = TypeTutor6;
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
if (TypeTutor6[i] == move && pi.TypeTutors[i])
|
||||
if (arr[i] == move && pi.TypeTutors[i])
|
||||
return GameVersion.Gen5;
|
||||
}
|
||||
|
||||
if (specialTutors && pkm.HasVisitedB2W2())
|
||||
{
|
||||
for (int i = 0; i < Tutors_B2W2.Length; i++)
|
||||
var tutors = Tutors_B2W2;
|
||||
for (int i = 0; i < tutors.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < Tutors_B2W2[i].Length; j++)
|
||||
for (int j = 0; j < tutors[i].Length; j++)
|
||||
{
|
||||
if (Tutors_B2W2[i][j] == move && pi.SpecialTutors[i][j])
|
||||
if (tutors[i][j] == move && pi.SpecialTutors[i][j])
|
||||
return GameVersion.B2W2;
|
||||
}
|
||||
}
|
||||
|
|
@ -124,19 +126,21 @@ private static GameVersion GetIsTutor5(PKM pkm, int species, int form, bool spec
|
|||
private static GameVersion GetIsTutor6(PKM pkm, int species, int form, bool specialTutors, int move)
|
||||
{
|
||||
var pi = PersonalTable.AO.GetFormeEntry(species, form);
|
||||
for (int i = 0; i < TypeTutor6.Length; i++)
|
||||
var arr = TypeTutor6;
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
if (TypeTutor6[i] == move && pi.TypeTutors[i])
|
||||
if (arr[i] == move && pi.TypeTutors[i])
|
||||
return GameVersion.Gen6;
|
||||
}
|
||||
|
||||
if (specialTutors && pkm.HasVisitedORAS())
|
||||
{
|
||||
for (int i = 0; i < Tutors_AO.Length; i++)
|
||||
var tutors = Tutors_AO;
|
||||
for (int i = 0; i < tutors.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < Tutors_AO[i].Length; j++)
|
||||
for (int j = 0; j < tutors[i].Length; j++)
|
||||
{
|
||||
if (Tutors_AO[i][j] == move && pi.SpecialTutors[i][j])
|
||||
if (tutors[i][j] == move && pi.SpecialTutors[i][j])
|
||||
return GameVersion.ORAS;
|
||||
}
|
||||
}
|
||||
|
|
@ -148,17 +152,19 @@ private static GameVersion GetIsTutor6(PKM pkm, int species, int form, bool spec
|
|||
private static GameVersion GetIsTutor7(PKM pkm, int species, int form, bool specialTutors, int move)
|
||||
{
|
||||
var pi = PersonalTable.USUM.GetFormeEntry(species, form);
|
||||
for (int i = 0; i < TypeTutor6.Length; i++)
|
||||
var arr = TypeTutor6;
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
if (TypeTutor6[i] == move && pi.TypeTutors[i])
|
||||
if (arr[i] == move && pi.TypeTutors[i])
|
||||
return GameVersion.Gen7;
|
||||
}
|
||||
|
||||
if (specialTutors && pkm.HasVisitedUSUM())
|
||||
{
|
||||
for (int i = 0; i < Tutors_USUM.Length; i++)
|
||||
var tutors = Tutors_USUM;
|
||||
for (int i = 0; i < tutors.Length; i++)
|
||||
{
|
||||
if (Tutors_USUM[i] == move && pi.SpecialTutors[0][i])
|
||||
if (tutors[i] == move && pi.SpecialTutors[0][i])
|
||||
return GameVersion.USUM;
|
||||
}
|
||||
}
|
||||
|
|
@ -168,6 +174,14 @@ private static GameVersion GetIsTutor7(PKM pkm, int species, int form, bool spec
|
|||
|
||||
private static GameVersion GetIsTutor8(PKM pkm, int species, int form, bool specialTutors, int move)
|
||||
{
|
||||
var pi = (PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(species, form);
|
||||
var arr = TypeTutor8;
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
if (arr[i] == move && pi.TypeTutors[i])
|
||||
return GameVersion.Gen8;
|
||||
}
|
||||
|
||||
return NONE;
|
||||
}
|
||||
|
||||
|
|
@ -249,11 +263,15 @@ private static void AddMovesTutor7(List<int> moves, int species, int form, PKM p
|
|||
var pi = PersonalTable.USUM.GetFormeEntry(species, form);
|
||||
moves.AddRange(TypeTutor6.Where((_, i) => pi.TypeTutors[i]));
|
||||
if (specialTutors && pkm.HasVisitedUSUM())
|
||||
moves.AddRange(GetTutors(PersonalTable.USUM.GetFormeEntry(species, form), Tutors_USUM));
|
||||
moves.AddRange(GetTutors(pi, Tutors_USUM));
|
||||
}
|
||||
|
||||
private static void AddMovesTutor8(List<int> moves, int species, int form, PKM pkm, bool specialTutors)
|
||||
{
|
||||
var pi = (PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(species, form);
|
||||
if (!pi.IsPresentInGame)
|
||||
return;
|
||||
moves.AddRange(TypeTutor8.Where((_, i) => pi.TypeTutors[i]));
|
||||
}
|
||||
|
||||
private static IEnumerable<int> GetTutors(PersonalInfo pi, params int[][] tutors)
|
||||
|
|
|
|||
|
|
@ -214,7 +214,13 @@ public static partial class Legal
|
|||
15, 19, 57, 70, 127,
|
||||
};
|
||||
|
||||
internal static readonly int[] TypeTutor6 = {520, 519, 518, 338, 307, 308, 434, 620};
|
||||
internal static readonly int[] TypeTutor6 =
|
||||
{
|
||||
520, 519, 518, // Pledge
|
||||
338, 307, 308, // Elemental Beam
|
||||
434, // Draco Meteor
|
||||
620, // Dragon Ascent
|
||||
};
|
||||
|
||||
internal static readonly int[][] Tutors_AO =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -404,5 +404,13 @@ public static partial class Legal
|
|||
710, 711, 715, 716, 718, 745, 746, 747, 748, 749,
|
||||
750, 751, 752, 753, 754, 755, 756,
|
||||
};
|
||||
|
||||
internal static readonly int[] TypeTutor8 =
|
||||
{
|
||||
520, 519, 518, // Pledge
|
||||
338, 307, 308, // Elemental Beam
|
||||
434, // Draco Meteor
|
||||
796, // Steel Beam
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,12 @@ public PersonalInfoSWSH(byte[] data) : base(data)
|
|||
TMHM[i] = FlagUtil.GetFlag(Data, 0x28 + (i >> 3), i);
|
||||
TMHM[i + 100] = FlagUtil.GetFlag(Data, 0x3C + (i >> 3), i);
|
||||
}
|
||||
TypeTutors = Array.Empty<bool>();
|
||||
|
||||
// 0x38-0x3B type tutors, but only 8 bits are valid flags.
|
||||
var typeTutors = new bool[8];
|
||||
for (int i = 0; i < typeTutors.Length; i++)
|
||||
typeTutors[i] = FlagUtil.GetFlag(Data, 0x38, i);
|
||||
TypeTutors = typeTutors;
|
||||
}
|
||||
|
||||
public override byte[] Write()
|
||||
|
|
@ -27,6 +32,8 @@ public override byte[] Write()
|
|||
FlagUtil.SetFlag(Data, 0x28 + (i >> 3), i, TMHM[i]);
|
||||
FlagUtil.SetFlag(Data, 0x3C + (i >> 3), i, TMHM[i + 100]);
|
||||
}
|
||||
for (int i = 0; i < TypeTutors.Length; i++)
|
||||
FlagUtil.SetFlag(Data, 0x38, i, TypeTutors[i]);
|
||||
return Data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user