Add gen3 personal info, move object refs

All PersonalInfo arrays are referenced from PersonalInfo's class instead
of Legal

Fixed a few bugs in the process (species translation, gen switch)
This commit is contained in:
Kaphotics 2016-07-03 15:05:15 -07:00
parent 4568bdc576
commit 1779420af1
18 changed files with 113 additions and 35 deletions

View file

@ -423,8 +423,8 @@ namespace PKHeX
}
private LegalityCheck verifyAbility()
{
int index = Legal.PersonalAO[pk6.Species].FormeIndex(pk6.Species, pk6.AltForm);
int[] abilities = Legal.PersonalAO[index].Abilities;
int index = PersonalInfo.AO[pk6.Species].FormeIndex(pk6.Species, pk6.AltForm);
int[] abilities = PersonalInfo.AO[index].Abilities;
int abilval = Array.IndexOf(abilities, pk6.Ability);
if (abilval < 0)
return new LegalityCheck(Severity.Invalid, "Ability is not valid for species/form.");

View file

@ -8,13 +8,6 @@ namespace PKHeX
// PKHeX master Wonder Card Database
internal static WC6[] WC6DB;
// PKHeX master personal.dat
internal static readonly PersonalInfo[] PersonalAO = PersonalInfo.getArray(Properties.Resources.personal_ao, GameVersion.ORAS);
internal static readonly PersonalInfo[] PersonalXY = PersonalInfo.getArray(Properties.Resources.personal_xy, GameVersion.XY);
internal static readonly PersonalInfo[] PersonalB2W2 = PersonalInfo.getArray(Properties.Resources.personal_b2w2, GameVersion.B2W2);
internal static readonly PersonalInfo[] PersonalBW = PersonalInfo.getArray(Properties.Resources.personal_bw, GameVersion.BW);
internal static readonly PersonalInfo[] PersonalHGSS = PersonalInfo.getArray(Properties.Resources.personal_hgss, GameVersion.HGSS);
internal static readonly PersonalInfo[] PersonalPt = PersonalInfo.getArray(Properties.Resources.personal_pt, GameVersion.Pt);
internal static readonly PersonalInfo[] PersonalDP = PersonalInfo.getArray(Properties.Resources.personal_dp, GameVersion.DP);
private static readonly EggMoves[] EggMoveXY = EggMoves.getArray(Data.unpackMini(Properties.Resources.eggmove_xy, "xy"));
private static readonly Learnset[] LevelUpXY = Learnset.getArray(Data.unpackMini(Properties.Resources.lvlmove_xy, "xy"));
@ -412,8 +405,8 @@ namespace PKHeX
}
private static IEnumerable<int> getLVLMoves(int species, int lvl, int formnum)
{
int ind_XY = PersonalXY[species].FormeIndex(species, formnum);
int ind_AO = PersonalAO[species].FormeIndex(species, formnum);
int ind_XY = PersonalInfo.XY[species].FormeIndex(species, formnum);
int ind_AO = PersonalInfo.AO[species].FormeIndex(species, formnum);
return LevelUpXY[ind_XY].getMoves(lvl).Concat(LevelUpAO[ind_AO].getMoves(lvl));
}
private static IEnumerable<EncounterArea> getEncounterSlots(PK6 pk6)
@ -550,7 +543,7 @@ namespace PKHeX
bool ORASTutors = Version == -1 || pk6.AO || !pk6.IsUntraded;
if (FormChangeMoves.Contains(species)) // Deoxys & Shaymin & Giratina (others don't have extra but whatever)
{
int formcount = PersonalAO[species].FormeCount;
int formcount = PersonalInfo.AO[species].FormeCount;
for (int i = 0; i < formcount; i++)
r.AddRange(getMoves(species, lvl, i, ORASTutors, Version, LVL, Tutor, Machine));
if (Relearn) r.AddRange(pk6.RelearnMoves);
@ -575,8 +568,8 @@ namespace PKHeX
List<int> r = new List<int> { 0 };
if (Version < 0 || Version == 0)
{
int index = PersonalXY[species].FormeIndex(species, form);
PersonalInfo pi = PersonalXY[index];
int index = PersonalInfo.XY[species].FormeIndex(species, form);
PersonalInfo pi = PersonalInfo.XY[index];
if (LVL) r.AddRange(LevelUpXY[index].getMoves(lvl));
if (Tutor) r.AddRange(getTutorMoves(species, form, ORASTutors));
@ -584,8 +577,8 @@ namespace PKHeX
}
if (Version < 0 || Version == 1)
{
int index = PersonalAO[species].FormeIndex(species, form);
PersonalInfo pi = PersonalAO[index];
int index = PersonalInfo.AO[species].FormeIndex(species, form);
PersonalInfo pi = PersonalInfo.AO[index];
if (LVL) r.AddRange(LevelUpAO[index].getMoves(lvl));
if (Tutor) r.AddRange(getTutorMoves(species, form, ORASTutors));
@ -595,13 +588,13 @@ namespace PKHeX
}
private static IEnumerable<int> getEggMoves(int species, int formnum)
{
int ind_XY = PersonalXY[species].FormeIndex(species, formnum);
int ind_AO = PersonalAO[species].FormeIndex(species, formnum);
int ind_XY = PersonalInfo.XY[species].FormeIndex(species, formnum);
int ind_AO = PersonalInfo.AO[species].FormeIndex(species, formnum);
return EggMoveAO[ind_AO].Moves.Concat(EggMoveXY[ind_XY].Moves);
}
private static IEnumerable<int> getTutorMoves(int species, int formnum, bool ORASTutors)
{
PersonalInfoORAS pkAO = (PersonalInfoORAS)PersonalAO[PersonalAO[species].FormeIndex(species, formnum)];
PersonalInfoORAS pkAO = (PersonalInfoORAS) PersonalInfo.AO[PersonalInfo.AO[species].FormeIndex(species, formnum)];
// Type Tutor
List<int> moves = TypeTutor.Where((t, i) => pkAO.TypeTutors[i]).ToList();

View file

@ -78,6 +78,7 @@
<Compile Include="PersonalInfo\PersonalInfo.cs" />
<Compile Include="PersonalInfo\PersonalInfoB2W2.cs" />
<Compile Include="PersonalInfo\PersonalInfoBW.cs" />
<Compile Include="PersonalInfo\PersonalInfoG3.cs" />
<Compile Include="PersonalInfo\PersonalInfoG4.cs" />
<Compile Include="PersonalInfo\PersonalInfoORAS.cs" />
<Compile Include="PersonalInfo\PersonalInfoXY.cs" />
@ -389,8 +390,12 @@
<None Include="Resources\byte\personal_b2w2" />
<None Include="Resources\byte\personal_bw" />
<None Include="Resources\byte\personal_dp" />
<None Include="Resources\byte\personal_e" />
<None Include="Resources\byte\personal_fr" />
<None Include="Resources\byte\personal_hgss" />
<None Include="Resources\byte\personal_lg" />
<None Include="Resources\byte\personal_pt" />
<None Include="Resources\byte\personal_rs" />
<None Include="Resources\byte\personal_xy" />
<None Include="Resources\byte\wc6.pkl" />
<None Include="Resources\byte\wc6full.pkl" />

View file

@ -181,7 +181,7 @@ namespace PKHeX
try { return SpeciesLang.All(list => list[species].ToUpper() != nick); }
catch { return false; }
}
internal static PersonalInfo[] Personal = Legal.PersonalAO;
internal static PersonalInfo[] Personal = PersonalInfo.AO;
// Stat Fetching
internal static int getMovePP(int move, int ppup)
@ -1199,11 +1199,11 @@ namespace PKHeX
}
}
#region Gen 3 Species Table
internal static readonly int[] newindex =
internal static int[] newindex => new[]
{
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,
59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,77,79,80,81,82,83,84,85,86,
59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,
87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,
111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,
132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,
@ -1221,7 +1221,7 @@ namespace PKHeX
385,386,358,
};
internal static readonly int[] oldindex =
internal static int[] oldindex => new[]
{
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,

View file

@ -763,11 +763,13 @@ namespace PKHeX
TB_Secure2.Text = (SAV as SAV6).Secure2.ToString("X16");
break;
}
PKX.Personal = SAV.Personal;
PKM pk = preparePKM();
PKX.Personal = SAV.Personal;
bool init = fieldsInitialized;
fieldsInitialized = false;
populateFilteredDataSources();
populateFields(pkm.Format != SAV.Generation ? SAV.BlankPKM : pk);
fieldsInitialized |= init;
// SAV Specific Limits
TB_OT.MaxLength = SAV.OTLength;

View file

@ -4,6 +4,18 @@ namespace PKHeX
{
public abstract class PersonalInfo
{
internal static readonly PersonalInfo[] AO = getArray(Properties.Resources.personal_ao, GameVersion.ORAS);
internal static readonly PersonalInfo[] XY = getArray(Properties.Resources.personal_xy, GameVersion.XY);
internal static readonly PersonalInfo[] B2W2 = getArray(Properties.Resources.personal_b2w2, GameVersion.B2W2);
internal static readonly PersonalInfo[] BW = getArray(Properties.Resources.personal_bw, GameVersion.BW);
internal static readonly PersonalInfo[] HGSS = getArray(Properties.Resources.personal_hgss, GameVersion.HGSS);
internal static readonly PersonalInfo[] Pt = getArray(Properties.Resources.personal_pt, GameVersion.Pt);
internal static readonly PersonalInfo[] DP = getArray(Properties.Resources.personal_dp, GameVersion.DP);
internal static readonly PersonalInfo[] LG = getArray(Properties.Resources.personal_lg, GameVersion.LG);
internal static readonly PersonalInfo[] FR = getArray(Properties.Resources.personal_fr, GameVersion.FR);
internal static readonly PersonalInfo[] E = getArray(Properties.Resources.personal_e, GameVersion.E);
internal static readonly PersonalInfo[] RS = getArray(Properties.Resources.personal_rs, GameVersion.RS);
protected const int SIZE_G3 = 0x1C;
protected const int SIZE_G4 = 0x2C;
protected const int SIZE_BW = 0x3C;
@ -103,6 +115,10 @@ namespace PKHeX
int size = 0;
switch (format)
{
case GameVersion.RS:
case GameVersion.E:
case GameVersion.FR:
case GameVersion.LG: size = SIZE_G3; break;
case GameVersion.DP:
case GameVersion.Pt:
case GameVersion.HGSS: size = SIZE_G4; break;
@ -120,6 +136,14 @@ namespace PKHeX
switch (format)
{
case GameVersion.RS:
case GameVersion.E:
case GameVersion.FR:
case GameVersion.LG:
Array.Resize(ref d, 387);
for (int i = 0; i < d.Length; i++) // entries are not in order of natdexID
d[i] = new PersonalInfoG3(entries[PKX.getG3Species(i)]);
break;
case GameVersion.DP:
case GameVersion.Pt:
case GameVersion.HGSS:

View file

@ -14665,6 +14665,26 @@ namespace PKHeX.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] personal_e {
get {
object obj = ResourceManager.GetObject("personal_e", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] personal_fr {
get {
object obj = ResourceManager.GetObject("personal_fr", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
@ -14675,6 +14695,16 @@ namespace PKHeX.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] personal_lg {
get {
object obj = ResourceManager.GetObject("personal_lg", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
@ -14685,6 +14715,16 @@ namespace PKHeX.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] personal_rs {
get {
object obj = ResourceManager.GetObject("personal_rs", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>

View file

@ -5884,4 +5884,16 @@
<data name="personal_pt" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\personal_pt;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="personal_e" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\personal_e;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="personal_fr" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\personal_fr;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="personal_lg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\personal_lg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="personal_rs" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\personal_rs;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

BIN
Resources/byte/personal_e Normal file

Binary file not shown.

BIN
Resources/byte/personal_fr Normal file

Binary file not shown.

BIN
Resources/byte/personal_lg Normal file

Binary file not shown.

BIN
Resources/byte/personal_rs Normal file

Binary file not shown.

View file

@ -363,7 +363,7 @@ namespace PKHeX
private void setForms()
{
int species = Util.getIndex(CB_Species);
bool hasForms = Legal.PersonalAO[species].HasFormes || new[] { 664, 665, 414 }.Contains(species);
bool hasForms = PersonalInfo.AO[species].HasFormes || new[] { 664, 665, 414 }.Contains(species);
CB_Form.Enabled = CB_Form.Visible = hasForms;
CB_Form.DisplayMember = "Text";

View file

@ -411,7 +411,7 @@ namespace PKHeX
int newabil = Convert.ToInt16(MT_AbilNo.Text) >> 1;
int species = Util.getIndex(CB_Species);
int formnum = CB_Form.SelectedIndex;
int[] abils = Legal.PersonalAO[Legal.PersonalAO[species].FormeIndex(species, formnum)].Abilities;
int[] abils = PersonalInfo.AO[PersonalInfo.AO[species].FormeIndex(species, formnum)].Abilities;
// Build Ability List
List<string> ability_list = new List<string>
@ -428,7 +428,7 @@ namespace PKHeX
private void setForms()
{
int species = Util.getIndex(CB_Species);
bool hasForms = Legal.PersonalAO[species].HasFormes || new[] { 664, 665, 414 }.Contains(species);
bool hasForms = PersonalInfo.AO[species].HasFormes || new[] { 664, 665, 414 }.Contains(species);
CB_Form.Enabled = CB_Form.Visible = hasForms;
CB_Form.DisplayMember = "Text";

View file

@ -82,6 +82,7 @@ namespace PKHeX
OFS_PouchBalls = Party + 0x0600;
OFS_PouchTMHM = Party + 0x0640;
OFS_PouchBerry = Party + 0x0740;
Personal = PersonalInfo.RS;
break;
case GameVersion.FRLG:
LegalKeyItems = Legal.Pouch_Key_FRLG;
@ -90,6 +91,7 @@ namespace PKHeX
OFS_PouchBalls = Party + 0x0430;
OFS_PouchTMHM = Party + 0x0464;
OFS_PouchBerry = Party + 0x054C;
Personal = PersonalInfo.FR; // todo
break;
case GameVersion.E:
LegalKeyItems = Legal.Pouch_Key_E;
@ -98,6 +100,7 @@ namespace PKHeX
OFS_PouchBalls = Party + 0x0650;
OFS_PouchTMHM = Party + 0x0690;
OFS_PouchBerry = Party + 0x0790;
Personal = PersonalInfo.E;
break;
}
LegalItems = Legal.Pouch_Items_RS;
@ -106,7 +109,6 @@ namespace PKHeX
LegalBerries = Legal.Pouch_Berries_RS;
HeldItems = Legal.HeldItems_RS;
Personal = Legal.PersonalAO; // todo
if (!Exportable)
resetBoxes();

View file

@ -28,9 +28,9 @@ namespace PKHeX
switch (Version)
{
case GameVersion.DP: Personal = Legal.PersonalDP; break;
case GameVersion.Pt: Personal = Legal.PersonalPt; break;
case GameVersion.HGSS: Personal = Legal.PersonalHGSS; break;
case GameVersion.DP: Personal = PersonalInfo.DP; break;
case GameVersion.Pt: Personal = PersonalInfo.Pt; break;
case GameVersion.HGSS: Personal = PersonalInfo.HGSS; break;
}
if (!Exportable)

View file

@ -53,7 +53,7 @@ namespace PKHeX
LegalMedicine = Legal.Pouch_Medicine_BW;
LegalBerries = Legal.Pouch_Berries_BW;
Personal = Legal.PersonalBW;
Personal = PersonalInfo.BW;
break;
case GameVersion.B2W2: // B2W2
BattleBox = 0x20900;
@ -74,7 +74,7 @@ namespace PKHeX
LegalMedicine = Legal.Pouch_Medicine_BW;
LegalBerries = Legal.Pouch_Berries_BW;
Personal = Legal.PersonalB2W2;
Personal = PersonalInfo.B2W2;
break;
}
HeldItems = Legal.HeldItems_BW;

View file

@ -21,7 +21,7 @@ namespace PKHeX
getSAVOffsets();
HeldItems = ORAS ? Legal.HeldItem_AO : Legal.HeldItem_XY;
Personal = ORAS ? Legal.PersonalAO : Legal.PersonalXY;
Personal = ORAS ? PersonalInfo.AO : PersonalInfo.XY;
if (!Exportable)
resetBoxes();
}