summaryrefslogtreecommitdiffstats
path: root/sigencore/TeamMember.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-02-13 00:55:27 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-02-13 00:55:27 -0500
commit928a361019ab4fe98f7432cd7fcccebbc390f9f5 (patch)
treed416f1af12c7190a5da9ded015016ea415cc9c2d /sigencore/TeamMember.cpp
parent6cb47f8872983a11902ca507dbe02b600e1e1411 (diff)
downloadsigen-928a361019ab4fe98f7432cd7fcccebbc390f9f5.tar.gz
sigen-928a361019ab4fe98f7432cd7fcccebbc390f9f5.tar.xz
sigen-928a361019ab4fe98f7432cd7fcccebbc390f9f5.zip
Added calcStat implementation and updated statValue to use it
Diffstat (limited to 'sigencore/TeamMember.cpp')
-rw-r--r--sigencore/TeamMember.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/sigencore/TeamMember.cpp b/sigencore/TeamMember.cpp
index a54f7d20..eb0aaa02 100644
--- a/sigencore/TeamMember.cpp
+++ b/sigencore/TeamMember.cpp
@@ -368,32 +368,37 @@ int Sigencore::TeamMember::statStage(const Sigmod::Stat stat) const
int Sigencore::TeamMember::statValue(const Sigmod::Stat stat) const
{
- int statValue = statExperience(stat);
- if (!m_sigmod->rules()->effortValuesAllowed() && statValue)
- statValue = sqrt(statValue - 1) + 1;
- statValue >>= 2;
- statValue += m_species->baseStat(stat) << 1;
- if (m_sigmod->rules()->specialDVSplit())
- statValue += dv(Sigmod::ST_Special) << 1;
- else
- statValue += dv(stat);
- statValue *= double(m_level) / m_sigmod->rules()->maxLevel();
- if (stat == Sigmod::ST_HP)
- statValue += 10 + m_level;
- else
+ Sigcore::Fraction multiplier;
+ if (stat != Sigmod::ST_HP)
{
- statValue += 5;
- Sigcore::Fraction multiplier;
foreach (Sigscript::NatureWrapper* nature, m_natures)
multiplier *= nature->stat(stat);
- statValue *= multiplier;
}
const int stage = statStage(stat);
if (0 < stage)
- statValue *= (stage + 2) << 1;
+ multiplier *= Sigcore::Fraction(stage + 2, 2);
else if (stage < 0)
- statValue /= (stage + 2) << 1;
- return statValue;
+ multiplier *= Sigcore::Fraction(2, stage + 2);
+ return calcStat(m_sigmod, stat, m_level, m_species->baseStat(stat), dv(stat), statExperience(stat), multiplier);
+}
+
+int Sigencore::TeamMember::calcStat(Sigscript::SigmodWrapper* sigmod, const Sigmod::Stat stat, const int level, const int baseStat, const int dv, const int statExp, const Sigcore::Fraction& multiplier)
+{
+ int statValue = statExp;
+ if (!sigmod->rules()->effortValuesAllowed() && statValue)
+ statValue = sqrt(statValue - 1) + 1;
+ statValue >>= 2;
+ statValue += baseStat << 1;
+ if (sigmod->rules()->specialDVSplit())
+ statValue += dv << 1;
+ else
+ statValue += dv;
+ statValue *= double(level) / sigmod->rules()->maxLevel();
+ if (stat == Sigmod::ST_HP)
+ statValue += 10 + level;
+ else
+ statValue += 5;
+ return statValue * multiplier;
}
QList<Sigscript::NatureWrapper*> Sigencore::TeamMember::natures() const