Implemented IV judgement formula.

This commit is contained in:
Greg Edwards 2015-03-14 17:56:45 -04:00
parent b5b31af68c
commit ef758a218b
2 changed files with 77 additions and 0 deletions

View File

@ -91,6 +91,26 @@ namespace PkmnFoundations.Structures
SpecialDefense = 6
}
[Flags]
public enum StatFlags
{
None = 0,
Hp = 1,
Attack = 2,
Defense = 4,
Speed = 8,
SpecialAttack = 16,
SpecialDefense = 32
}
public enum Potential
{
Decent,
AboveAverage,
RelativelySuperior,
Outstanding
}
public enum Conditions
{
Cool = 1,

View File

@ -45,5 +45,62 @@ namespace PkmnFoundations.Structures
}
return result;
}
public JudgeSummary JudgeSummary
{
get
{
Potential overall = Potential.Decent;
int overallInt = Stats.Sum(s => (int)s);
if (overallInt > 90) overall = Potential.AboveAverage;
if (overallInt > 120) overall = Potential.RelativelySuperior;
if (overallInt > 150) overall = Potential.Outstanding;
byte bestIvValue = 0;
StatFlags bestIvs = StatFlags.None;
StatFlags zeroIvs = StatFlags.None;
int current = 1;
for (int x = 0; x < Stats.Length; x++)
{
if (Stats[x] > bestIvValue)
{
bestIvValue = Stats[x];
bestIvs = (StatFlags)current;
}
else if (Stats[x] == bestIvValue)
{
bestIvs |= (StatFlags)current;
}
if (Stats[x] == 0)
{
zeroIvs |= (StatFlags)current;
}
current <<= 1;
}
Potential bestPotential = Potential.Decent;
if (bestIvValue > 15) bestPotential = Potential.AboveAverage;
if (bestIvValue > 25) bestPotential = Potential.RelativelySuperior;
if (bestIvValue > 30) bestPotential = Potential.Outstanding;
return new JudgeSummary(overall, bestIvs, bestPotential, zeroIvs);
}
}
}
public struct JudgeSummary
{
public Potential OverallPotential;
public StatFlags BestIvs;
public Potential BestPotential;
public StatFlags ZeroIvs;
public JudgeSummary(Potential overall_potential, StatFlags best_ivs, Potential best_potential, StatFlags zero_ivs)
{
OverallPotential = overall_potential;
BestIvs = best_ivs;
BestPotential = best_potential;
ZeroIvs = zero_ivs;
}
}
}