Update personalinfo usages

less temp array usages, add methods for cleaner understanding
This commit is contained in:
Kurt 2018-03-25 13:53:48 -07:00
parent 5bf4fde15c
commit a24e5aa742
7 changed files with 18 additions and 10 deletions

View file

@ -2207,8 +2207,8 @@ namespace PKHeX.Core
} }
else // Types must match species types else // Types must match species types
{ {
var Type_A_Match = Type_A == PersonalTable.RB[pkm.Species].Types[0]; var Type_A_Match = Type_A == PersonalTable.RB[pkm.Species].Type1;
var Type_B_Match = Type_B == PersonalTable.RB[pkm.Species].Types[1]; var Type_B_Match = Type_B == PersonalTable.RB[pkm.Species].Type2;
AddLine(Type_A_Match ? Severity.Valid : Severity.Invalid, Type_A_Match ? V392 : V389, CheckIdentifier.Misc); AddLine(Type_A_Match ? Severity.Valid : Severity.Invalid, Type_A_Match ? V392 : V389, CheckIdentifier.Misc);
AddLine(Type_B_Match ? Severity.Valid : Severity.Invalid, Type_B_Match ? V393 : V390, CheckIdentifier.Misc); AddLine(Type_B_Match ? Severity.Valid : Severity.Invalid, Type_B_Match ? V393 : V390, CheckIdentifier.Misc);

View file

@ -145,10 +145,10 @@ namespace PKHeX.Core
m = new List<EncounterSlot>(); m = new List<EncounterSlot>();
foreach (EncounterSlot Slot in grp) foreach (EncounterSlot Slot in grp)
{ {
var types = t[Slot.Species].Types; var p = t[Slot.Species];
if (types[0] == steel || types[1] == steel) if (p.IsType(steel))
m.Add(Slot); m.Add(Slot);
if (types[0] == electric || types[1] == electric) if (p.IsType(electric))
s.Add(Slot); s.Add(Slot);
} }
} }

View file

@ -174,8 +174,8 @@ namespace PKHeX.Core
if (Enumerable.Range(baseSpecies, count).All(z => Rate != PersonalTable.RB[z].CatchRate)) if (Enumerable.Range(baseSpecies, count).All(z => Rate != PersonalTable.RB[z].CatchRate))
Catch_Rate = PersonalTable.RB[value].CatchRate; Catch_Rate = PersonalTable.RB[value].CatchRate;
} }
Type_A = PersonalInfo.Types[0]; Type_A = PersonalInfo.Type1;
Type_B = PersonalInfo.Types[1]; Type_B = PersonalInfo.Type2;
} }
} }

View file

@ -364,7 +364,11 @@ namespace PKHeX.Core
public override int Language { get => Data[0xE3]; set => Data[0xE3] = (byte)value; } public override int Language { get => Data[0xE3]; set => Data[0xE3] = (byte)value; }
#endregion #endregion
#region Battle Stats #region Battle Stats
public int Status { get => BitConverter.ToInt32(Data, 0xE8); set => BitConverter.GetBytes(value).CopyTo(Data, 0xE8); }
public override int Stat_Level { get => Data[0xEC]; set => Data[0xEC] = (byte)value; } public override int Stat_Level { get => Data[0xEC]; set => Data[0xEC] = (byte)value; }
public byte DirtType { get => Data[0xED]; set => Data[0xED] = value; }
public byte DirtLocation { get => Data[0xEE]; set => Data[0xEE] = value; }
// 0xEF unused
public override int Stat_HPCurrent { get => BitConverter.ToUInt16(Data, 0xF0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF0); } public override int Stat_HPCurrent { get => BitConverter.ToUInt16(Data, 0xF0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF0); }
public override int Stat_HPMax { get => BitConverter.ToUInt16(Data, 0xF2); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF2); } public override int Stat_HPMax { get => BitConverter.ToUInt16(Data, 0xF2); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF2); }
public override int Stat_ATK { get => BitConverter.ToUInt16(Data, 0xF4); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF4); } public override int Stat_ATK { get => BitConverter.ToUInt16(Data, 0xF4); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xF4); }

View file

@ -147,5 +147,9 @@
return true; return true;
return forme < FormeCount; return forme < FormeCount;
} }
public bool IsValidTypeCombination(int type1, int type2) => Type1 == type1 && Type2 == type2;
public bool IsType(int type1) => Type1 == type1 || Type2 == type1;
public bool IsType(int type1, int type2) => (Type1 == type1 || Type2 == type1) && (Type1 == type2 || Type2 == type2);
public bool IsEggGroup(int group) => EggGroup1 == group || EggGroup2 == group;
} }
} }

View file

@ -312,7 +312,7 @@ namespace PKHeX.Core
/// <returns>Indication that the combination exists in the table.</returns> /// <returns>Indication that the combination exists in the table.</returns>
public bool IsValidTypeCombination(int Type1, int Type2) public bool IsValidTypeCombination(int Type1, int Type2)
{ {
return Table.Any(p => p.Types[0] == Type1 && p.Types[1] == Type2); return Table.Any(p => p.IsValidTypeCombination(Type1, Type2));
} }
} }
} }

View file

@ -55,8 +55,8 @@ namespace PKHeX.WinForms
row.Cells[r++].Value = s > 721 || Legal.PastGenAlolanNatives.Contains(s); row.Cells[r++].Value = s > 721 || Legal.PastGenAlolanNatives.Contains(s);
row.Cells[r].Style.BackColor = MapColor((int)((Math.Max(p.BST - 175, 0)) / 3f)); row.Cells[r].Style.BackColor = MapColor((int)((Math.Max(p.BST - 175, 0)) / 3f));
row.Cells[r++].Value = p.BST.ToString("000"); row.Cells[r++].Value = p.BST.ToString("000");
row.Cells[r++].Value = PKMUtil.GetTypeSprite(p.Types[0], SAV.Generation); row.Cells[r++].Value = PKMUtil.GetTypeSprite(p.Type1, SAV.Generation);
row.Cells[r++].Value = p.Types[0] == p.Types[1] ? Resources.slotTrans : PKMUtil.GetTypeSprite(p.Types[1], SAV.Generation); row.Cells[r++].Value = p.Type1 == p.Type2 ? Resources.slotTrans : PKMUtil.GetTypeSprite(p.Type2, SAV.Generation);
row.Cells[r].Style.BackColor = MapColor(p.HP); row.Cells[r].Style.BackColor = MapColor(p.HP);
row.Cells[r++].Value = p.HP.ToString("000"); row.Cells[r++].Value = p.HP.ToString("000");
row.Cells[r].Style.BackColor = MapColor(p.ATK); row.Cells[r].Style.BackColor = MapColor(p.ATK);