mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Add hidden power power calculating
Add setter for HPType for gen2 pkm obviously can mess with gender in gen2 also tweaked gen1/2 IsNicknamed setters to clear nickname, as well as use the PKX get species name per format rather than doing it within the class.
This commit is contained in:
parent
529f8d1348
commit
a52083ee21
3 changed files with 38 additions and 23 deletions
|
@ -101,30 +101,31 @@ namespace PKHeX.Core
|
|||
{
|
||||
get
|
||||
{
|
||||
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
|
||||
spName = spName.Replace(" ", ""); // Gen I/II didn't have a space for Mr. Mime
|
||||
string spName = PKX.getSpeciesNameGeneration(Species, Japanese ? 1 : 2, Format);
|
||||
return !nick.SequenceEqual(
|
||||
PKX.setG1Str(spName, Japanese)
|
||||
.Concat(Enumerable.Repeat((byte) 0x50, StringLength - spName.Length - 1))
|
||||
.Select(b => (byte)(b == 0xF2 ? 0xE8 : b)));
|
||||
}
|
||||
set { }
|
||||
set
|
||||
{
|
||||
if (!value)
|
||||
setNotNicknamed();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNicknamedBank
|
||||
{
|
||||
get
|
||||
{
|
||||
var spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
|
||||
spName = spName.Replace(" ", ""); // Gen I/II didn't have a space for Mr. Mime
|
||||
var spName = PKX.getSpeciesNameGeneration(Species, Japanese ? 1 : 2, Format);
|
||||
return Nickname != spName;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNotNicknamed()
|
||||
{
|
||||
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
|
||||
spName = spName.Replace(" ", ""); // Gen I/II didn't have a space for Mr. Mime
|
||||
string spName = PKX.getSpeciesNameGeneration(Species, Japanese ? 1 : 2, Format);
|
||||
nick = PKX.setG1Str(spName, Japanese)
|
||||
.Concat(Enumerable.Repeat((byte)0x50, StringLength - spName.Length - 1))
|
||||
.Select(b => (byte)(b == 0xF2 ? 0xE8 : b)) // Decimal point<->period fix
|
||||
|
|
|
@ -111,27 +111,27 @@ namespace PKHeX.Core
|
|||
{
|
||||
get
|
||||
{
|
||||
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
|
||||
spName = spName.Replace(" ", ""); // Gen I/II didn't have a space for Mr. Mime
|
||||
string spName = PKX.getSpeciesNameGeneration(Species, Japanese ? 1 : 2, Format);
|
||||
return !nick.SequenceEqual(
|
||||
PKX.setG1Str(spName, Japanese)
|
||||
.Concat(Enumerable.Repeat((byte) 0x50, StringLength - spName.Length - 1))
|
||||
.Select(b => (byte)(b == 0xF2 ? 0xE8 : b)));
|
||||
}
|
||||
set { }
|
||||
set
|
||||
{
|
||||
if (!value)
|
||||
setNotNicknamed();
|
||||
}
|
||||
}
|
||||
|
||||
public void setNotNicknamed()
|
||||
{
|
||||
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
|
||||
spName = spName.Replace(" ", ""); // Gen I/II didn't have a space for Mr. Mime
|
||||
string spName = PKX.getSpeciesNameGeneration(Species, Japanese ? 1 : 2, Format);
|
||||
nick = PKX.setG1Str(spName, Japanese)
|
||||
.Concat(Enumerable.Repeat((byte)0x50, StringLength - spName.Length - 1))
|
||||
.Select(b => (byte)(b == 0xF2 ? 0xE8 : b)) // Decimal point<->period fix
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Stored Attributes
|
||||
public override int Species
|
||||
{
|
||||
|
@ -228,14 +228,15 @@ namespace PKHeX.Core
|
|||
{
|
||||
int gv = PersonalInfo.Gender;
|
||||
|
||||
if (gv == 255)
|
||||
return Gender == 2;
|
||||
if (gv == 254)
|
||||
return Gender == 1;
|
||||
if (gv == 0)
|
||||
return Gender == 0;
|
||||
switch (gv)
|
||||
{
|
||||
case 255:
|
||||
return Gender == 2;
|
||||
case 254:
|
||||
return Gender == 1;
|
||||
case 0:
|
||||
return Gender == 0;
|
||||
|
||||
case 31:
|
||||
return IV_ATK >= 2 ? Gender == 0 : Gender == 1;
|
||||
case 63:
|
||||
|
@ -304,12 +305,15 @@ namespace PKHeX.Core
|
|||
set{ }
|
||||
}
|
||||
|
||||
private int HPVal => getHiddenPowerBitVal(new[] {IV_SPC, IV_SPE, IV_DEF, IV_ATK});
|
||||
public override int HPPower => (5 * HPVal + IV_SPC % 4) / 2 + 31;
|
||||
public override int HPType
|
||||
{
|
||||
get { return ((IV_ATK & 3) << 2) | (IV_DEF & 3); }
|
||||
set
|
||||
{
|
||||
|
||||
IV_DEF = ((IV_DEF >> 2) << 2) | (value & 3);
|
||||
IV_DEF = ((IV_ATK >> 2) << 2) | ((value >> 2) & 3);
|
||||
}
|
||||
}
|
||||
public override bool IsShiny => IV_DEF == 10 && IV_SPE == 10 && IV_SPC == 10 && (IV_ATK & 2) == 2;
|
||||
|
|
|
@ -387,9 +387,19 @@ namespace PKHeX.Core
|
|||
get { return new[] { CNT_Cool, CNT_Beauty, CNT_Cute, CNT_Smart, CNT_Tough, CNT_Sheen }; }
|
||||
set { if (value?.Length != 6) return; CNT_Cool = value[0]; CNT_Beauty = value[1]; CNT_Cute = value[2]; CNT_Smart = value[3]; CNT_Tough = value[4]; CNT_Sheen = value[5]; }
|
||||
}
|
||||
|
||||
protected static int getHiddenPowerBitVal(int[] ivs)
|
||||
{
|
||||
int sum = 0;
|
||||
for (int i = 0; i < ivs.Length; i++)
|
||||
sum |= (ivs[i] & 1) << i;
|
||||
return sum;
|
||||
}
|
||||
private int HPVal => getHiddenPowerBitVal(new[] {IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD});
|
||||
public virtual int HPPower => Format < 6 ? 40*HPVal/63 + 30 : 60;
|
||||
public virtual int HPType
|
||||
{
|
||||
get { return 0xF * ((IV_HP & 1) << 0 | (IV_ATK & 1) << 1 | (IV_DEF & 1) << 2 | (IV_SPE & 1) << 3 | (IV_SPA & 1) << 4 | (IV_SPD & 1) << 5) / 0x3F; }
|
||||
get { return 15*HPVal/63; }
|
||||
set
|
||||
{
|
||||
IV_HP = (IV_HP & ~1) + PKX.hpivs[value, 0];
|
||||
|
|
Loading…
Reference in a new issue