2018-06-09 03:10:41 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
{
|
2020-10-27 16:25:33 +00:00
|
|
|
public static class MoveTechnicalMachine
|
2018-06-09 03:10:41 +00:00
|
|
|
{
|
2020-12-22 17:10:10 +00:00
|
|
|
public static GameVersion GetIsMachineMove(PKM pkm, int species, int form, int generation, int move, GameVersion ver = GameVersion.Any, bool RemoveTransfer = false)
|
2018-06-09 03:10:41 +00:00
|
|
|
{
|
2020-02-13 04:25:39 +00:00
|
|
|
if (pkm.IsMovesetRestricted(generation))
|
2018-11-12 06:49:17 +00:00
|
|
|
ver = (GameVersion) pkm.Version;
|
2018-06-09 03:10:41 +00:00
|
|
|
switch (generation)
|
|
|
|
{
|
|
|
|
case 1: return GetIsMachine1(species, move);
|
2018-06-15 01:52:43 +00:00
|
|
|
case 2:
|
|
|
|
if (pkm.VC1 && move > Legal.MaxMoveID_1)
|
|
|
|
return Legal.NONE;
|
|
|
|
return GetIsMachine2(species, move);
|
2018-06-09 03:10:41 +00:00
|
|
|
case 3: return GetIsMachine3(species, move, pkm.Format, RemoveTransfer);
|
|
|
|
case 4: return GetIsMachine4(species, move, pkm.Format, RemoveTransfer, form);
|
|
|
|
case 5: return GetIsMachine5(species, move, form);
|
|
|
|
case 6: return GetIsMachine6(species, move, form, ver);
|
|
|
|
case 7: return GetIsMachine7(species, move, form, ver);
|
2020-12-22 17:10:10 +00:00
|
|
|
case 8: return GetIsMachine8(species, move, form, ver);
|
|
|
|
default:
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static GameVersion GetIsRecordMove(PKM pkm, int species, int form, int generation, int move, GameVersion ver = GameVersion.Any, bool allowBit = false)
|
|
|
|
{
|
|
|
|
if (pkm.IsMovesetRestricted(generation))
|
|
|
|
ver = (GameVersion)pkm.Version;
|
2020-12-24 01:14:38 +00:00
|
|
|
return generation switch
|
2020-12-22 17:10:10 +00:00
|
|
|
{
|
2020-12-24 01:14:38 +00:00
|
|
|
8 => GetIsRecord8(pkm, species, move, form, ver, allowBit),
|
|
|
|
_ => Legal.NONE
|
|
|
|
};
|
2018-06-09 03:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static GameVersion GetIsMachine1(int species, int move)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < Legal.TMHM_RBY.Length; i++)
|
2018-08-03 03:11:42 +00:00
|
|
|
{
|
|
|
|
if (Legal.TMHM_RBY[i] != move)
|
|
|
|
continue;
|
|
|
|
if (PersonalTable.RB[species].TMHM[i])
|
|
|
|
return GameVersion.RB;
|
|
|
|
if (PersonalTable.Y[species].TMHM[i])
|
|
|
|
return GameVersion.Y;
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine2(int species, int move)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < Legal.TMHM_GSC.Length; i++)
|
2018-08-03 03:11:42 +00:00
|
|
|
{
|
2018-06-09 03:10:41 +00:00
|
|
|
if (Legal.TMHM_GSC[i] == move && PersonalTable.C[species].TMHM[i])
|
|
|
|
return GameVersion.GS;
|
2018-08-03 03:11:42 +00:00
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine3(int species, int move, int format, bool RemoveTransfer)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < Legal.TM_3.Length; i++)
|
2018-08-03 03:11:42 +00:00
|
|
|
{
|
2018-06-09 03:10:41 +00:00
|
|
|
if (Legal.TM_3[i] == move && PersonalTable.E[species].TMHM[i])
|
|
|
|
return GameVersion.Gen3;
|
2018-08-03 03:11:42 +00:00
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
|
|
if (!RemoveTransfer && format <= 3)
|
|
|
|
return GetIsMachine3HM(species, move);
|
|
|
|
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine3HM(int species, int move)
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
foreach (var m in Legal.HM_3)
|
|
|
|
{
|
|
|
|
if (m == move && PersonalTable.E[species].TMHM[x + 50])
|
|
|
|
return GameVersion.Gen3;
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine4(int species, int move, int format, bool RemoveTransfer, int form)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < Legal.TM_3.Length; i++)
|
2018-08-03 03:11:42 +00:00
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
if (Legal.TM_4[i] == move && PersonalTable.HGSS.GetFormEntry(species, form).TMHM[i])
|
2018-06-09 03:10:41 +00:00
|
|
|
return GameVersion.Gen4;
|
2018-08-03 03:11:42 +00:00
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
|
|
if (RemoveTransfer && format > 4)
|
|
|
|
return GetIsMachine4HMTransfer(species, move, form);
|
|
|
|
|
|
|
|
return GetIsMachine4HM(species, move, form);
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine4HMTransfer(int species, int move, int form)
|
|
|
|
{
|
|
|
|
// The combination of both these moves is illegal, it should be checked that the pokemon only learn one
|
|
|
|
// except if it can learn any of these moves in gen 5 or later
|
|
|
|
switch (move)
|
|
|
|
{
|
|
|
|
case 250: // Whirlpool
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.HGSS.GetFormEntry(species, form).TMHM[96])
|
2018-06-09 03:10:41 +00:00
|
|
|
return GameVersion.HGSS;
|
|
|
|
break;
|
|
|
|
case 432: // Defog
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.Pt.GetFormEntry(species, form).TMHM[96])
|
2018-06-09 03:10:41 +00:00
|
|
|
return GameVersion.DPPt;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine4HM(int species, int move, int form)
|
|
|
|
{
|
2021-01-26 04:58:56 +00:00
|
|
|
var dp = Legal.HM_DPPt;
|
|
|
|
for (var i = 0; i < dp.Length; i++)
|
2018-06-09 03:10:41 +00:00
|
|
|
{
|
2021-01-26 04:58:56 +00:00
|
|
|
var m = dp[i];
|
|
|
|
if (m != move)
|
|
|
|
continue;
|
|
|
|
if (PersonalTable.Pt.GetFormEntry(species, form).TMHM[i + 92])
|
|
|
|
return GameVersion.DPPt;
|
|
|
|
break;
|
2018-06-09 03:10:41 +00:00
|
|
|
}
|
2021-01-26 04:58:56 +00:00
|
|
|
|
|
|
|
var hgss = Legal.HM_HGSS;
|
|
|
|
for (var i = 0; i < hgss.Length; i++)
|
|
|
|
{
|
|
|
|
var m = hgss[i];
|
|
|
|
if (m != move)
|
|
|
|
continue;
|
|
|
|
if (PersonalTable.HGSS.GetFormEntry(species, form).TMHM[i + 92])
|
|
|
|
return GameVersion.HGSS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine5(int species, int move, int form)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < Legal.TMHM_BW.Length; i++)
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
2018-06-09 03:10:41 +00:00
|
|
|
if (Legal.TMHM_BW[i] == move)
|
2020-12-11 04:42:30 +00:00
|
|
|
return PersonalTable.B2W2.GetFormEntry(species, form).TMHM[i] ? GameVersion.Gen5 : Legal.NONE;
|
2018-08-13 02:27:11 +00:00
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine6(int species, int move, int form, GameVersion ver)
|
|
|
|
{
|
|
|
|
if (GameVersion.XY.Contains(ver))
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
2018-06-09 03:10:41 +00:00
|
|
|
for (int i = 0; i < Legal.TMHM_XY.Length; i++)
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
|
|
|
if (Legal.TMHM_XY[i] != move)
|
|
|
|
continue;
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.XY.GetFormEntry(species, form).TMHM[i])
|
2018-08-13 02:27:11 +00:00
|
|
|
return GameVersion.XY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
if (GameVersion.ORAS.Contains(ver))
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
2018-06-09 03:10:41 +00:00
|
|
|
for (int i = 0; i < Legal.TMHM_AO.Length; i++)
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
|
|
|
if (Legal.TMHM_AO[i] != move)
|
|
|
|
continue;
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.AO.GetFormEntry(species, form).TMHM[i])
|
2018-08-13 02:27:11 +00:00
|
|
|
return GameVersion.ORAS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
return Legal.NONE;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static GameVersion GetIsMachine7(int species, int move, int form, GameVersion ver)
|
|
|
|
{
|
2020-08-07 01:24:20 +00:00
|
|
|
if (GameVersion.Gen7b.Contains(ver))
|
2018-11-12 06:49:17 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < Legal.TMHM_GG.Length; i++)
|
|
|
|
{
|
|
|
|
if (Legal.TMHM_GG[i] != move)
|
|
|
|
continue;
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.GG.GetFormEntry(species, form).TMHM[i])
|
2018-11-12 06:49:17 +00:00
|
|
|
return GameVersion.GG;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
if (GameVersion.SM.Contains(ver) && species <= Legal.MaxSpeciesID_7)
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
2018-11-12 06:49:17 +00:00
|
|
|
for (int i = 0; i < Legal.TMHM_SM.Length; i++)
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
2018-11-12 06:49:17 +00:00
|
|
|
if (Legal.TMHM_SM[i] != move)
|
2018-08-13 02:27:11 +00:00
|
|
|
continue;
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.SM.GetFormEntry(species, form).TMHM[i])
|
2018-08-13 02:27:11 +00:00
|
|
|
return GameVersion.SM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-12 06:49:17 +00:00
|
|
|
if (GameVersion.USUM.Contains(ver) && species <= Legal.MaxSpeciesID_7_USUM)
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
2018-06-09 03:10:41 +00:00
|
|
|
for (int i = 0; i < Legal.TMHM_SM.Length; i++)
|
2018-08-13 02:27:11 +00:00
|
|
|
{
|
|
|
|
if (Legal.TMHM_SM[i] != move)
|
|
|
|
continue;
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.USUM.GetFormEntry(species, form).TMHM[i])
|
2018-08-13 02:27:11 +00:00
|
|
|
return GameVersion.USUM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
return Legal.NONE;
|
|
|
|
}
|
|
|
|
|
2020-12-22 17:10:10 +00:00
|
|
|
private static GameVersion GetIsMachine8(int species, int move, int form, GameVersion ver)
|
2019-09-23 23:56:47 +00:00
|
|
|
{
|
|
|
|
if (GameVersion.SWSH.Contains(ver))
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
for (int i = 0; i < 100; i++)
|
2019-09-23 23:56:47 +00:00
|
|
|
{
|
|
|
|
if (Legal.TMHM_SWSH[i] != move)
|
|
|
|
continue;
|
2020-12-11 04:42:30 +00:00
|
|
|
if (PersonalTable.SWSH.GetFormEntry(species, form).TMHM[i])
|
2019-09-23 23:56:47 +00:00
|
|
|
return GameVersion.SWSH;
|
|
|
|
break;
|
|
|
|
}
|
2020-12-22 17:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static GameVersion GetIsRecord8(PKM pkm, int species, int move, int form, GameVersion ver, bool allowBit)
|
|
|
|
{
|
|
|
|
if (GameVersion.SWSH.Contains(ver))
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
{
|
|
|
|
if (Legal.TMHM_SWSH[i + 100] != move)
|
|
|
|
continue;
|
2020-12-11 04:42:30 +00:00
|
|
|
if (!PersonalTable.SWSH.GetFormEntry(species, form).TMHM[i + 100])
|
2019-11-16 01:34:18 +00:00
|
|
|
break;
|
|
|
|
if (allowBit)
|
|
|
|
return GameVersion.SWSH;
|
2020-12-22 17:10:10 +00:00
|
|
|
if (((PK8)pkm).GetMoveRecordFlag(i))
|
2019-11-16 01:34:18 +00:00
|
|
|
return GameVersion.SWSH;
|
2020-10-24 18:12:25 +00:00
|
|
|
if (i == 12 && species == (int)Species.Calyrex && form == 0) // TR12
|
|
|
|
return GameVersion.SWSH; // Agility Calyrex without TR glitch.
|
2019-11-16 01:34:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-09-23 23:56:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Legal.NONE;
|
|
|
|
}
|
|
|
|
|
2020-10-13 18:22:13 +00:00
|
|
|
public static IEnumerable<int> GetTMHM(PKM pkm, int species, int form, int generation, GameVersion ver = GameVersion.Any, bool RemoveTransfer = true)
|
2018-06-09 03:10:41 +00:00
|
|
|
{
|
2018-08-13 02:27:11 +00:00
|
|
|
var r = new List<int>();
|
2020-02-13 04:25:39 +00:00
|
|
|
if (pkm.IsMovesetRestricted(generation))
|
2018-11-12 06:49:17 +00:00
|
|
|
ver = (GameVersion)pkm.Version;
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
|
|
switch (generation)
|
|
|
|
{
|
|
|
|
case 1: AddMachine1(r, species); break;
|
2018-06-15 01:52:43 +00:00
|
|
|
case 2: AddMachine2(r, species);
|
|
|
|
if (pkm.Format >= 7 && pkm.VC1)
|
|
|
|
r.RemoveAll(z => z > Legal.MaxMoveID_1);
|
|
|
|
break;
|
2018-06-09 03:10:41 +00:00
|
|
|
case 3: AddMachine3(r, species, pkm.Format, RemoveTransfer); break;
|
|
|
|
case 4: AddMachine4(r, species, pkm.Format, RemoveTransfer, form); break;
|
|
|
|
case 5: AddMachine5(r, species, form); break;
|
|
|
|
case 6: AddMachine6(r, species, form, ver); break;
|
|
|
|
case 7: AddMachine7(r, species, form, ver); break;
|
2020-12-22 17:10:10 +00:00
|
|
|
case 8: AddMachine8(r, species, form, ver); break;
|
|
|
|
}
|
|
|
|
return r.Distinct();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IEnumerable<int> GetRecords(PKM pkm, int species, int form, int generation)
|
|
|
|
{
|
|
|
|
var r = new List<int>();
|
|
|
|
switch (generation)
|
|
|
|
{
|
|
|
|
case 8: AddRecordSWSH(r, species, form, pkm); break;
|
2018-06-09 03:10:41 +00:00
|
|
|
}
|
2018-06-09 23:04:06 +00:00
|
|
|
return r.Distinct();
|
2018-06-09 03:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void AddMachine1(List<int> r, int species)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
int index = PersonalTable.RB.GetFormIndex(species, 0);
|
2018-06-09 03:10:41 +00:00
|
|
|
if (index == 0)
|
|
|
|
return;
|
|
|
|
var pi_rb = (PersonalInfoG1)PersonalTable.RB[index];
|
|
|
|
var pi_y = (PersonalInfoG1)PersonalTable.Y[index];
|
|
|
|
r.AddRange(Legal.TMHM_RBY.Where((_, m) => pi_rb.TMHM[m]));
|
|
|
|
r.AddRange(Legal.TMHM_RBY.Where((_, m) => pi_y.TMHM[m]));
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine2(List<int> r, int species)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
int index = PersonalTable.C.GetFormIndex(species, 0);
|
2018-06-09 03:10:41 +00:00
|
|
|
if (index == 0)
|
|
|
|
return;
|
|
|
|
var pi_c = PersonalTable.C[index];
|
|
|
|
r.AddRange(Legal.TMHM_GSC.Where((_, m) => pi_c.TMHM[m]));
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine3(List<int> r, int species, int format, bool RemoveTransfer)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
int index = PersonalTable.E.GetFormIndex(species, 0);
|
2018-06-09 03:10:41 +00:00
|
|
|
if (index == 0)
|
|
|
|
return;
|
|
|
|
var pi_c = PersonalTable.E[index];
|
|
|
|
r.AddRange(Legal.TM_3.Where((_, m) => pi_c.TMHM[m]));
|
|
|
|
|
|
|
|
if (!RemoveTransfer || format == 3) // HM moves must be removed for 3->4, only give if current format.
|
|
|
|
r.AddRange(Legal.HM_3.Where((_, m) => pi_c.TMHM[m + 50]));
|
|
|
|
else if (format > 3) //Remove HM
|
|
|
|
r.AddRange(Legal.HM_3.Where((_, m) => pi_c.TMHM[m + 50]).Except(Legal.HM_3));
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine4(List<int> r, int species, int format, bool RemoveTransfer, int form)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi_hgss = PersonalTable.HGSS.GetFormEntry(species, form);
|
|
|
|
var pi_dppt = PersonalTable.Pt.GetFormEntry(species, form);
|
2018-06-09 03:10:41 +00:00
|
|
|
r.AddRange(Legal.TM_4.Where((_, m) => pi_hgss.TMHM[m]));
|
|
|
|
|
|
|
|
if (RemoveTransfer && format > 4)
|
|
|
|
{
|
|
|
|
// The combination of both these moves is illegal, it should be checked that the pokemon only learn one
|
|
|
|
// except if it can learn any of these moves in gen 5 or later
|
|
|
|
if (pi_hgss.TMHM[96])
|
|
|
|
r.Add(250); // Whirlpool
|
|
|
|
if (pi_dppt.TMHM[96])
|
|
|
|
r.Add(432); // Defog
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r.AddRange(Legal.HM_DPPt.Where((_, m) => pi_dppt.TMHM[m + 92]));
|
|
|
|
r.AddRange(Legal.HM_HGSS.Where((_, m) => pi_hgss.TMHM[m + 92]));
|
|
|
|
}
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine5(List<int> r, int species, int form)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi = PersonalTable.B2W2.GetFormEntry(species, form);
|
2018-06-09 03:10:41 +00:00
|
|
|
r.AddRange(Legal.TMHM_BW.Where((_, m) => pi.TMHM[m]));
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine6(List<int> r, int species, int form, GameVersion ver = GameVersion.Any)
|
|
|
|
{
|
|
|
|
switch (ver)
|
|
|
|
{
|
|
|
|
case GameVersion.Any: // Start at the top, hit every table
|
2020-12-25 18:58:33 +00:00
|
|
|
case GameVersion.X or GameVersion.Y or GameVersion.XY:
|
2018-06-09 03:10:41 +00:00
|
|
|
AddMachine6XY(r, species, form);
|
|
|
|
if (ver == GameVersion.Any) // Fall Through
|
|
|
|
AddMachine6AO(r, species, form);
|
|
|
|
break;
|
2020-12-25 18:58:33 +00:00
|
|
|
case GameVersion.AS or GameVersion.OR or GameVersion.ORAS:
|
2018-06-09 03:10:41 +00:00
|
|
|
AddMachine6AO(r, species, form);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine7(List<int> r, int species, int form, GameVersion ver = GameVersion.Any)
|
|
|
|
{
|
|
|
|
switch (ver)
|
|
|
|
{
|
2020-12-25 18:58:33 +00:00
|
|
|
case GameVersion.GP or GameVersion.GE or GameVersion.GG or GameVersion.GO:
|
2018-11-12 06:49:17 +00:00
|
|
|
AddMachineGG(r, species, form);
|
|
|
|
return;
|
2020-12-25 18:58:33 +00:00
|
|
|
case GameVersion.SN or GameVersion.MN or GameVersion.SM:
|
2018-06-09 03:10:41 +00:00
|
|
|
if (species <= Legal.MaxSpeciesID_7)
|
|
|
|
AddMachineSM(r, species, form);
|
|
|
|
return;
|
|
|
|
case GameVersion.Any:
|
2020-12-25 18:58:33 +00:00
|
|
|
case GameVersion.US or GameVersion.UM or GameVersion.USUM:
|
2018-06-09 03:10:41 +00:00
|
|
|
AddMachineUSUM(r, species, form);
|
|
|
|
if (ver == GameVersion.Any) // Fall Through
|
|
|
|
AddMachineSM(r, species, form);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2020-12-22 17:10:10 +00:00
|
|
|
private static void AddMachine8(List<int> r, int species, int form, GameVersion ver = GameVersion.Any)
|
2019-09-23 23:56:47 +00:00
|
|
|
{
|
|
|
|
switch (ver)
|
|
|
|
{
|
|
|
|
case GameVersion.Any:
|
2020-12-25 18:58:33 +00:00
|
|
|
case GameVersion.SW or GameVersion.SH or GameVersion.SWSH:
|
2020-12-22 17:10:10 +00:00
|
|
|
AddMachineSWSH(r, species, form);
|
2019-09-23 23:56:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine6XY(List<int> r, int species, int form)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi = PersonalTable.XY.GetFormEntry(species, form);
|
2018-06-09 03:10:41 +00:00
|
|
|
r.AddRange(Legal.TMHM_XY.Where((_, m) => pi.TMHM[m]));
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachine6AO(List<int> r, int species, int form)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi = PersonalTable.AO.GetFormEntry(species, form);
|
2018-06-09 03:10:41 +00:00
|
|
|
r.AddRange(Legal.TMHM_AO.Where((_, m) => pi.TMHM[m]));
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachineSM(List<int> r, int species, int form)
|
|
|
|
{
|
|
|
|
if (species > Legal.MaxSpeciesID_7)
|
|
|
|
return;
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi = PersonalTable.SM.GetFormEntry(species, form);
|
2018-06-09 03:10:41 +00:00
|
|
|
r.AddRange(Legal.TMHM_SM.Where((_, m) => pi.TMHM[m]));
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
private static void AddMachineUSUM(List<int> r, int species, int form)
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi = PersonalTable.USUM.GetFormEntry(species, form);
|
2018-06-09 03:10:41 +00:00
|
|
|
r.AddRange(Legal.TMHM_SM.Where((_, m) => pi.TMHM[m]));
|
|
|
|
}
|
2018-11-12 06:49:17 +00:00
|
|
|
|
|
|
|
private static void AddMachineGG(List<int> r, int species, int form)
|
|
|
|
{
|
|
|
|
if (species > Legal.MaxSpeciesID_7b)
|
|
|
|
return;
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi = PersonalTable.GG.GetFormEntry(species, form);
|
2018-11-12 06:49:17 +00:00
|
|
|
r.AddRange(Legal.TMHM_GG.Where((_, m) => pi.TMHM[m]));
|
|
|
|
}
|
2019-09-23 23:56:47 +00:00
|
|
|
|
2020-12-22 17:10:10 +00:00
|
|
|
private static void AddMachineSWSH(List<int> r, int species, int form)
|
2019-09-23 23:56:47 +00:00
|
|
|
{
|
|
|
|
if (species > Legal.MaxSpeciesID_8)
|
|
|
|
return;
|
2020-12-11 04:42:30 +00:00
|
|
|
var pi = PersonalTable.SWSH.GetFormEntry(species, form);
|
2019-11-16 01:34:18 +00:00
|
|
|
var tmhm = pi.TMHM;
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
{
|
|
|
|
if (!tmhm[i])
|
|
|
|
continue;
|
|
|
|
r.Add(Legal.TMHM_SWSH[i]);
|
|
|
|
}
|
2020-12-22 17:10:10 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2020-12-22 17:10:10 +00:00
|
|
|
public static void AddRecordSWSH(List<int> r, int species, int form, PKM pkm)
|
|
|
|
{
|
|
|
|
var pi = PersonalTable.SWSH.GetFormEntry(species, form);
|
|
|
|
var tmhm = pi.TMHM;
|
2019-11-16 01:34:18 +00:00
|
|
|
var pk8 = (PK8)pkm;
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
{
|
|
|
|
if (!tmhm[i + 100])
|
|
|
|
continue;
|
|
|
|
if (!pk8.GetMoveRecordFlag(i))
|
2020-10-24 18:12:25 +00:00
|
|
|
{
|
|
|
|
if (i == 12 && species == (int) Species.Calyrex && form == 0) // TR12
|
|
|
|
{
|
|
|
|
// Unfuse logic does not check if the currently known TR move has the flag or not.
|
|
|
|
// Agility can be learned via Level Up while fused, but only via TR when Unfused.
|
|
|
|
// We'll let Agility be a legal TR move without the flag, only for Calyrex!
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
r.Add(Legal.TMHM_SWSH[i + 100]);
|
|
|
|
}
|
2019-09-23 23:56:47 +00:00
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
}
|
|
|
|
}
|